1. Go to this page and download the library: Download iammordaty/musly-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
iammordaty / musly-php example snippets
use Musly\Musly;
$musly = new Musly();
$musly->initializeCollection();
$musly->analyze('/path/to/dir/or/track.mp3');
$similarTracks = $musly->getSimilarTracks('/path/to/track.mp3');
use Musly\Collection
use Musly\Exception\FileNotFoundException
use Musly\Exception\FileNotFoundInCollectionException
use Musly\Exception\MuslyProcessFailedException
use Musly\Musly;
$collection = new Collection([
'pathname' => '/path/to/collection.musly',
'similarityMethod' => Collection::SIMILARITY_METHOD_TIMBRE,
'jukeboxPathname' => '/path/to/collection.jbox',
]);
// ... or
// $collection = new Collection('/path/to/collection.musly');
// $collection->setSimilarityMethod(Collection::SIMILARITY_METHOD_TIMBRE);
// $collection->setJukeboxPathname('/path/to/collection.jbox');
$musly = new Musly([ 'binary' => '/path/to/musly/binary' ]);
try {
if (!$collection->isInitialized()) {
$musly->initializeCollection($collection);
}
$musly->setCollection($collection);
$musly->analyze('/path/to/dir/', 'mp3');
$musly->analyze('/path/to/track.mp3');
$similarTracks = $musly->getSimilarTracks('/path/to/track.mp3', 20);
$collectionTracks = $musly->getAllTracks();
}
catch (FileNotFoundException | FileNotFoundInCollectionException $e) {
// handle exception
}
catch (MuslyProcessFailedException $e) {
// handle exception
}
bash
$ composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.