poleguy Posted September 16, 2009 Share Posted September 16, 2009 I'm having trouble with this script. It worked fine on a different computer (maybe on an earlier version of auto-it too?), but then I brought it back to my main machine and it crashed in the dll call. I found that to fix it I needed to increase the size of $pointer to be at least the size of the _entire_ wave file. According to the libsndfile spec, this should only have to be as big as the number of items requested. Obviously this will make this solution quite painful to use on large wav files. Any idea if this bug is AutoIt related or libsndfile related? I'm running AutoIt 3.3.0.0 Any idea how to work around this problem? Anybody got a better idea of how to access sample data in 24 bit wave files? That's my eventual goal. I want to write a file to check for repeated/dropped samples in studio recordings using an algorithm I've come up with. To get this to run you'll need to install this: http://www.mega-nerd.com/libsndfile/#Download expandcollapse popup#Include <string.au3> ;#Include <GUIConstants.au3> ;#include <misc.au3> Opt( "GUIOnEventMode", 1 ) Dim $retError $sfm_read = 0x10 dim $lpszPath = 'C:\windows\Media\Windows XP Shutdown.wav' ;dim $lpszPath = 'g:\data\2009\AutoIt_wave\test.wav' dim $sf_info = _StringRepeat(" ", 103) $retError = _checkFile(); If $retError <> 0 Then msgbox(0,"error","error") EndIf Exit Func _checkFile() ;dim $sndfile = _StringRepeat(" ", 1000) $sf_info = DllStructCreate("int64 frames;int samplerate;int channels ;int format ;int sections ;int seekable;") if @error Then MsgBox(0,"","Error in DllStructCreate " & @error); exit endif $stString = DLLStructCreate("char[260]") DllStructSetData($stString, 1, $lpszPath) $test = DllStructGetData($stString,1); ;msgbox(0,"path",$test) $dll = DllOpen("C:\Program Files\Mega-Nerd\libsndfile\libsndfile-1.dll") $sndfile = DllCall($dll, "int*:cdecl", "sf_open", "ptr", DllStructGetPtr($stString), "int", $sfm_read, "ptr", DllStructGetPtr($sf_info)) ;$sndfile = DllCall("libsndfile-1.dll", "int", "sf_open", "str", $lpszPath, "int", $sfm_read,"str", $sf_info) $err = @error if $err > 0 Then msgbox(0,"ack","can't use the dll: " & $err) EndIf $test = DllStructGetPtr($sndfile); msgbox(0,"pointer",$test) msgbox(0,"sndfile","Sound file pointer: " & $sndfile[0]) $items = 14 ;dim $pointer = _StringRepeat( " ", 1000) $pointer = DllStructCreate("int data[141282];") if @error Then MsgBox(0,"","Error in DllStructCreate " & @error); exit endif msgbox(0,"test","test2") $result = DllCall($dll, "int64:cdecl", "sf_read_int", "ptr", $sndfile[0], "ptr", DllStructGetPtr($pointer), "int", $items) msgbox(0,"test","test3") $err = @error if $err > 0 Then msgbox(0,"ack","can't use the dll: " & $err) EndIf msgbox(0,"data","Items returned: " & hex($result[0]/(2^32)) & " " & hex(mod($result[0],2^32))) ;msgbox(0,"compare", $result[2] & " vs " & $pointer & " vs " & DllStructGetPtr($pointer)) for $item = 0 to $items $sample = DllStructGetData($pointer,1,$item) msgbox(0,"data","Values: " & $item & ": " & hex($sample)) next DllClose($dll) ;DllCall("libsndfile-1", "int*", "sf_open", "const char *", $lpszPath, "int", $sfm_read,"char *", $sf_info) Return 0 EndFunc ;==>_mciSendString 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