I use ctypes to play AUDIO using bass.dll found here:
I have gone so far and tried as they advised me at their forum entry here:
But I still get errors. Can anyone take code and analyze to point out source of error?
Here is the code, pse ignore any useless comment, I was using the editor as scratch pad too :D
#import ctypes module import ctypes as ct #import OS import os #get BOOL C++ value from ctypes from ctypes.wintypes import BOOL from ctypes.wintypes import HANDLE #Loading the DLL see: http://www.daniweb.com/forums/thread160430.html bass_dll = ct.windll.bass #initialize the DLL # sample I got somehwere: BASS_Init(-1,44100,0,win,NULL) win The application's main window... 0 = the current foreground window (use this for console applications). #function to intialize the DLL def onInit_Lib(): #define arg types bass_dll.BASS_Init.argtypes = [ct.c_int, ct.c_int, ct.c_int, ct.c_int, ct.c_int] #define result types bass_dll.BASS_Init.restype = ct.c_int #call function with args c= bass_dll.BASS_Init(-1, 44100, 0,0, 0) print c def onStream(): #arg definitions #HSTREAM BASS_StreamCreateFile(BOOL mem, void *file, QWORD offset, QWORD length, DWORD flags); bass_dll.BASS_StreamCreateFile.argtypes = [BOOL, ct.c_char_p, ct.c_int , ct.c_int, ct.c_int] #defining restypes bass_dll.BASS_StreamCreateFile.restype = HANDLE path = os.getcwd() full = os.path.join(path, "test.mp3") print full stream = bass_dll.BASS_StreamCreateFile(False, full, 0, 0, 0) print stream return stream def onPlay(stream): #define args #BASS_ChannelPlay(stream, FALSE); // play the stream bass_dll.BASS_ChannelPlay.argtypes = [HANDLE, BOOL] #call function bass_dll.BASS_ChannelPlay(stream, False) onInit_Lib() stream = onStream() onPlay(stream)