load stream from memory

(xi pan) #1

I want to build a stream to play the music by the movie data I get from other API. But I don’t know how long the data is unless I read all the audio data from the movie.So I don’t know how to create stream from memory so that I could frequently change the data. Just like how it create stream from file,you see that if we use system::createstream to create a stream from a big file, It may not use a lot of memory to save all the file, But it could also play the file data.Thanks for your helping.

(Brett Paterson) #2

You can use FMOD_OPENMEMORY and use the pointer to the sound memory with char *name_or_data, in the createSound call.

You also have to use FMOD_CREATESOUNDEXINFO to say how big the block of memory is.

(xi pan) #3

thanks for your answer,and I know that I can create a memory by using FMOD_OPENMEMORY. But the movie data I read is so huge(maybe 1GB or more bigger AVI or MP4 file) that I can’t read them to memory directly. Morever, not all of the video data is music data,so I need to read a little data and find the music part in each frame, and I want to know how to play the music in each frame so that I don’t need to read the whole video data.Thanks

(Brett Paterson) #4

Sorry I missed the bit about the big file issue. You can stream PCM data into a pcmreadcallback if you use FMOD_OPENUSER , from your own source, but you would have to decode it yourself.

(xi pan) #5

wow! That’s really a good way,thaks for your help.