ehat like are you getting the ACM not possible error on? And what are the values of MP3WaveFormat at that point?
New Post: Play mp3 from stream in real-time
Commented Issue: BlockAlignReductionStream.Read cannot read large chunks. [16378]
A simple fix would be to clamp the number of bytes read from the input stream to the size of the circular buffer. I could not find the svn url for the source tree or figure out where to submit a patch, so I just attached the modified source file.
Comments: BlockAlignReductionStream is not really designed to be called with large values in the count parameter of Read. The trouble with this solution is that Read could return less than the requested number of bytes even though the stream has not ended, which could cause partially complete buffers to get written to the soundcard.
New Post: How to get notified Wave In Device disabled or enabled at run time (in short volume manipulation)
Hi..
I am creating a user control which will support all functionality like we can enable,disable, Mute also we can change audio capture device volume..etc. and it should be synchronized with windows audio settings dialog (Mixer settings)
Please check following code. using this i am only getting volume and mute value.
foreach (var control in mixerline.Controls) { var audioControl = control as NAudio.Mixer.UnsignedMixerControl; if (audioControl != null) { _volume = (int)audioControl.Percent; } var audioControl1 = control as NAudio.Mixer.BooleanMixerControl; if (audioControl1 != null) { _isMute = audioControl1.Value; } }
Thanks in advanced.
NileshN
New Post: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Hi..
I have created Audio player which support GUI as well as thread environment it works fine if we are playing audio on GUI thread but if there are so many background threads which are playing audio file then within 1 hour audio player getting crashed with above exception.
to support threading i am using WaveOutEvent.
Also internally for each play i am creating new device to play loaded audio.
All operation like create device, stop, play audio, reset duration am doing on single thread using AutoResetEvent.
Also if we want to play audio for 30 seconds then i am playing same audio for 30 second but for each replay i am creating new device and loading same file again.
for play and replay purpose i am using same code please check following
privatebool PlayAudioFile() { if (_wavePlayer == null || _fileStream == null || _wavePlayer.PlaybackState == PlaybackState.Playing) returnfalse; _fileStream.Position = 0; CloseWavePlayer(); EnsureDeviceCreated(); _wavePlayer.Init(new SampleToWaveProvider(_sampleChannel)); _wavePlayer.Play(); _dontFireEvent = false; returntrue; }
here EnsureDeviceCreated creating new WaveOutEvent with 200 latency.
Exception coming at following line in WaveOutBuffer's constructor.
MmException.Try(WaveInterop.waveOutPrepareHeader(hWaveOut, header, Marshal.SizeOf(header)), "waveOutPrepareHeader");
Please help me to sort out above issue...
Thanks in Advanced..
NileshN
New Post: Working example for the use of the BiQuadFilter class
Hi all!
First of all I want to thank you for this great library and the well described explanations in the discussions!
But here's my problem: I want to use the BiQuadFilter, but I can't find any example. I did find some discussions about it, but couldn't figure out how to make them run.
Does anybody have a simple example for e.g. the use of a low pass filter?
Thanks in advance!
New Post: Play mp3 from stream in real-time
Are you sure that your stream is a mp3 stream?
New Post: Can I Use NAudio library for commercial purpose?
http://naudio.codeplex.com/license
New Post: NAudio Error question
Hello guys, first NAudio library is awsome keep up the good work. :)
So I am using it with one of my project and I have created this class to play a sond when a intersection with rectangle is available :
publicclass Music {privatestring fileLocation;private IWavePlayer waveout;private WaveStream outputStream; WaveOutEvent audio ;public Drum(string file) {this.fileLocation = file;this.waveout = new WaveOut(); audio = new WaveOutEvent(); }static WaveStream CreateInputStream(string name) { WaveChannel32 inputStream;if (name.EndsWith(".wav")) { WaveStream readerStream = new WaveFileReader(name);if (readerStream.WaveFormat.Encoding != WaveFormatEncoding.Pcm) { readerStream = WaveFormatConversionStream.CreatePcmStream(readerStream); readerStream = new BlockAlignReductionStream(readerStream); }if (readerStream.WaveFormat.BitsPerSample != 16) {var format = new WaveFormat(readerStream.WaveFormat.SampleRate, 16, readerStream.WaveFormat.Channels); readerStream = new WaveFormatConversionStream(format, readerStream); } inputStream = new WaveChannel32(readerStream); }else {thrownew InvalidOperationException("Invalid extension"); }return inputStream; }publicvoid Play() { this.outputStream = CreateInputStream(this.fileLocation); audio.Init(outputStream); audio.Play(); } }
the problem is that I get this error when I intersect alot : AlreadyAllocated calling waveOutOpen.
My first question is how to resolve this error with the class above,and if you have time to correct my code will be greate. :)
My second question is: Is it possible to mix the sounds lets say that I have intersected with two rectangles and I want to mix the both sounds together, I now that NAudio have a mixer.
New Post: how to convert gsm.wav to g711.wav?
I know it might be a stupid or easy question for some, but after reading the formats convertion i still very unclear on what should i do in order to convert from gsm to g711.
can someone help me on this?
thks
New Post: NAudio Error question
this is because you are opening the sound card too many times. Probably a better approach would be to open the soundcard only once and mix your audio. In the NAudio WPF Demo project, I have created a Drum Machine demo which shows how this can be done. If you click the source code tab above, you can explore the code and see how the MixingSampleProvider is used for this purpose.
Mark
New Post: Microphone input simulation
Does the Win32 API allow us to simulate a microphone input (using wave file, etc.)?
Thank you.
New Post: NAudio and soundmax integrated digital HD audio
I am trying to see if a pc has a mic plugged in with C#
int count = NAudio.Wave.WaveIn.DeviceCount;
Normally that returns a 1 when i plug a mic in and 0 if it isn't. But when i use it on a pc with a soundmax integrated digital hd audio it always returns 2 no matter what.
I've searched around for a solution and could not find one, so any advice would be great.
I did see that there were 2 older discussions about issues with soundmax, but they did not offer a solution that i need. Thanks in advance
New Post: Playing AAC (.m4a) Files
Does naudio have any plans to support playing AAC (.m4a) files? Right now when you try to load one into AudioFileReader
fileWaveStream=newAudioFileReader(@"c:\music\test.m4a");
New Post: Playing AAC (.m4a) Files
The issue is with CreateReaderStream(string fileName) in audioFileReader it doesn't look for anything other than ".wav",".mp3", and ".aiff". I'm I just stupid and missing something and should be using another FileReader?
Source code checked in, #b7e02a6d510a
Commented Issue: WaveFileReader.TryReadFloat does not consider channel count [14798]
in WaveFileReader.TryReadFloat data is read by Read(value, 0, x), with x, for example, =2 for 16 bits per sample.
However, if the wav file is multichannel, say 6 channels, each sample has 12 bytes. So the Read method throws an exception "Must read complete blocks".
Comments: This will be fixed in NAudio 1.7 with a new method called ReadSampleFrame. This will return an array of floats, one per channel, or null at end of file. I've marked TryReadFloat as Obsolete.
Edited Issue: WaveFileReader.TryReadFloat does not consider channel count [14798]
Edited Issue: Playing Short Audio Files [16377]
Commented Issue: Playing Short Audio Files [16377]
Comments: marking as fixed with the changes to MixingSampleProvider
New Post: WasapiLoopbackCapture Dropouts
Hello,
I experience dropouts in irregular time spans when I try to record via WasapiLoopbackCapture (tried on three PCs - even on a intel core i7 in idle mode). Does anyone have an idea on how to fix this problem?
Thanks in advance.