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

New Post: How to uniquely identify audio capture device?

$
0
0
PPavan wrote:

I found one more problem for me! Actually I am going to record the captured video and audio in a WMV file. For which I need to know few properties of the audio format like bits per sample, sample rate, etc.. I am getting these properties using MMDevice.AudioClient.MixFormat but again this will not work on XP! What could be the solution?

Thanks.

 

Complement the properties in "WaveInCapabilities.cs", and make public the SupportedFormats.
You have all the opportunities Audio card after you Choose your currency format.

Must remain cautious about this option because some drivers do not respect this option.


New Post: Need a function urgently

$
0
0

I think I might have sorted out the mixing while multiplexing thing! Now I am looking for a way to loop the result. You wrote earlier:

Looping would probably be best implemented with another wrapped layer on top of this.

Could you please provide the noob a little bit more information just to get me going?

Thanks!

New Post: Need a function urgently

$
0
0

you'd implement a waveprovider or sampleprovider that in its Read method, returning from the source provider. However, if the source provider's Read method returns 0, then you need to loop. If the source is a WaveStream, then you can loop by setting its Position to 0. However, if you are working with sample providers, then I'd have a delegate that I called back to reset the sources to the start.

a very quick and dirty example, with a lambda being passed to the looper so it can request reposition to start

var input1 = new WaveFileReader(...);
var input2 = new WaveFileReader(...);
var mixer = new YourMixingAndMultiplexingSamplePovider(input1, input2);
var looper = new Looper(mixer, () => { input1.Position=0; input2.Position=0; });

New Post: handling Seek position in case of streaming audio

$
0
0

Hi

 

i am working on the project that uses web stream to play audio using Naudio Library, i need to show the slider for the playing audio and also to allow seek position backward/forward for the streaming audio.

 

Is there any way that we can feature out the length of audio playback time and can allow seeking track for at least to the portion of the track that has been already downloaded or cached.

Thanks if anyone can help with the sample code.

Thank

Ajay

New Post: handling Seek position in case of streaming audio

$
0
0

it can be done, but it is a little tricky. Essentially you'd need to keep hold of the audio you'd already downloaded in some kind of memory buffer or temporary file. I'm afraid there is no sample code. One thing that you might want to check out is the new MediaFoundationReader in the very latest NAudio code (you'll probably have to download and build it yourself). That can actually do repositioning on streaming files and works surprisingly well. I don't know if you can tell how far it has downloaded though.

New Post: Speex Echo Cancellation with NAudio?

$
0
0

I could fix the problem. It was all about frame length.

Now it works great. Just there's a problem. I can say that it works great with win7(I have totally no any echo). But with win XP, it doesn't work stable. It just reduces the echo a little and it shows strange behavior(like it works for some seconds and some seconds not). It's like a sample rate difference between input and output sound or something like this.

Is there any difference between win xp and win 7 in their audio device handling?

Any idea?

New Post: Speex Echo Cancellation with NAudio?

$
0
0

omatrix what frame length are you using? I'm not sure what difference is there between windows xp and windows 7.

New Post: Speex Echo Cancellation with NAudio?

$
0
0

Thanks for reply

I used 256 for frame size and 4096 for filter length. Also the sample rate is 8000.

Thanks again


Created Issue: NAudio.WindowsMediaFormat.NSSBuffer IntPtr.ToInt32() OverflowException [16379]

$
0
0
Please change the NAudio.WindowsMediaFormat.NSSBuffer class Read and Write methods. Under load you will get an OverflowException such as this:

System.OverflowException: Arithmetic operation resulted in an overflow.
at System.IntPtr.ToInt32()
at NAudio.WindowsMediaFormat.NSSBuffer.Read(Byte[] buffer, Int32 offset, Int32 count)
at NAudio.WindowsMediaFormat.WmaStream.Read(Byte[] buffer, Int32 offset, Int32 count)

The change should check the system architecture and perform the correct casting to an integer type like so:

IntPtr src;
if (IntPtr.Size == 8) {
src = (IntPtr)(m_BufferPtr.ToInt64() + m_Position);
}
else {
src = (IntPtr)(m_BufferPtr.ToInt32() + m_Position);
}

I have tested this change and it does fix this exception.

Please see MSDN at http://msdn.microsoft.com/en-us/library/system.intptr.toint32.aspx for details on this exception as it reads: OverflowExceptions will occur on a 64-bit platform. The value of this instance may be too large or too small to be represented as a 32-bit signed integer.

Thanks for such an amazing library. :)

Commented Issue: NAudio.WindowsMediaFormat.NSSBuffer IntPtr.ToInt32() OverflowException [16379]

$
0
0
Please change the NAudio.WindowsMediaFormat.NSSBuffer class Read and Write methods. Under load you will get an OverflowException such as this:

System.OverflowException: Arithmetic operation resulted in an overflow.
at System.IntPtr.ToInt32()
at NAudio.WindowsMediaFormat.NSSBuffer.Read(Byte[] buffer, Int32 offset, Int32 count)
at NAudio.WindowsMediaFormat.WmaStream.Read(Byte[] buffer, Int32 offset, Int32 count)

The change should check the system architecture and perform the correct casting to an integer type like so:

IntPtr src;
if (IntPtr.Size == 8) {
src = (IntPtr)(m_BufferPtr.ToInt64() + m_Position);
}
else {
src = (IntPtr)(m_BufferPtr.ToInt32() + m_Position);
}

I have tested this change and it does fix this exception.

Please see MSDN at http://msdn.microsoft.com/en-us/library/system.intptr.toint32.aspx for details on this exception as it reads: OverflowExceptions will occur on a 64-bit platform. The value of this instance may be too large or too small to be represented as a 32-bit signed integer.

Thanks for such an amazing library. :)
Comments: thanks for reporting this. In fact, there is probably a simpler fix - you ought to be able to use ToInt64 on both architectures. If you get a chance to test this let me know.

Commented Issue: NAudio.WindowsMediaFormat.NSSBuffer IntPtr.ToInt32() OverflowException [16379]

$
0
0
Please change the NAudio.WindowsMediaFormat.NSSBuffer class Read and Write methods. Under load you will get an OverflowException such as this:

System.OverflowException: Arithmetic operation resulted in an overflow.
at System.IntPtr.ToInt32()
at NAudio.WindowsMediaFormat.NSSBuffer.Read(Byte[] buffer, Int32 offset, Int32 count)
at NAudio.WindowsMediaFormat.WmaStream.Read(Byte[] buffer, Int32 offset, Int32 count)

The change should check the system architecture and perform the correct casting to an integer type like so:

IntPtr src;
if (IntPtr.Size == 8) {
src = (IntPtr)(m_BufferPtr.ToInt64() + m_Position);
}
else {
src = (IntPtr)(m_BufferPtr.ToInt32() + m_Position);
}

I have tested this change and it does fix this exception.

Please see MSDN at http://msdn.microsoft.com/en-us/library/system.intptr.toint32.aspx for details on this exception as it reads: OverflowExceptions will occur on a 64-bit platform. The value of this instance may be too large or too small to be represented as a 32-bit signed integer.

Thanks for such an amazing library. :)
Comments: I'm afraid I do not have any 32-bit machines anymore, but I feel like that might work as well. :P

Source code checked in, #604d828837e1

$
0
0
fixing issue 16379 - possible NSSBuffer overflow exception with WMA in x64

Commented Issue: NAudio.WindowsMediaFormat.NSSBuffer IntPtr.ToInt32() OverflowException [16379]

$
0
0
Please change the NAudio.WindowsMediaFormat.NSSBuffer class Read and Write methods. Under load you will get an OverflowException such as this:

System.OverflowException: Arithmetic operation resulted in an overflow.
at System.IntPtr.ToInt32()
at NAudio.WindowsMediaFormat.NSSBuffer.Read(Byte[] buffer, Int32 offset, Int32 count)
at NAudio.WindowsMediaFormat.WmaStream.Read(Byte[] buffer, Int32 offset, Int32 count)

The change should check the system architecture and perform the correct casting to an integer type like so:

IntPtr src;
if (IntPtr.Size == 8) {
src = (IntPtr)(m_BufferPtr.ToInt64() + m_Position);
}
else {
src = (IntPtr)(m_BufferPtr.ToInt32() + m_Position);
}

I have tested this change and it does fix this exception.

Please see MSDN at http://msdn.microsoft.com/en-us/library/system.intptr.toint32.aspx for details on this exception as it reads: OverflowExceptions will occur on a 64-bit platform. The value of this instance may be too large or too small to be represented as a 32-bit signed integer.

Thanks for such an amazing library. :)
Comments: I've committed the fix that just uses ToInt64.

Edited Issue: NAudio.WindowsMediaFormat.NSSBuffer IntPtr.ToInt32() OverflowException [16379]

$
0
0
Please change the NAudio.WindowsMediaFormat.NSSBuffer class Read and Write methods. Under load you will get an OverflowException such as this:<br /><br />System.OverflowException: Arithmetic operation resulted in an overflow.<br /> at System.IntPtr.ToInt32()<br /> at NAudio.WindowsMediaFormat.NSSBuffer.Read(Byte[] buffer, Int32 offset, Int32 count)<br /> at NAudio.WindowsMediaFormat.WmaStream.Read(Byte[] buffer, Int32 offset, Int32 count)<br /><br />The change should check the system architecture and perform the correct casting to an integer type like so:<br /><br />IntPtr src;<br />if (IntPtr.Size == 8) {<br /> src = (IntPtr)(m_BufferPtr.ToInt64() + m_Position);<br />}<br />else {<br /> src = (IntPtr)(m_BufferPtr.ToInt32() + m_Position);<br />}<br /><br />I have tested this change and it does fix this exception.<br /><br />Please see MSDN at http://msdn.microsoft.com/en-us/library/system.intptr.toint32.aspx for details on this exception as it reads: OverflowExceptions will occur on a 64-bit platform. The value of this instance may be too large or too small to be represented as a 32-bit signed integer.<br /><br />Thanks for such an amazing library. :)

New Post: How to get Preferred Format List for any audio capture device?

$
0
0

Hello everyone,

I am not able to find the preferred/default audio format for the selected audio capture device. Actually I am using IWaveIn.WaveFormat property to get the audio format but I am not sure if its a default format. How NAudio retrieves this WaveFormat? (I am facing problem if I try to use this format for recording, audio codec is not supporting this format!).

I was comparing the default format retrieved using NAudio and DirectShow and I found that both are different! DirectShow provides a way to get the preferred format list for the audio capture device (using IPin::EnumMediaTypes), is there any way in NAudio to get the same list?


New Post: How to get Preferred Format List for any audio capture device?

$
0
0

As far as I know, WaveIn doesn't offer this capability. Wasapi in does though if you are using Windows Vista or above. There is some enum wrappers for DirectSound in NAudio, but it doesn't cover the whole API, and I suspect EnumMediaTypes is not included,

New Post: How to get Preferred Format List for any audio capture device?

$
0
0

The WaveFormat that I am getting using IWaveIn.WaveFormat for my capture device has values as follows - BitsPerSample = 32, SampleRate = 48000 and Channels = 1. I want to record using Windows Media Audio 9.2 codec but this codec does not support a stream with such format. I tried other formats (available in this codec) which has same Sample Rate and Channel values but my output recording is not proper (audio is like blablakchilblachilbal...)!!!

New Post: Converting M4A to Wav/PCM

$
0
0

Hi,
I'm little newbie to the NAudio API.

I'd like to convert an M4A audio file (produced by iOS Dropvox app) to a Wav or PCM MemoryStream. Then use this Stream as an AudioStream for a SpeechRecognitionEngine.

using (var ms = File.OpenRead(file))using (var mp3Reader = new Mp3FileReader(ms))using (var pcmStream = WaveFormatConversionStream.CreatePcmStream(mp3Reader))using (var baStream = new BlockAlignReductionStream(pcmStream)) {
        sre.SetInputToWaveStream(baStream);
        RecognitionResult rr = sre.Recognize();
      }

 

It's seems Mp3FileReader can't read M4A. I don't know if there is any workaround ? 

Thanks !
Regards 

New Post: How to get Preferred Format List for any audio capture device?

$
0
0

I want to capture audio with stereo CBR so I tried configuring my wavIn instance with a WaveFormat (stereo) which is supported by the codec but it is not working and throws "Unsupported wave format" exception!  I tried almost all stereo formats that are available in the codec but same exception is coming for all.

What should I do? Any suggestion?

Thanks.

New Post: How to get Preferred Format List for any audio capture device?

$
0
0

you can't capture audio directly in a compressed audio format. You must capture it in PCM and then encode it afterwards. Read this article on CodeProject to get a better understanding of working with compressed audio formats.

Mark

Viewing all 5831 articles
Browse latest View live


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