Amarok / Manual / Różne / Moodbar

From KDE UserBase Wiki
Revision as of 15:12, 26 November 2011 by Kustosz (talk | contribs)

Pasek nastroju

Pasek nastroju oficjalnie powraca w Amaroku 2.2.2. Jest to narzędzie do wykrywania "nastroju" utworu, które pozwala zobaczyć w którym miejscu piosenki dzieje się coś ciekawego.

Aby Amarok analizował twoje pliki muzyczne pod kątem nastroju, potrzebny będzie program Moodbar (poniżej informacje o pobieraniu plików źródłowych oraz pakietów binarnych).

Pakiet Moodbar wymaga GStreamera oraz różnych pluginów, zależnie od tego, jakich typów plików używasz (zobacz: Obsługiwane pliki). Pakiet phonon-backend-gstreamer nie będzie potrzebny do tworzenia plików .mood.

Nowa implementacja Moodbara składa się z dwóch części: pakietu Moodbar, który zawiera program generujący pliki .mood dla utworów oraz dodatkowego kodu w źródle Amaroka, który włącza i wyświetla pasek nastroju. Pakiet Moodbar wymaga biblioteki GStreamer. Bez pakietu Moodbar Amarok nie będzie analizował nastroju Twojej muzyki.

Alternatywą jest nowy skrypt, który może tworzyć pliki Moodbara dla utworów na liście odtwarzania Amaroka. Stanowi on wyjątek od powyższych wymagań - do działania nie wymaga niczego poza Amarokiem, jednak tworzy pliki .mood tylko dla plików z listy odtwarzania.

Moodbar istnieje dzięki Gavinowi Woodowi oraz Simonowi O'Kneefe, którzy stworzyli potrzebne algorytmy. Ich oryginalną pracę można znaleźć tutaj.

Wymagania

  • Wykonywalny plik Moodbar w PATH (powinien wyświetlić się po wpisaniu
    which moodbar
    w konsoli) -- pamiętaj o konfigurowaniu Moodbara z
    ./configure --prefix=`pkg-config --variable=prefix gstreamer-0.10`
  • Biblioteka GStreamer 0.10 i pluginy dla formatów, z którymi będziesz używał Moodbara.
  • Biblioteka Fastest Fourier Transform In The West (http://www.fftw.org) FFTW w wersji 3.0 lub wyższej (numer wersji z co najmniej jednym miejscem po przecinku - libfftw3f) -- Jeśli Twój system nie zapewnia tej biblioteki, lub potrzebujesz skompilować własną wersję, pamiętaj by konfigurować z
    ./configure --enable-single
  • Wersja Amaroka z opcją Pokaż pasek nastroju w sekcji Ogólne w menu konfiguracji. To znaczy wersja 1.4.4 lub wyższa dla serii 1.4 lub 2.2.2 lub wyższa dla serii 2.x.

Informacja

Systemy zawierające menedżer pakietów powinny automatycznie instalować pluginy GStreamer oraz FFTW razem z Moodbarem. Powyższa informacja jest zamieszczona głównie dla osób, które chcą lub muszą skompilować program ze źródła lub ręcznie zainstalować pakiety.


Sposób użycia

Obecnie pliki .mood są generowane ręcznie. Aby dokonać tego dla całej swojej kolekcji użyj skryptu do generowania plików Moodbara opisanego poniżej.

Aby włączyć wyświetlanie pasków nastroju w Amaroku, zaznacz odpowiednią opcję w menu konfiguracyjnym: Ustawienia -> Konfiguruj -> Ogólne -> Pokaż pasek nastroju w suwaku postępu. Pasek nastroju powinien się teraz pojawić w suwaku postępu w oknie odtwarzacza i w oknie playlisty. Pojawi się także pole "nastrój", które będziesz mógł dodać do swoich szablonów list odtwarzania.

Instalacja

Pliki źródłowe
Najnowsze wydanie: moodbar-0.1.2.tar.gz -- pakiet źródłowy Moodbar, który zawiera program Moodbar (generujący pliki .mood z plików muzycznych) oraz niezbędny do działania plugin GStreamer. Pakiet Moodbar wymaga GStreamera 0.10.* oraz wersji 0.10.* odpowiednich pluginów. Koniecznie zainstaluj pakiet Moodbar dokładnie w tym samym miejscu gdzie GStreamer -- trzymaj się instrukcji zawartych w pliku INSTALL.

Jeśli znajdziesz jakiekolwiek błędy, prosimy o raport na bugs.kde.org.

Pakiety Debiana

Pakiet Moodbar jest dostępny w repozytorium Debiana. Po prostu użyj

apt-get install moodbar

Prawdopodobnie będą Ci też potrzebne: gstreamer0.10-plugins-ugly, gstreamer0.10-plugins-good i gstreamer0.10-plugins-bad do obsługi różnych formatów plików.

Pakiety dla Ubuntu oraz Kubuntu

Pakiet Moodbar jest dostępny w oficjalnym repozytorium -- upewnij się tylko, że repozytorium universe jest aktywne (jest tak domyślnie). Zainstaluj pakiet 'moodbar' przy pomocy swojego ulubionego menedżera pakietów (Kpackageit, Aptitude, Adept, Synaptic). Prawdopodobnie będą Ci też potrzebne: gstreamer0.10-plugins-ugly, gstreamer0.10-plugins-good i gstreamer0.10-plugins-bad do obsługi różnych formatów plików.

Lub wklej poniższą linię w Firefoksie lub Konquerorze i wciśnij Enter.

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

Moodbar jest dostępny w Protage, po prostu użyj

emerge moodbar

Nieoficjalne ebuildy nie są już więcej potrzebne.

Paczki RPM

Jeśli jesteś użytkownikiem dystrybucji opartej na paczkach RPM, możesz, używając 'rpmbuild', skompilować paczkę z gstreamer-plugins-moodbar.spec. Pakiet będzie niebawem dostępny w dystrybucji PLD-linux.

Fedora

W Fedorze 7 oraz nowszych (do 16 w momencie pisania artykułu) Moodbar jest dostępny w domyślnym repozytorium. Po prostu zainstaluj go używając swojego PackageKit GUI lub przy po pomocy następującej komendy:

yum install moodbar
Pakiety openSUSE

openSUSE 11.0 oraz nowsze automatycznie instalują następujące pakiety:

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

Jeśli Twoje piosenki zawierają tagi ID3 musisz dodatkowo zainstalować

  • gstreamer-0_10-plugins-good

Instalacja Moodbara

Szybka instalacja dla openSUSE 11.* - po prostu wybierz odpowiednią wersję, a instalator wykona całą resztę za Ciebie:

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