1. create an AudioFileReader for each MP3 file
2. then add them as inputs to MixingSampleProvider (AddMixerInput)
3. Use SampleToWaveProvider or SampleToWaveProvider16 to convert back to an IWaveProvider to enable playback using
1. create an AudioFileReader for each MP3 file
2. then add them as inputs to MixingSampleProvider (AddMixerInput)
3. Use SampleToWaveProvider or SampleToWaveProvider16 to convert back to an IWaveProvider to enable playback using
hi, thanks. It is a bit odd - almost as though you are starting to play at the exact instant you shut down? But I will add your fix and update the readme
Mark
I guess it could be the garbage collector getting in the way. Also, have you tried with WaveInEvent and WaveOutEvent?
yes, I agree that the DesiredLatency property isn't ideal for those who want exact control over buffer sizes. I don't want to break existing code, but I will have a think about how I can make it easier to do this.
Mark
yes, I would like to move the WinForms suff out in the future. But it shouldn't stop you using NAudio in a non WinForms context.
that is strange. Is the Read method of the BufferedWaveprovider still being called when the sound stops playing? Did you get a PlaybackStopped event at any point?
you need to convert the incoming data into samples (use BitConverter.ToInt16 if it is 16 bit). Then you can multiply the sample value. But you need to beware of clipping when doing integer arithmetic, which is why most audio applications convert to floating point, before doing any DSP, and then hard limit the audio before going back down to 16 bit.
Just wanted to add that perception of loudness of sound is a logarithmic function, and not proportional to the voltage (floats in this case).
I remember seeing some DSP code in the latest branch. Is there a class to convert the bytes into floats taking the bitrate into account?
It's working fine in my non-WinForms project, thanks for commenting on my request ^^
File: WaveInEvent.cs
Method: StopRecording()
Line: 188
MmException.Try(WaveInterop.waveInStop(waveInHandle), "waveInStop");
Build: naudio_b3a412ad55a8
Hi, I want to know if we can directly use the PCM data that we get using the microphone class inside XNA. Without making the recording with the function wavein
thanks in advancec
Hi,
What is the best way to convert a WAV file created by NAudio (from a MP3 source file) to a PCM file? I need to have a 16Khz 16bit PCM output file. I tried to use the following piece of code but I receive the A"cmNotPossible calling acmStreamSize" error:
......
WaveStream waveStream = new WaveFileReader(outputFileName); WaveFormat targetFormat = default(NAudio.Wave.WaveFormat); targetFormat = WaveFormat.CreateCustomFormat(WaveFormatEncoding.Pcm, 16000, 1, 16000, 1, 16); using (WaveStream convertedStream = new WaveFormatConversionStream(targetFormat, waveStream)) { WaveFileWriter.CreateWaveFile(pcmFilename, convertedStream); }
Thanks.
mark can post some example of how do this "If you really want to use a background thread, create just one background thread and let that send events in a loop / read from a queue"
I need find way to send midi in faster way, without thread affect all application.
Right now send midi act like a bottleneck, specially affecting the UI thread making all work slow when send midi.
Bets regards!
Hi, thanks for replying, I have this code sample:
Int16 int16 = BitConverter.ToInt16(buffer, 0);
int16 *= 2;
buffer = BitConverter.GetBytes(int16);
but not worked !
any help please?
are you sure that wav header is always 44 bytes long?
take a look at the documentation
by the way you don t have to remove anything. If you convert the file it will only convert the audio data.
I had this code:
Int16 int16 = BitConverter.ToInt16(buffer, 0);
int16 *= 2;
buffer = BitConverter.GetBytes(int16);
of course it doesnt work, but I check the buffer array of bytes, I found the lenght of array is 8820 bytes and after multiplying by two, I found the array of byte (buffer) is going to two bytes only !!!!
so BitConverter.ToInt16 does not work with me ! do I need to do foreach loop and multiply each byte?
please help !
I think so (I read different documentations on the net). In my case, it works because when I remove the first 44 bytes of my Naudio Wave file, the result is a PCM file containing only the data. The file is valid because the remote service I use can decode it without problem.