Convert song volume to album volume

Download and get help for different MediaMonkey for Windows 4 Addons.

Moderators: Peke, Gurus

Teknojnky
Posts: 5537
Joined: Tue Sep 06, 2005 11:01 pm
Contact:

Post by Teknojnky »

I went to use this script to remove some leveling info so I could rescan it, and got an error while trying to run it.

So I poked around and figured out there is a type on the comments to put in the scripts.ini... below is the corrected code, the only modification is the commented out script ini info "'ProcName=AlbumVolumeLeveler ' CORRECTED PROCNAME".

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 ' CORRECTED PROCNAME
'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

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

Post by Big_Berny »

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

Version 2.0

Post by Big_Berny »

Hello,
as I already told somewhere I plan to create a second version of that script which allows you to choose between the two modes (track- and album-gain) over a button on the toolbar (like ScrobblerDJ).

As I'm not a real programmer I need some help:
1. Is there a possibility to select all songs from the database instead of "list = SDB.AllVisibleSongList"? (Sure there is, but I don't know how... :wink:)
2. After calculating the album-gain it will be saved into a field together with the track-gain. This way it hasn't to be recalculated all the time. Where should I save this information? Is there an other possibility than Custom1, Custom2, Custom3?

Well, that's it for the moment! :) Would be reat if someone could help.
Big_Berny
Big_Berny
Posts: 1784
Joined: Mon Nov 28, 2005 11:55 am
Location: Switzerland
Contact:

Post by Big_Berny »

Nobody wants to help?
onkel_enno
Posts: 2158
Joined: Fri Jan 14, 2005 1:45 am
Location: Germany
Contact:

Post by onkel_enno »

1. Set SongIter = SDB.DataBase.QuerySongs("")
2. You could create another field in the database and update it with Database.ExecSQL(...) but I wouldn't prefer that.

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

Post by Big_Berny »

Thanks! :)
So you would use a custom fiel instead? Well the problem is that maybe someone already has informations in it...

Big_Berny
onkel_enno
Posts: 2158
Joined: Fri Jan 14, 2005 1:45 am
Location: Germany
Contact:

Post by onkel_enno »

Let the people choose which Custom Field they want to use. Any of the three will be useable I think. I have Custom#1 free :lol:
DiddeLeeDoo
Posts: 1017
Joined: Wed Mar 01, 2006 1:09 am
Location: In a jungle down under
Contact:

Post by DiddeLeeDoo »

Cool Stuff!
Thank you Big_Berny.
It's very nice to have this option for albums that suppose to be heard in a certain way, and especially handy for those 'no-gap-between-tracks' albums.
gab
Posts: 328
Joined: Tue Oct 11, 2005 1:20 pm

Post by gab »

Do the download links on the first page of this post contain all the latest updates to the code? If not, how would I install the latest version. Thanks for the help
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

The latest version is at the top of this page (page 2, not the whole thread), posted by Teknojnky (here).

This is a copy of Big_Berny's official release, but with a typo corrected.
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:

Post by Big_Berny »

Hi Gap,
trixmoto is absolutely right! Unfortunately I can't edit my first posts because i was logged in as guest... :-?

Big_Berny
Image
Scripts in use: Genre Finder / Last.fm DJ / Magic Nodes / AutoRateAccurate / Last.FM Node
Skins in use: ZuneSkin SP / Eclipse SP
AutoRateAccurate 3.0.0 (New) - Rates all your songs in less than 5 seconds!
About me: icoaching - internet | marketing | design
Teknojnky
Posts: 5537
Joined: Tue Sep 06, 2005 11:01 pm
Contact:

Post by Teknojnky »

Should start a new thread and ask trix or other mods to split this thread to the new one.

Edit: or just post whatever the current version is under your logged and I can remove the code in my post to reduce confusion.
gab
Posts: 328
Joined: Tue Oct 11, 2005 1:20 pm

Post by gab »

The second instruction in the script says to "add this section..." to scripts.ini How do you do that?
Big_Berny
Posts: 1784
Joined: Mon Nov 28, 2005 11:55 am
Location: Switzerland
Contact:

Post by Big_Berny »

In the MediaMonkey\Scripts-folder there is a scripts.ini-file. Open it with notepad and add this lines to the end of the file:

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

Big_Berny
Image
Scripts in use: Genre Finder / Last.fm DJ / Magic Nodes / AutoRateAccurate / Last.FM Node
Skins in use: ZuneSkin SP / Eclipse SP
AutoRateAccurate 3.0.0 (New) - Rates all your songs in less than 5 seconds!
About me: icoaching - internet | marketing | design
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

I have now edited your original Guest posts and corrected your version 1.1 posting. Hope this is ok.
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.
Post Reply