My audio data is coming from many large non-standard audio files. When the user selects play I need to start playing straight away I do not have time to scan and convert the files to a standard audio format. I will need to do this ‘on the fly’ …. that’s streaming isn’t it ?
So I guess need to set the sound as a stream, and fille the buffers from my own custom routines.
I can’t seem to find any ‘getting started’ examples can anyone help ?
- chris r asked 13 years ago
Good News ! Got it workling quite quickly.
Bad news: After about 20 seconds ( with many buffer reads ) it suddenly gets stuck on a buffer and keeps playing the same buffer over and over and over…..
I guess that I have introduced a bug some how but it is difficult to track down. I have put breakpoints in the open,, read, close, seek functions and open, seek and read all seem ok. It’s too early for it to call close.
It’s done about 8 reads ok before this happens,
Is tis a typically newbie problem, hav I missed something or is there a reccomended way of looking into this ?
P.S. I do call system.update() approx once per second in a timer loop but the problem occured with or without this running ??
It works ok if I miss out the setfilesystem call. So FMOD is ok and the C Sharp version works – but my VB one does’nt.
All calls to open., read, seek and close seem to work ok.
It crashes with a System.NullReferenceException in some code that it could not find the source for – but at a time not dependent on the buffer size ( 100 bytes or 10000 bytes ).
Is this something to do with Garbage Collection. SO I tried some GC.Collect() ‘s and sure enough. If I call it straight after I start to play the sound it crashes almost straight away. If not then it takes longer.
So the CLR seems to be cleaning up my callbacks ( or something ) when I don’t want it to.
So I revisited the C# code and noticed way you declare the function eg the statement
private FMOD.FILE_OPENCALLBACK = myopen = new FMOD.FILE_OPENCALLBACK(OPENCALLBACK);
This I guess creates an instance of myopen – which will preventI have no idea on how to do this in VB.
Can you give me any guidance on this ?
Getting sound from non-standard files.
Having (mostly) understood the streaming ( from .wav files) , I have started to looking into the getting the sound data from our own complex file formats.
I cannot quite see how I can get FMOD to stream from files that are not in a format that it understands.
I have 100’s of 000’s of files in our own format. Each file contains ( among other things ) 1 second of PCM sound per channel ( for up to 16 channels ).
My plan was to set the read call back to read 1 second of data each time it called me – which would be extracted from the file and placed into the memory buffer. I may need to play sounds that last up to 1 hour ( ie 3600 files ).
I cannot see how to do that directly in fmod. If I use the setfilesystem call it seems to assume that it is a file format it understands and checks the headers etc ?
Fmod also seems to need to know in advance how many samples to play.
At a second glance the usercreatedsound example would seem to be appropriate.. Could I use creatsoundexinfo ? Set length to the total length of the no of samples I wanted to palce ( from all files ) and then make PCMreadcallback from from my own files ?
Brett Thanks for your help on all of this. 😀
It appears to me that the only way to process a truely custom file format, with streaming, is to use the PCMREADCALLBACK where I can maintain full control of the file formatting etc. It also has the advantage that I can call a seperate instance of PCMREADCALLBACK for each instance of my class that processes the file. Whereas I think you can only have once instance of the open/close/rfead/write file system callbacks per system ?
Please login first to submit.