cscore icon indicating copy to clipboard operation
cscore copied to clipboard

Playing from memory

Open trevorboultwood opened this issue 4 years ago • 2 comments

I'm Currently writing audio to disk and playing back from said location. I'm now trying to skip the writing to disk part and cant figure it out, would anyone be able to advise?

So far I have been going of this:

https://stackoverflow.com/questions/37333969/cscore-play-audio-from-a-filestream-or-memorystream

How I need to so for a wav and marry the two together.

Thank you,

trevorboultwood avatar Aug 27 '20 13:08 trevorboultwood

Initialize a WriteableBufferingSource with the correct format and set FillWithZeros to true. Playback the initialized WriteableBufferingSource with the soundout. Use the Write method of the WriteableBufferingSource to write data to the buffer.

Note that the format of the data must be any decoded raw format like pcm or ieeefloat.

filoe avatar Aug 31 '20 09:08 filoe

If you have a program to write the diskfile, change it to write to MemoryStream. instead of close/open the file, set MemoryStream.Position=0 and offer the file to the player.

Ambusy avatar Mar 22 '21 19:03 Ambusy