Perpetual playlist with Spicefly SugarCube, MusicIP and Logitechmediaserver

AVForums

Help Support AVForums:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

Now Playing

AVForums Super Veteran
Joined
May 25, 2010
Messages
1,208
Reaction score
13
Location
South Africa
Some time ago I made reference to an automatically generated perpetual playlist I'd enjoyed after having selected a single seed song (Automated playlisting: My afternoon's listening after picking a single track).  This thread describes what's involved in setting it up on a Linux server so that anyone using LogitechMediaServer on Linux can enjoy the same with their own music library.  Windows users will get a good idea of what goes into getting it done (particularly the analysis part). If you're a Windows user, refer to Spicefly's guides for installation instructions - it contains everything you need to know.

What is MusicIP?
In a nutshell, MiP is an acoustic analysis and playlisting engine that allows you to dynamically generate playlists using the acoustic properties of individual tracks/ albums or a combination of tracks/ albums as the seed. MiP uses the acoustic properties of the seed to dynamically generate a playlist of tracks from your music library. Various aspects of the seed can be fine-tuned to inform the mix.  Suffice it to say that it's a great tool for rediscovering music in your library and also for set and forget playlisting, e.g. when you've got a bunch of chores to get done and don't want to have to think about which album you'd like to listen to or you're having people over for a braai etc. and the music's just part of the backdrop.

MiP can operate as a standalone tool/ playlist generator (pushing playlists to SC) via MiP GUI, or it can be integrated into LMS via MiP headless. The standalone tool is generally referred to as MusicIP Mixer (MiP GUI) and the version that can be integrated with SC is known as MusicIP Server or MusicIP headless. Headless refers to it running in the background as a server with its UI accessible via a web interface and an API. By default the web interface for MiP headless is accessed via http://localhost:10002 (assuming of course it is in fact installed and running on the local PC).

What is Spicefly SugarCube?
Spicefly Sugarcube is a 3rd party Logitechmediaserver plugin that leverages MusicIP technology to create perpertual parameter driven playlists based on your audio library.

Instructions for installation, FAQ's etc. are available here.  Install Spicefly SugarCube after following the instuctions set out below to install MusicIP.

Installing MusicIP

Assumptions:
You have a fully functional Linux server on which Logitechmediaserver (LMS) is installed and your audio library is either located on the same server or otherwise accessible across your network. Whilst this guide is based on a Ubuntu/ Debian Server install, the principles apply equally across any Linux distro.

What you'll need where software is concerned:
genpuid: to analyze your audio files and write the results of the analysis to the track metadata
musicip server: the backbone of the playlisting engine
spicefly: LMS plugin that enables perpetual playlisting using musicip server (there's a free and a licensed version, licensed = richer functionality)

Considerations if running 64 bit OS
If you're running a 64 bit OS on your server you will need to install the 32 bit compatibility library (MusicIP is 32 bit software).  This is done as follows:
Code:
sudo apt-get install ia32-libs

Installing and configuring MusicIP
You need to install the MiP server on the same machine you're running LMS. For integration to work it is essential that MiP server be loaded PRIOR to LMS on startup.

Access the terminal of your server or use ssh to interact with the server from another PC/ laptop etc.

Download MusicIP and unpack its archive:
Code:
wget http://205.196.121.143/gc8m899l7oeg/jmxjm2t5dmz/MusicMixer_x86_1.8.tgz
gzip -dc MusicMixer_x86_1.8.tgz | tar xf -
rm MusicMixer_x86_1.8.tgz

The extraction process will create a folder called MusicIP, containing a subfolder called MusicMagicMixer . It's the MusicMagicMixer folder and its contents you're interested in. For ease of use rename/move it to a folder called musicip, clean up and get ready to configure MiP:
Code:
mv MusicIP/MusicMagicMixer/ musicip
rm -R MusicIP/
rm MusicMixer_x86_1.8.tgz
cd musicip/

One of the files that is extracted from the archive is called "mmserver". This is the startup script for MiP server. It needs to be customised to reflect your configuration and then added to your Linux boot process.
The default file looks as follows:
Code:
#! /bin/sh
# NON-PRIVILEGED USER TO RUN MUSICMAGICSERVER.
USER=
# PATH TO THE MUSICMAGICMIXERSERVER 
export MUSICHOME=
case $1 in
    start)
        su - $USER -c $MUSICHOME"MusicMagicServer start  & > /dev/null" 
        echo "Running MusicMagicServer"
        exit
        ;;
    stop)
        su - $USER -c $MUSICHOME"MusicMagicServer stop  & > /dev/null" 
        echo "Stopped MusicMagicServer"
        exit
        ;;
    *)
        echo "Usage: /etc/rc.d/init.d/mmserver { start | stop }"
        exit
        ;;
esac

There are two variables in the above file that need be customised:
  • USER
  • MUSICHOME

"USER=" should be set to your Ubuntu/ Debian login name on the server e.g. "USER=audiomuze".
"MUSICHOME=" should be edited to reflect the location of your MusicIP installation (if you're following this step by step it would become: MUSICHOME=/home/<username>/musicip/

To make the changes do the following:
Code:
sudo nano mmserver
scroll to the relevant entries in the file (line 3 and line 5) and make the changes.  When done hit Ctrl-O and enter to save the file and Ctrl-X to quit the nano editior and be returned to the command prompt.

You can then copy mmserver to /etc/init.d/ and make sure it's executable as follows:
Code:
sudo cp mmserver /etc/init.d/
sudo chmod 755 /etc/init.d/mmserver

Then you need to add the appropriate symbolic links to cause the script to be executed when the system goes down, or comes up.  The simplest way of doing this is to use the Debian-specific command update-rc.d:

Code:
sudo update-rc.d mmserver defaults

Now you need to tell Ubuntu/ Debian to start MiP BEFORE LMS.  To to this you need to ascertain the boot priority of LMS and name the symbolic link such that it fires before LMS on startup:
Code:
cd /etc/rc2.d
ls -la

You should see a symbolic link listed containing 'logitechmediaserver' in its name and another containing 'mmserver'.  The links are most probably named S20logitechmediaserver and S20mmserver, meaning they will fire up in the order they were created.  To ensure that MusicIP fires up before LMS you need to rename the mmserver symlink:
Code:
sudo mv S20mmserver S19mmserver

If you're running your OS on a flash drive
If you're running your OS on a flash drive you probably want to limit database intensive activity so it's best to move the folder and create a symbolic link pointing to another drive.  In my case my server drives are mounted as /diskpool/d1, d2 etc. and the LMS database is stored in subfolder in /diskpool/d1.  Create the symlink as follows:

Code:
## copy mmm.ini to the target folder, delete .MusicMagic and create a symlink pointing to where you'd like the database stored
cp .MusicMagic/mmm.ini /diskpool/d1/musicipdata/
rm -r .MusicMagic/
ln -s /diskpool/d1/musicipdata/ .MusicMagic

If you create the symlink as shown above there's no need to add anything to mmm.ini's cache= setting.

Now you can either reboot the machine to fire up MusicIP and LMS or you can do so manually (I'd recommend the reboot route because it's the acid test of whether the changes you've made are correct and operating as intended).

If you choose to reboot:
Code:
sudo reboot

If all's gone well, when the server has rebooted both MusicIP and LMS should be up and accessible.  You should find LMS on serverip:9000 and MusicIP on serverip:10002/

USING MUSICIP

How to use MusicIP with LMS
To use MiP it is first necessary to have it analyse your music library. The analysis process is CPU intensive and requires Internet access to expedite the process. It is theoretically possible to do the analysis without Internet access, however, this will very significantly increase analysis time. The reason for this is that MiP calculates a unique hash based on the song's acoustic signature and is usually able to use this hash to identify the song in its vast online MusicDNS database and retrieve the acoustic attributes relating to that song, negating the need for further analysis on your PC.

Once the analysis is done, MiP stores the results of the analysis in a database file and uses the information in this database to generate the playlists. Unfortunately, MiP GUI is not entirely stable and is known to occasionally corrupt the m3lib database. This is particularly the case if your music library is large, which results in a correspondingly large MiP database. For this reason, I recommend that you use MiP's capability of writing the analysis information to the tags of your audio files. This way, if the MiP database is ever corrupted there is no need to reperform the analysis, ever ? you'd simply have MiP rescan your library and it will rebuild its database using the analysis information saved to the audio file's tag.

I've been a long time MiP user and have archived analysis to many, many thousands of tracks and never once experienced a file corruption, so there's no need to be precious about allowing MusicIP to write to your audio files - it simply adds MusicIP specific tags to the file metadata.

Doing the analysis
Analysis is the voodoo required for MusicIP to work its mixing magic. Analysis of your audio files can be done using MiP GUI for Linux/ Windows or GenPUID for Linux/ Windows. GenPUID is a command line based tool that has the added flexibility of allowing you to invoke multiple concurrent analyses on different portions of your audio library.  Some MiP analysis lessons I've learned:
  • if you're using an older/ slower PC to do the analysis work, do your scanning overnight or run it as a low priority process in the background and accept that it may take days/ perhaps weeks depending on the size of your library - the end result is worth the wait (on a positive note the MusicDNS database is extensive so it's unlikely your Pc will be doing much heavy lifting where analysis is concerned)
  • if you're doing analysis across a network and a song comes back unanalyzable, try copying the song to your local drive and reanalyzing. This is particularly the case if you're running a Windows box (don't ask me why, but I suspect it has something to do with the CIFS protocol)
  • if you have a dual/quad core PC you can pretty much do the analysis at high priority without impacting the PC's overall performance
  • if you have a dual/quad core PC you can run multiple instances of GenPUID, with each pointed at a different portion of your library = get the job done a hell of a lot faster.

To facilitate this you may need to temporarily move your library structure around to be able to point GenPUID to discrete parts of the library. For example, my library is stored on my server as follows:
0-E/
F-J/
K-O/
P-R/
S-T/
U-Z/

with a separate sub-folder for each album. This means I can launch multiple instances of GenPUID to run in parallel, with each instance pointing at a different branch of the abovementioned tree. So long as I have the CPU grunt available, each instance of GenPUID will use a different CPU and the analysis will be completed that much faster.  There is nothing stopping you using SC whilst analysis is being performed so long as you avoid playing tracks from that portion of your library being analysed, so keep enjoying your music and let GenPUID do its thing in the background.

Using GenPUID
GenPUID requires you to include a key at the command line when it is invoked.  Since development stopped, two anonymous keys were made publicly available (use either): 57aae6071e74345f69143baa210bda87 or e4230822bede81ef71cde723db743e27

GenPUID's syntax is as follows:
Code:
GenPUID dns-key [options] [file1] [file2] [...]
Options are as follows:
Code:
dns-key

-archive
Archive tags when songs are identified
-ext=[opt]
Return extended metadata (XML format only)

-logex
Write analysis results to a log file
m3lib=[cache.m3lib]
Save cache in [cache.m3lib] after processing

-r
Process files recursively
-rmd=#
Return metadata (XML format only, #=1 or 2)

-v
Print version and exit

-xml
[XML format]

I always invoke GenPUID from the root of the folder I want to analyse and the command line I use is as follows:
Code:
~/musicip/GenPUID e4230822bede81ef71cde723db743e27 -archive -data -logex -m3lib=analysis.m3lib -r -threads=4 .

Basically it means run GenPUID on the current folder, traversing all child folders, write activities to a log file, generate a MiP database called analysis.m3lib containing the analysis results and archive the analysis results to the file tags.

Note the period "." at the end of the command line ? it implies the current directory is the one to be traversed, which is in general my approach ? navigate to that part of the tree you want to work on and have GenPUID analyse the contents of that folder and all its children.  By having GenPUID create an analysis database I can load it in MiP GUI and inspect the results of the analysis if I choose to. For all intents and purposes however, these analysis databases of a subset of a library are redundant and can be deleted [or not generated in the first place].

Some quick tips
Through lots of experimenting and questioning of the developers when it was still an ongoing project I've come to the following means of using MusicIP with consistently reproducible results.

  • do the analysis as mentioned above and archive the analysis to tag
  • build a MiP database for LMS integration via the headless API once your analysis is complete and archived.
  • after building the MiP database commit its cache to disk like so: http://serverip:10002/api/flush
  • make sure MiP headless loads BEFORE LMS ? if this doesn't happen there is nothing you can do to get LMS to see/ integrate with MiP

Building the MiP database
Once you've configured MiP, you need to build a MiP analysis database and configure LMS to integrate with MiP. To build the MiP database, access MiP's HTTP API via (http://localhost:10002/), enter the path to your music library in the text field next to the 'Add Music' button, then click the button to have MiP traverse your library and create the analysis database. This is generally a pretty quick process as all that's happening is all the analysis tags in the audio files in the path you've specified are read and written to the MiP database. Note, the MiP database will be stored and named as specified in mmm.ini's cache= setting. MiP will look for mmm.ini in /home/<user>/.MusicMagic - if you put it anywhere else it will be ignored.

What happens when I add new tracks to my library? Do I have to explicitly select them for analysis, or will MiP headless detect new tracks in the library?
You will need to explicitly analyse and add new tracks to the MiP database and have the MiP database refresh using the method described above to create it - nothing to it really.
 
Top