Code Monkey home page Code Monkey logo

blissify's Introduction

Blissify

Blissify is a wrapper around Bliss to compute and store values in an SQLite database.

It is done in an attempt to bind Bliss to MPD to be able to play smooth mixes with MPD, à la Grooveshark radio.

Dependencies

To build it you will need sqlite3, plus the required dependencies from bliss (see https://github.com/Polochon-street/bliss).

Build

git clone --recursive https://github.com/phyks/blissify
cd blissify; mkdir build; cd build
cmake ..
make

This will build a blissify executable.

Usage

This repo contains several codes and scripts.

The main blissify executable

The main blissify executable can be used to compute the values necessary to use Bliss for various song files and store them in a SQLite database.

This executable takes a first argument being the basepath and a list of filenames relative to this basepath as argument. It will compute values using Bliss and store them in a SQLite database located in $XDG_DATA_HOME/blissify/db.sqlite3 (defaults to ~/.local/share/blissify/db.sqlite3).

You can do whatever you want with this db afterwards.

The MPD server-side script

In the mpd/ folder of this repo, you will find a server.py script. This is a simple Python script to easily build the database from your MPD music library. It calls blissify under the hood, so note that the blissify executable SHOULD be in your $PATH.

It takes a mpd_root argument to set the top path of your MPD music library. You can use either

  • --full-rescan to purge the db and perform a full scan of your MPD music library.
  • --rescan-errored to scan failed files stored in database (from a previous run). This option is usable even if you do not use MPD.
  • --update to perform an update based on new additions to the library.
  • --listen to listen to MPD IDLE signals on database update and update the database accordingly in realtime.

Connection to your MPD server is handled by $MPD_HOST and $MPD_PORT (defaulting to localhost and 6600), as described in mpc man page.

Note: This step can be quite long. It took me around 50 hours to build the database for a library with 50k songs.

The MPD client-side script

Once you have built the database, you may want to play a continuous mix with MPD. This is the purpose of the client.py script in mpd/× folder.

This script also uses the same environment variables as mpc does to connect to your MPD server.

Note: This script needs to have access to the database you built previously. Then, you should either copy the database on the client (in the same $XDG_DATA_HOME/blissify folder) or run it on the server.

It takes a single (optional) argument which is the number of songs to add to the playlist. Default is 20.

It builds a continuous mix starting from the latest song in your playlist. If your playlist is empty, it will start from a random song.

Note: If random mode is enabled in MPD, the script will warn you about it. Indeed, in this case, the mix is no longer continuous.

The cache building script

Finally, in scripts folder, you will find a Python script build_cache.py to build the distances cache.

Whenever you want to create a continuous mix, the client script will iterate through your music library, compute pairwise distances and take a close enough song. These computed distances are stored in the database as a cache, to generate a playlist faster the next time.

This build_cache.py script can be used to precompute the pairwise distances and build the cache, if you are willing to make some extra computation to generate mixes faster.

License

This code is distributed under an MIT license.

Feel free to contribute and reuse. For more details, see LICENSE file.

blissify's People

Contributors

phyks avatar polochon-street avatar taziden avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

polochon-street

blissify's Issues

MPD server script : Argument list too long

Hi,

I seem to hit a limit on the number of arguments while executing the mpd server script :

$ python3 server.py --full-rescan ~/music/
Traceback (most recent call last):
  File "server.py", line 183, in <module>
    full_rescan(args.mpd_root)
  File "server.py", line 88, in full_rescan
    subprocess.check_call(["blissify", mpd_root] + all_songs)
  File "/usr/lib/python3.4/subprocess.py", line 556, in check_call
    retcode = call(*popenargs, **kwargs)
  File "/usr/lib/python3.4/subprocess.py", line 537, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/usr/lib/python3.4/subprocess.py", line 859, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.4/subprocess.py", line 1457, in _execute_child
    raise child_exception_type(errno_num, err_msg)
OSError: [Errno 7] Argument list too long

Stats from my mpd db :

$ mpc stats
Artists:   3120
Albums:    3030
Songs:    37429

Segfault

Adding new song to db: good/Maurice Ravel; Orchestre philharmonique de Berlin, Pierre Boulez/1994 - Boléro _ Ma mère l’oye _ Rapsodie espagnole _ Alborada del Gracioso/03 - Ma mère l’oye_ III. Pavane de la belle au bois dormant. Lent - Allegro - Mouvement de valse modéré.mp3
Couldn't open file: /home/phyks/Musique/good/Maurice Ravel; Orchestre philharmonique de Berlin, Pierre Boulez/1994 - Boléro _ Ma mère l’oye _ Rapsodie espagnole _ Alborada del Gracioso/03 - Ma mère l’oye_ III. Pavane de la belle au bois dormant. Lent - Allegro - Mouvement de valse modér. Error 2 encountered.
Couldn't decode song
Error while parsing song: /home/phyks/Musique/good/Maurice Ravel; Orchestre philharmonique de Berlin, Pierre Boulez/1994 - Boléro _ Ma mère l’oye _ Rapsodie espagnole _ Alborada del Gracioso/03 - Ma mère l’oye_ III. Pavane de la belle au bois dormant. Lent - Allegro - Mouvement de valse modér.


Program received signal SIGSEGV, Segmentation fault.
update_database (conn=<error reading variable: Cannot access memory at address 0x7fff0072a95b>, initial_mtime=<error reading variable: Cannot access memory at address 0x7fff0072a953>,
    mpd_base_path=<error reading variable: Cannot access memory at address 0x7fff0072a94b>) at /home/phyks/MPDBliss/src/main.c:249
249                 mpd_entity_free(entity);

Need to be investigated further.

Traceback at the end of the program

Done! :)
Traceback (most recent call last):
  File "server.py", line 183, in <module>
    full_rescan(args.mpd_root)
  File "server.py", line 98, in full_rescan
    last_modified = client.find("file", song)["last_modified"]
  File "/usr/lib/python3.5/site-packages/mpd.py", line 629, in decorator
    return wrapper(self, name, args, bound_decorator(self, returnValue))
  File "/usr/lib/python3.5/site-packages/mpd.py", line 254, in _execute
    return retval()
  File "/usr/lib/python3.5/site-packages/mpd.py", line 623, in decorator
    return function(self, *args, **kwargs)
  File "/usr/lib/python3.5/site-packages/mpd.py", line 422, in _fetch_songs
    return self._fetch_objects(["file"])
  File "/usr/lib/python3.5/site-packages/mpd.py", line 410, in _fetch_objects
    return self._wrap_iterator(self._read_objects(delimiters))
  File "/usr/lib/python3.5/site-packages/mpd.py", line 374, in _wrap_iterator
    return list(iterator)
  File "/usr/lib/python3.5/site-packages/mpd.py", line 332, in _read_objects
    for key, value in self._read_pairs():
  File "/usr/lib/python3.5/site-packages/mpd.py", line 311, in _read_pairs
    pair = self._read_pair(separator)
  File "/usr/lib/python3.5/site-packages/mpd.py", line 302, in _read_pair
    line = self._read_line()
  File "/usr/lib/python3.5/site-packages/mpd.py", line 287, in _read_line
    raise ConnectionError("Connection lost while reading line")
mpd.ConnectionError: Connection lost while reading line

Missing fftw3 dependency on Debian Jessie

Hi guys,

I don't find the right package to satisfy fttw3 dependency. Anybody have same issue ?

Distributor ID: Debian
Description:    Debian GNU/Linux 8.7 (jessie)
Release:        8.7
Codename:       jessie
~/blissify/build# cmake ..
-- checking for modules 'libavformat;libavutil;libavcodec;fftw3'
--   package 'fftw3' not found
CMake Error at /usr/share/cmake-3.0/Modules/FindPkgConfig.cmake:341 (message):
  A required package was not found
Call Stack (most recent call first):
  /usr/share/cmake-3.0/Modules/FindPkgConfig.cmake:395 (_pkg_check_modules_internal)
  bliss/CMakeLists.txt:7 (pkg_check_modules)


-- checking for modules 'libavformat;libavutil;libavcodec;fftw3'
--   package 'fftw3' not found
CMake Error at /usr/share/cmake-3.0/Modules/FindPkgConfig.cmake:341 (message):
  A required package was not found
Call Stack (most recent call first):
  /usr/share/cmake-3.0/Modules/FindPkgConfig.cmake:395 (_pkg_check_modules_internal)
  CMakeLists.txt:10 (pkg_check_modules)


-- Configuring incomplete, errors occurred!
See also "/root/blissify/build/CMakeFiles/CMakeOutput.log".
~/blissify/build# apt-cache search fftw
cl-fftw3 - Common Lisp package for using the FFTW3 library
fftw-dev - library for computing Fast Fourier Transforms
fftw-docs - documentation for fftw
fftw2 - library for computing Fast Fourier Transforms
sfftw-dev - library for computing Fast Fourier Transforms
sfftw2 - library for computing Fast Fourier Transforms
libfftw3-3 - Library for computing Fast Fourier Transforms
libfftw3-bin - Library for computing Fast Fourier Transforms - Tools
libfftw3-dbg - Library for computing Fast Fourier Transforms - debug symbols
libfftw3-dev - Library for computing Fast Fourier Transforms - development
libfftw3-doc - Documentation for fftw version 3
libfftw3-double3 - Library for computing Fast Fourier Transforms - Double precision
libfftw3-long3 - Library for computing Fast Fourier Transforms - Long precision
libfftw3-mpi-dev - MPI Library for computing Fast Fourier Transforms - development
libfftw3-mpi3 - MPI Library for computing Fast Fourier Transforms
libfftw3-single3 - Library for computing Fast Fourier Transforms - Single precision
mffm-fftw-dev - A C++ wrapper for the fftw.org C library (version 3)
mffm-fftw1 - A C++ wrapper for the fftw.org C library (version 3)
pd-bsaylor - library of FFT-based Pd objects by Ben Saylor
python-fftw - Python bindings to the FFTW3 C-library for Fourier transforms
root-plugin-math-fftw3 - FFTw plugin for ROOT
ruby-fftw3 - Ruby interface to the FFTW Ver.3 library
ruby-fftw3-dbg - Ruby FFT library using FFTW Ver.3
sndfile-tools - Collection of programs for operating on sound files
yorick-yeti-fftw - FFT plugin for the Yorick language
yorick-ynfft - nonequispaced fast Fourier transform for Yorick

Thx

server.py is very sensible to path's format

Hi,

Server.py crashed when I tried to do python ./server.py --full-rescan /home/polochon/Musique/MPD because I omitted the trailing slash; /home/polochon/Musique/MPD/ worked, though.

Just thought it would be cool to report - the database is being built as I speak :p

Thanks!

Playlist generation

For now, we always take closest song. This implies when many songs from the same artist are in the music library, they are chosen preferentially.

We should introduce some randomness or impose a minimal distance between songs to avoid this.

Ping @Polochon-street who noticed this.

Do not use listall

From MPD manual:

listall [URI]
[...]
Do not use this command. Do not manage a client-side copy of MPD's database. That is fragile and adds huge overhead. It will break with large databases. Instead, query MPD whenever you need something.

We should instead use find with modified-since filter.

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.