Sign in to follow this  
Followers 0
guestscripter

BPM Analyser

4 posts in this topic

I got the idea for this this morning and like how it turned out:

#Include <Misc.au3>
#Include <Array.au3>

$iTunesApp = ObjCreate("iTunes.Application")

HotKeySet("b","_Display")
HotKeySet("{SPACE}","_Beat")
HotKeySet("{ESC}","_Quit")
HotKeySet("{F3}","_Pause")

Dim $beat[4]
$time = TimerInit()
$pressed = 0
$paused = 0

While 1
    $i = 0
    Do
        Do
            Sleep(500)
        Until $pressed = 1
        $pressed = 0
        $i = $i + 1
    Until $i = 4
WEnd


Func _Beat()
    SplashOff()
    _ArrayPush($beat,TimerDiff($time))
    $pressed = 1
    ConsoleWrite($i)
    $beat3 = $beat[3] - $beat[2]
    $beat2 = $beat[2] - $beat[1]
    $beat1 = $beat[1] - $beat[0]
    $total = $beat1 + $beat2 + $beat3
    $average = $total / 3000
    $final = 60 / $average
    $final = Round($final + 0.5,0)
    SplashTextOn("BPM Tapper",$final & " Beats Per Minute",200,30)
EndFunc

Func _Quit()
    Exit
EndFunc

Func _Pause()
    If $paused = 0 Then
        $paused = 1
    Else
        $paused = 0
    EndIf
    HotKeySet("b")
    HotKeySet("{SPACE}")
    HotKeySet("{ESC}")
    SplashOff()
    While $paused = 1
        Sleep(500)
    WEnd
    HotKeySet("b","_Display")
    HotKeySet("{SPACE}","_Beat")
    HotKeySet("{ESC}","_Quit")
    $pressed = 1
    $i = 4
    ReDim $beat[4]
    $time = TimerInit()
EndFunc

Func _Display()
    SplashOff()
    $beat[3] = $beat[3] - $beat[2]
    $beat[2] = $beat[2] - $beat[1]
    $beat[1] = $beat[1] - $beat[0]
    $total = $beat[1] + $beat[2] + $beat[3]
    $average = $total / 3000
    $final = 60 / $average
    $final = Round($final + 0.5,0)
    MsgBox(0,"Final BPM",$final & "bpm")
    $iTunesApp.CurrentTrack.BPM = $final
    $pressed = 1
    $i = 6
    ReDim $beat[4]
    $time = TimerInit()
EndFunc

What you do is start up the script, play a song file (at the moment it's set up for itunes but that's just one line of code - easily changed), and then tap your space bar to the beat until you think you've done it steadily at least 4 times. The script then works out the beats per minute from those taps and puts it into the song data in iTunes.

It's useful for me cos i do a bit of DJ'ing.

Please let me know if you like it.

I don't use GUI's cos i don't know how but if somebody redid this using GUI's that would be awesome.

P.S. I was initially hoping to be able to tap out the beat on my mouse pad, bt HotKeySet doesn't recognize mouse presses and when I tried to use IsPressed it didn't really work the way I wanted. Any ideas anyone?

Share this post


Link to post
Share on other sites



mouse pad? you mean like a tablet? or just a mouse?

If you just want to click the mouse, whipping up a GUI for that woulden't be hard.


MUHAHAHAHAHA

Share this post


Link to post
Share on other sites

nice idea but isnt it supposed to do all the work?


[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Share this post


Link to post
Share on other sites

Simple and effective.

Cheers,

Llamnuds

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0