CSCore - Play audio from a MemoryStream

I am new to CsCore. Help is needed. I want to create an Audio Recorder that is capable of recording microphone and speakers to file and external Recorder. I have successfully finished writing to the file. Now I want to do the same thing again but play on a specific audio device. I thought about putting a pipeline into a stream and using that stream as the source for WasapiOut. However, I was unable to connect this stream to the IWaveSource.

private Stream _strm;
private WaveWriter _waveWriterFile;
private WaveWriter _wavewriterStream;
private WasapiOut _externalRecorder;

_strm = new MemoryStream();
_wavewriterStream = new WaveWriter(_strm, _SpkCapture.WaveFormat);
IWaveSource ws = new WaveFileReader(_strm);
_externalRecorder.Initialize(ws);
_externalRecorder.Play();

// on Event I do following:
_waveWriterFile.Write(e.Data, e.Offset, e.ByteCount);
_wavewriterStream.Write(e.Data, e.Offset, e.ByteCount);

      

Everything works fine until I call 'new WaveFileReader (_strm);'. I am getting an exception (translation from me) "cannot read outside of stream". The stream contains data at this point in time. Allow 100ms to sleep before trying to fetch the stream. I have also tried

IWaveSource ws = new CSCore.MediaFoundation.MediaFoundationDecoder(strm); 

      

But no luck. I really need help.

+3
memorystream wasapi cscore


source to share


No one has answered this question yet

Check out similar questions:

432
How do you get a string from a MemoryStream?
176
Save and load MemoryStream to / from file
6
How to route the audio of the microphone system to the connected audio stream of the microphone of the device
4
Windows Vista / 7: How to Select the Output Audio Component?
3
CSCore - play audio files from FileStream or MemoryStream
1
Cscore play state change event
1
How to find out if audio is being used in Windows 7
1
rendering PCM C ++ sound buffer using Media Foundation / WASAPI for UWP
1
How to play the same sound twice in parallel in CSCore?
0
CSCore 2 vs 6 RMS channels



All Articles
Loading...
X
Show
Funny
Dev
Pics