Image 01


Miguel Angel maacruz
Amarok 1.x Scripts

Amarok 1.x Scripts 274 comments

Score 58.0%
Oct 20 2007
Are you sure you have installed mp3gain or aacgain?
Open the configuration dialog and look in the dependencies tab. - Jul 25 2009
The way you are using mp3gain modifies the mp3 sound data.
I use it in a different way, just writing to the replaygain tags.
mp3gain *.mp3
Just with that, you'll get the same effect as running the script's scanner. - Mar 16 2009
Thanks :)
- Mar 16 2009
That's because the script detect's a lag too big: amarok takes too much time in responding to the script
One reason for lagging is cover rendering, if you have covers, you can try removing the covers to see if it helps. - Mar 16 2009
It seems the package is now named python-kde3 - Feb 22 2009
It seems amarok 2.1 will support replaygain tags, but will be unable of tagging the files. That being the case, I'll port the tagging part of the script, but not before amarok's replaygaing support is in place. - Jan 31 2009
The script is working as expected, but it seems scim (do you write in chinesse?) messes with the stdio communication between the gui module and the script.
Let's try to disable scim and see if it works.
Edit the file ~/.kde/share/apps/amarok/scripts/amarok_replaygain/
Look for the line with the text:
gui_in,gui_out = os.popen2('python '+sys.path[0]+'/')
Modify it so it says:
gui_in,gui_out = os.popen2('GTK_IM_MODULE=gtk-im-context-simple python '+sys.path[0]+'/')
Save it, run amarok and see if the script works as it should. - Oct 29 2008
Open a xterm/konsole and cd to
There, run the following command (copy and paste):

echo "{'pregain':'+6', 'gain_default':'-3.0', 'use_slider':'false', 'no_peak':'false','mode':'track', 'no_osd':'false', 'smooth':'true', 'smooth_time':'0.5', 'autoscan':'true', 'no_guess':'false', 'autoscan_delay':'1.0', 'external_scanner':'false'}" | python >/tmp/gui_gtk.out
The dialog should open, press ok and send me the /tmp/gui_gtk.out
Tell me also what messages appear on the xterm. - Oct 25 2008
I don't know why.
The site selects what get shown in amarok, but I don't know how the selection is made. - Sep 10 2008
By the way, install python-kde bindings if you haven't done so, otherwise any IPC communication with amarok is done via command line which is much slower.
- Aug 01 2008

quite often when quitting amarok, it fails to close. processlist shows that replaygain is still running.
i suspect that for some reason replaygain fails to close, thus preventing amarok from shutting down correctly.
can i somehow debug what replaygain is doing at this point ?

It is the other way around. When amarok exits it kills all running scripts, so if the script keeps running it is because amarok fails to exit. There is no way the script can prevent amarok from exiting, since it is a child process.
Try finding what may cause amarok to hang on exit, it may be the sound engine (change it and see what happens), a buggy release from your distro (try another release or build from sources), or may be some problem related to network shares (if your collection is in a samba or nfs network share) - Aug 01 2008

Even after setting up MySQL for the Amarok collection and keeping Amarok to the tray, even while there are no demanding applications running, there is a delay to the volume change in Amarok after a new track begins. The ReplayGain tag is just a value for volume adjustment, right? Why can't the script have the volume adjusted before the track begins? Or is there something wrong on my end?

Of course there is something wrong.
Don't you think if that avenue would be available wouldn't have I tried it already?
There is simply no way to do that. Have a look at amarok notification system.
- Aug 01 2008
Yes, it still applies, since amarok is a kde3 application, and the script must communicate with amarok using dcop, which is a kde3 ipc protocol.
Also, if your collection is somewhat large, switching to mysql database backend would greatly reduce lag.
And last, running amarok minimized in the system tray, also has a quite noticeable lag reduction. - Jun 17 2008
I hate those "updates" to bsdDB :-(
Just delete ~/.kde/share/apps/amarok/scripts-data/streamdb.db
Restart the script and you are done. - Jun 10 2008

I have installed all lag-reducing packages although I was unable to find the "pygtk" package?

Make sure you have python-xml and pykde (aka python-kde aka kdebindings3-python) packages installed.
pygtk is also known as python-gtk and python-gtk2 (I don't understand why the distros have to be creative with package naming)


I tried disabling album covers but that didn't make any difference. I have "kirocker" installed if that might add some lag?
I have disabled OSD (although it might turn itself on again with kirocker?).

Are album covers still rendered? The rendering of existing albumcovers and other UI operations cause much of amarok slow response (because of high cpu usage during its timeslice).
I don't know about the effects of kirocker, I don't use it. If in doubt, you can do some tests with it disabled to see if there is any influence.
You can check the OSD state via dcop, type this in a konsole/xterm:
dcop amarok player osdEnabled


My current playlist is approx. 200 songs.

I've got 768 mb of RAM and I'm running Kontact and Amarok.

I don't see any problem here, I have been using much less memory until recently.
I haven't seen any noticeable dependency of performance with playlist length.


When I check the lag time I see that the "url time" is most likely the cause?

Use secuential play and "url time" won't be an issue.


My values:
Get url time: 1.43864703178
Tag reading time: 0.013689994812
Total trackchange time: 1.46719884872

They are huge!
I usually have 1/10 of those (with the amarok window opened).


I've got all my mp3's on a separate partition and it's separated from the album covers that are fetched from amazon.

Don't see any problem here (disk issues impact "tag reading time" only)


Any suggestions on what might be wrong please? Would love to get it working "properly" :)

Run amarok minimized in the system tray, it will not do any grapical operation. I get a x10-20 speedup this way.
The script does tricks if you use secuential playlist playing, which can't be done if you use random play. Do not use random play (random album is ok, though, since only the first song of each album will be affected), use secuential play and randomize your playlist first if you so wish (this is a x2-4 seedup)
xine-engine is much faster than yauap/gstreamer engine.
If your collection is large, sqllite will have efficiency issues, which mysql doesn't have.
Filesharing applications can cause more system latency, so they can increase lag.
Run a cpu monitor and see what is the system load, are there any cpu hungry processes? - May 21 2008
I think it may be some issue of remuco, is it really controlling amarok via dcop?
The replaygain script respects volume settings done via dcop, as long you have enabled "allow pregain adjustment with volume bar".
Just try it by hand, open a konsole/xterm and type:
dcop amarok player setVolume volume_value
dcop amarok player volumeUp
dcop amarok player volumeDown - May 21 2008
I don't know. It was until recently.
I think it is some bug in - Apr 25 2008
1. When rescanning whole collection all files are scanned in album mode. If an album has been previously scanned in track mode, then it will be rescanned in album mode. If an album has been previously scanned in album mode, it will be skipped, since there is no need to rescan again in album mode.

2. The album selection is done with amarok's database internal representation, not based only in album names. So, two different artists will have different albums, although they could have the same name. About compilations, I don't know, but amarok's database depends on file tags, so if the tags are different I think it will be the same case. - Apr 25 2008
>I run Amarok on top of gnome, and the latest version of your script broke because I use gnome:
> /bin/sh: kdialog: command not found
> I might remedy this by installing something that can handle the kdialog call. Do you know what package I can install to get this to work? Or maybe you could add lines to your code so that if this call fails, it defaults to whatever it did in the versions before this?

You need to have kdebase3 installed.
Sorry, but this always have been a needed dependency, the console dcop command is provided by this package so I can't get rid of it. - Apr 09 2008
That is NOT what you are looking for, unless you have encoded your LP's as musepack files.
Read carefully this web page, it says:

. metaflac (flac): to apply replaygain tags on flac files. This is likely a standard package on your distribution
. vorbisgain: to apply replaygain tags on vorbis ogg files
. aacgain: to apply replaygain tags on mp4/m4a aac files (works for mp3 too)
. mp3gain: to apply replaygain tags on mp3 files. Not needed if you have aacgain
So, depending how you have encoded your tracks, you may have to install one of such utilities.
And, by the way, replaygain is a method to normalize playback (it only can change the playback volume between 0-100%), not to increase the volume of a track. If you have captured the sound too low, I suggest you increase the wav's amplitude using audacity or any other audio processing tool. - Apr 09 2008
Not related to the script itself, but to your python installation and/or berkeley db packages.
Try deleting the file ~/.kde/share/apps/amarok/scripts-data/streamdb.db
If that doesn't work, file a bug in debian bugzilla for the python package maintainer. - Mar 06 2008
You should read this web page more carefully.
Read it again, read it slowly, read it fully; it is here to document what the script does and how to use it. Even this same content is available in several languages, and you can read it just by simply clicking "About" in amarok's script manager. - Feb 11 2008

Would it be possible to add an entry to the context menu of albums in the collection view to apply tags? (e.g. right click an album in the left frame and select "Apply RG tags in album mode).

Unfortunately no. Amarok lacks that functionality, that is, it only allows to have submenus in the playlist context menu.

Right now my method of doing this is to load the album into the playlist and use that context menu entry. Or is there a better (automatic) way to do this?

That is the only way if you want to scan just an album. As an alternative you can do a full collection scan (it is quite fast since only albums which lack replaygain data are scanned) - Jan 29 2008
Don't worry, with "complaining" I was joking where it really means bug reporting ;-) - Jan 07 2008
Then you would stick with the old version instead of complaining here, and I couldn't find and fix those subtle bugs :-)
I have found the play/pause bug, but the spikes souldn't happen except ocasionally in random album mode when switching albums.
I'm very interested in your replaygain debug log. Please, play a while until the bug happens a few times and send me the file ~/.kde/share/apps/amarok/scripts-data/replaygain.log
Also tell me which amarok release do you use, what play mode (random, random album, dynamic playlist....) do you use that makes the bug happen, and what of the following packages you do have installed: python-xml, python-kde3 (aka pykde aka kdebindings3-python).

Anyway, future releases may have a configuration option to disable the code which causes this particular problem. - Jan 07 2008
Could you please send me by email your playlist (saved in /home/yoda/.kde/share/apps/amarok/current.xml) when it crashes? Include the error message too. - Sep 28 2007
Your installation seems defective, some files may be lost.
Please, reinstall. - Sep 25 2007
Thanks. Fixed. - Sep 25 2007
Thanks. Fixed. - Sep 22 2007
It seems a problem with the alsa driver or a hardware problem.
You can try reducing the max alsa buffer size writing a number to /proc/asound/card0/pcm0p/sub0/prealloc
I don't know if it will work, but nothing is lost for trying. - Sep 11 2007
What output do you use?
Some outputs, particulary sound daemons, have a noticeable delay caused by their buffers. - Sep 10 2007
Maybe I missed that part. But assuming I have tagged my collection and want to add a new album. Do I select only those new tracks and let replaygain calculate the gain values or does it need some already tagged files for comparison?

Just load the new album in the playlist and select "Apply replaygain"->"To playlist (album mode)"
If you have several new albums, do it secuentially for each album.
If you have many new albums, just scan the collection again, it is much faster in already tagged files. - Jul 12 2007
On some albums, the error message is just "command failed". If possible, it would be better if you could be informed of why it failed. I would guess that depends on what kind of error message say mp3gain returns.

That means that either some files in such album are not writable (check file permisions!), or are not mp3 but some other filetype (like mp1 or mp2).
I'll try to add more informative error messages in the next major release.
It also fails when an album has files of more than one type in it. I.e. I have some albums where some songs are mp3s and others are oggs.

The tagging utilities don't mix together. May be I can find a workaround, but don't hold your breath. - Jul 12 2007
[as I understand, replaygain only writes the gain into the database instead of storing it in the files directly. Is that correct?]
No. It stores the gain in the file's tags. For mp3 the tags are APEv2, the rest of the supported file formats use their own standard.

[ Does the script use tags in the files if they are present]
Yes, the script read the tags before modifying amarok's volume. The utilities used for the gain calculation also usually do use the tags if present, although this depends on the utility itself.

[other players can profit from the work done by your script.]
As the info is written in the tags, it is up to the player itself to support replaigain.

[The only thing missing is a bit more documentation]
Thanks for your suggestion, I'll add that bit here and in the readme. - Jun 03 2007
Err, if I understand you, yes, it is, short off. But I can't reproduce such issue, it works for me (that is, the song info is shown in OSD) in all configurations I have tryed. Could you please provide more information? - May 10 2007
I'll upload soon a new release with this bug fixed.
About collection tagging, don't worry about album mode because album mode implies track mode too, that is, each song will have both track mode tags and album mode tags. - Feb 22 2007
It's a remmant from old releases, when it depended on external utilities to read tags...
Will be fixed in next release, thanks. - Feb 22 2007
That is a feature I had planned for a later release.
Unfortunately posting here has messed the code, please send me your script by mail.
Thanks. - Feb 01 2007
Not a bad idea. Thanks for the suggestion. - Feb 01 2007
> Is the script replaygaining a playlist in album mode on basis of the album tags or does it take the playlist as one album?

The playlist is taken as one album, tags are not taken into account because the user can select exactly what he wants to be in the playlist, and tags may be broken.
If you want to use tags to replaygain albums you should use the collection scan.
I have no plans to replicate foobar's scan modes because I think it doesn't have much sense in amarok, foobar doesn't have a database as amarok has.
If you have to do a mass scanning, simply use the collection scanner. It doesn't scan already scanned albums, so it is faster in succesive uses.
If you have your collection already scanned and add an album from time to time, use the playlist scan. - Nov 11 2006
Works fine for me with amarok 1.4.4
What database are you using?
Anything special with your collection's filesystem? - Nov 06 2006
>> It is developed with gtk 1.2.10 ---That's me sleeping, I mean gtk 2.6 :)
It seems that, for some reason, the kdialog combobox doesn't return the expected string when you select one option, so it miss and return. You may safely ignore the popup (it opens after the configuration is done).
Please, send me the file replaygain.log located in ~/.kde/share/apps/amarok/scripts/scripts-data
May be I can get some more info there. - Oct 26 2006
Replaygain is developed with python 2.4. It works with python 2.3 too, and should work with python 2.5 (although I have not tested it).

The gtk dependencies are voluntary, you don't need them to do a basic usage of the script, it should use the kdialog interface instead.

To run the gtk interface you need only two dependences, the gtk libraries (obviously) and the python-gtk (aka pygtk) python package. Not gnome at all, just plain gtk. It is developed with gtk 1.2.10 and pygtk 2.8, but I think it should work on any later version.

The kdialog interface should work, at least it works for me with no trouble.
Are you running the latest script release? Which kde release? - Oct 20 2006
It should work regardless if those bindings are installed or not. If it doesn't work, then probably there is a bug, so please, tell me if really didn't worked at all. - Oct 20 2006
I think in (k)ubuntu/debian it is called python-kde3
If you don't want to install it you may safely check the "Don't ask again" checkbox. - Oct 17 2006
Thanks for your suggestion. I'll have a look into it.
It's unfortunate you have lost all those dates. - Oct 16 2006
Yes, scanning the whole collection will use album mode.
The only restriction is that all files in an album must be same filetype (either mp3, ogg, or whatever) - Sep 30 2006
It's a bug that crept in beta6. Should be fixed now. - Sep 18 2006
It works for me (flac 1.1.2).
flac is rather picky about sampling rates and replaygain, as it documentation states:
The sample rate must be one of 8, 11.025, 12, 16, 22.05, 24, 32, 44.1, or 48 kHz.
Please check your files (metaflac --list or even mplayer will give you enough information). Check file permissions too.
If everything is right, you should send me a sample file. - Sep 18 2006
Of course I'm interested. Please, send me your patch. - Sep 10 2006