Amarok/Manual/Diverse/Stemningslinje

From KDE UserBase Wiki
Revision as of 12:44, 17 December 2011 by Claus chr (talk | contribs) (Importing a new version from external source)

Stemningslinjen

Stemningslinjen vender officielt tilbage til Amarok med version 2.2.2. Den viser dig et spors "stemning", som du kan bruge til at finde ud af, om der sker noget interessant i nummeret.

Amarok skal bruge programmet Moodbar for at kunne analysere musikken og lave stemningslinjer (se nedenfor om downloads og binære pakker).

Pakken Moodbar skal bruge GStreamer og diverse plugins afhængigt af, hvilke filtyper du bruger (se Understøttede filtyper). Du har ikke brug for pakken phonon-backend-gstreamer for at lave .mood-filer.

Den nye implementering af Stemningslinjen består af to dele: dels pakken Moodbar, som indeholder et program, som tager en musikfil og genererer en .mood-fil, dels understøttelse i Amarok selv, som viser stemningslinjen. Pakken Moodbar afhænger af GStreamer-bibliotekerne. Uden pakken Moodbar kan Amarok ikke generere stemningslinjer for din musik.

Som et alternativ er der et nyt script, som kan lave moodbar-filer for spor i en af Amaroks spillelister. Dette er en undtagelse til ovenstående. Scriptet skal blot bruge Amarok for at virke, men laver kun .mood-filer når de spilles i Spillelisten.

Stemningslinjen skyldes Gavin Woods and Simon O'Keefes arbejde. De designede algoritmerne; deres oprindelige artikel er her.

Oversigt over forudsætningerne

  • Programmet Moodbar skal kunne findes i din PATH (det skal blive fundet, hvis du kører
    which moodbar
    i en konsol) — husk at konfigurere pakken Moodbar med
    ./configure --prefix=`pkg-config --variable=prefix gstreamer-0.10`
  • Biblioteket Gstreamer 0.10 og plugins til de formater, som du vil have Stemningslinjen til at kunne bruge.
  • Biblioteket FFTW (Den hurtigste Fouriertransformation i vesten, fftw.org) i version 3.0 eller derover (mindst en udgave med single-precision flydende-tal - libfftw3f) — hvis din platform ikke giver dig dette, eller hvis du er nødt til at kompilere din egen version, så husk at konfigurere pakken FFTW med
    ./configure --enable-single
  • En udgave af Amarok med tilvalget Vis stemningslinje i fremgangslinjen i afsnittet Generelt i indstillingsdialogen, det vil sige version 1.4.4 eller højere i 1.4-serien eller 2.2.2 eller højere i 2.x-serien.

Information

Systemer med pakkehåndtering skulle automatisk installere plugins til GStreamer samt FFTW sammen med pakken Moodbar. Denne information er mest beregnet til de, der selv skal kompilere kildekoden og manuelt installere pakkerne.


Brug

I øjeblikket skal .mood-filerne genereres manuelt. For at gøre det for hele din musiksamling kan du bruge scriptet til at generere stemningslinjer, som beskrevet nedenfor.

For at muliggøre visning af stemningslinjer i Amarok skal det aktiveres i indstillingerne: Indststillinger -> Indstil Amarok... -> Generelt -> Vis stemningslinje i fremgangslinjen. Nu skulle stemningslinjer dukke op i skyderen for sporet i afspillervinduet og i Spillelisten. Der er også en stemningslinje, som du kan føje til dit spillelistelayout.

Installation

Download kildekoden
Seneste udgave: moodbar-0.1.2.tar.gz — dette er kildekoden til Moodbar-pallen, som indeholder programmet Moodbar (som genererer .mood-filerne fra musikfilerne) og et plugin til GStreamer, som laver arbejdet. Pakken Moodbar skal bruge GStreamer 0.10.* samt 0.10.* udgaven af forskellige plugins. Sørg for at installere pakken Moodbar i det samme prefiks som GStreamer — følg instruktionerne i filen INSTALL.

Hvis du opdager programfejl, så indrapportér dem venligst til bugs.kde.org.

Pakker til Debian

Der findes nu en Moodbar-pakke i Debian unstable. Kør blot

apt-get install moodbar

. Du vil nok også skulle installere gstreamer0.10-plugins-ugly, gstreamer0.10-plugins-good og gstreamer0.10-plugins-bad til at understøtte filformater.

Kubuntu and Ubuntu packages

A package for Moodbar is available in the official package repository; just ensure the universe section is activated (which should be default anyway). Just install the package 'moodbar' with your preferred package manager (Kpackagekit, Aptitude, Adept, Synaptic). You will likely also want to install gstreamer0.10-plugins-ugly, gstreamer0.10-plugins-good, and gstreamer0.10-plugins-bad for format support.

Or, to install, paste this into Firefox or Konqueror and hit Enter.

apt://moodbar,gstreamer0.10-plugins-ugly,gstreamer0.10-plugins-good,gstreamer0.10-plugins-bad?section=universe?refresh=yep
Gentoo ebuilds

Moodbar is available in Portage, simply

emerge moodbar

Unofficial ebuilds are no longer required.

RPM builds

If you are a rpm-based distro user, you can build a .rpm using `rpmbuild` with latest gstreamer-plugins-moodbar.spec. The binary package will be soon available for PLD-linux distro.

Fedora

In Fedora 7 and higher (up to 16 as of this writing) Moodbar is available in the default repositories. Simply install it with your PackageKit GUI or with the following yum command:

yum install moodbar
openSUSE packages

openSUSE 11.0 and later, automatically install the following packages:

  • gstreamer-0_10-fluendo-mp3
  • gstreamer-0_10-plugins-base

Also, if your songs contain ID3 tags, you must install

  • gstreamer-0_10-plugins-good

Moodbar Installation

1-Click Install for openSUSE 11.* - just choose your version and installation procedure will do the rest:

To install, add the correct repository for your version of openSUSE to YaST then make sure the following packages are installed:

  • gstreamer-0_10-plugins-good
  • gstreamer-0_10-plugins-ugly
  • gstreamer-0_10-plugins-moodbar
  • mad

For details on how to add repositories, see the openSUSE wiki.

If you are using the Smart software management tool, add the channel by entering the following at the command line, remember to change the URL to match your version of openSUSE:

smart channel --add http://software.opensuse.org/download/home:/d7/openSUSE_10.2/home:d7.repo

Then enter

smart update home:d7

You can now install the required packages by

smart install gstreamer10-plugins-moodbar

Dependencies are resolved automatically.

Mandriva packages

First of all, you need to add PLF repositories, so visit easyurpmi.zarb.org and add them to your repositories list. Then simply install the following packages:

  • gstreamer0.10-moodbar
  • gstreamer0.10-plugins-ugly
  • gstreamer0.10-plugins-good
  • gstreamer0.10-plugins-bad
Arch Linux

There is a PKGBUILD for Moodbar in the Arch User Repository (AUR) available here.

For more information about the AUR and working with PKGBUILDs, see the AUR User Guidelines.

FreeBSD

There is a port: audio/gstreamer-plugins-moodbar here.

To install the port:

cd /usr/ports/audio/gstreamer-plugins-moodbar/ && make install clean

To add the package:

pkg_add -r gstreamer-plugins-moodbar

Moodbar File Generation Script

Here is a simple bash script that will add .mood files to your entire collection. It adds mood files for all files matching the extensions in the current directory and all subdirectories, so it's best run from the base of your music directory.

#!/bin/bash
 DIR=${1:-.}
 LAST=~/.moodbar-lastreadsong
 C_RET=0
 
 control_c()        # run if user hits control-c
 {
   echo "" > "$LAST"
   echo "Exiting..."
   exit
 }
 
 if [ -e "$LAST" ]; then
   read filetodelete < "$LAST"
   rm "$filetodelete" "$LAST"
 fi
 exec 9< <(find "$DIR" -type f -regextype posix-awk -iregex '.*\.(mp3|ogg|flac|wma)') # you may need to add m4a and mp4
 while read i
 do
   TEMP="${i%.*}.mood"
   OUTF=`echo "$TEMP" | sed 's#\(.*\)/\([^,]*\)#\1/.\2#'`
   trap 'control_c "$OUTF"' INT
   if [ ! -e "$OUTF" ] || [ "$i" -nt "$OUTF" ]; then
     moodbar -o "$OUTF" "$i" || { C_RET=1; echo "An error occurred!" >&2; }
   fi
 done <&9
 exec 9<&-
 
 exit $C_RET

Copy and paste the above into a text file named moodbar.sh in your music directory and run the following commands:

cd /path/to/music
 bash moodbar.sh

Alternatively if the above does not work, you may try:

chmod +x moodbar.sh
 ./moodbar.sh

This may take a very long time for large collections! Note that the moodbars will not appear in Amarok until Amarok rescans the collection. The generated mood files will be dotfiles (i.e., prefixed with a full stop), or hidden files - so keep this in mind if you can't find any generated mood files.

Based on the above script, an alternative for multicore CPUs:

#!/bin/bash
 NUMCPU="$(grep ^processor /proc/cpuinfo | wc -l)"
 
 find . -type f -regextype posix-awk -iregex '.*\.(mp3|ogg|flac|wma)' | while read i ; do
 
        while [ `jobs -p | wc -l` -ge $NUMCPU ] ; do
                sleep 0.1
        done
 
        TEMP="${i%.*}.mood"
        OUTF=`echo "$TEMP" | sed 's#\(.*\)/\([^,]*\)#\1/.\2#'`
        if [ ! -e "$OUTF" ] ; then
                moodbar -o "$OUTF" "$i" &
        fi
 done

There is another script at Github, which shows previews of the generated mood files on the command line while they are being generated. Read more about it at the author's blog.

Troubleshooting

  • If the Moodbar executable gives you a bus error, that almost always means it can't decode (or can't find) your file. Take a look at the supported file types below for ideas on which GStreamer plugins to install. You can also try the command below to test whether GStreamer can decode your file:
    gst-launch filesrc location=[file] ! decodebin ! fakesink
  • If you are using the ffmpeg plugin to decode mp3s, you may also receive mysterious bus errors. The solution is to stop using the ffmpeg plugin, as it is extremely buggy -- use mad instead.
  • If the Moodbar executable tells you that it can't find an element -- i.e, it gives an error message like
    Could not create element of type fftwspectrum, please install it.
    -- that usually means that you either don't have the required plugins installed (see the plugin list here), or that you didn't install the Moodbar package in the same prefix as GStreamer. If libmoodbar.so and libgstdecodebin.so are not in the same directory, then Moodbar is not installed in the same prefix as GStreamer. Please read the INSTALL file for instructions on how to configure the moodbar package correctly. Alternatively, if you know what you're doing, it may be easier for you to take a look at the GST_PLUGIN_PATH environment variable.
  • If you're wondering why the Moodbar isn't working, either not working at all or not working for a particular file, run the command below, where [file] is a music file:
    moodbar -o test.mood [file]
  • If you have multiple versions of GStreamer installed, make sure all of the required plugins are installed for version 0.10.* -- different versions cannot use each other's plugins.

Supported Filetypes

You will need various Gstreamer plugins to enable Moodbar to analyze your files. Here is a list of the plugins you will need; make sure to install the 0.10.* version of each plugin:

Filetype Required Plugin Note
All gstreamer-0.10.*, gst-plugins-base, gst-plugins-good
mp3 gst-plugins-mad (in gst-plugins-ugly) ffmpeg plugin has problems; do not use for mp3
ogg gst-plugins-vorbis, gst-plugins-ogg
flac gst-plugins-flac
mp4 gst-plugins-faad, gst-plugins-bad
musepack gst-plugins-musepack
wma gst-plugins-ffmpeg

Screenshots

Moodbar in progress slider in Amarok 2
Moodbar in progress slider in Amarok 2