I am trying to set the Tempo based upon the BPM in an auto script. While it does set the tempo field as desired, it does not appear to be recognized by MM. For example, the Tempo will get set to 'Fast', but the tracks are still showing up under the Unknown Tempo node, and do not show up under the Fast node. This is even after a restart of MM.
It looks like tempo is a simple text field, but now I am thinking it is not. Can anyone give me an idea why this script does not work correctly?
Sub OnStartup
Dim SDB
Set SDB = CreateObject( "SongsDB.SDBApplication")
' Set Tempo where BPM is known, and the Tempo has not been set.
SDB.Database.ExecSQL("Update Songs Set Tempo = 'Very Slow' Where (Tempo = '' or Tempo = 'None') AND (BPM >= 0 and BPM <=56)")
SDB.Database.ExecSQL("Update Songs Set Tempo = 'Slow' Where (Tempo = '' or Tempo = 'None') AND (BPM >= 57 and BPM <=82)")
SDB.Database.ExecSQL("Update Songs Set Tempo = 'Moderate' Where (Tempo = '' or Tempo = 'None') AND (BPM >= 83 and BPM <=145)")
SDB.Database.ExecSQL("Update Songs Set Tempo = 'Fast' Where (Tempo = '' or Tempo = 'None') AND (BPM >= 146 and BPM <=200)")
SDB.Database.ExecSQL("Update Songs Set Tempo = 'Very Fast' Where (Tempo = '' or Tempo = 'None') AND (BPM >200)")
Set SDB = Nothing
End Sub
Sub OnStartup
Dim Song
SDB.Database.BeginTransaction
Dim SongIter : Set SongIter = SDB.Database.QuerySongs("")
Do While Not SongIter.EOF
Set Song = SongIter.Item
if Song.Tempo = "None" or Song.Tempo = "" then
if Song.BPM >= 0 and Song.BPM < 57 then
Song.Tempo = "Very Slow"
elseif Song.BPM >= 58 and Song.BPM < 83 then
Song.Tempo = "Slow"
elseif Song.BPM >= 83 and Song.BPM < 145 then
Song.Tempo = "Moderate"
elseif Song.BPM >= 146 and Song.BPM <= 200 then
Song.Tempo = "Fast"
elseif Song.BPM > 200 then
Song.Tempo = "Very Fast"
end if
end if
end if
end if
end if
Song.UpdateDB
Song.WriteTags
end if
SongIter.Next
Loop
Set SongIter = Nothing
SDB.Database.Commit
end sub
Didn't tested it so I don't know if it works. And unfortunately I don't have time anymore today to test or change it but maybe it helps.
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
Sub OnStartup
Dim Song
' Set Tempo for non-podcasts, where BPM is known and the Tempo has not already been set.
SDB.Database.BeginTransaction
Dim SongIter : Set SongIter = SDB.Database.QuerySongs("")
Do While Not SongIter.EOF
Set Song = SongIter.Item
if UCase(Song.Genre) <> UCase("Podcast") And UCase(Song.Tempo) = UCase("None") or Song.Tempo = "" And Song.BPM >= 0 Then
if Song.BPM <= 56 then
Song.Tempo = "Very Slow"
elseif Song.BPM <= 82 then
Song.Tempo = "Slow"
elseif Song.BPM <= 145 then
Song.Tempo = "Moderate"
elseif Song.BPM <= 200 then
Song.Tempo = "Fast"
Else
Song.Tempo = "Very Fast"
end if
Song.UpdateDB
Song.WriteTags
end if
SongIter.Next
Loop
Set SongIter = Nothing
SDB.Database.Commit
end sub
@Killjoy: Oh dear, what a b*llsh*t did I post here this morning... But at least it helped!
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
Well ok, but the elseif part was kind of... just WRONG!
But glad I could help. You're right it's a great community.
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
@Guest: All you have to do is copy the text above and paste it in your favorite text editor. Click Save and when the program asks you for a file name, change .txt to .vbs
@Killjoy12: Thanks, this looks like it will come in handy after I've got all my BPMs set.
MM Gold 3.0.3.1183 : Vista HP SP1 (x86) : Zen Stone (2GB) Zekton: An original MM3 skin by Eyal. Scripts in Use: Add/Remove PlayStat | Auto Album DJ | AutoRateAccurate | Backup
Case & Leading Zero Fixer | Classification & Genre Changer | Clean Scripts.ini | Clear
Field | Custom Report | Discogs Auto-Tag Web Search | Forget Crossfade | Invert
Selection/Select None | Last 100... | Lyricator | Lyrics to Instrumental | MonkeyRok
MusicBrainz Tagger | My Custom Nodes | Now Playing Art Node | Play History & Stats
Right Click for Reports | Right Click for Scripts | Right Click for Web | Stop After Current
WebNodes
Can this script be modified to only monitor one folder instead of scanning the whole database at startup? Or, after startup, to run from "Tools/Scripts" only on selected tracks? I really like this script but as my database gets larger, it's taking a long time to scan at startup. An excellent script Killjoy12/Teknojnky. 5 stars. Thank you.
i've modified the original script to only process the selected files. i'm not sure if it's the most efficient but it works. To get MediaMonkey to register the new script on Windows10 i had to start media monkey by right clicking and "Run As Administrator".
[SetTempo]
FileName=SetTempoSelected.vbs
ProcName=SetTempoFromBPM
Order=10
DisplayName=Set Tempo
Description=Set Selected Tracks Tempo based on BPM
Language=VBScript
ScriptType=0
in the ..\MediaMonkey\Scripts folder make a new file named SetTempoSelected.vbs with the following code
Sub SetTempoFromBPM
Dim Song, list
' Get list of selected tracks from MediaMonkey
Set list = SDB.SelectedSongList
' Process all selected tracks
For i=0 To list.count-1
Set Song = list.Item(i)
' Set Tempo where BPM is known and the Tempo has not already been set.
if UCase(Song.Tempo) = UCase("None") or Song.Tempo = "" And Song.BPM >= 0 Then
if Song.BPM <= 56 then
Song.Tempo = "Very Slow"
elseif Song.BPM <= 82 then
Song.Tempo = "Slow"
elseif Song.BPM <= 145 then
Song.Tempo = "Moderate"
elseif Song.BPM <= 200 then
Song.Tempo = "Fast"
Else
Song.Tempo = "Very Fast"
end if
Song.UpdateDB
Song.WriteTags
end if
Next
' Write all back to DB and update tags
list.UpdateAll
End sub