FAQ Database Discussion Community


NAudio File Conversion

c#,converter,naudio
I have Mp3 audio files with the same music, which are encoded at different sample rate and bit depth. For example: Titanic - 96 Kbps - 44 KHz.mp3 Titanic - 96 Kbps - 48 KHz.mp3 Titanic - 128 Kbps - 44 KHz.mp3 Titanic - 128 Kbps - 48 KHz.mp3 Titanic...

Why Recording Audio gives error Buffer full after 5 seconds?

c#,naudio
Following code gives me the error 'Buffer full' and I have no idea why. My code was supposed to give me wave chart while it's recording the audio. However, wave chart is working and the after 5 seconds above error is brought to the screen my the program Please help...

Record specific application audio with naudio

c#,audio,record,naudio
Based on this naudio tutorial, I'm aware that naudio has the ability to record audio output in Windows. The article also mentions that you can set naudio to only record audio mixed by naudio. It seems to me as though the tools to accomplish application-specific recording are in there, but...

mp3 to sample array NAudio

mp3,naudio
How can I use NAudio library to get sample float array from mp3 file? Here is my code: float[] buffer = new float[2000]; AudioFileReader reader = new AudioFileReader(filePath); reader.Read(buffer, 0, 2000); After that buffer is always empty (only zeros inside). You could also provide me another useful library in C#...

Applying a linear fade at a specify position using NAudio

c#,audio,naudio
I am making use of NAudio in a C# program I've written. I want to apply a linear fade at a certain position within a piece of audio I'm working with. In the NAudio example project is a file called FadeInOutSampleProvider.cs (Cached example) which has BeginFadeIn(double fadeDurationInMilliseconds) and BeginFadeOut(double fadeDurationInMilliseconds)...

c# Naudio MemoryStream Exception was not readable

c#,naudio
I'm using Naudio. And I'm trying to write .mp3 stream to .wav stream. This is my code: MemoryStream outputStream = new MemoryStream(); WaveStream waveStream = WaveFormatConversionStream.CreatePcmStream(new Mp3FileReader(@"C:\Users\practice\Desktop\ORIG FILE.mp3")); using (WaveFileWriter waveFileWriter = new WaveFileWriter(outputStream, waveStream.WaveFormat)) { byte[] bytes = new byte[waveStream.Length]; waveStream.Position = 0; waveStream.Read(bytes, 0, (int)waveStream.Length); waveFileWriter.Write(bytes, 0, bytes.Length);...

Sound clipping/clicking when lowering volume with NAudio

c#,naudio
Audio is clipping (or clicking) when trying to lower the volume of a WAV file in real time. I've tried it on a SampleChannel, VolumeSampleProvider and WaveChannel32 instance, the source being a 32bit WAV file. If I try it on a WaveOut instance, the clipping doesn't occur anymore, but I...

RawSourceWaveStream volume control and playback time estimation with Naudio

audio,volume,naudio
I'm using Naudio to play audio samples from memory. private RawSourceWaveStream waveStream; private MemoryStream ms; private int sampleRate = 48000; private IWavePlayer wavePlayer; //generate sine wave signal short[] buffer = new short[(int)Math.Round(sampleRate * 10.00)]; double amplitude = 0.25 * short.MaxValue; double frequency = 1000; for (int n = 0; n...

How to connect to Windows 7 audio

c#,.net,audio,windows-7,naudio
I want to programmatically be able to connect to my computer's audio output (the exact same thing I'd hear if I plugged my headphones into the side of my laptop) and collect the audio. So far, I haven't really been able to find anything that does this, other than Core...

LameMP3FileWriter: Unsupported encoding format MuLaw Parameter name: format

wav,naudio,lame
Trying to convert a 12 year old wav file to mp3, 8K, 8bit, Mono-channel, Mu-Law format, WAV and I am getting this error in LameMP3FileWriter line: LameMP3FileWriter: Unsupported encoding format MuLaw Parameter name: format static void Main(string[] args) { string wavFilePath = @"C:\temp\Message.wav"; string mp3FilePath = @"C:\temp\Message.mp3"; if (!File.Exists(mp3FilePath)) {...

Cannot play a note with NAudio.Midi

c#,midi,naudio
I read this answer and tried playing a single note with NAudio.Midi: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using NAudio.Midi; using System.Threading; namespace SoundVision10 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object...

C# - How to make the BiQuadFilter Code work

c#,naudio,lowpass-filter
I have to following C# code which passes my WAV file through a low pass filter. I am using NAudio's BiQuadFilter for this. However there is no changes in the sound and it is still the same. My code: public void setValues(ISampleProvider sourceProvider,int cutOffFreq) { this.sourceProvider = sourceProvider; this.cutOffFreq =...

AccessViolationException on sp_session_player_load()

c#,naudio,libspotify
I'm trying to create a stream application based on Spotify's libspotify SDK. To achieve this in C# I'm using the ohLibspotify bindings and wrapper. This is only a thin abstraction layer so most of it will be a 1:1 mapping to the libspotify SDK. To play the incoming PCM data...

SignalGenerator class at naudio library - duration time play

c#,signal-processing,naudio
I use naudio for generating a tone in a specified frequency like that: private void gen_Sinus(double frequency) { WaveOut _myWaveOut = new WaveOut(); SignalGenerator mySinus = new SignalGenerator(44100, 1);//using NAudio.Wave.SampleProviders; mySinus.Frequency = frequency; mySinus.Type = SignalGeneratorType.Sin; _myWaveOut.Init(mySinus); _myWaveOut.Play(); } I want that when clicking a button it will play that...

MFT NAudio Resampling on the fly

naudio,ms-media-foundation,resampling
I want to resample an audio file using NAudio and MFT on-the-fly. For example, I have the following audio file: File name: MyAudioFile.mp3 Duration: 10 sec When this file is being played, I only want to resample that particular position to WAV in the desired format. So, if the length...

Using equalizer in NAudio loopback

c#,naudio,equalizer
I wrote this simple method using NAudio to create a reverb effect on the current sound device. It's already working. However, I would like to apply the reverb effect only on the higher frequencies, because otherwise you hear a lot of base drum echoes, which isn't what I want it...

With NAudio howto capture an signal played

.net,audio,naudio
Is there any way to capture a sound signal being played (by another application) in .NET (with or without the NAudio library)? What I want to do is build an graphical visualization of the sounds played (like there are plenty apps), but without playing the sound itself (which seems non...

NAudio effect not working and behaving differently on different sound cards

c#,.net,audio,naudio,audioeffect
I'm using NAudio and the WasapiLoopbackCapture in combination with WaveOut in order to create an echo effect that is global, i.e. affects the current audio output. However, my implementation, which seems pretty poor to me, doesn't work well at all. On every machine it sounds different, sometimes it even crashes....

Can't play audio stream recorded with naudio

c#,wpf,playback,naudio
I try to record some audio(after Record click button) into a MemoryStream and then Play it in visual studio(WPF) using NAudio. I generated a RawSourceWaveStream that gets the myMemoryStream when click play button but I think this is bugging the code. It doesn't play... here is my code. Where am...

playing and stopping audio from two different buttons

c#,naudio
I'm running this code for pausing the song but it obliviously doesn't work. I can't access the variables of the first button from the second one, so I can't pause the song. How do you think I could do that? I'm using the naudio library cause I wanted to put...

BufferedWaveProvider doesnt work in Unity

c#,audio,unity3d,naudio
I am trying to implement NAudio into Unity. I managed to link the NAudio dll, but I am getting a strange error when I try to play music with NAudio BufferedWaveProvider. If I to this: WaveOut player; BufferedWaveProvider buf; AudioFileReader reader; void Start () { reader = new AudioFileReader(@"..\music.mp3"); //...

Resampling WasapiLoopbackCapture

c#,signal-processing,naudio,resampling
I'm trying to resample the WasapiLoopbackCapture's output from my soundcards 44100Hz, 16bit, 2 channel waveformat to a 16000Hz, 16bit, 1 channel format for later use in a System.Net.Sockets.NetworkStream (I want to write the converted bytes to the network stream) But I have no idea how to start even! I'm really...

Append WAV Header in NAudio

c#,header,wav,naudio
I am trying to convert audio MP3 files to WAV with a standard rate (48 KHz, 16 bits, 2 channels) by opening with "MediaFoundationReaderRT" and specifying the standard settings in it. After the file is converted to PCM WAV, when I try to play the WAV file, it gives corrupt...

C# equivalent for Java's AudioFormat.isBigEndian and AudioFormat.Encoding.PCM_SIGNED

java,c#,audio,naudio
I am having hard time trying to port some Java code to C# for my simple project. The Java code makes use of format.isBigEndian and checks if the audio file data is signed or not. My C# project makes use of NAudio for handling audio files. Here is the Java...

Audio stream for multiple outputs (single producer, multi-consumer)

c#,naudio,producer-consumer
I am attempting to propagate a single sound source to multiple outputs (such as one microphone input to multiple sound cards or channels). The output does not have to be sync'd (a few ms delay is acceptable) but it would be nice if it could be sync'd. I have successfully...

C# NAudio makes Noise WAV file without errors after POST from another page

c#,audio,wav,naudio
I am posting a file in callback(base64data); to the server using. When I get the file all seems well but the file sounds like white noise. Thanks for your help. protected void Page_Load(object sender, EventArgs e) { var strUser = Request.Form["UserId"]; int userId = Convert.ToInt32(strUser); var reader = new RawSourceWaveStream(HttpContext.Current.Request.InputStream,...

wav file concatenation exception with naudio library

c#,wpf,ioexception,naudio
I use the following method which I found here at this forum. In my WPF user interface I have a button the calls this method in order to concatenate some sound files and plays the new file. After the first click the concatenated file is generated and I wait for...