davecollinsnz Posted August 9, 2008 Share Posted August 9, 2008 (edited) What I am trying to do is get the bpm from a song that is playing on the computer using bass.dll from http://www.un4seen.com/. This is my code While 1 $bpmdata=DllCall("bass.dll","Long", "BASS_ChannelGetAttribute","DWORD","HMUSIC","DWORD","BASS_ATTRIB_MUSIC_BPM","float"," ") msgbox(0,"$bpmdata",$bpmdata) msgbox(0,"$bpmdata[0]",$bpmdata[0]) msgbox(0,"$bpmdata[1]",$bpmdata[1]) msgbox(0,"$bpmdata[2]",$bpmdata[2]) Wend And here is a page from the bass help file. BASS_ChannelGetAttribute -------------------------------------------------------------------------------- Retrieves the value of a channel's attribute. BOOL BASS_ChannelGetAttribute( DWORD handle, DWORD attrib, float *value ); Parameters handle The channel handle... a HCHANNEL, HMUSIC, HSTREAM, or HRECORD. attrib The attribute to set the value of... one of the following. BASS_ATTRIB_EAXMIX EAX wet/dry mix. (HCHANNEL/HMUSIC/HSTREAM only) BASS_ATTRIB_FREQ Sample rate. BASS_ATTRIB_MUSIC_AMPLIFY Amplification level. (HMUSIC) BASS_ATTRIB_MUSIC_BPM BPM. (HMUSIC) BASS_ATTRIB_MUSIC_PANSEP Pan separation level. (HMUSIC) BASS_ATTRIB_MUSIC_PSCALER Position scaler. (HMUSIC) BASS_ATTRIB_MUSIC_SPEED Speed. (HMUSIC) BASS_ATTRIB_MUSIC_VOL_CHAN A channel volume level. (HMUSIC) BASS_ATTRIB_MUSIC_VOL_GLOBAL Global volume level. (HMUSIC) BASS_ATTRIB_MUSIC_VOL_INST An instrument/sample volume level. (HMUSIC) BASS_ATTRIB_PAN Panning/balance position. BASS_ATTRIB_VOL Volume level. other attributes may be supported by add-ons, see the documentation. value Pointer to a variable to receive the attribute value. Return value If successful, then TRUE is returned, else FALSE is returned. Use BASS_ErrorGetCode to get the error code. Error codes BASS_ERROR_HANDLE handle is not a valid channel. BASS_ERROR_ILLTYPE attrib is not valid. some attributes may have additional error codes, see the documentation. I have been searching through the forums for several days and I need someone to show me if I was close to it or was completely wrong and should start from scratch. Cheers. Edited August 9, 2008 by TheDarkEngineer Trust me to make SkyNet with AutoIt... Link to comment Share on other sites More sharing options...
BrettF Posted August 9, 2008 Share Posted August 9, 2008 Maybe something like this: Global Const $BASS_ATTRIB_MUSIC_BPM = 0x103 ; DLL Stuff $test_mp3 = "d:\my documents\My Music\Nirvana20-20Smells20Like20Teen20Spirit.mp3" ;$test_mp3 = "d:\my documents\autoit\Media Player\Downloaded Files\BASS DLL\SAMPLES\6chan\6chan.ogg" $bassdll = DllOpen("bass.dll") $ret = DllCall($bassdll, "int", "BASS_Init", "int", -1, _ "int", 44100, _ "int", 0, _ "hwnd", 0, _ "ptr", 0) If Not $ret[0] Then MsgBox(0, "Error", 'Error initializing audio!'); Exit EndIf $fName = DllStructCreate("char[255]") DllStructSetData($fName, 1, $test_mp3) $stream = DllCall($bassdll, "int", "BASS_StreamCreateFile", "int", False, "ptr", DllStructGetPtr($fName), "uint64", 0, "uint64", 0, "dword", 0x200) $music_handle = $stream[0] $fName = 0 $ret = DllCall($bassdll, "int", "BASS_ChannelPlay", "dword", $music_handle, "int", 0) $return2 = DllStructCreate ("ptr") $bpmdata = DllCall("bass.dll","int", "BASS_ChannelGetAttribute","DWORD",$music_handle, "DWORD",$BASS_ATTRIB_MUSIC_BPM, "ptr", DllStructGetPtr ($return2)) $ret = DllStructGetData ($return2, 1) MsgBox (0, "", $ret) Still learning dll calls using Structs... Getting better though Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
davecollinsnz Posted August 10, 2008 Author Share Posted August 10, 2008 Thanks for the code, but I don't think I'm getting the data back I need. I'm going start from scratch and try again. If I ever figure it out, I'll post the code. Trust me to make SkyNet with AutoIt... Link to comment Share on other sites More sharing options...
BrettF Posted August 10, 2008 Share Posted August 10, 2008 I didn't work for me either, but you had some constants missing, but I'm sure we're headed in the right direction Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! 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