Tuesday, November 15, 2011

Building Release dll from Source

To generate a release of the banshee-community-extensions with our NoNoise plug-in first call
make prepare-release
which generates archives containing the release files. To install the plug-in, first extract one of the archives (for example 'banshee-community-extensions-2.2.0.zip'). After that run
./configure
make
in the extraction directory to build the dlls. At last, run
sudo cp ./bin/Banshee.NoNoise.dll* /usr/lib/banshee/Extensions
sudo cp ./bin/clutter-gtk-sharp.dll* /usr/lib/banshee/Extensions
sudo cp ./bin/clutter-sharp.dll*  /usr/lib/banshee/Extensions
to copy the dlls into the banshee folder (the location of this folder may vary on different systems). Now, if you run banshee, you can enable the NoNoise plug-in in the Edit > Preferences > Extensions menu. Do not forget to install Mirage or the banshee-community-extensions first. Otherwise our plug-in will not work.

Friday, October 28, 2011

Useful methods for getting track infos from banshee music library

Since I spent quite some time wondering how to do this, I decided to write down how you can get TrackInfos for certain TrackIds from banshee.

First you need banshee's DatabaseTrackModelProvider which can be found in Banshee.Collection.Database. One way of accessing the DatabaseTrackModelProvider<DatabaseTrackInfo> is using the static attribute Provider in DatabaseTrackInfo.
With this provider it is possible to get the TrackInfo for a track with a certain id using the following code:

TrackInfo ti = DatabaseTrackInfo.Provider.FetchSingle (bid) as TrackInfo; 

with bid being the ID used by banshee. In other words bid equals DatabaseTrackInfo.Provider.FetchSingle (bid).TrackId.

The provider can also be used for iterating over all tracks in banshee's database.

foreach (DatabaseTrackInfo dti in DatabaseTrackInfo.Provider.FetchAll ()) {
    // do something with dti
}

Tuesday, September 20, 2011

Merging two git repositories and keeping their history

To merge our repositories together we use the instructions given in [1].

<might be unnecessary>
First we create a new branch with
git branch newbranch
on MIRPCADB and switch to it using
git checkout newbranch 
and push it using
git push -u origin newbranch
</might be unnecessary>

Now we move over to our No.Noise repository and use the following command to fetch the contents of MIRPCADB in a new branch of No.Noise
git fetch git@github.com:tjom/MIRPCADB.git master:newbranch
To be able to use the commit history we use the following command to move the files from newbranch into a directory called old in our master branch
git filter-branch --index-filter \
    'git ls-files -s | \
        sed "s-\t-&'"old"'/-" | \
        GIT_INDEX_FILE=$GIT_INDEX_FILE.new git update-index --index-info && \
        mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE
    ' "newbranch"
followed by
git merge newbranch
Now we can simply move (copy and delete(!)) the files to our NoNoise plug-in src directory. After calling
git add -u
all files should be recognized as 'renamed', which means that their history will be preserved.

After committing and pushing the changes to the desired branch, we call
git branch -d newbranch
to remove the dummy branch.


[1] http://zrajm.org/ref/git-repo-merging.html

Friday, September 16, 2011

Had to add the following to BANSHEE_LIBS/the LINK variable in the makefile to use these packages.

BANSHEE_LIBS = ... -r:System.Data -r:Mono.Data.SqliteClient

Monday, September 5, 2011

Adding Math.NET lib

Nothing entirely new. Just to remember how it is done.

Add the path to the redistributable dll to the LINK variable of the project make file (e.g. Foo) with a leading "-r:". It should look like the following.

LINK = $(BANSHEE_LIBS) $(am__append_1) -r:/home/thomas/NoNoise/MathNet.Iridium-2008.8.16.470/ForRedistribution/MathNet.Iridium.dll 

PS: Also had to copy the dll to /bin/addins although I'm sure there's a better solution to that.

Monday, June 6, 2011

Compiling with unsafe code blocks

To compile code with unsafe blocks, it is necessary to add/alter the following line in the Makefile:

GMCS_FLAGS = -unsafe

Thursday, May 5, 2011

BPM detection using Banshee.Bpm

Banshee has a built-in extension to detect Beats Per Minute (BPM) in Banshee.Bpm. Unfortunately it is not possible to use this extension directly for our purpose, because the visibility of GetDetector () is set to internal. A quick and dirty solution to this is to copy the BpmDetectJob.cs file (which can be found in /banshee/src/Extensions/Banshee.Bpm/Banshee.Bpm/ after checking out the source from the git repository) to our project and change the visibility to public, since everything else we need is accessible from the Banshee API.

To see if the detection works, we use the following pieces of code.

We declare the private member IBpmDetector detector in our extension class and use the following code to initialize it in the constructor and set the FileFinished handler:

detector = BpmDetectJob.GetDetector ();
if (detector != null) {
    detector.FileFinished += OnFileFinished;
}

with

private void OnFileFinished (object o, BpmEventArgs args)
{
    Hyena.ThreadAssist.ProxyToMain (delegate {
        Hyena.Log.DebugFormat ("Foo1 - Detected BPM of {0} for {1}", args.Bpm, args.Uri);
    });
}

This simply outputs the BPM to the log. Now all we have to do is use the detector on a track, which can be done using the following method.

private void DetectBPMs(TrackInfo track) 
{
    if (track != null) {
        detector.ProcessFile (track.Uri);
    }
}

Now if we call DetectBPMs(TrackInfo track) with the first song in our library (i.e. ServiceManager.SourceManager.MusicLibrary.TrackModel[0]) as parameter, we get an output like "Foo1 - Detected BPM of 65 for file:///home/thomas/Musik/Black%20Holes%20and%20Revelations/Muse%20-%2001%20-%20Take%20a%20Bow.mp3".

Caution:
The class ThreadAssist was recently moved from Banshee.Base to Hyena!