guestscripter Posted December 21, 2006 Share Posted December 21, 2006 I got the idea for this this morning and like how it turned out: expandcollapse popup#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? ImageSearch15.au3 featuring _ImageSearchStartup() and _ImageSearchShutdown() Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now