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

New Post: Bitrate

$
0
0
MP3 files consist of MP3 frames, each of which has its own bitrate. In constant bitrate file (CBR) all frames have the same bitrate, but you can also get variable bitrate MP3s (VBR). If you have the whole file, you can calcualte the bitrate by dividing the number of bytes by the total number of seconds (and MP3FileReader can give you the duration).

Mp3FileReader also has a Mp3WaveFormat property which contains AverageBytesPerSecond. If you multiply that by 8, you get Average bits per second. And divide by 1000 to get kbps.

Commented Unassigned: DirectSoundOut.Devices.Count() returns wrong value [16497]

$
0
0
Here is the code

Dim dscount As Integer = 0
dscount = DirectSoundOut.Devices.Count()

dscount value is 8. the correct value is 4.
if i see in watch window and evaluate expression " DirectSoundOut.Devices.Count() " then it gives integer and value 4.

What is wrong?
Comments: markheath: If i run dscount = DirectSoundOut.Devices.Count() 3 times it gives different result. thats the problem. (no sound card removed, or installed meanwhile)

Created Unassigned: AsioOut dispose() - keep signal [16500]

$
0
0
Hello,
I'm reading some wave files using AsioOut and a WaveMixerStream32. Everything works great but I noticed that sometimes (1 time on 5) when I close and start again my program, I have a loud signal playing in the output of my audiocard and I have to restart the app to delete the signal and come back to normal.

I'm thinking it's the asioOut which stays open or something like that.
When i close the app, I'm doing the following :
1. I remove all the input stream in my audio mixer and I stop the asioOut
_asioOut.Stop();

2. After 0.5s, I dispose all the mixer, the channels and asioOut and set them to null.

Am I doing something wrong here?
How can I get rid of the loud signal ?

Thanks for your help !

Edited Unassigned: AsioOut dispose() - keep signal [16500]

$
0
0
Hello,
I'm reading some wave files using AsioOut and a WaveMixerStream32. Everything works great but I noticed that sometimes (1 time on 5) when I close and start again my program, I have a loud signal playing in the output of my audiocard and I have to restart the app to delete the signal and come back to normal.

I'm thinking it's the asioOut which stays open or something like that.
When i close the app, I'm doing the following :
1. I remove all the input stream in my audio mixer and I stop the asioOut
_asioOut.Stop();

2. After 0.5s, I dispose all the mixer, the channels and asioOut and set them to null.

Am I doing something wrong here?
How can I get rid of the loud signal ?

(My audio card is a Komplete Audio 6 and it's compatible asio driver)

Thanks for your help !

New Post: [UWA] WaveFormat unsupported

$
0
0
Hello! I'm trying to record raw data from mic and its okay, but i need to get a smaller file, so i have to reduce the frequency and switch to mono-channel.
The only way accepted is this
recorder = new WasapiCaptureRT();
recorder.WaveFormat = WaveFormat.CreateIeeeFloatWaveFormat(48000, 2);
Any other config threw an exception:
Unsupported Wave Format
at the end i would convert my raw array to mp3 (most important step probably)
Actually my raw file is like ~2mb for 10s (the records should have this duration)

I'm using Naudio.Universal for uwa, target is raspberry.
  1. How i can use a different wave form?
  2. There are an example how to convert raw to mp3?
thanks

New Post: [UWA] WaveFormat unsupported

$
0
0
Unfortunately, WASAPI will not let you specify any sample rate and channel count and convert for you like WaveIn can. So you have to do this yourself after capturing the audio, which is a real pain.

However, you might want to consider using the AudioGraph API that is new to Windows 10 UWP platform, which makes it much easier to do things like this. And if you have a Pluralsight subscription (or want to sign up for a free trial), then you can watch my latest course which shows how to do this. So you might find that an easier option.

Commented Unassigned: AsioOut dispose() - keep signal [16500]

$
0
0
Hello,
I'm reading some wave files using AsioOut and a WaveMixerStream32. Everything works great but I noticed that sometimes (1 time on 5) when I close and start again my program, I have a loud signal playing in the output of my audiocard and I have to restart the app to delete the signal and come back to normal.

I'm thinking it's the asioOut which stays open or something like that.
When i close the app, I'm doing the following :
1. I remove all the input stream in my audio mixer and I stop the asioOut
_asioOut.Stop();

2. After 0.5s, I dispose all the mixer, the channels and asioOut and set them to null.

Am I doing something wrong here?
How can I get rid of the loud signal ?

(My audio card is a Komplete Audio 6 and it's compatible asio driver)

Thanks for your help !
Comments: Sometimes some audio card drivers seem to get stuck playing the same buffer over and over. That might be what's happening here. But it's very hard to suggest what could be done to work around this. Does it happen at higher latency settings?

Commented Unassigned: DirectSoundOut.Devices.Count() returns wrong value [16497]

$
0
0
Here is the code

Dim dscount As Integer = 0
dscount = DirectSoundOut.Devices.Count()

dscount value is 8. the correct value is 4.
if i see in watch window and evaluate expression " DirectSoundOut.Devices.Count() " then it gives integer and value 4.

What is wrong?
Comments: Sorry, I can't reproduce this. Have you tried it on different computers? Or with different soundcards installed?

Created Unassigned: Dictation recorder hangs on waveInClose [16501]

$
0
0
Our dictation software hangs on NAudio call as described below. This has been tried to get fixed for ages but no luck. Hope you can help!


Hang happens in WaveIn.cs in CloseWaveInDevice() function, line 336 WaveInterop.waveInClose(waveInHandle), that row is in bold below.

private void CloseWaveInDevice()
{

if (waveInHandle == IntPtr.Zero) return;
_logger.Log(LogLevel.Debug, () => "close wavein");

MmException.Try(WaveInterop.waveInStop(waveInHandle), "waveInStop");

MmException.Try(WaveInterop.waveInReset(waveInHandle), "waveInReset");

if (buffers != null)
{
_logger.Log(LogLevel.Debug, () => "close wavein, buffers=" + buffers.Length.ToString());
for (int n = 0; n < buffers.Length; n++)
{
_logger.Log(LogLevel.Debug, () => "buffers[" + n + "] dispose call");
buffers[n].Dispose();
_logger.Log(LogLevel.Debug, () => "buffers[" + n + "] disposed");
}
buffers = null;
}
_logger.Log(LogLevel.Debug, () => "buffers disposed, try to close waveIn");
var result = WaveInterop.waveInClose(waveInHandle);
_logger.Log(LogLevel.Debug, () => "waveInClose result: " + result.ToString());

waveInHandle = IntPtr.Zero;
// _logger.Log(LogLevel.Debug, () => "close wavein method end");
}


WaveInClose is called every time recording is paused to control recording led on Olympus DR-2X00 mic.

waveInClose is from winmm library ->
[DllImport("winmm.dll")]
public static extern MmResult waveInClose(IntPtr hWaveIn);

msdn -> https://msdn.microsoft.com/en-us/library/dd743840(v=vs.85).aspx

Problem is that it doesn't return error code -> it just never returns from this function in this case.

attached is a debug log from the software. It hangs on the last row.

-Juha

Commented Unassigned: Dictation recorder hangs on waveInClose [16501]

$
0
0
Our dictation software hangs on NAudio call as described below. This has been tried to get fixed for ages but no luck. Hope you can help!


Hang happens in WaveIn.cs in CloseWaveInDevice() function, line 336 WaveInterop.waveInClose(waveInHandle), that row is in bold below.

private void CloseWaveInDevice()
{

if (waveInHandle == IntPtr.Zero) return;
_logger.Log(LogLevel.Debug, () => "close wavein");

MmException.Try(WaveInterop.waveInStop(waveInHandle), "waveInStop");

MmException.Try(WaveInterop.waveInReset(waveInHandle), "waveInReset");

if (buffers != null)
{
_logger.Log(LogLevel.Debug, () => "close wavein, buffers=" + buffers.Length.ToString());
for (int n = 0; n < buffers.Length; n++)
{
_logger.Log(LogLevel.Debug, () => "buffers[" + n + "] dispose call");
buffers[n].Dispose();
_logger.Log(LogLevel.Debug, () => "buffers[" + n + "] disposed");
}
buffers = null;
}
_logger.Log(LogLevel.Debug, () => "buffers disposed, try to close waveIn");
var result = WaveInterop.waveInClose(waveInHandle);
_logger.Log(LogLevel.Debug, () => "waveInClose result: " + result.ToString());

waveInHandle = IntPtr.Zero;
// _logger.Log(LogLevel.Debug, () => "close wavein method end");
}


WaveInClose is called every time recording is paused to control recording led on Olympus DR-2X00 mic.

waveInClose is from winmm library ->
[DllImport("winmm.dll")]
public static extern MmResult waveInClose(IntPtr hWaveIn);

msdn -> https://msdn.microsoft.com/en-us/library/dd743840(v=vs.85).aspx

Problem is that it doesn't return error code -> it just never returns from this function in this case.

attached is a debug log from the software. It hangs on the last row.

-Juha

Comments: attachement

Commented Unassigned: Dictation recorder hangs on waveInClose [16501]

$
0
0
Our dictation software hangs on NAudio call as described below. This has been tried to get fixed for ages but no luck. Hope you can help!


Hang happens in WaveIn.cs in CloseWaveInDevice() function, line 336 WaveInterop.waveInClose(waveInHandle), that row is in bold below.

private void CloseWaveInDevice()
{

if (waveInHandle == IntPtr.Zero) return;
_logger.Log(LogLevel.Debug, () => "close wavein");

MmException.Try(WaveInterop.waveInStop(waveInHandle), "waveInStop");

MmException.Try(WaveInterop.waveInReset(waveInHandle), "waveInReset");

if (buffers != null)
{
_logger.Log(LogLevel.Debug, () => "close wavein, buffers=" + buffers.Length.ToString());
for (int n = 0; n < buffers.Length; n++)
{
_logger.Log(LogLevel.Debug, () => "buffers[" + n + "] dispose call");
buffers[n].Dispose();
_logger.Log(LogLevel.Debug, () => "buffers[" + n + "] disposed");
}
buffers = null;
}
_logger.Log(LogLevel.Debug, () => "buffers disposed, try to close waveIn");
var result = WaveInterop.waveInClose(waveInHandle);
_logger.Log(LogLevel.Debug, () => "waveInClose result: " + result.ToString());

waveInHandle = IntPtr.Zero;
// _logger.Log(LogLevel.Debug, () => "close wavein method end");
}


WaveInClose is called every time recording is paused to control recording led on Olympus DR-2X00 mic.

waveInClose is from winmm library ->
[DllImport("winmm.dll")]
public static extern MmResult waveInClose(IntPtr hWaveIn);

msdn -> https://msdn.microsoft.com/en-us/library/dd743840(v=vs.85).aspx

Problem is that it doesn't return error code -> it just never returns from this function in this case.

attached is a debug log from the software. It hangs on the last row.

-Juha

Comments: what sort of application are you writing (winforms/wpf?) try to make all calls to your waveIn on the same thread Also try with WaveInEvent instead, see if that improves things

New Post: Stopped playing event

$
0
0
hi Sid, I've just added something similar to this. Let me know if it meets your needs. Thanks for the suggestion

New Post: naudio Sound record from Multiple inputs and Multiple outputs.

$
0
0
Hi ,

Am using NAudio in my application. In that i want to record from soundcard (Mulitple Inputs,Multiple outputs) at same time.

EX:
Mic1
Mic2
soundcardout1
soundcardout2.

Thanks in Advance.

New Post: Convert wav to ulaw wav??

$
0
0
Mark,

I am doing something similar. I just got drafted to support our agency's IVR programming and I am learning Convergsys Interaction Composer and all the associated software that goes with their product. I have to support two massive existing applications. Right now I am having issues with calls recorded (I assume in PCM format) and compressing them to CCITT u-law 16 bit. I can use Sound Forge 11 to compress the files manually, but I need to write a script to do so programmatically. I discovered your project through an existing script we have in .NET, but it is not compressing the files properly.

Should this compression be done in two steps as you mention here? I assume the processing is all done in memory and the final output is the compressed file in mulaw?

Sorry, I'm really new at this, like just started looking at this last week. Fortunately, I have a Pluralsight account so I've been watching your tutorials this weekend. :)

Randy

New Post: Playing dynamically generated floats.

$
0
0
A lot of the documentation I've seen is gear towards playing audio files (.wav and .mp3) I'm doing something a bit different. My application is generating sound on the fly as floating point numbers in the range of 1.0 to -1.0. Whats the easiest way to go about pushing these values out to the sound card?

New Post: Convert wav to ulaw wav??

$
0
0
I hope I get a response to this.

I'm posting the existing code that compresses the wav files from one directory and saves them to another.
private static void compressWaveAndRename(string fileStart, string fileEnd)
        //COMPRESSES THE FILES AND PUTS THEM INTO ULAW FORMAT FOR THE IVR TO BE ABLE TO PLAY
        {
            try
            {
                WaveFormat newFormat = WaveFormat.CreateMuLawFormat(8000, 1);
                using (var strm = new RawSourceWaveStream(new WaveFileReader(fileStart), new WaveFormat(8000, 16, 1)))
                {
                    using (var conversionStream = new WaveFormatConversionStream(newFormat, strm))
                    {
                        WaveFileWriter.CreateWaveFile(fileEnd, conversionStream);
                    }
                }
                System.IO.File.Move(fileStart, fileEnd);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
Do you see anything here that should be corrected?

Thanks,

Randy

New Post: Convert wav to ulaw wav??

$
0
0
You need to get rid of the RawSourceWaveStream. You're essentially applying a different WaveFormat to the audio in the file without converting it.
You might need a few WaveFormatConversionStreams in a row - one to go mono, then to downsample, and finally to go to mulaw. This is because ACM codecs often are quite limited in the input and output formats they support.

New Post: Convert wav to ulaw wav??

$
0
0
Thank you, this is existing code I need to modify. I did not write it,
but I am trying to learn how to fix it. :)

Thank you for answering.

Randy

New Post: Convert wav to ulaw wav??

$
0
0
I forgot to mention that the input files are all
8,000kHz, 8 bit, mono recorded telephone
conversations that need to be converted to
16 bit mulaw. That is the only way the
IVR software will play them back correctly.

New Post: Convert wav to ulaw wav??

$
0
0
mu-law is 8 bit. If the original recording was 8 bit linear PCM, then going to mu-law doesn't really make much sense.
Viewing all 5831 articles
Browse latest View live


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