Nach eniger Zeit hab ich mal wieder mein Purebasic ausgepackt, und spiele mal wieder damit.
Und weil Sound so schön ist, versuche ich es mal wieder mit FMOD.
Also Purebasic 4.1 herundergeladen und FMOD 4.13.07.
Im englischen Forum habe ich folgendes Beispiel gefunden:
Code: Alles auswählen
Enumeration
#FMOD_OK
#FMOD_ERR_ALREADYLOCKED
#FMOD_ERR_BADCOMMAND
#FMOD_ERR_CDDA_DRIVERS
#FMOD_ERR_CDDA_INIT
#FMOD_ERR_CDDA_INVALID_DEVICE
#FMOD_ERR_CDDA_NOAUDIO
#FMOD_ERR_CDDA_NODEVICES
#FMOD_ERR_CDDA_NODISC
#FMOD_ERR_CDDA_READ
#FMOD_ERR_CHANNEL_ALLOC
#FMOD_ERR_CHANNEL_STOLEN
#FMOD_ERR_COM
#FMOD_ERR_DMA
#FMOD_ERR_DSP_CONNECTION
#FMOD_ERR_DSP_FORMAT
#FMOD_ERR_DSP_NOTFOUND
#FMOD_ERR_DSP_RUNNING
#FMOD_ERR_DSP_TOOMANYCONNECTIONS
#FMOD_ERR_FILE_BAD
#FMOD_ERR_FILE_COULDNOTSEEK
#FMOD_ERR_FILE_EOF
#FMOD_ERR_FILE_NOTFOUND
#FMOD_ERR_FILE_UNWANTED
#FMOD_ERR_FORMAT
#FMOD_ERR_HTTP
#FMOD_ERR_HTTP_ACCESS
#FMOD_ERR_HTTP_PROXY_AUTH
#FMOD_ERR_HTTP_SERVER_ERROR
#FMOD_ERR_HTTP_TIMEOUT
#FMOD_ERR_INITIALIZATION
#FMOD_ERR_INITIALIZED
#FMOD_ERR_INTERNAL
#FMOD_ERR_INVALID_HANDLE
#FMOD_ERR_INVALID_PARAM
#FMOD_ERR_INVALID_SPEAKER
#FMOD_ERR_IRX
#FMOD_ERR_MEMORY
#FMOD_ERR_MEMORY_IOP
#FMOD_ERR_MEMORY_SRAM
#FMOD_ERR_NEEDS2D
#FMOD_ERR_NEEDS3D
#FMOD_ERR_NEEDSHARDWARE
#FMOD_ERR_NEEDSSOFTWARE
#FMOD_ERR_NET_CONNECT
#FMOD_ERR_NET_SOCKET_ERROR
#FMOD_ERR_NET_URL
#FMOD_ERR_NOTREADY
#FMOD_ERR_OUTPUT_ALLOCATED
#FMOD_ERR_OUTPUT_CREATEBUFFER
#FMOD_ERR_OUTPUT_DRIVERCALL
#FMOD_ERR_OUTPUT_FORMAT
#FMOD_ERR_OUTPUT_INIT
#FMOD_ERR_OUTPUT_NOHARDWARE
#FMOD_ERR_OUTPUT_NOSOFTWARE
#FMOD_ERR_PAN
#FMOD_ERR_PLUGIN
#FMOD_ERR_PLUGIN_MISSING
#FMOD_ERR_PLUGIN_RESOURCE
#FMOD_ERR_RECORD
#FMOD_ERR_REVERB_INSTANCE
#FMOD_ERR_SUBSOUNDS
#FMOD_ERR_SUBSOUND_ALLOCATED
#FMOD_ERR_TAGNOTFOUND
#FMOD_ERR_TOOMANYCHANNELS
#FMOD_ERR_UNIMPLEMENTED
#FMOD_ERR_UNINITIALIZED
#FMOD_ERR_UNSUPPORTED
#FMOD_ERR_UPDATE
#FMOD_ERR_VERSION
EndEnumeration
Procedure.s FMOD_ErrorString(FMOD_RESULT.l)
;MessageRequester ("ErrorStr", Str(FMOD_RESULT.l))
Select FMOD_RESULT
Case #FMOD_ERR_ALREADYLOCKED: ProcedureReturn "Tried to call lock a second time before unlock was called. ";
Case #FMOD_ERR_BADCOMMAND: ProcedureReturn "Tried to call a function on a data type that does not allow this type of functionality (ie calling Sound::lock on a streaming sound). ";
Case #FMOD_ERR_CDDA_DRIVERS: ProcedureReturn "Neither NTSCSI nor ASPI could be initialised. ";
Case #FMOD_ERR_CDDA_INIT: ProcedureReturn "An error occurred while initialising the CDDA subsystem. ";
Case #FMOD_ERR_CDDA_INVALID_DEVICE: ProcedureReturn "Couldn't find the specified device. ";
Case #FMOD_ERR_CDDA_NOAUDIO: ProcedureReturn "No audio tracks on the specified disc. ";
Case #FMOD_ERR_CDDA_NODEVICES: ProcedureReturn "No CD/DVD devices were found. ";
Case #FMOD_ERR_CDDA_NODISC: ProcedureReturn "No disc present in the specified drive. ";
Case #FMOD_ERR_CDDA_READ: ProcedureReturn "A CDDA read error occurred. ";
Case #FMOD_ERR_CHANNEL_ALLOC: ProcedureReturn "Error trying to allocate a channel. ";
Case #FMOD_ERR_CHANNEL_STOLEN: ProcedureReturn "The specified channel has been reused to play another sound. ";
Case #FMOD_ERR_COM: ProcedureReturn "A Win32 COM related error occured. COM failed to initialize or a QueryInterface failed meaning a Windows codec or driver was not installed properly. ";
Case #FMOD_ERR_DMA: ProcedureReturn "DMA Failure. See debug output for more information. ";
Case #FMOD_ERR_DSP_CONNECTION: ProcedureReturn "DSP connection error. Connection possibly caused a cyclic dependancy. ";
Case #FMOD_ERR_DSP_FORMAT: ProcedureReturn "DSP Format error. A DSP unit may have attempted to connect to this network with the wrong format. ";
Case #FMOD_ERR_DSP_NOTFOUND: ProcedureReturn "DSP connection error. Couldn't find the DSP unit specified. ";
Case #FMOD_ERR_DSP_RUNNING: ProcedureReturn "DSP error. Cannot perform this operation while the network is in the middle of running. This will most likely happen if a connection or disconnection is attempted in a DSP callback. ";
Case #FMOD_ERR_DSP_TOOMANYCONNECTIONS: ProcedureReturn "DSP connection error. The unit being connected to or disconnected should only have 1 input or output. ";
; Case #FMOD_ERR_EVENT_FAILED: ProcedureReturn "An Event failed to be retrieved, most likely due to 'just fail' being specified as the max playbacks behaviour. ";
; Case #FMOD_ERR_EVENT_INFOONLY: ProcedureReturn "Can't execute this command on an EVENT_INFOONLY event. ";
; Case #FMOD_ERR_EVENT_INTERNAL: ProcedureReturn "An error occured that wasn't supposed to. See debug log for reason. ";
; Case #FMOD_ERR_EVENT_NAMECONFLICT: ProcedureReturn "A category with the same name already exists. ";
; Case #FMOD_ERR_EVENT_NOTFOUND: ProcedureReturn "The requested event, event group, event category or event property could not be found. ";
Case #FMOD_ERR_FILE_BAD: ProcedureReturn "Error loading file. ";
Case #FMOD_ERR_FILE_COULDNOTSEEK: ProcedureReturn "Couldn't perform seek operation. This is a limitation of the medium (ie netstreams) or the file format. ";
Case #FMOD_ERR_FILE_EOF: ProcedureReturn "End of file unexpectedly reached while trying to read essential data (truncated data?). ";
Case #FMOD_ERR_FILE_NOTFOUND: ProcedureReturn "File not found. ";
Case #FMOD_ERR_FILE_UNWANTED: ProcedureReturn "Unwanted file access occured. ";
Case #FMOD_ERR_FORMAT: ProcedureReturn "Unsupported file or audio format. ";
Case #FMOD_ERR_HTTP: ProcedureReturn "A HTTP error occurred. This is a catch-all for HTTP errors not listed elsewhere. ";
Case #FMOD_ERR_HTTP_ACCESS: ProcedureReturn "The specified resource requires authentication or is forbidden. ";
Case #FMOD_ERR_HTTP_PROXY_AUTH: ProcedureReturn "Proxy authentication is required to access the specified resource. ";
Case #FMOD_ERR_HTTP_SERVER_ERROR: ProcedureReturn "A HTTP server error occurred. ";
Case #FMOD_ERR_HTTP_TIMEOUT: ProcedureReturn "The HTTP request timed out. ";
Case #FMOD_ERR_INITIALIZATION: ProcedureReturn "FMOD was not initialized correctly to support this function. ";
Case #FMOD_ERR_INITIALIZED: ProcedureReturn "Cannot call this command after System::init. ";
Case #FMOD_ERR_INTERNAL: ProcedureReturn "An error occured that wasn't supposed to. Contact support. ";
; Case #FMOD_ERR_INVALID_ADDRESS: ProcedureReturn "On Xbox 360, this memory address passed to FMOD must be physical, (ie allocated with XPhysicalAlloc.) ";
; Case #FMOD_ERR_INVALID_FLOAT: ProcedureReturn "Value passed in was a NaN, Inf or denormalized float. ";
Case #FMOD_ERR_INVALID_HANDLE: ProcedureReturn "An invalid object handle was used. ";
Case #FMOD_ERR_INVALID_PARAM: ProcedureReturn "An invalid parameter was passed to this function. ";
Case #FMOD_ERR_INVALID_SPEAKER: ProcedureReturn "An invalid speaker was passed to this function based on the current speaker mode. ";
; Case #FMOD_ERR_INVALID_VECTOR: ProcedureReturn "The vectors passed in are not unit length, or perpendicular. ";
Case #FMOD_ERR_IRX: ProcedureReturn "PS2 only. fmodex.irx failed to initialize. This is most likely because you forgot to load it. ";
Case #FMOD_ERR_MEMORY: ProcedureReturn "Not enough memory or resources. ";
; Case #FMOD_ERR_MEMORY_CANTPOINT: ProcedureReturn "Can't use FMOD_OPENMEMORY_POINT on non PCM source data, or non mp3/xma/adpcm data if FMOD_CREATECOMPRESSEDSAMPLE was used. ";
Case #FMOD_ERR_MEMORY_IOP: ProcedureReturn "PS2 only. Not enough memory or resources on PlayStation 2 IOP ram. ";
Case #FMOD_ERR_MEMORY_SRAM: ProcedureReturn "Not enough memory or resources on console sound ram. ";
Case #FMOD_ERR_NEEDS2D: ProcedureReturn "Tried to call a command on a 3d sound when the command was meant for 2d sound. ";
Case #FMOD_ERR_NEEDS3D: ProcedureReturn "Tried to call a command on a 2d sound when the command was meant for 3d sound. ";
Case #FMOD_ERR_NEEDSHARDWARE: ProcedureReturn "Tried to use a feature that requires hardware support. (ie trying to play a VAG compressed sound in software on PS2). ";
Case #FMOD_ERR_NEEDSSOFTWARE: ProcedureReturn "Tried to use a feature that requires the software engine. Software engine has either been turned off, or command was executed on a hardware channel which does not support this feature. ";
Case #FMOD_ERR_NET_CONNECT: ProcedureReturn "Couldn't connect to the specified host. ";
Case #FMOD_ERR_NET_SOCKET_ERROR: ProcedureReturn "A socket error occurred. This is a catch-all for socket-related errors not listed elsewhere. ";
Case #FMOD_ERR_NET_URL: ProcedureReturn "The specified URL couldn't be resolved. ";
Case #FMOD_ERR_NOTREADY: ProcedureReturn "Operation could not be performed because specified sound is not ready. ";
Case #FMOD_ERR_OUTPUT_ALLOCATED: ProcedureReturn "Error initializing output device, but more specifically, the output device is already in use and cannot be reused. ";
Case #FMOD_ERR_OUTPUT_CREATEBUFFER: ProcedureReturn "Error creating hardware sound buffer. ";
Case #FMOD_ERR_OUTPUT_DRIVERCALL: ProcedureReturn "A call to a standard soundcard driver failed, which could possibly mean a bug in the driver or resources were missing or exhausted. ";
Case #FMOD_ERR_OUTPUT_FORMAT: ProcedureReturn "Soundcard does not support the minimum features needed for this soundsystem (16bit stereo output). ";
Case #FMOD_ERR_OUTPUT_INIT: ProcedureReturn "Error initializing output device. ";
Case #FMOD_ERR_OUTPUT_NOHARDWARE: ProcedureReturn "FMOD_HARDWARE was specified but the sound card does not have the resources nescessary to play it. ";
Case #FMOD_ERR_OUTPUT_NOSOFTWARE: ProcedureReturn "Attempted to create a software sound but no software channels were specified in System::init. ";
Case #FMOD_ERR_PAN: ProcedureReturn "Panning only works with mono or stereo sound sources. ";
Case #FMOD_ERR_PLUGIN: ProcedureReturn "An unspecified error has been ProcedureReturned from a 3rd party plugin. ";
Case #FMOD_ERR_PLUGIN_MISSING: ProcedureReturn "A requested output, dsp unit type or codec was not available. ";
Case #FMOD_ERR_PLUGIN_RESOURCE: ProcedureReturn "A resource that the plugin requires cannot be found. (ie the DLS file for MIDI playback) ";
Case #FMOD_ERR_RECORD: ProcedureReturn "An error occured trying to initialize the recording device. ";
Case #FMOD_ERR_REVERB_INSTANCE: ProcedureReturn "Specified Instance in FMOD_REVERB_PROPERTIES couldn't be set. Most likely because another application has locked the EAX4 FX slot. ";
Case #FMOD_ERR_SUBSOUNDS: ProcedureReturn "The error occured because the sound referenced contains subsounds. (ie you cannot play the parent sound as a static sample, only its subsounds.) ";
Case #FMOD_ERR_SUBSOUND_ALLOCATED: ProcedureReturn "This subsound is already being used by another sound, you cannot have more than one parent to a sound. Null out the other parent's entry first. ";
Case #FMOD_ERR_TAGNOTFOUND: ProcedureReturn "The specified tag could not be found or there are no tags. ";
Case #FMOD_ERR_TOOMANYCHANNELS: ProcedureReturn "The sound created exceeds the allowable input channel count. This can be increased using the maxinputchannels parameter in System::setSoftwareFormat. ";
Case #FMOD_ERR_UNIMPLEMENTED: ProcedureReturn "Something in FMOD hasn't been implemented when it should be! contact support! ";
Case #FMOD_ERR_UNINITIALIZED: ProcedureReturn "This command failed because System::init or System::setDriver was not called. ";
Case #FMOD_ERR_UNSUPPORTED: ProcedureReturn "A command issued was not supported by this object. Possibly a plugin without certain callbacks specified. ";
Case #FMOD_ERR_UPDATE: ProcedureReturn "An error caused by System::update occured. ";
Case #FMOD_ERR_VERSION: ProcedureReturn "The version number of this file format is not supported. ";
Case #FMOD_OK: ProcedureReturn "No errors.";
Default : ProcedureReturn "Unknown error.";
EndSelect
EndProcedure
#FMOD_DEFAULT = 0
#FMOD_INIT_NORMAL = 0
#FMOD_HARDWARE = 20
#FMOD_SOFTWARE = $40
#FMOD_OPENMEMORY = $800
#FMOD_LOOP_OFF = 1
#FMOD_CHANNEL_FREE = -1
#FMOD_CREATECOMPRESSEDSAMPLE = $200
Structure FMOD_CREATESOUNDEXINFO
cbsize.l
Length.l
fileoffset.l
Numchannels.l
defaultfrequency.l
Format.l ; FSOUND_FORMAT
decodebuffersize.l
initialsubsound.l
Numsubsounds.l
inclusionlist.l
inclusionlistnum.l
pcmreadcallback.l
pcmsetposcallback.l
nonblockcallback.l
dlsname.s
encryptionkey.s
maxpolyphony.l
userdata.l
suggestedsoundtype.l
useropen.l
userclose.l
userread.l
userseek.l
EndStructure
file.s =OpenFileRequester("","","*.wav", 0)
FileHwd.l = ReadFile(#PB_Any, file)
filesize.l = Lof(FileHwd)
*FileMem.l =AllocateMemory( filesize )
ReadData(FileHwd, *FileMem, filesize )
CloseFile(FileHwd)
exinfo.FMOD_CREATESOUNDEXINFO
exinfo\cbsize=SizeOf(FMOD_CREATESOUNDEXINFO)
exinfo\Length=filesize
OpenLibrary(0,"C:\Programme\FMOD SoundSystem\FMOD Programmers API Win32\api\fmodex.dll")
F1 = CallFunction(0,"FMOD_System_Create", @system)
Debug "FMOD_System_Create: " + FMOD_ErrorString(F1)
F2 =CallFunction(0, "FMOD_System_Init", system, 32, #FMOD_INIT_NORMAL | #FMOD_LOOP_OFF, 0)
Debug "FMOD_System_Init: " + FMOD_ErrorString(F2)
F3 = CallFunction(0, "FMOD_System_CreateSound", system, *FileMem, #FMOD_OPENMEMORY| #FMOD_HARDWARE | #FMOD_LOOP_OFF|#FMOD_CREATECOMPRESSEDSAMPLE, *exinfo, @sound)
;F3 = CallFunction(0, "FMOD_System_CreateSound", system, file, #FMOD_HARDWARE,0, @sound)
Debug "FMOD_System_CreateSound: "+ FMOD_ErrorString(F3)
F4 = CallFunction(0, "FMOD_Sound_SetMode", sound, #FMOD_LOOP_OFF)
Debug "FMOD_Sound_SetMode:" + FMOD_ErrorString(F4)
OpenWindow(0,0,0,100,100,"",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
CreateGadgetList(WindowID(0))
ButtonGadget (1, 10, 10,80, 80, "Play sound")
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_Event_Gadget And EventGadget() = 1
PS = CallFunction(0, "FMOD_System_PlaySound", system, #FMOD_CHANNEL_FREE, sound, 0, @channel)
Debug "PlayError: " + FMOD_ErrorString(PS) + ", Kanal: " + Str(channel)
EndIf
Until EventID = #PB_Event_CloseWindow
CallFunction(0, "FMOD_Sound_Release", sound)
CallFunction(0, "FMOD_System_Close", system)
FreeMemory(*FileMem)
CloseLibrary(0)
Code: Alles auswählen
CallFunction(0, "FMOD_System_CreateSound", system, *FileMem, #FMOD_OPENMEMORY| #FMOD_HARDWARE | #FMOD_LOOP_OFF|#FMOD_CREATECOMPRESSEDSAMPLE, *exinfo, @sound)
Anscheinend findet die Funktion nicht die im Speicher abgelegte wav-Datei nicht.
Kann mir bitte jemand sagen, was ich hier falsch mache?
Vielen Dank!
Lemy