Table of Contents

log

log(message);

Add message to the Similarity log.

process

process(path, callback1, [callback2]);

Start enumerating files and folders from path, calling callback1 for files and callback2 for folders. callback1 called with FileItem object as argument, callback2 with string containing folder path.

This function always asynchronous (ie. doesn't wait for completion before returning, completed callbacks can be called before any other API method). The JavaScript process is still single threaded.

wait

wait();

Wait before all pending asynchronous callbacks completed.

openFile

openFile(path, [flags]);

Open/create path file for writing or reading, all files processed as text file with UTF-8 encoding, flags can be:
'r' - Open file for reading (default).
'r+' - Open file for reading and writing.
'w' - Open file for writing. The file is created (if it does not exist) or truncated (if it exists).
'w+' - Open file for reading and writing. The file is created (if it does not exist) or truncated (if it exists).
'a' - Open file for appending. The file is created if it does not exist.
'a+' - Open file for reading and appending. The file is created if it does not exist.

Returns the FileIO object.

settings.folders

settings.folders;

List of selected folders in the Folders tab. Returns array of objects with structure:

path - folder path
groupId - selected groupId
withChilds - boolean value of sub-folders processing

settings.audio

settings.audio;

Return object with settings of audio comparing. Current properties:

tags - threshold for tag comparing algorithm
content - threshold for content comparing algorithm
precise - threshold for precise comparing algorithm
duration - duration check value.

settings.image

settings.image;

Return object with settings of image comparing. Current properties:

content - threshold for content comparing algorithm
experimental - threshold for experimental comparing algorithm

audio.prepare

audio.prepare(item, [algorithms, callback]);

Prepares audio algorithms in advance, primary for optimization. item is FileItem object or string with path. Algorithms list can be an array or just arguments list. If you add any callback (function argument), this method works as asyncronous. Callback format callback(item, result), item your prepared FileItem object, result boolean argument with result (success or fail).

audio.prepare('c:\Media\Folder\file1.mp3', ['tags', 'content', 'precise']);
audio.prepare(file1, ['tags', 'content', 'precise']);

function onprepare(file, result) {
    if (!result) return;
    ...
}

audio.prepare(file1, ['tags', 'content', 'precise'], onprepare);
audio.prepare(file1, ['tags', 'content', 'precise'], function(file, result) {
    if (!result) return;
    ...
});

This function can be asynchronous (ie. doesn't wait for completion before returning, completed callbacks can be called before any other API method). The JavaScript process is still single threaded.

audio.queue

audio.queue(item, [algorithms, callback]);

Queue item for comparing (using audio.compare method) and prepare audio algorithms in advance. item is FileItem object or string with path. Algorithms list can be an array, or just arguments list. If you add any callback (function argument), this method works as asyncronous. Callback format callback(item, result), item your prepared FileItem object, result boolean argument with result (success or fail).

audio.queue('c:\Media\Folder\file1.mp3', ['tags', 'content', 'precise']);
audio.queue(file1, ['tags', 'content', 'precise']);

function onqueue(file, result) {
    if (!result) return;
    ...
}

audio.queue(file1, ['tags', 'content', 'precise'], onqueue);
audio.queue(file1, ['tags', 'content', 'precise'], function(file, result) {
    if (!result) return;
    ...
});

This function can be asynchronous (ie. doesn't wait for completion before returning, completed callbacks can be called before any other API method). The JavaScript process is still single threaded.

audio.compare

audio.compare(item, callback);

Call callback on all items previously queued with audio.queue. callback(item1, item2) first argument is item, second argument is each queued item added with audio.queue before this call.

This function always asynchronous (ie. doesn't wait for completion before returning, completed callbacks can be called before any other API method). The JavaScript process is still single threaded.

audio.calculate

audio.calculate(item1, item2, [algorithms]);

Calculate scores for selected algorithms (or all of them). item1, item2 - FileItem objects or any strings with pathes. Algorithms list can be an array or just arguments list.

var scores = audio.calculate('c:\Media\Folder\file1.mp3', 'c:\Media\Folder\file2.ogg');
var scores = audio.calculate('c:\Media\Folder\file1.mp3', 'c:\Media\Folder\file2.ogg', 'precise');
var scores = audio.calculate(file1, file2, ['content', 'precise']);

image.prepare

image.prepare(item, [algorithms, callback]);

Prepares image algorithms in advance, primary for optimization. item is FileItem object or string with path. Algorithms list can be an array or just arguments list. If you add any callback (function argument), this method works as asyncronous. Callback format callback(item, result), item your prepared FileItem object, result boolean argument with result (success or fail).

image.prepare('c:\Media\Folder\file1.jpg', ['content', 'experimental']);
image.prepare(file1, ['content', 'experimental']);

function onprepare(file, result) {
    if (!result) return;
    ...
}

image.prepare(file1, ['content', 'experimental'], onprepare);
image.prepare(file1, ['content', 'experimental'], function(file, result) {
    if (!result) return;
    ...
});

This function can be asynchronous (ie. doesn't wait for completion before returning, completed callbacks can be called before any other API method). The JavaScript process is still single threaded.

image.queue

image.queue(item, [algorithms, callback]);

Queue item for comparing (using image.compare method) and prepare image algorithms in advance. item is FileItem object or string with path. Algorithms list can be an array, or just arguments list. If you add any callback (function argument), this method works as asyncronous. Callback format callback(item, result), item your prepared FileItem object, result boolean argument with result (success or fail).

image.queue('c:\Media\Folder\file1.jpg', ['content', 'experimental']);
image.queue(file1, ['content', 'experimental']);

function onqueue(file, result) {
    if (!result) return;
    ...
}

image.queue(file1, ['content', 'experimental'], onqueue);
image.queue(file1, ['content', 'experimental'], function(file, result) {
    if (!result) return;
    ...
});

This function can be asynchronous (ie. doesn't wait for completion before returning, completed callbacks can be called before any other API method). The JavaScript process is still single threaded.

image.compare

image.compare(item, callback);

Call callback on all items previously queued with image.queue. callback(item1, item2) first argument is item, second argument is each queued item added with image.queue before this call.

This function always asynchronous (ie. doesn't wait for completion before returning, completed callbacks can be called before any other API method). The JavaScript process is still single threaded.

image.calculate

image.calculate(item1, item2, [algorithms]);

Calculate scores for selected algorithms (or all of them). item1, item2 - FileItem objects or any strings with pathes. Algorithms list can be an array or just arguments list.

var scores = image.calculate('c:\Media\Folder\file1.jpg', 'c:\Media\Folder\file2.png');
var scores = image.calculate('c:\Media\Folder\file1.jpg', 'c:\Media\Folder\file2.png', 'content');
var scores = image.calculate(file1, file2, ['content', 'experimental']);

analysis.prepare

analysis.prepare(item, [callback]);

Prepares analysis data in advance, primary for optimization. item is FileItem object or string with path. If you add any callback (function argument), this method works as asyncronous. Callback format callback(item, status), item your prepared FileItem object, result boolean argument with result (success or fail).

analysis.prepare('c:\Media\Folder\file1.mp3');
analysis.prepare(file1);

function onprepare(file, result) {
    if (!result) return;
    ...
}

analysis.prepare(file1, onprepare);
analysis.prepare(file1, function(file, result) {
    if (!result) return;
    ...
});

This function can be asynchronous (ie. doesn't wait for completion before returning, completed callbacks can be called before any other API method). The JavaScript process is still single threaded.

text.calculate

text.calculate(text1, text2);

Calculates similarity score between text1 and text2. Score result lies between [0,1].

res = text.calculate('test', 'tst');
res = text.calculate('test value', '1234');

results.audio.items, results.audio.files

results.audio.items;
results.audio.files;

Returns array of FileItem objects containing all files shown in Audio Results tab. Each FileItem object additionally has pairs, dups, duplicates property that conatain array of duplicate files. This property structure:

[0], item1, file1 - first FileItem object in pair (same with base FileItem item)
[1], item2, file2 - second FileItem object in pair
tags - tags method result between this files
content - content method result between this files
precise - precise method result between this files

var files = results.audio.files;
for (var idx = 0; idx < files.length; ++idx) {
    // receiving duplicates for files[idx] only
    var dups = files[idx].dups;
    for (var idx2 = 0; idx2 < dups.length; ++idx2) {
       ...
    }
}

results.audio.pairs, results.audio.dups, results.audio.duplicates

results.audio.pairs;
results.audio.dups;
results.audio.duplicates;

Returns all pairs shown in Audio Results tab. Array of objects with structure:

[0], item1, file1 - first FileItem object in pair (same with base FileItem item)
[1], item2, file2 - second FileItem object in pair
tags - tags method result between this files
content - content method result between this files
precise - precise method result between this files

var dups = results.audio.dups;
for (var idx = 0; idx < dups.length; ++idx) {
    // skip counter-pair (1-2 and 2-1), process pair only once
    if (dups[idx].item1.path > dups[idx].item2.path) continue;
    ...
}

results.audio.clear

results.audio.clear();

Clear all results from Audio Results tab.

results.audio.add

results.audio.add(item1, item2, [scores]);

Add new duplicate pair into Audio Results tab. item1, item2 - FileItem objects or any strings with pathes. Additional argument is object with scores example {'tags' : 0.7, 'content' : 0.0, 'precise' : 1.0} or just list of arguments with scores example 'tags', 0.7, 'content', 0.0, 'precise', 1.0

function oncompare(item1, item2) {
    // calculate results for all algorithms
    var scores = audio.calculate(item1, item2);

    var mix = scores.tags * scores.content * scores.precise;
    if (mix > 0.7) {
        results.audio.add(item1, item2, { 'precise': mix });
    }
}

results.audio.ismarked

results.audio.ismarked(item);

Checks if item is marked in the Audio Results tab. Returns true if item marked or false if not or absent.

results.audio.mark

results.audio.mark(item, [mark]);

Set item to marked or mark boolean value in the Audio Results tab.

results.audio.unmark

results.audio.unmark([item]);

Remove mark from item in the Audio Results tab. Without arguments remove all marks from Audio Results tab.

results.image.items, results.image.files

results.image.items;
results.image.files;

Returns array of FileItem objects containing all files shown in Image Results tab. Each FileItem object additionally has pairs, dups, duplicates property that conatain array of duplicate files. This property structure:

[0], item1, file1 - first FileItem object in pair (same with base FileItem item)
[1], item2, file2 - second FileItem object in pair
content - content method result between this files
experimental - experimental method result between this files

var files = results.image.files;
for (var idx = 0; idx < files.length; ++idx) {
    // receiving duplicates for files[idx] only
    var dups = files[idx].dups;
    for (var idx2 = 0; idx2 < dups.length; ++idx2) {
       ...
    }
}

results.image.pairs, results.image.dups, results.image.duplicates

results.image.pairs;
results.image.dups;
results.image.duplicates;

Returns all pairs shown in Image Results tab. Array of objects with structure:

[0], item1, file1 - first FileItem object in pair (same with base FileItem item)
[1], item2, file2 - second FileItem object in pair
content - content method result between this files
experimental - experimental method result between this files

var dups = results.image.dups;
for (var idx = 0; idx < dups.length; ++idx) {
    // skip counter-pair (1-2 and 2-1), process pair only once
    if (dups[idx].item1.path > dups[idx].item2.path) continue;
    ...
}

results.image.clear

results.image.clear();

Clear all results from Image Results tab.

results.image.add

results.image.add(item1, item2, [scores]);

Add new duplicate pair into Image Results tab. item1, item2 - FileItem objects or any strings with pathes. Additional argument is object with scores example {'content' : 0.7, 'experimental' : 1.0} or just list of arguments with scores example 'content', 0.7, 'experimental', 1.0

function oncompare(item1, item2) {
    // calculate results for all algorithms
    var scores = image.calculate(item1, item2);

    var mix = scores.content * scores.experimental;
    if (mix > 0.7) {
        results.image.add(item1, item2, { 'content': mix });
    }
}

results.image.ismarked

results.image.ismarked(item);

Checks if item is marked in the Image Results tab. Returns true if item marked or false if not or absent.

results.image.mark

results.image.mark(item, [mark]);

Set item to marked or mark boolean value in the Image Results tab.

results.image.unmark

results.image.unmark([item]);

Remove mark from item in the Image Results tab. Without arguments remove all marks from Image Results tab.

results.analysis.items, results.analysis.files

results.analysis.items;
results.analysis.files;

Returns array of FileItem objects containing all files shown in Analysis Results tab.

results.analysis.clear

results.analysis.clear();

Clear all results from Analysis Results tab.

results.analysis.add

results.analysis.add(item, [rating]);

Add new item into Analysis Results tab. item - FileItem object or any string with path. Additional arguments is object with user defined rating example {'rating' : 1.0} or just list of arguments with rating example 'rating', 0.7

function onprepare(file, result) {
    results.analysis.add(file, 'rating', myrating(file.analysis));
}

function myrating(data) {
    var score = 1.0;
    // sample rate
    score *= 0.5 + 0.5 * (Math.min(44100, Math.max(22050, data.samplerate)) - 22050) / 22050;
    // bitrate
    if (data.bitrate > 0) score *= 0.5 + 0.5 *
        (Math.min(128000, Math.max(64000, data.bitrate)) - 64000) / 64000;
    return score;
}

results.analysis.ismarked

results.analysis.ismarked(item);

Checks for item is marked in the Analysis Results tab. Returns true if item marked or false if not or absent.

results.analysis.mark

results.analysis.mark(item, [mark]);

Set item to marked or mark boolean value in the Analysis Results tab.

results.analysis.unmark

results.analysis.unmark([item]);

Remove mark from item in the Analysis Results tab. Without arguments remove all marks from Audio Results tab.

FileItem class

Wrapper on processing file

FileItem constructor

new FileItem(path);

Constructs a FileItem object.

FileItem.path

FileItem.path;

Returns file path

FileItem.filename

FileItem.filename;

Returns filename and extension

FileItem.marked

FileItem.marked;

Sets or receive marked status of item. Marked status received and set on all tabs (Audio, Image, Analysis)

FileItem.mark

FileItem.mark([mark]);

Set to marked or mark boolean value in the Results tab. Marked status received and set on all tabs (Audio, Image, Analysis)

FileItem.unmark

FileItem.unmark();

Remove mark in the Results tab. Marked status received and set on all tabs (Audio, Image, Analysis)

FileItem.copyTags

FileItem.copyTags(srcPath);

Copy all tags (including images, extended tags) from srcPath file to this FileItem. srcPath can be any FileItem object or path string.

var fileDst = new FileItem("c:\\Music\\WMA to AAC\\23 - Gibson Brothers - Cuba.m4a");
var fileSrc = new FileItem("c:\\Music\\WMA to AAC\\23 - Gibson Brothers - Cuba.wma");
fileDst.copyTags(fileSrc);

FileItem.attributes.archive

FileItem.attributes.archive;

Retreive archive boolean file attribute.

FileItem.attributes.encrypted

FileItem.attributes.encrypted;

Retreive encrypted boolean file attribute.

FileItem.attributes.compressed

FileItem.attributes.compressed;

Retreive compressed boolean file attribute.

FileItem.attributes.hidden

FileItem.attributes.hidden;

Retreive hidden boolean file attribute.

FileItem.attributes.readonly

FileItem.attributes.readonly;

Retreive readonly boolean file attribute.

FileItem.attributes.system

FileItem.attributes.system;

Retreive system boolean file attribute.

FileItem.attributes.raw

FileItem.attributes.raw;

Raw integer file attribute value (system depended).

FileItem.attributes.size

FileItem.attributes.size;

Returns file size value in bytes.

FileItem.attributes.creationTime

FileItem.attributes.creationTime;

Returns DateTime object of file creation.

FileItem.attributes.modificationTime

FileItem.attributes.modificationTime;

Returns DateTime object of last file modification.

FileItem.audio.format

FileItem.audio.format;

Returns format of audio file. Example 'MP3', 'AC-3', etc.

FileItem.audio.bitrate

FileItem.audio.bitrate;

Returns bitrate of audio file.

FileItem.audio.duration

FileItem.audio.duration;

Returns duration in ms of audio file.

FileItem.audio.artist

FileItem.audio.artist;

Returns artist tag of audio file, retreved by decoder.

FileItem.audio.album

FileItem.audio.album;

Returns album tag of audio file, retreved by decoder.

FileItem.audio.title

FileItem.audio.title;

Returns title tag of audio file, retreved by decoder.

FileItem.image.format

FileItem.image.format;

Returns format of image file. Example 'JPEG', 'PNG', etc.

FileItem.image.bpp

FileItem.image.bpp;

Returns number of bits per pixel of image file. Example 8, 16.

FileItem.image.width

FileItem.image.width;

Returns width of image file.

FileItem.image.height

FileItem.image.height;

Returns height of image file.

FileItem.tags.title

FileItem.tags.title;

Set/Receive title tag from file, value returned by tagger. Value is string.

FileItem.tags.album

FileItem.tags.album;

Set/Receive album tag from file, value returned by tagger. Value is string.

FileItem.tags.artist

FileItem.tags.artist;

Set/Receive artist tag from file, value returned by tagger. Value is string.

FileItem.tags.genre

FileItem.tags.genre;

Set/Receive genre tag from file, value returned by tagger. Value is string.

FileItem.tags.comment

FileItem.tags.comment;

Set/Receive comment tag from file, value returned by tagger. Value is string.

FileItem.tags.year

FileItem.tags.year;

Set/Receive year tag from file, value returned by tagger. Value is integer.

FileItem.tags.track

FileItem.tags.track;

Set/Receive track tag from file, value returned by tagger. Value is integer.

FileItem.analysis.artist

FileItem.analysis.artist;

Returns artist tag of audio file, retreved by decoder.

FileItem.analysis.album

FileItem.analysis.album;

Returns album tag of audio file, retreved by decoder.

FileItem.analysis.title

FileItem.analysis.title;

Returns title tag of audio file, retreved by decoder.

FileItem.analysis.bitrate

FileItem.analysis.bitrate;

Returns bitrate of audio file.

FileItem.analysis.duration

FileItem.analysis.duration;

Returns duration in ms of audio file.

FileItem.analysis.samplerate

FileItem.analysis.samplerate;

Returns sample rate of audio file.

FileItem.analysis.datatype

FileItem.analysis.datatype;

Returns data type of audio file. Possible values '8', '16', 'float'.

FileItem.analysis.channels

FileItem.analysis.channels;

Returns channels format of audio file. Possible values 'mono', 'stereo', '5.1', '7.1'.

FileItem.analysis.format

FileItem.analysis.format;

Returns format of audio file. Example 'MP3', 'AC-3', etc.

FileItem.analysis.clips

FileItem.analysis.clips;

Returns analysis clips value.

FileItem.analysis.silence

FileItem.analysis.silence;

Returns analysis silence value.

FileItem.analysis.absMean

FileItem.analysis.absMean;

Returns analysis absMean value.

FileItem.analysis.minStep

FileItem.analysis.minStep;

Returns analysis minStep value.

FileItem.analysis.absMax

FileItem.analysis.absMax;

Returns analysis absMax value.

FileItem.analysis.maxFreq

FileItem.analysis.maxFreq;

Returns analysis maxFreq value.

FileItem.analysis.clicks

FileItem.analysis.clicks;

Returns analysis clicks value.

FileItem.analysis.rating

FileItem.analysis.rating;

Returns analysis rating value.

FileIO class

Class for working with UTF-8 text files.

FileIO.open

FileIO.open(path, [flags]);

Open FileIO object, arguments same as openFile.

FileIO.close

FileIO.close();

Close already opened file.

FileIO.write

FileIO.write(text);

Write text data into opened file.

FileIO.read

FileIO.read([size]);

Read size bytes from file. Without size read entire file. Return readed data as string.

 
Downloads
Premium version
Latest news