naudio

Naudio,how to tell playback is completed

こ雲淡風輕ζ 提交于 2020-05-26 04:02:09
问题 I am using the NAudio library to write a simple WinForms audio recorder/player. My problem is how can I tell that playback is completed? I need to close the wave stream after that. I knew there is a PlaybackStopped event listed below: wfr = new NAudio.Wave.WaveFileReader(this.outputFilename); audioOutput = new DirectSoundOut(); WaveChannel32 wc = new NAudio.Wave.WaveChannel32(wfr); audioOutput.Init(wc); audioOutput.PlaybackStopped += new EventHandler<StoppedEventArgs>(audioOutput

How to perform the FFT to a wave-file using NAudio

爷,独闯天下 提交于 2020-04-15 13:03:28
问题 I'm working with the NAudio-library and would like to perform the fast fourier transformation to a WaveStream. I saw that NAudio has already built-in the FFT but how do I use it? I heard i have to use the SampleAggregator class. 回答1: You need to read this entire blog article to best understand the following code sample I lifted to ensure the sample is preserved even if the article isn't: using (WaveFileReader reader = new WaveFileReader(fileToProcess)) { IWaveProvider stream32 = new

C#获取设备(Audio和Video)名称 简单整理

孤街浪徒 提交于 2020-04-12 15:11:45
直接上测试代码和运行结果 static void Main(string[] args) { #region 测试代码 List<string> dataList; dataList = DirectXHelper.GetAudioDevicesList(); OutPutInfo("DirectX获取麦克风:", dataList); dataList = NAudioHelper.GetInDeviceList(); OutPutInfo("NAudio获取麦克风", dataList); dataList = NAudioHelper.GetInDeviceListFull(); OutPutInfo("NAudio获取麦克风完整名称", dataList); dataList = NAudioHelper.GetOutDeviceList(); OutPutInfo("NAudio获取扬声器", dataList); dataList = NAudioHelper.GetOutDeviceListFull(); OutPutInfo("NAudio获取扬声器完整名称", dataList); dataList = AForgeHelper.GetAudioInDevicesList(); OutPutInfo("AForge获取麦克风", dataList);

how to eliminate latency and echo from the direct-monitoring using AsioOut (NAudio)

删除回忆录丶 提交于 2020-02-05 04:43:04
问题 Based on this question made ​​by me: How to record and playback with NAudio using AsioOut With this code: [DllImport("Kernel32.dll", EntryPoint = "RtlMoveMemory", SetLastError = false)] private static unsafe extern void MoveMemory(IntPtr dest, IntPtr src, int size); private void OnAudioAvailable(object sender, AsioAudioAvailableEventArgs e) { for (int i = 0; i < e.InputBuffers.Length; i++) { MoveMemory(e.OutputBuffers[i], e.InputBuffers[i], e.SamplesPerBuffer * e.InputBuffers.Length); } e

Capture audio from WasapiLoopbackCapture, and convert to muLaw

喜夏-厌秋 提交于 2020-02-01 07:59:13
问题 I'm capturing audio with WasapiLoopbackCapture - format = IeeeFloat - SampleRate = 48000 - BitsPerSample = 32 I need to convert this to muLaw (8Khz, 8 bit, mono) - eventually it'll be sent to a phone via SIP trunking. I've tried 100s of samples (most of them with NAudio) and solutions but still have no clue how to do this ... 回答1: The Mu-Law tools in NAudio are limited so you might have to roll your own. You'll need to set up a chain of IWaveProvider filters to convert to mono, change bit

How to stream an mp3 file from a URL without using much RAM?

拜拜、爱过 提交于 2020-01-25 21:51:13
问题 I have a method to stream mp3 from url sources. In this method, the file begins downloading and at the same time the downloaded bytes are stored in a MemoryStream. But I realized that this method is not good. Because the RAM usage is approximately 50 mb when the mp3 file is being played. So I want to make it without storing in MemoryStream. I tried storing the downloaded bytes in a temporary file, but it didn't worked. How to fix it to work with FileStream? It works good using MemoryStream:

how to trim header and side information of mp3 frame using Naudio and c#

冷暖自知 提交于 2020-01-25 11:51:15
问题 My Problem is to get ACTUAL DATA of a mp3 frame. For this I have used NAudio and get RawData but I think in the RawData property, it returns all the bytes of the frame including header and side information. Code is given below: private void button1_Click(object sender, EventArgs e) { Mp3FileReader reader = new Mp3FileReader("file.mp3"); Mp3Frame mp3Frame = reader.ReadNextFrame(); byte [] FrameByteArray = mp3Frame.RawData; BitArray bits = new BitArray(FrameByteArray); Console.Write(mp3Frame

How to properly write a fade-out to a WAV file using NAudio?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-24 15:23:46
问题 I'm using NAudio to convert & trim some audio files, and I'm trying to add a fade-out to the last few seconds of each file. I have checked this question, this, and this, but all the answers are talking about playing the wav file with fade, while I need to actually write that fade to an output file. So, is there any way to do this using NAudio? If not, I'm open to other suggestions. Edit: This is what I've tried: private void PerformFadeOut(string inputPath, string outputPath) { WaveFileReader

How to properly write a fade-out to a WAV file using NAudio?

*爱你&永不变心* 提交于 2020-01-24 15:22:25
问题 I'm using NAudio to convert & trim some audio files, and I'm trying to add a fade-out to the last few seconds of each file. I have checked this question, this, and this, but all the answers are talking about playing the wav file with fade, while I need to actually write that fade to an output file. So, is there any way to do this using NAudio? If not, I'm open to other suggestions. Edit: This is what I've tried: private void PerformFadeOut(string inputPath, string outputPath) { WaveFileReader

How to get Bass, Mid, Treble data from FFT

纵饮孤独 提交于 2020-01-13 19:20:08
问题 I'm new to this whole audio processing area and I'm wondering how to extract Bass, Mid and treble from an FFT output. I'm currently using this to get the data: https://stackoverflow.com/a/20414331/2714577 which uses Naudio. But I'm using a fftlength of 1024 (require speed). I'm trying to get these 3 sections in a format such as 0-255 for colour purposes. I currently have this: double[] data = new double[512]; void FftCalculated(object sender, FftEventArgs e) { for (int j = 0; j < e.Result