naudio

How to get Bass, Mid, Treble data from FFT

风格不统一 提交于 2019-12-06 11:49:17
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.Length / 2; j++) { double magnitude = Math.Sqrt(e.Result[j].X * e.Result[j].X + e.Result[j].Y * e.Result[j

Delay (approx 200 ms) in streamed audio playback

旧城冷巷雨未停 提交于 2019-12-06 06:18:43
问题 I have an application which plays the streamed audio data (like a chat client). The workflow involves three simple steps: The file header info (sample rate, bits per sample and num of channels) is sent first. Audio waveout device is initialized based on the above parameters. Audio (pcm) data is sent and is played on the above device. The data receiving code is native (C code). and it reads data on a socket. Then it calls the managed C# code, which uses Naudio library to initialize device and

Save streaming data to a WAV file using NAudio

江枫思渺然 提交于 2019-12-06 06:09:01
I want to save the incoming stream data to a WAV file on my hard disk drive. How can I change the code below to be able to record the stream into a valid WAV file? From the demo here : private void StreamMP3(object state) { this.fullyDownloaded = false; string url = (string)state; webRequest = (HttpWebRequest)WebRequest.Create(url); HttpWebResponse resp = null; try { resp = (HttpWebResponse)webRequest.GetResponse(); } catch(WebException e) { if (e.Status != WebExceptionStatus.RequestCanceled) { ShowError(e.Message); } return; } byte[] buffer = new byte[16384 * 4]; // Needs to be big enough to

Get default output audio device with NAudio

心已入冬 提交于 2019-12-06 05:57:16
I want to get the default output audio device (i.e. my speakers) using NAudio, to get the master sound volume as in this question . I am trying to use MMDeviceEnumerator.GetDevice() , but the id it takes is a string, not the device number. Here's the code I've written so far: var enumerator = new MMDeviceEnumerator(); for (int i = 0; i < WaveOut.DeviceCount; i++) { var cap = WaveOut.GetCapabilities(i); Console.WriteLine("{0}: {1}", i, cap.ProductName); var device = enumerator.GetDevice(???); } Console.WriteLine(); Console.ReadLine(); I've tried passing the various Guids from the capabilities,

MonoDevelop + NAudio + Ubuntu Linux tells me Winmm.dll not found?

和自甴很熟 提交于 2019-12-06 04:08:09
问题 So I'm attempting to use MonoDevelop with NAudio and Ubuntu Linux, For some reason It errors saying that winmm.dll isn't found so I attempted to download it and and the "Add Reference" dialogue claims its not a valid .NET library. Here is my code.... using System; using System.IO; using Gst; using GLib; using Gst.BasePlugins; using NAudio; using NAudio.Wave; namespace record_audio_simple_test { class MainClass { //Define class variables private NAudio.Wave.WaveFileReader waveFile = null;

Trying to understand buffers with regard to NAudio in C#

元气小坏坏 提交于 2019-12-06 00:02:06
I'm a chemistry student trying to use NAudio in C# to gather data from my computer's microphone (planning on switching to an audio port later, in case that's pertinent to how this gets answered). I understand what source streams are, and how NAudio uses an event handler to know whether or not to start reading information from said stream, but I get stumped when it comes to working with the data that has been read from the stream. As I understand it, a buffer array is populated in either byte or WAV format from the source stream (with the AddSamples command). For now, all that I'm trying to do

Remove the headers from several WAV files, and then concatenate the remaining data into one RAW file

扶醉桌前 提交于 2019-12-05 13:02:47
I have a RAW audio file which is made up of several concatenated, smaller WAV files. I can open and play this file as 48,000, 8 bit PCM, signed, mono, in Sound Forge. What I would like to do, in C#, is programmatically overwrite each individual WAV within the file with new data of equal or smaller length, which I think I'm fairly close to being able to do. I can do a File.ReadAllBytes on the RAW file, loop through the byte array, and determine the start and end location of each WAV. I then pick the new WAV files on my PC, remove the headers, and write the remaining data into my RAW file. If

Naudio - Convert 32 bit wav to 16 bit wav

半城伤御伤魂 提交于 2019-12-05 02:11:33
问题 I've been trying to convert a 32 bit stereo wav to 16 bit mono wav. I use naudio to capture the sound I and thought that using just the two of four more significant bytes will work. Here is the DataAvailable implementation: void _waveIn_DataAvailable(object sender, WaveInEventArgs e) { byte[] newArray = new byte[e.BytesRecorded / 2]; short two; for (int i = 0, j = 0; i < e.BytesRecorded; i = i + 4, j = j + 2) { two = (short)BitConverter.ToInt16(e.Buffer, i + 2); newArray[j] = (byte)(two &

Convert PCM to MP3/OGG

此生再无相见时 提交于 2019-12-04 16:30:59
I need to convert a continuous stream of PCM, or encoded audio (ADPCM, uLaw, Opus), into MP3/OGG format so that it can be streamed to a browser (using html's audio tag). I have the "stream-mp3/ogg-using-audio-tag" part working, now I need to develop the conversion layer. I have two questions: How can I convert PCM into MP3/OGG using NAudio and/or some other C# library/framework? I assume there is a code snippet or two in the NAudio demo app that may be doing this, but I haven't been able to find it. Do I have to convert the encoded data (ADPCM, uLaw, OPUS) into PCM (which I can) before I

Enumerate Recording Devices in NAudio

我的梦境 提交于 2019-12-04 11:15:04
问题 How can you get a list of all the recording devices on a computer using NAudio? When you want to record, you have to give it the index of the device you want to use, but there's no way of knowing what device that is. I'd like to be able to select from Mic, Stereo Mix, etc. 回答1: For WaveIn, you can use the static WaveIn.GetCapabilities method. This will give you a device name, but with the annoying limitation that it is a maximum of 31 characters. I am still looking for the way to get the full