Quantcast
Channel: NAudio
Viewing all 5831 articles
Browse latest View live

New Post: Play mp3 from stream in real-time

$
0
0

ehat like are you getting the ACM not possible error on? And what are the values of MP3WaveFormat at that point?


Commented Issue: BlockAlignReductionStream.Read cannot read large chunks. [16378]

$
0
0
The BlockAlignReductionStream uses a circular buffer to allow unaligned reading from an otherwise block aligned source stream. If the user tries to read more bytes than would fit in the circular buffer, the BlockAlignReductionStream only reads the amount that fits in the circular buffer, but internally advanced the input stream by the actual requested number of bytes. Future read requests will therefore miss a portion of the input stream.

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)

$
0
0

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.

$
0
0

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

$
0
0

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

$
0
0

Are you sure that your stream is a mp3 stream?

New Post: Can I Use NAudio library for commercial purpose?

$
0
0

http://naudio.codeplex.com/license

New Post: NAudio Error question

$
0
0

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?

$
0
0

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

$
0
0

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

$
0
0

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

$
0
0

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

$
0
0

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

$
0
0

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

$
0
0
adding ReadNextSampleFrame to WaveFileReader which will become the replacement for TryReadFloat which never worked on stereo files

Commented Issue: WaveFileReader.TryReadFloat does not consider channel count [14798]

$
0
0
Hi,
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]

$
0
0
Hi,<br />in WaveFileReader.TryReadFloat data is read by Read(value, 0, x), with x, for example, =2 for 16 bits per sample.<br />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".

Edited Issue: Playing Short Audio Files [16377]

$
0
0
I'm writing a game and I'd like to use NAudio to add sound to it. I followed a few examples and was rather pleased with NAudio's API and performance.<br /><br />I ran into the following issue: NAudio will not play short audio files. I've used WaveChannel32.Length to get the following numbers.<br />Files with length 755712 or less will not play.<br />Files with length 5935104 do play.<br />I'm not sure where the exact limit is. There are no exceptions thrown. I was hoping to use NAudio to play files of about 1 second long. Is anyone else having this issue? Is there a fix? Do I need to find a different library?

Commented Issue: Playing Short Audio Files [16377]

$
0
0
I'm writing a game and I'd like to use NAudio to add sound to it. I followed a few examples and was rather pleased with NAudio's API and performance.<br /><br />I ran into the following issue: NAudio will not play short audio files. I've used WaveChannel32.Length to get the following numbers.<br />Files with length 755712 or less will not play.<br />Files with length 5935104 do play.<br />I'm not sure where the exact limit is. There are no exceptions thrown. I was hoping to use NAudio to play files of about 1 second long. Is anyone else having this issue? Is there a fix? Do I need to find a different library?
Comments: marking as fixed with the changes to MixingSampleProvider

New Post: WasapiLoopbackCapture Dropouts

$
0
0

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.

Viewing all 5831 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>