WASAPI will only record at the format the soundcard is using. If it is not the sample rate you want then you have to resample manually.
New Post: Audio Recording
New Post: how to amplify grabbed recorded voice bytes from microphone?
I'd probably use this ReplayGain 1.0 specification
New Post: how to amplify grabbed recorded voice bytes from microphone?
markheath wrote:
you would normally scale it to [-1.0f. 1.0f]. You can do this by just dividing by 32768f, then constrain to the range, then multiply back up before casting to a short.
ah, right ^^
New Post: how to amplify grabbed recorded voice bytes from microphone?
hmmm, wait a min, isn't it slightly inaccurate to simply divide it by 32768f?
if it is signed 16 bits, the negative [-32768, 0) range scales into [-1.0f, 0) range, and the positive (0, +32767] range scales into (0, +1.0f] range.
the error margin would be greater if it was signed 8 bits since the ranges map to [-128, 0)->[-1.0f, 0) and (0, +127]->(0, +1.0f]
New Post: Audio Recording
sorry, how can i Resample manually ...?
i tryed like this....
outputfile is the name of audio recorded using WasApi loopback method.
WaveFileReader Reader = new WaveFileReader(outputfile);
WaveFormat
TargetFormat = new WaveFormat();
WaveStream convertedStream;
TargetFormat =
convertedStream =
WaveFileWriter.CreateWaveFile(CompresedFileName, convertedStream);
convertedStream.Dispose();
but getting the error "AcmNotPossible calling acmStreamOpen"
New Post: how to amplify grabbed recorded voice bytes from microphone?
yes, it is a bit ugly. But I always think of 0 in signed audio as being silence, so there is fractionally more negative range than positive. I multiply up by 32767 when I am done. This is to avoid inadvertently adding some DC offset, but I'm not sure its the best way
New Post: Audio Recording
what is Reader.WaveFormat?
New Post: how to clean background noise using naudio?
hi,
is there methods or algorithms that can remove noise from recording samples, ?
New Post: Audio Recording
Reader.WaveFormat.
- AverageBytesPerSecond :352800
- BitsPerSample:32
- BlockAlign:8
- Chanels:2
- ExtraSize:22
- SAmpleRate:44100
- Encoding:Extensible
New Post: how to clean background noise using naudio?
*shakes head*
this is a good start: "open source" audio noise filtering
I love it when NAudio forum gets bombed by Windows hacking or DSP questions, even though these are not advertised in NAudio features list.
New Post: Audio Recording
the ACM codec that does the format conversion doesn't like extensible, so the reader format passed in should be a regular WaveFormat(44100,16,2). You could create a very simple IWaveProvider implementor that replaces the WaveFormat with one of your choosing and passes on Read to the underlying source
Mark
New Post: MmException issue
As a part of a bigger program I am including a wave player. I have used Naudio for this. Where I define a WaveFileReader and a WaveOut object. I use a simple button that toggles between pause and play. When the usb headset is removed I am able to use
try and catch to handle the MmException. As the waveout reaches the end of the wavefile I use the playbackStopped event to reset the player. However, if the headset is removed during the playback I get "MmException was unhandled" "NoDriver calling WaveOutWrite".
I don't know how to catch that exception, I would really appreciate all the help I can get! :)
New Post: MmException issue
I've addressed this problem in the latest version of the code. Now you get an exception in the PlaybackStopped event that tells you that playback stopped because of a problem. You can either download the code and build it yourself, or if you know how to use NuGet with pre-release packages, you can download one of those
Mark
Updated Wiki: Home
NAudio Overview
NAudio is an open source .NET audio and MIDI library, containing dozens of useful audio related classes intended to speed development of audio related utilities in .NET. It has been in development since 2001 and has grown to include a wide variety of features. While some parts of the library are relatively new and incomplete, the more mature features have undergone extensive testing and can be quickly used to add audio capabilities to an existing .NET application.NAudio demo project showing an MP3 file playing:
NAudio WPF Project showing waveform visualisation and spectrum analyser:
Latest News
For the latest news and more documentation on NAudio, visit Mark Heath's blog.- 19 Dec 2011 NAudio 1.5 Released. Read the release notes
- 20 Apr 2011 NAudio 1.4 Released. Read the release notes
- 15 Apr 2011 NAudio demo now shows how to select output devices (for WaveOut, DirectSound, WASAPI and ASIO), and can play 8 bit, 16 bit, 24 bit, and 32 bit float WAV files. Fixed a longstanding ASIO issue.
- 7 Nov 2010 Major improvements to Mp3FileReader
- 10 Oct 2009 Version 1.3 Released. Read the release notes
- 20 Sep 2009 We are getting close to feature complete for 1.3. Last chance to get in any feedback on the API
- 26 Aug 2009 WPF Waveform drawing demo project including FFT added
- 28 Feb 2009 Lots of new stuff is being added and planned, so do check out the Source Code tab to have a sneak peak at what's coming in 1.3
- 26 June 2008 Version 1.2 Released. Read the release notes
NAudio Features
- Play back audio using a variety of APIs
- WaveOut
- DirectSound
- ASIO (not currently working with all soundcards)
- WASAPI (Windows Vista Core Audio)
- Decompress audio from different Wave Formats
- MP3 decode using ACM or DMO codec
- AIFF
- G.711 mu-law and a-law
- ADPCM
- G.722
- Speex (using NSpeex)
- SF2 files
- Decode using any ACM codec installed on your computer
- Record audio using WaveIn or WASAPI
- Read and Write standard .WAV files
- Mix and manipulate audio streams using a 32 bit floating mixing engine
- Extensive support for reading and writing MIDI files
- Full MIDI event model
- Basic support for Windows Mixer APIs
- A collection of useful Windows Forms Controls
- Some basic audio effects, including a compressor
Projects Using NAudio
NAudio currently is used to support a number of audio related utilities, some of which may be moved to be hosted on CodePlex in the future. If you have used NAudio for a project, please get in touch so we can post it here.- Skype Voice Changer - Modify your voice with audio effects while talking on Skype
- .NET Voice Recorder - Record your voice, save to MP3, and visualise the waveform using WPF. Now includes autotune
- MIDI File Mapper - Utility for mapping MIDI drum files for use on other samplers
- MIDI File Splitter - Split MIDI files up at their markers
- SharpMod - managed port of MikMod, can play mod files in both WinForms and Silverlight
- NVorbis - Fully managed Vorbis decoder, with support for NAudio
- Practice# - Windows tool for practicing playing an instrument with playback music. Includes FLAC playback support and an equaliser for NAudio.
- WPF Sound Visualization Library - beautiful waveform and spectrum analyzer code written for WPF, comes with NAudio sample
- SIPSorcery - .NET softphone framework
- Squiggle - A free open source LAN Messenger
- Helix 3D toolkit
- airphone-tv - A revival of axStream to implement control through the iPhone
- JamNet - a Silverlight drum sample player
- Jingle Jim - Jingle Software (German language)
- All My Music
- iSpy - Open Source Camera Security Software
- RadioTuna - Online internet radio player
- Fire Talk New - chat program
- AVR Audio Guard - utility to fix a HDMI related issue
More Info
For more information, please visit the NAudio Documentation WikiDonate
NAudio is a free open source project that is developed in personal time. You can show your appreciation for NAudio and support future development by donating.Source code checked in, #574018214436
Source code checked in, #25e1ba2cce59
New Post: MmException issue
I tried downloading the latest sourcecode. After a bit of experimenting with the new playbackStopped event i got it working.
Thank you so much for your quick response and the amazing tool that is naudio!
Kristian
Commented Issue: Need to record all sounds from sound card. [16353]
Comments: Check out this thread for a WasapiLoopbackCapture class that takes the output from your soundcard and turns it into a wavein device you can record or whatever... https://naudio.codeplex.com/discussions/203605/
New Post: Repeated Start/StopRecording does not work
I have tested on a (Parallels) Windows 7 virtual machine on a MacBook Pro. I have not observed any other audio issues with this setup until now.
In the meantime I have worked around this issue by separating recording and playback into different processes.
New Post: BadDeviceId calling waveInOpen when running NAudioTutorial5
My platform is Windows 7 Professional 64-bit
I got the following errors when running NAudioTutorial5:
NAudio.MmException was unhandled
Message=BadDeviceId calling waveInOpen
Source=NAudio
StackTrace:
at NAudio.MmException.Try(MmResult result, String function) in D:\naudio\NAudio\Wave\MmeInterop\MmException.cs:line 39
at NAudio.Wave.WaveIn..ctor(Int32 deviceNumber, Int32 sampleRate, Int32 bitDepth, Int32 channels, Boolean callbackWindow) in D:\naudio\NAudio\Wave\MmeInterop\WaveIn.cs:line 64
at NAudio.Wave.WaveIn..ctor(Int32 sampleRate, Int32 channels) in D:\naudio\NAudio\Wave\MmeInterop\WaveIn.cs:line 40
at NAudioTutorial5.NAudioTutorial5.cmbRecord_Click(Object sender, EventArgs e) in C:\Users\jwoo\Documents\Visual Studio 2010\Projects\NAudioTutorial5\NAudioTutorial5\NAudioTutorial5.cs:line 102
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at NAudioTutorial5.Program.Main() in C:\Users\jwoo\Documents\Visual Studio 2010\Projects\NAudioTutorial5\NAudioTutorial5\Program.cs:line 17
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: