Convert song volume to album volume

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

Big_Berny (Guest)

Convert song volume to album volume

Post by Big_Berny (Guest) »

Hello together,
I just wrote a script, that changes the track-based volume-gain to an album-based volume gain.
The two main advantages are: Songs which are planed to be lowder stay lowder, because only the average of the album will change and songs which are splitted into more tracks have the same volume.

Example:

Album 1:
Song 1A: +2 dB
Song 1B: -3 dB
Song 1C: -5 dB

Album 2:
Song 2A: -1 dB
Song 2B: 0 dB
Song 2C: 1 dB

In this case all songs get a different volumegain. With this script all songs of a album get the same gain. So first the gain of the album has to be calculated. In this case the album1 gain is (2-3-5)/3 = -2dB. And the gain of album 2 is -1+0+1=0.
(Well, this example is a bit simplified, because in the script also the lenght of the tracks affect the albumgain.)

So after running this script, Album1 and Album2 have the same volume but louder songs are still louder than others.

Result:
Album 1:
Song 1A: -2 dB
Song 1B: -2 dB
Song 1C: -2 dB

Album 2:
Song 2A: 0 dB
Song 2B: 0 dB
Song 2C: 0 dB

Summary: This script corrects the volume of a whole album and doesn't affect the volume differences of different tracks of the same album.

I hope that you understand what I'm trying to describe. (It's not as easy as you think! :))

And here the script (parts of it ware based on the script on the script of this threat: http://www.mediamonkey.com/forum/viewtopic.php?t=5385, so thanks to Sarkos and onkel_enno)

Code: Select all

Updated
Would be great if someone could test it. Here it works!

It also has a function to reset/delete the gain-value so that MediaMonkey can recalculate it. To do that you need to click on "Cancel" in the first windows and on "Ok" in the second.

Greets
Big_Berny
Big_Berny (Guest)

Post by Big_Berny (Guest) »

Oh, I forgot to add: Use it at your own risk! :lol:

And here is an English version of the script.

Code: Select all

Updated
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

Does this actually update the volume levelling field, or does it populate a custom field with the album level?
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Big_Berny

Post by Big_Berny »

It updates the volume levelling field! Because MediaMonkey can only use this field AFAIK. But perhaps I could backup the original value in to a custom field... Would that be useful?

Big_Berny
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

Yes, I would use this script if it backed up my values. In fact, a script that allowed you to swap between the two sets might be useful. Or at least an option to revert to the original values. Looks like excellent work otherwise! :)
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Big_Berny (Guest)

Post by Big_Berny (Guest) »

Ok, here is a new version with backup-function!
ATTENTION: It overwrites Custom1-field!
To restore the original values, click first on Cancel, and then on Ok.
I hope you like it!



Nevertheless: Use it at your own risk! :D

Code: Select all

Updated
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

Still analysing all my songs (7000 to go) but I will test this script once they have been completed. Looks like good work.

You might want to remove your earlier code otherwise people might install the old version. Just a suggestion.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
rovingcowboy
Posts: 14162
Joined: Sat Oct 25, 2003 7:57 am
Location: (Texas)
Contact:

Post by rovingcowboy »

i don't understand it yet?

why is it needed if the level is all done for every song then it will play every song at the same level?

so why need album level?

can you please explain it to me and use simple none techy explainations please :wink:
roving cowboy / keith hall. My skins http://www.mediamonkey.com/forum/viewto ... =9&t=16724 for some help check on Monkey's helpful messages at http://www.mediamonkey.com/forum/viewto ... 4008#44008 MY SYSTEMS.1.Jukebox WinXp pro sp 3 version 3.5 gigabyte mb. 281 GHz amd athlon x2 240 built by me.) 2.WinXP pro sp3, vers 2.5.5 and vers 3.5 backup storage, shuttle 32a mb,734 MHz amd athlon put together by me.) 3.Dell demension, winxp pro sp3, mm3.5 spare jukebox.) 4.WinXp pro sp3, vers 3.5, dad's computer bought from computer store. )5. Samsung Galaxy 5 Android 5) 6. amd a8-5600 apu 3.60ghz mm version 4 windows 7 pro bought from computer store.
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

If an album has on it a quiet song and a loud song, when you listen to the album with volume levelling switched on, they will be played at the same level. Using an album levelling, the quiet song will be quiet, and the loud song will be loud. Each album should (on average) also be the same volume now. This script is useful for people who listen to whole albums (like me!) instead of individual tracks in their own playlists.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
rovingcowboy
Posts: 14162
Joined: Sat Oct 25, 2003 7:57 am
Location: (Texas)
Contact:

Post by rovingcowboy »

Ah!!!

i see thanks.

i use my own playlists and put the songs from the albums in random order.

i never do like to listen to ablums they way they were pressed in the factory. i like to make my own order or pick them at random.

so the low volume would be driving me nuts turning up and down the volume on the speakers.

so i will have to pass on this script. thanks for making it thought i am sure there are lots that will use it. 8)
roving cowboy / keith hall. My skins http://www.mediamonkey.com/forum/viewto ... =9&t=16724 for some help check on Monkey's helpful messages at http://www.mediamonkey.com/forum/viewto ... 4008#44008 MY SYSTEMS.1.Jukebox WinXp pro sp 3 version 3.5 gigabyte mb. 281 GHz amd athlon x2 240 built by me.) 2.WinXP pro sp3, vers 2.5.5 and vers 3.5 backup storage, shuttle 32a mb,734 MHz amd athlon put together by me.) 3.Dell demension, winxp pro sp3, mm3.5 spare jukebox.) 4.WinXp pro sp3, vers 3.5, dad's computer bought from computer store. )5. Samsung Galaxy 5 Android 5) 6. amd a8-5600 apu 3.60ghz mm version 4 windows 7 pro bought from computer store.
Big_Berny

Post by Big_Berny »

The idea of volume levelling is to correct the different volume of different albums. There are albums which are mastered a lot louder than others.

Gain-per-Track (which MediaMonkey uses) corercts this by levelling each track seperately. But this leveling-algorithm has the disadvantage that all musikfiles have the same volume also if the artist intented to make a song louder than the other. Another disadvantage is that on classicalbums symphonies are someties splitted into different tracks. So if one track has lowder passages (=parts) than the other track, MediaMonkey sets a different volume-correction. So you hear a volume difference when the next track begins.

Gain-per-Album doesn't have this problems. This algorithm detects the overall-volume (average-volume) of an album and uses the same volume-correction for each track. So songs which are intended to be lowder stay lowder and songs which are inteded to be less lowder stay less lowder.

I hope you understand what I'm trying to say. If not we need someone who speaks a better English! :wink:

Big_Berny
Big_Berny
Posts: 1784
Joined: Mon Nov 28, 2005 11:55 am
Location: Switzerland
Contact:

Post by Big_Berny »

@trixmoto: Unfortunately I was a guest, so I can't modify my older posts... :-? But I have a queston: How I get Inno Setup to compile an installer? It always gives me an error 'Unknown identifier: csFinished'....
Big_Berny
Posts: 1784
Joined: Mon Nov 28, 2005 11:55 am
Location: Switzerland
Contact:

Post by Big_Berny »

Between I think this script is also useful for people who don't hear complete albums, because there are songs which are intended to be lowder and songs which are inteded to be more quiet than other. So the volume of the songs should be a bit dynamic, I think.
But if you got some files of differen sources that Gain-per-track is definetly the correct choice.

Big_Berny
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

The Inno Setup compiler is great. I love that thing. Check this out: http://www.mediamonkey.com/forum/viewtopic.php?t=4040
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Big_Berny
Posts: 1784
Joined: Mon Nov 28, 2005 11:55 am
Location: Switzerland
Contact:

Album Volume Leveler 1.1

Post by Big_Berny »

Hiho,
et voilà: Here is the final version of Album Volume Leveler.

Image

It has a new "GUI" and 4 functions:
-Level Album Volume (and backup the original value into Custom1)
-Restore the original MediaMonkey volume value
-Reset(/delete) the volume informations (then MediaMonkey can scan it again)
-Close the windows :wink:

Download:
Album Volume Leveler 1.1 Installer
Album Volume Leveler 1.1 VB-Script (zipped)

I hope you like it!
Big_Berny

And for those who are interested:

Code: Select all

Option Explicit 
'1. Create a file AlbumVolumeLeveler.vbs in MediaMonkey\Scripts and paste these lines 
'2. Add this Section to Scripts.ini 

'[AlbumVolumeLeveler] 
'FileName=AlbumVolumeLeveler.vbs 
'ProcName=AlbumVolumeLeveler
'Order=1
'DisplayName=Album Volume Leveler
'Description=Album Volume Leveler 
'Language=VBScript 
'ScriptType=0 

'3. restart MediaMonkey 
'4. you'll find "Album Volume Leveler" in Tools\Scripts

sub AlbumVolumeLeveler
	dim list 
	dim song 
	dim result 
	dim i 
	dim albumVolume 
	dim albumId
	dim albumLength
	dim level
	dim length
	dim form
	dim btn1
	dim btn2
	dim btn3
	dim btn4

Set list = SDB.CurrentSongList
Set albumVolume = CreateObject( "Scripting.Dictionary" )
Set albumLength = CreateObject( "Scripting.Dictionary" )

if list.Count = 0 then 
	set list = SDB.AllVisibleSongList 
	if list.Count = 0 then 
		SDB.MessageBox "No songs selected", mtError, Array(mbOK) 
		exit sub 
	end if 
end if

Set Form = SDB.UI.NewForm 
Form.Common.SetRect 100, 100, 400, 170
Form.BorderStyle  = 3
Form.FormPosition = 4
Form.Caption = "Album Volume Leveler" 

Set Btn1 = SDB.UI.NewButton(Form) 
Btn1.Caption = "Analyze album volume and modify the MediaMonkey leveling field" 
Btn1.Common.SetRect 10, 10, 370, 25
Btn1.ModalResult = 1 
Btn1.Default = True

Set Btn2 = SDB.UI.NewButton(Form) 
Btn2.Caption = "Restore the original MediaMonkey leveling field" 
Btn2.Common.SetRect 10, 40, 370, 25
Btn2.ModalResult = 4

Set Btn3 = SDB.UI.NewButton(Form) 
Btn3.Caption = "Reset the MediaMonkey leveling field" 
Btn3.Common.SetRect 10, 70, 370, 25
Btn3.ModalResult = 3 

Set Btn4 = SDB.UI.NewButton(Form) 
Btn4.Caption = "Close without any modification" 
Btn4.Common.SetRect 10, 100, 370, 25
Btn4.ModalResult = 2
Btn4.Cancel = true

result = Form.showModal

if result = 1 then 
	for i = 0 to list.Count - 1 
		set song = list.Item(i) 
		albumId = song.Album.ID 
		level = song.Leveling
		length = song.SongLength
		if level <> -999999 and albumId > 0 then
			if albumVolume.exists( albumId ) then 
				albumVolume.Item( albumId ) = albumVolume.Item( albumId ) + level*length 
				albumLength.Item( albumId ) = albumLength.Item( albumId ) + length
			else
				albumVolume.add albumId, level*length
				albumLength.add albumId, length
			end if      
		end if
	next
	
	for i = 0 to list.Count - 1 
		set song = list.Item(i) 
		albumId = song.Album.ID 
		if albumId > 0 and albumVolume.exists( albumId ) then 
			song.Custom1 = song.Leveling
			song.Leveling = albumVolume.Item(albumId)/albumLength.Item(albumId)
			song.UpdateDB 
		end if 
	next
	SDB.MessageBox "Volume level has been modified.", mtInformation, Array(mbOK)
end if

if result = 4 then
	for i = 0 to list.Count - 1 
		set song = list.Item(i)
		song.Leveling = song.Custom1
		song.UpdateDB
	next
	SDB.MessageBox "Volume level has been restored.", mtInformation, Array(mbOK)
end if

if result = 3 then
	for i = 0 to list.Count - 1 
		set song = list.Item(i)
		song.Leveling = -999999
		song.UpdateDB
	next
	SDB.MessageBox "Volume level has been reseted.", mtInformation, Array(mbOK)
end if

if result = 2 then
	exit sub
end if

end sub
Post Reply