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

New Post: Resample problem

$
0
0

When I'm trying to resample IeeeFloat wave format with sample rate of 48000 to wave format with sample rate of 41000, an exception occurred - "AcmNotPossible calling acmStreamOpen".

What is the right way to convert an input stream from one wave format to another. I need to feed MixingSampleProvider with two streams with equal wave formats.


New Post: Resample problem

$
0
0

Are they both IEEE float? And do they both have the same number of channels? I can't remember off the top of my head if the ACM resampler can do IEEE. There is also the DmoResampler available on Vista and Win 7 if not. I've also got a fully managed resampler in the works but its not ready yet

Mark

Commented Issue: WaveIn class - DataAvailable is not raised when class is used in Console Application [16131]

$
0
0
I've created own wav recording class using WaveIn, based on example from WavRecording demo. It was working perfectly when i was testing my class in the GUI application.
When I moved my code, without any change, to the console application or to the library, then it stopped working.
I've notticed that DataAvailable is never launched in these cases, so the buffer is never dumped to the wav file.
Only wav header is written to the output wav file.

I am working under Win7 x64. I compile code with .NET Framework target 3.5, Any CPU configuration.
Comments: Same issue here in my console app. I had a hunch it had something to do with the message pump, got here by Googling "WaveIn message thread". Has anyone already tried the function callbacks to solve this ?

New Post: Problem Converting To GSM610

$
0
0

That's fantastic, thanks! 

Works a charm.

New Post: Resample problem

$
0
0

They are both IEEE float. The number of channels is equal - 2. Maybe I have to convert them first to 16bit PCM and then resample?

New Post: Resample problem

$
0
0

yes, you might have to to use the ACM resampler.

Commented Issue: WaveIn class - DataAvailable is not raised when class is used in Console Application [16131]

$
0
0
I've created own wav recording class using WaveIn, based on example from WavRecording demo. It was working perfectly when i was testing my class in the GUI application.
When I moved my code, without any change, to the console application or to the library, then it stopped working.
I've notticed that DataAvailable is never launched in these cases, so the buffer is never dumped to the wav file.
Only wav header is written to the output wav file.

I am working under Win7 x64. I compile code with .NET Framework target 3.5, Any CPU configuration.
Comments: I've just checked in WaveInEvent, which uses event callbacks. You can try using this. Will be officially part of NAudio 1.6

Created Issue: WaveOut Resume function does not work properly [16342]

$
0
0
Repeatedly pausing and resuming a WaveOut object sometimes reduces the buffering functionality. Resuming using the Play function does not have this problem (because it calls EnqueueBuffers before resuming).

Proposed fix: make the WaveOut Resume function private to force users to use the Play function to resume.

This solution might solve issue 15702 as well.

Commented Issue: WaveIn class - DataAvailable is not raised when class is used in Console Application [16131]

$
0
0
I've created own wav recording class using WaveIn, based on example from WavRecording demo. It was working perfectly when i was testing my class in the GUI application.
When I moved my code, without any change, to the console application or to the library, then it stopped working.
I've notticed that DataAvailable is never launched in these cases, so the buffer is never dumped to the wav file.
Only wav header is written to the output wav file.

I am working under Win7 x64. I compile code with .NET Framework target 3.5, Any CPU configuration.
Comments: Jesuschristonapogostick Mark, you're fast ! I'll try it tonight, cheers !

Commented Issue: WaveOut Resume function does not work properly [16342]

$
0
0
Repeatedly pausing and resuming a WaveOut object sometimes reduces the buffering functionality. Resuming using the Play function does not have this problem (because it calls EnqueueBuffers before resuming).

Proposed fix: make the WaveOut Resume function private to force users to use the Play function to resume.

This solution might solve issue 15702 as well.
Comments: Resume is not a member of the IWavePlayer interface, and is not intended to be used in normal situations. Making it private might be a good solution.

Commented Issue: WaveIn class - DataAvailable is not raised when class is used in Console Application [16131]

$
0
0
I've created own wav recording class using WaveIn, based on example from WavRecording demo. It was working perfectly when i was testing my class in the GUI application.
When I moved my code, without any change, to the console application or to the library, then it stopped working.
I've notticed that DataAvailable is never launched in these cases, so the buffer is never dumped to the wav file.
Only wav header is written to the output wav file.

I am working under Win7 x64. I compile code with .NET Framework target 3.5, Any CPU configuration.
Comments: Hi Mark, I've just tested and confirmed it works using WaveInEvent..

Commented Issue: WaveIn class - DataAvailable is not raised when class is used in Console Application [16131]

$
0
0
I've created own wav recording class using WaveIn, based on example from WavRecording demo. It was working perfectly when i was testing my class in the GUI application.
When I moved my code, without any change, to the console application or to the library, then it stopped working.
I've notticed that DataAvailable is never launched in these cases, so the buffer is never dumped to the wav file.
Only wav header is written to the output wav file.

I am working under Win7 x64. I compile code with .NET Framework target 3.5, Any CPU configuration.
Comments: glad to hear it, its a class I should have made a while ago. Long-term the plan is for WaveIn to automatically work out what the best mode is depending on whether you are in a GUI app or not

New Post: Resample problem

$
0
0

If I use

WaveFormat waveFormat = new WaveFormat(44100, 2); 
mixer = new MixingSampleProvider(waveFormat);

everything is ok with the WaveFormatConversionStream. But then I'm trying to save mixed song to the disk like this

WaveFileWriter.CreateWaveFile(mixedSong, new SampleToWaveProvider(mixer));

I recieve error: "Must be already floating point".

New Post: nodriver calling waveInPrepareHeader

$
0
0

I'm running into the same problem.

I'm using your (just added) WaveInEvent, and when I pull the plug of the Mic while recording I get a MMException "NoDriver" in WaveInPrepareHeader called in WaveInBuffer::Reuse().

This exception is thrown in WaveInEvent's recording-thread so there is no way for me to catch it.
Letting it escalate to the application's Unhandled Exception handler is of no use since there's no way to keep running the program in that case - it has to exit.

Am I correct in assuming there is no handling for unforeseen events like unplugged devices ?
Anyway, I'm fixing it locally by modifying the WaveInEvent's recording thread to handle the exception by flipping 'recording' to false, but I'd rather not work with locally modified versions of NAudio of course ;)

Cheers,

Lennart.

New Post: nodriver calling waveInPrepareHeader

$
0
0

My plan for the future (hopefully near future) is for the PlaybackStopped and RecordingStopped events to include a possible Exception. Then all IWavePlayer and IWaveIn implementations have an easy way of reporting exceptions back to the user.


New Post: nodriver calling waveInPrepareHeader

$
0
0

FYI I am successfully catching this in the unhandled exception handler and the application does continue working afterwards:

private static void ApplicationThreadException(object sender, ThreadExceptionEventArgs e)    {       

if (e.Exception.Message == "NoDriver calling waveInPrepareHeader")            {               

//USB audio unplugged (typically the cause) - no other way to catch this exception in the volume level control due to limitation in NAudio           

}            else            { 

}

}

New Post: nodriver calling waveInPrepareHeader

$
0
0

have checked in some code that will form part of the next version of NAudio. The PlaybackStopped and RecordingStopped events now contain an Exception property that you can examine to see why playback stopped

New Post: Resample problem

$
0
0

How did you manage to create MixingSampleProvider with that WaveFormat? It should have thrown an exception

Updated Wiki: Documentation

$
0
0

The NAudio Documentation Wiki

NAudio FAQ

What is NAudio?

NAudio is an open source audio API for .NET written in C# by Mark Heath, with contributions from many other developers. It is intended to provide a comprehensive set of useful utility classes from which you can construct your own audio application.

Why NAudio?

NAudio was created because the Framework Class Library that shipped with .NET 1.0 had no support for playing audio. The System.Media namespace introduced in .NET 2.0 provided a small amount of support, and the MediaElement in WPF and Silverlight took that a bit further. The vision behind NAudio is to provide a comprehensive set of audio related classes allowing easy development of utilities that play or record audio, or manipulate audio files in some way.

Can I Use NAudio in my Project?

NAudio is licensed under the Microsoft Public License (Ms-PL) which means that you can use it in whatever project you like including commercial projects. Of course we would love it if you share any bug-fixes or enhancements you made to the original NAudio project files.

Is .NET Performance Good Enough for Audio?

While .NET cannot compete with unmanaged languages for very low latency audio work, it still performs better than many people would expect. On a fairly modest PC, you can quite easily mix multiple WAV files together, including pass them through various effects and codecs, play back glitch free with a latency of around 100ms.

How can I get help?

There are three main ways to get help. If you have a specific question concerning how to use NAudio, then I recommend that you ask on StackOverflow and tag your question with naudio. This gives you the best chance of getting a quick answer. You can also ask a question on the NAudio discussion forums here on CodePlex. I attempt to answer all questions, but since this is a spare time project, occasionally I get behind. Finally, I am occasionally able to offer paid support for situations where you need quick advice, bugfixes or new features. Use the contact feature of the Codeplex website to get in touch with Mark Heath if you wish to pursue this option.

How do I submit a patch?

I welcome contributions to NAudio and have accepted many patches, but if you want your code to be included, please familiarise yourself with the following guidelines:

  • Your submission must be your own work, and able to be released under the MS-PL license.
  • You will need to make sure your code conforms to the layout and naming conventions used elsewhere in NAudio.
  • Remember that there are many existing users of NAudio. A patch that changes the public interface is not likely to be accepted.
  • Try to write "clean code" - avoid long functions and long classes. Try to add a new featue by creating a new class rather than putting loads of extra code inside an existing one.
  • I don't usually accept contributions I can't test, so please write unit tests (using NUnit) if at all possible. If not, give a clear explanation of how your feature can be unit tested and provide test data if appropriate. Tell me what you did to test it yourself, including what operating systems and soundcards you used.
  • If you are adding a new feature, please consider writing a short tutorial on how to use it.
  • Unless your patch is a small bugfix, I will code review it and give you feedback. You will need to be willing to make the recommended changes before it can be integrated into the main code.
  • The easiest way to provide a patch is to create your own fork on Mercurial and issue a pull request. See this video if you are new to Mercurial.
  • Please also bear in mind that when you add a feature to NAudio, that feature will generate future support requests and bug reports. Are you willing to stick around on the forums and help out people using it?

How do I...?

The best way to learn how to use NAudio is to download the source code and look at the two demo applications - NAudioDemo and NAudioWpfDemo. These demonstrate several of the key capabilities of the NAudio framework. They also have the advantage of being kept up to date, whilst some of the tutorials you will find on the internet refer to old versions of NAudio.

Getting Started with NAudio – Downloading and Compiling

  1. Download a copy of the NAudio source code (or a pre-compiled version but the newest available code is available in source form first).
    http://naudio.codeplex.com/SourceControl/list/changesets
  2. The default project is set to the NAudio class library. Class Library’s don’t have anything to look at when you press F5. If this is your first time with NAudio, set the start-up project as NAudioDemo and then hit F5. The NAudioDemo project shows the base functionality you can utilise through your own project.
  3. In the BIN directory for the built solution, you can find a copy of the NAudio library for using and referencing in your own project. Make sure that you grab a copy of the NAudio.XML file as well if your copying it over to your own projects directory, that way you will have the intellisense documentation for use in Visual Studio when working with the NAudio API.

Additional Tutorials from OpenSebJ's blog (n.b. these are for NAudio 1.3):

http://stackoverflow.com/

Updated Wiki: Documentation

$
0
0

The NAudio Documentation Wiki

NAudio FAQ

What is NAudio?

NAudio is an open source audio API for .NET written in C# by Mark Heath, with contributions from many other developers. It is intended to provide a comprehensive set of useful utility classes from which you can construct your own audio application.

Why NAudio?

NAudio was created because the Framework Class Library that shipped with .NET 1.0 had no support for playing audio. The System.Media namespace introduced in .NET 2.0 provided a small amount of support, and the MediaElement in WPF and Silverlight took that a bit further. The vision behind NAudio is to provide a comprehensive set of audio related classes allowing easy development of utilities that play or record audio, or manipulate audio files in some way.

Can I Use NAudio in my Project?

NAudio is licensed under the Microsoft Public License (Ms-PL) which means that you can use it in whatever project you like including commercial projects. Of course we would love it if you share any bug-fixes or enhancements you made to the original NAudio project files.

Is .NET Performance Good Enough for Audio?

While .NET cannot compete with unmanaged languages for very low latency audio work, it still performs better than many people would expect. On a fairly modest PC, you can quite easily mix multiple WAV files together, including pass them through various effects and codecs, play back glitch free with a latency of around 100ms.

How can I get help?

There are three main ways to get help. If you have a specific question concerning how to use NAudio, then I recommend that you ask on StackOverflow and tag your question with naudio. This gives you the best chance of getting a quick answer. You can also ask a question on the NAudio discussion forums here on CodePlex. I attempt to answer all questions, but since this is a spare time project, occasionally I get behind. Finally, I am occasionally able to offer paid support for situations where you need quick advice, bugfixes or new features. Use the contact feature of the Codeplex website to get in touch with Mark Heath if you wish to pursue this option.

How do I submit a patch?

I welcome contributions to NAudio and have accepted many patches, but if you want your code to be included, please familiarise yourself with the following guidelines:

  • Your submission must be your own work, and able to be released under the MS-PL license.
  • You will need to make sure your code conforms to the layout and naming conventions used elsewhere in NAudio.
  • Remember that there are many existing users of NAudio. A patch that changes the public interface is not likely to be accepted.
  • Try to write "clean code" - avoid long functions and long classes. Try to add a new featue by creating a new class rather than putting loads of extra code inside an existing one.
  • I don't usually accept contributions I can't test, so please write unit tests (using NUnit) if at all possible. If not, give a clear explanation of how your feature can be unit tested and provide test data if appropriate. Tell me what you did to test it yourself, including what operating systems and soundcards you used.
  • If you are adding a new feature, please consider writing a short tutorial on how to use it.
  • Unless your patch is a small bugfix, I will code review it and give you feedback. You will need to be willing to make the recommended changes before it can be integrated into the main code.
  • The easiest way to provide a patch is to create your own fork on Mercurial and issue a pull request. See this video if you are new to Mercurial.
  • Please also bear in mind that when you add a feature to NAudio, that feature will generate future support requests and bug reports. Are you willing to stick around on the forums and help out people using it?

How do I...?

The best way to learn how to use NAudio is to download the source code and look at the two demo applications - NAudioDemo and NAudioWpfDemo. These demonstrate several of the key capabilities of the NAudio framework. They also have the advantage of being kept up to date, whilst some of the tutorials you will find on the internet refer to old versions of NAudio.

Getting Started with NAudio – Downloading and Compiling

  1. Download a copy of the NAudio source code (or a pre-compiled version but the newest available code is available in source form first).
    http://naudio.codeplex.com/SourceControl/list/changesets
  2. The default project is set to the NAudio class library. Class Library’s don’t have anything to look at when you press F5. If this is your first time with NAudio, set the start-up project as NAudioDemo and then hit F5. The NAudioDemo project shows the base functionality you can utilise through your own project.
  3. In the BIN directory for the built solution, you can find a copy of the NAudio library for using and referencing in your own project. Make sure that you grab a copy of the NAudio.XML file as well if your copying it over to your own projects directory, that way you will have the intellisense documentation for use in Visual Studio when working with the NAudio API.

Additional Tutorials from OpenSebJ's blog (n.b. these are for NAudio 1.3):

http://stackoverflow.com/
Viewing all 5831 articles
Browse latest View live