Giter VIP home page Giter VIP logo

musly-php's Introduction

iammordaty/musly-php

musly-php is simple PHP wrapper around the musly commandline tool.

Musly is a fast and high-quality audio music similarity library written in C/C++.

-- Musly website

Installation

It's recommended that you use Composer to install musly-php.

$ composer require iammordaty/musly-php

Requirements

You may also be interested in iammordaty/musly fork, which allows you to get the distance between similar tracks (see PR #51 for more info).

Basic usage

use Musly\Musly;

$musly = new Musly();

$musly->initializeCollection();
$musly->analyze('/path/to/dir/or/track.mp3');

$similarTracks = $musly->getSimilarTracks('/path/to/track.mp3');

Advanced usage

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
}

See the musly commandline tool help for more information.

Tests

Copy phpunit.xml.dist file to phpunit.xml and use PHPUnit to run tests:

$ ./vendor/bin/phpunit

Further information

License

iammordaty/musly-php is licensed under the MIT License.

musly-php's People

Contributors

iammordaty avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.