This project has moved. For the latest updates, please go here.

NAudio Recording Performance

Apr 27, 2012 at 6:36 PM

I'm using NAudio to record audio.

It seems to work well on my new desktop machine, which is a 4 core i7, but on my 3 year old laptop, the recorded audio has all sorts of "popping" noises. I suspect what's going on here is that because the app does lots of processing, and because the system overall is under 60% CPU load, perhaps the thread that is sampling the audio is getting interrupted, etc.

I was really hoping to release my app this weekend, and so to discover this at the last minute is really unfortunate.  I'm hoping there is some way to set a thread priority somewhere so that the thread used by NAudio to do the recording is able to do its job without resulting in these popping noises.

If anyone know how to help, I'd be most grateful.

Thanks!

Daniel

Coordinator
Apr 30, 2012 at 9:32 AM

The best way round popping is either to increase the latency (buffer sizes) or to find ways to optimise your playback code. Some of the NAudio playback models do create background threads, so you could copy the code and create one with a higher priority background thread, but I suspect the implact would be fairly limited.

May 2, 2012 at 11:15 PM

Thanks for your reply Mark. Some follow-up questions:

- When you say "optimise your playback code": I'm not actually playing the audio back, just recording it. The popping I hear is right in the WAV files that I'm producing, as heard in any audio program.

- How does one increase the buffer size for NAudio recording?

- "Some of the NAudio playback models do create background threads": Again, this is a recording issue. Not sure if that changes your answer at all.

Coordinator
May 3, 2012 at 9:19 AM

OK, that is very strange. I wouldn't expect there to be any pops if you are writing the recorded buffers directly to disk unless your computer is struggling so much it can't keep up at all. Do you write directly to WAV file or are you processing in any way? You can increase the size and number of record buffers that might take a bit of the strain off your machine.

You can set the BufferMilliseconds property to 200 or 300 on WaveIn (or WaveInEvent which does use a background thread). Could also try increasing NumberOfBuffers from 2 to 3.

Mark

May 8, 2012 at 4:06 PM
Thanks so much for your responses Mark. Wonderful that you offer people help like this.

I gave this a try and it seemed to help a lot. It's been a crazy week and so haven't had time to do really careful testing, so I'll try and do that and report back whether this indeed solves the issue on my test machine.

One thing that I seem to have noticed is that when I play the WAV back along with the recorded visuals, the audio seems to be off by about 150 milliseconds when I set BufferMilliseconds to 300. Does that make any sense? The way my program works is that it records the audio and takes screenshots of the video it's recording, and then tries to play them back in sync.

Thanks,
Daniel



On Thu, May 3, 2012 at 5:19 AM, markheath <notifications@codeplex.com> wrote:

From: markheath

OK, that is very strange. I wouldn't expect there to be any pops if you are writing the recorded buffers directly to disk unless your computer is struggling so much it can't keep up at all. Do you write directly to WAV file or are you processing in any way? You can increase the size and number of record buffers that might take a bit of the strain off your machine.

You can set the BufferMilliseconds property to 200 or 300 on WaveIn (or WaveInEvent which does use a background thread). Could also try increasing NumberOfBuffers from 2 to 3.

Mark

Read the full discussion online.

To add a post to this discussion, reply to this email (naudio@discussions.codeplex.com)

To start a new discussion for this project, email naudio@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com


Jun 1, 2012 at 12:42 PM

Hi,

    Is there any way to record from specific channel using ASIO , please let me know if any sample code is available.

    My requirement is to record from Channel 1L and Channel 1R .

Thanks in advance. 

Coordinator
Jun 11, 2012 at 10:22 AM

ASIO recording has not yet been added to NAudio. I hope to do that in the near future (it is not a particularly big change)

Jul 5, 2012 at 12:29 PM

Hi,

    If you don't mind sharing the code for ASIO recording from specific input channel if it is not a big change. I need for my application development activity.

 

Thanks in advance.