naudio

Detect current volume level while a file is playing using Naudio

丶灬走出姿态 提交于 2019-12-11 18:55:06
问题 So I have IWavePlayer waveOutDevice; WaveStream mainOutputStream; WaveChannel32 volumeStream; private WaveStream CreateInputStream(string fileName) { WaveChannel32 inputStream; if (fileName.EndsWith(".mp3")) { WaveStream mp3Reader = new Mp3FileReader(fileName); inputStream = new WaveChannel32(mp3Reader); } else { throw new InvalidOperationException("Unsupported extension"); } volumeStream = inputStream; return volumeStream; } private void Stop() { if (waveOutDevice != null) { waveOutDevice

NAudio FFT returns small and equal magnitude values for all frequencies

流过昼夜 提交于 2019-12-11 18:05:35
问题 I'm working on a project with NAudio 1.9 and I want to compute an fft for an entire song, i.e split the song in chunks of equal size and compute fft for each chunk. The problem is that NAudio FFT function returns really small and equal values for any freq in the freq spectrum. I searched for previous related posts but none seemed to help me. The code that computes FFT using NAudio: public IList<FrequencySpectrum> Fft(uint windowSize) { IList<Complex[]> timeDomainChunks = this.SplitInChunks

NAudio - Change pitch of buffered microphone audio and send to Virtual Audio Cable

别说谁变了你拦得住时间么 提交于 2019-12-11 16:47:43
问题 I decided to have a go at creating a sound board for use with Discord (or similar software) using NAudio and a Virtual Audio Cable. I was able to 'inject' the audio from the microphone to the audio cable so I could play sound files and mic audio to Discord by selecting the virtual audio cable as the input device in Discord. For fun I thought I would see if I could modify the mic audio to make it 'squeaky' or 'deep'. So I started looking into modifying the pitch of the audio. I discovered that

FFT frequency of sound

让人想犯罪 __ 提交于 2019-12-11 12:55:09
问题 On microphone at some time, starts flowing sound defined frequency(500hz). How do I know when the signal began to come to the microphone? To solve this problem, I know that I need to use FFT(Fast Fourier transform). But I dont understand, how should I take after FFT frequency? I'm use NAudio on C#. And my buffer from microphone is byte array. 回答1: Using an FFT for this is overkill and not particularly appropriate. A much simpler solution for this kind of problem (tone detection/onset

Applying a linear fade at a specify position using NAudio

两盒软妹~` 提交于 2019-12-11 12:15:22
问题 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) methods. I've reworked these methods to BeginFadeOut(double fadeDurationInMilliseconds, double beginFadeAtMilliseconds) and BeginFadeOut(double

NAudio record never receiving a sample

天大地大妈咪最大 提交于 2019-12-11 11:08:52
问题 I'm attempting the simplest possible NAudio example to record from an input device but for some reason I can't get the DataAvailable callback function to be called. In the example below a break point on Do Something never gets hit. WaveIn waveIn = new WaveIn(); waveIn.DeviceNumber = 0; waveIn.DataAvailable += waveIn_DataAvailable; waveIn.RecordingStopped += new EventHandler(waveIn_RecordingStopped); waveIn.WaveFormat = new WaveFormat(44100, 1); waveIn.StartRecording(); private void waveIn

How can i make the sound louder with Naudio c#?

末鹿安然 提交于 2019-12-11 09:21:28
问题 I am trying to increase the amplitude of the sound wave in my code. I have the buffer consisting of all the bytes needed to make the wave. Here is my code for the audio Playback: public void AddSamples(byte[] buffer) { //somehow adjust the buffer to make the sound louder bufferedWaveProvider.AddSamples(buffer, 0, buffer.Length); WaveOut waveout = new WaveOut(); waveout.Init(bufferedWaveProvider); waveout.Play(); //to make the program more memory efficient bufferedWaveProvider.ClearBuffer(); }

Naudio sound normalize

ⅰ亾dé卋堺 提交于 2019-12-11 07:45:48
问题 I am using Naudio and I have a stream which I need to read as array and then when I have found maximum I need to multiply each value with ( 1/ biggest ) and then I should have values in my array as [-1,1]. 回答1: I don't see really what you mean by "convert", but instead of the code you wrote you could just do: var bytes = stream.ToArray(); var biggest = (float)bytes.Max(); var floats = bytes.Select(b => b / biggest).ToArray(); This will result with floats between 0 and 1, since bytes are

NAudio select the proper frame for AcmMp3FrameDecompressor

拥有回忆 提交于 2019-12-11 05:54:57
问题 I'm working on streaming mp3 player. Initialy when creating AcmMp3FrameDecompressor I used the first frame to determine wave format as the demo shows. Then I realized that some files play at the wrong speed (usually slower). I looked at the implementation of Mp3FileReader and found that it decides between the first and the second frames. // workaround for a longstanding issue with some files failing to load // because they report a spurious sample rate change var secondFrame = Mp3Frame

`Not a WAVE file - no RIFF header` locks file

对着背影说爱祢 提交于 2019-12-11 04:51:08
问题 Using the code: using (var reader = new WaveFileReader(audioFileLocation)) { // Do something.... } If given a wav file that throws the exception: Not a WAVE file - no RIFF header Exception Details: System.FormatException: Not a WAVE file - no RIFF header It locks the file audioFileLocation which prevents it from being deleted. Is there any way to check for the existence of a valid RIFF header before using the reader? 回答1: Try using a stream: using(var inputStream = new FileStream