great, glad you got it working in the end
Mark
great, glad you got it working in the end
Mark
please read this article
This is done using "loopback recording", which can be done using WASAPI in on Windows Vista and above (see the WasapiLoopbackCapture class). If you want to do it with WaveIn, you are completely reliant on what your soundcard drivers allow, and it is a lot of work.
You probably don't need to use WaveOffsetStream which might simplify your code a bit. Are there any actions happening on other threads (such as changing position)? There could be threading issues if Read is called on a different thread to a reposition.
hi, glad you got it working in the end
I have an application where I need the ability to loop the audio stream from the input to the speakers. I am currently doing this with WaveIn and DirectSoundOut.
Everything here works except that the DirectSoundOut says that it does not support volume when I get down to that line of code. How can I change the volume of the audio being sent to the speakers? If it means I cannot use DirectSoundOut that is fine, but what would I use?
I'm setting up using the code below:
private void button1_Click(object sender, EventArgs e) { if (waveIn == null) { waveIn = new WaveIn(); waveIn.WaveFormat = new NAudio.Wave.WaveFormat(sampleRate, bitsPerSample, channels); if (waveOut == null) { WaveInProvider waveInProvider = new WaveInProvider(waveIn); waveOut = new DirectSoundOut(); waveOut.Init(waveInProvider); } waveOut.Volume = volumeSlider1.Volume; waveIn.StartRecording(); waveOut.Play(); } }
Hi Mark,
I read your stackoverflow's answer... Ok, i can't understand if the voice i'm analyzing is human or not but i know about the dB range of human voice and for now it's ok....
In my last test i wrote wrong code to calculate dBs... my mistake....
P.S.: Good job with NAudio because it's a very interesting and useful library!
Thanks,
Enrico
WaveOut in FunctionCallback mode does not generate a PlaybackStopped event on USB device pull out. I switched to WaveOutEvent and that worked.
Hi Tom,
Have you done your patch yet ? I'm also considering doing mine. I want to convert a subset of NAudio (CoreAudio) in order to use it in a store application. Right now I'm stuck with custom marshaling (ICustomMarshaler doesn't exist). Is your patch available ? Have you the same problem ?
Thanks.
Olivier
Yes,that Gsm610WaveFormat was just a random idea and as I now remember the gsm modem send the data in format as used above.
Well. Now I changed the initalizing as shown
waveProvider = new BufferedWaveProvider(new WaveFormat(8000, 16, 1)); waveRecorder = new WaveRecorder(waveProvider, incomingWavFilename); waveOut = new WaveOutEvent(); waveOut.DeviceNumber = waveDevice.OutDeviceNumber; waveOut.DesiredLatency = 150; waveOut.Init(waveRecorder); waveOut.PlaybackStopped += new EventHandler<StoppedEventArgs>(waveOut_PlaybackStopped); waveOut.Play();
And now in SerialPort DataReceived I just call BufferedWaveProvider.AddSamples?
Is there any problems if the buffer starts to increase, ie. 2h calls?
Thanks.
NAudio isn't highly optimised for speed, but it should be possible with 44.1kHz audio on a relatively modern machine. Are you mixing down to file or trying to play the mixed audio back?
I suspect its a problem with the way you're adding rows to your ListView control. Try adding rows with hard-coded values to narrow down where the problem is occuring.
Either use WaveOut/WaveOutEvent instead, or you would need to modify the levels of each sample (e.g. using VolumeWaveProvider16)
Mark
this exception should no longer be unhandled in the latest code as we catch any exceptions thrown in buffer.OnDone
WaveInProvider fills a buffer with audio as it is received. If there is nothing in the buffer, you'll hear a gap in playback. You will probably need to tweak your buffer sizes for input and output latency to get this working smoothly.
We are playing back. In fact we are streaming, but it would have to be pretty much real time. All we are interested in is the resampling code... literally converting 6 sample streams into 2.
I don't recommend using FunctionCallback. It has been nothing but trouble. WaveOutEvent is the preferred approach.
Oh, was edit.
You mean just manually add some strings to my list?
Thanks for the quick reply!
I have looked through the source code, and I'm not actually trying to do a direct playback. I am eventually going to add features that allow me to speed up and slow down playback and I don't think this can be done without buffers.
My goal at this point is the ability to mix say 10 audio files and play them back simultaneously. I've looked through the MixDiff project and doesn't seem to do this currently.
Any other advice or tips on how I could accomplish this?