BPM not being interpreted correctly (Magic Nodes)
BPM not being interpreted correctly (Magic Nodes)
Hi,
I saw a posting recently in response to a request to group or classify tracks according to the BPM value. The Magic Node code looked something like this...
Allegro|filter:BPM<120 and BPM>80
(just as an example.)
This does nothing ! MN does not give any errors, but it does not filter the tracks according to their BPM value. ALL tracks show in the node, regardless of the BPM value.
I also want to apply a set of groupings according to the range of the BPM. I understand that the BPM is stored as a "Long" type, so I cannot understand why the values are not being interpreted correctly. Even trying them as quoted strings produced the same result.
Any ideas or other solutions ?
I saw a posting recently in response to a request to group or classify tracks according to the BPM value. The Magic Node code looked something like this...
Allegro|filter:BPM<120 and BPM>80
(just as an example.)
This does nothing ! MN does not give any errors, but it does not filter the tracks according to their BPM value. ALL tracks show in the node, regardless of the BPM value.
I also want to apply a set of groupings according to the range of the BPM. I understand that the BPM is stored as a "Long" type, so I cannot understand why the values are not being interpreted correctly. Even trying them as quoted strings produced the same result.
Any ideas or other solutions ?
Regards
Philby
Philby
-
- Posts: 2153
- Joined: Fri Jan 14, 2005 1:45 am
- Location: Germany
- Contact:
OK, I can do this for you.
Do you want me to set the tempo of each file according to the bpm or do you want me to create a node were the files are grouped by the bpm?
"Unknown" for BPM < 1
"Largo" for BPM between 0 and 56
"Andante" for BPM between 57 and 82
"Allegro" for BPM between 83 and 145
"Presto" for BPM > 145
BTW In MagicNodes there seems to be an error with SQLFilter and Filter and the Function getQualifierValue
But that's not my task.
Do you want me to set the tempo of each file according to the bpm or do you want me to create a node were the files are grouped by the bpm?
"Unknown" for BPM < 1
"Largo" for BPM between 0 and 56
"Andante" for BPM between 57 and 82
"Allegro" for BPM between 83 and 145
"Presto" for BPM > 145
BTW In MagicNodes there seems to be an error with SQLFilter and Filter and the Function getQualifierValue
But that's not my task.
-
- Posts: 2153
- Joined: Fri Jan 14, 2005 1:45 am
- Location: Germany
- Contact:
lolPhilby wrote:onkel_enno
I dont wish to sound greedy, but BOTH options would be great !
Many thanks
If a update the tempo-tag, then you can use magic node, so I will do that.
EDIT:
Here it is:
Create a file SetTempo.vbs and paste the code into it.
Code: Select all
Option Explicit
REM "Unknown" for BPM < 1
REM "Largo" for BPM between 0 and 56
REM "Andante" for BPM between 57 and 82
REM "Allegro" for BPM between 83 and 145
REM "Presto" for BPM > 145
Dim SDB
Set SDB = CreateObject( "SongsDB.SDBApplication")
Dim KeyLargo
Dim KeyAndante
Dim KeyAllegro
Dim KeyPresto
Dim dsTemp
Set dsTemp = SDB.Database.OpenSQL("SELECT ID FROM Lists WHERE IDListType = 1 AND TextData = 'Largo'")
if not dsTemp.EOF then KeyLargo = dsTemp.ValueByIndex(0)
Set dsTemp = SDB.Database.OpenSQL("SELECT ID FROM Lists WHERE IDListType = 1 AND TextData = 'Andante'")
if not dsTemp.EOF then KeyAndante = dsTemp.ValueByIndex(0)
Set dsTemp = SDB.Database.OpenSQL("SELECT ID FROM Lists WHERE IDListType = 1 AND TextData = 'Allegro'")
if not dsTemp.EOF then KeyAllegro = dsTemp.ValueByIndex(0)
Set dsTemp = SDB.Database.OpenSQL("SELECT ID FROM Lists WHERE IDListType = 1 AND TextData = 'Presto'")
if not dsTemp.EOF then KeyPresto = dsTemp.ValueByIndex(0)
set dsTemp = Nothing
'Delete all Tempos
SDB.Database.ExecSQL("Delete from AddSongInfoInt WHERE DataType = 10101")
'Set all Tempos to Largo, where BPM between 0 and 56
if CStr(KeyLargo) <> "" then
SDB.Database.ExecSQL("INSERT INTO AddSongInfoInt (IDSong, DataType, IntData) Select Songs.ID, 10101, " & KeyLargo & " FROM Songs WHERE BPM BETWEEN 0 AND 56")
else
MsgBox "Largo is not part of the Tempo-List"
end if
'Set all Tempos to Andante, where BPM between 57 and 82
if CStr(KeyAndante) <> "" then
SDB.Database.ExecSQL("INSERT INTO AddSongInfoInt (IDSong, DataType, IntData) Select Songs.ID, 10101, " & KeyAndante & " FROM Songs WHERE BPM BETWEEN 57 AND 82")
else
MsgBox "Andante is not part of the Tempo-List"
end if
'Set all Tempos to Allegro, where BPM between 83 and 145
if CStr(KeyAllegro) <> "" then
SDB.Database.ExecSQL("INSERT INTO AddSongInfoInt (IDSong, DataType, IntData) Select Songs.ID, 10101, " & KeyAllegro & " FROM Songs WHERE BPM BETWEEN 83 AND 145")
else
MsgBox "Allegro is not part of the Tempo-List"
end if
'Set all Tempos to Presto, where BPM between 0 and 56
if CStr(KeyPresto) <> "" then
SDB.Database.ExecSQL("INSERT INTO AddSongInfoInt (IDSong, DataType, IntData) Select Songs.ID, 10101, " & KeyPresto & " FROM Songs WHERE BPM > 145")
else
MsgBox "Presto is not part of the Tempo-List"
end if
Set SDB = Nothing
Please make a Backup of your Database before executing the script.
Give me your feedback!
onkel-enno
Thank you for taking the time to prepare this script.
When I ran it, I got 4 errors
"Largo is not part of the Tempo-List"
"Andante is not part of the Tempo-List"
"Allegro is not part of the Tempo-List"
"Presto is not part of the Tempo-List"
My knowledge of VBScript is limited. What exactly is the script tyring to do ?
Does it make my database structure non-standard ?
Will future updates of MM install OK ?
What will the Magic Node code need to look like to access the Tempo's ?
Thanks again for your help.
Thank you for taking the time to prepare this script.
When I ran it, I got 4 errors
"Largo is not part of the Tempo-List"
"Andante is not part of the Tempo-List"
"Allegro is not part of the Tempo-List"
"Presto is not part of the Tempo-List"
My knowledge of VBScript is limited. What exactly is the script tyring to do ?
Does it make my database structure non-standard ?
Will future updates of MM install OK ?
What will the Magic Node code need to look like to access the Tempo's ?
Thanks again for your help.
Regards
Philby
Philby
-
- Posts: 14163
- Joined: Sat Oct 25, 2003 7:57 am
- Location: (Texas)
- Contact:
OKay now you got my intrest peaked..
will this script make autoplaylists according to the tempo of the songs.
as well as set the temp of the songs by the bpm
if so that will help out a lot for the internet radio's to have fast paced hour and a slow paced hour.
I also added in the needed header to the script ini file and then put the settemp script in the scripts folder.
when i started media monkey i got all the same alerts as he did. and i can not find the link to click on under the scripts header on the tools menu.?
so what did we or what didn't we screw up
will this script make autoplaylists according to the tempo of the songs.
as well as set the temp of the songs by the bpm
if so that will help out a lot for the internet radio's to have fast paced hour and a slow paced hour.
I also added in the needed header to the script ini file and then put the settemp script in the scripts folder.
when i started media monkey i got all the same alerts as he did. and i can not find the link to click on under the scripts header on the tools menu.?
so what did we or what didn't we screw up
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 A51 5G Android ) 6. amd a8-5600 apu 3.60ghz mm version 4 windows 7 pro bought from computer store.
OK,
A liitle bit of lateral thinking here.
The errors in the script are because the child "Tempo" node under "Classification" does not have these categories already set up. They need to be added. I did it by directly editing the List table in the mediamonkey.mdb.
Then onkel-enno's script works fine and all my Tempos are set correctly !
Happiness
A liitle bit of lateral thinking here.
The errors in the script are because the child "Tempo" node under "Classification" does not have these categories already set up. They need to be added. I did it by directly editing the List table in the mediamonkey.mdb.
Then onkel-enno's script works fine and all my Tempos are set correctly !
Happiness
Regards
Philby
Philby
-
- Posts: 14163
- Joined: Sat Oct 25, 2003 7:57 am
- Location: (Texas)
- Contact:
i need more step by steps i am not a programer i just mess with what i can which is very little in scripting.
so how do i do that what you did, and how do i get this script to show up in the script menu on the tools menu?
in other words.
way in over my
so how do i do that what you did, and how do i get this script to show up in the script menu on the tools menu?
in other words.
way in over my
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 A51 5G Android ) 6. amd a8-5600 apu 3.60ghz mm version 4 windows 7 pro bought from computer store.
-
- Posts: 2153
- Joined: Fri Jan 14, 2005 1:45 am
- Location: Germany
- Contact:
Hi Guys,
sorry for replying so late.
@rovingcowboy
If you want to add it to the scripts menu, you will have to edit the script and add the two bold lines
//code
Option Explicit
Sub SetTempo
REM "Unknown" for BPM < 1
REM "Largo" for BPM between 0 and 56
REM "Andante" for BPM between 57 and 82
REM "Allegro" for BPM between 83 and 145
REM "Presto" for BPM > 145
...
End Sub
//code
and add following to the scripts.ini:
If you want to use other captions for the tempo, you could edit the Set dsTemp-Lines
Example:
Set dsTemp = SDB.Database.OpenSQL("SELECT ID FROM Lists WHERE IDListType = 1 AND TextData = 'Presto'")
->
Set dsTemp = SDB.Database.OpenSQL("SELECT ID FROM Lists WHERE IDListType = 1 AND TextData = 'Fast'")
sorry for replying so late.
@rovingcowboy
If you want to add it to the scripts menu, you will have to edit the script and add the two bold lines
//code
Option Explicit
Sub SetTempo
REM "Unknown" for BPM < 1
REM "Largo" for BPM between 0 and 56
REM "Andante" for BPM between 57 and 82
REM "Allegro" for BPM between 83 and 145
REM "Presto" for BPM > 145
...
End Sub
//code
and add following to the scripts.ini:
Code: Select all
[SetTempo]
FileName=SetTempo.vbs
ProcName=SetTempo
Order=6
DisplayName=Set Tempo Script
Description=...
Language=VBScript
ScriptType=0
Example:
Set dsTemp = SDB.Database.OpenSQL("SELECT ID FROM Lists WHERE IDListType = 1 AND TextData = 'Presto'")
->
Set dsTemp = SDB.Database.OpenSQL("SELECT ID FROM Lists WHERE IDListType = 1 AND TextData = 'Fast'")
To onkel_enno,
Many thanks for your efforts with this script. I have impemented it and it works well. I am now wanting to run this sort of logic without it processing my entire library. I have written a couple of simple scripts to set some Custom fields, and they work only on the tracks I have selected. I would really like to hook this Tempo setting logic into my script so that the Tempo gets set only on the tracks that are selected. Naturally I have the looping logic sorted out, but could you help with the lines to just set the track currently active (I use ITM.fieldname) ? I tried .....
ITM.Tempo = 'Presto' , but got a script error.
Many thanks
Many thanks for your efforts with this script. I have impemented it and it works well. I am now wanting to run this sort of logic without it processing my entire library. I have written a couple of simple scripts to set some Custom fields, and they work only on the tracks I have selected. I would really like to hook this Tempo setting logic into my script so that the Tempo gets set only on the tracks that are selected. Naturally I have the looping logic sorted out, but could you help with the lines to just set the track currently active (I use ITM.fieldname) ? I tried .....
ITM.Tempo = 'Presto' , but got a script error.
Many thanks
Regards
Philby
Philby
-
- Posts: 2153
- Joined: Fri Jan 14, 2005 1:45 am
- Location: Germany
- Contact:
@Philby
It should be s.th. like that:
But I didn't try it!
Of course You'll have to complete the rest of the script!
Hope I could help
It should be s.th. like that:
Code: Select all
Dim Songs
Set Songs = SDB.SelectedSongList
Dim a
Dim SongIDs
for a = 0 to Songs.Count -1
if SongIDs <> "" then SongIDs = SongIDs & ", "
SongIDs = SongIDs & Songs.Item(a).ID
next
'Delete all Tempos
SDB.Database.ExecSQL("Delete from AddSongInfoInt WHERE DataType = 10101 AND IDSong IN (" & SongIDs & ")")
'Set all Tempos to Largo, where BPM between 0 and 56
if CStr(KeyLargo) <> "" then
SDB.Database.ExecSQL("INSERT INTO AddSongInfoInt (IDSong, DataType, IntData) Select Songs.ID, 10101, " & KeyLargo & " FROM Songs WHERE (BPM BETWEEN 0 AND 56) AND (IDSong IN (" & SongIDs & "))")
else
MsgBox "Largo is not part of the Tempo-List"
end if
Of course You'll have to complete the rest of the script!
Hope I could help