naudio

How to record and playback with NAudio using AsioOut

十年热恋 提交于 2019-11-28 00:36:43
I'm trying to get the sound input and send output directly with less latency possible with C#. I'm using the library NAudio that supports ASIO for better latency. In particular, I use the AsioOut object for recording and another for playback initialized with a BufferedWaveProvider , which is filled in a Callback function: OnAudioAvailable , which allows me to use the ASIO buffers. The problem is that I hear the sound with various glitches and with a bit of delay . I think the problem is in the function OnAudioAvailable where the buffer is filled with data taken as input from the sound card.

naudio record sound from microphone then save

强颜欢笑 提交于 2019-11-27 20:15:28
I'm having some issues with naudio and saving sound recordings. The code I currently have works to the point where it saves the wav file, but when I open it up, Windows Media Player returns an error: "Windows Media Player encountered a problem while playing the file" I have two buttons, a "Record" button, which turns into the stop button after it's pressed. And I have a "Save" button which when clicked, saves the recording to sample.wav . NAudio.Wave.WaveIn sourceStream = null; NAudio.Wave.DirectSoundOut waveOut = null; NAudio.Wave.WaveFileWriter waveWriter = null; private void recordButton

Using NAudio to decode mu-law audio

天涯浪子 提交于 2019-11-27 18:51:20
问题 I'm attempting to use NAudio to decode mu-law encoded audio into pcm audio. My service is POSTed the raw mu-law encoded audio bytes and I'm getting an error from NAudio that the data does not have a RIFF header. Do I need to add this somehow? The code I'm using is: WaveFileReader reader = new WaveFileReader(tmpMemStream); using (WaveStream convertedStream = WaveFormatConversionStream.CreatePcmStream(reader)) { WaveFileWriter.CreateWaveFile(recordingsPath + "/" + outputFileName,

Record input from NAudio WaveIn, and output to NAudio WaveOut

旧城冷巷雨未停 提交于 2019-11-27 15:08:23
问题 I want to be able to get input from a microphone device via NAudio.WaveIn, and then output that exact input to an output device via NAudio.WaveOut. How would I do this? 回答1: Here is the code that worked for me: 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.Wave; using NAudio.CoreAudioApi; namespace WindowsFormsApplication1 { public partial

MVC4 App "Unable to load DLL 'libmp3lame.32.dll'

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-27 06:58:13
问题 I am trying to use the NAudio.Lame library in an MVC4 application and am getting the error: Unable to load DLL 'libmp3lame.32.dll': The specified module could not be found. I added the library via NuGet. I was able to get the library to work fine with a Windows Forms application, so I believe the problem is specific to MVC4. I tried the advice from the library author here: https://stackoverflow.com/a/20065606/910348 回答1: The problem turns out to be that the native DLLs ( libmp3lame.32.dll and

Reading notes from MIDI file using NAudio

◇◆丶佛笑我妖孽 提交于 2019-11-27 06:24:43
问题 Task is to get all notes and their time from MIDI file using NAudio library. So far I get all notes from file but I can't get their time. Note noteOn = new Note(); //custom class Note MidiFile midi = new MidiFile(open.FileName); List<TempoEvent> tempo = new List<TempoEvent>(); for (int i = 0; i < midi.Events.Count(); i++) { foreach (MidiEvent note in midi.Events[i]) { TempoEvent tempoE; try { tempoE = (TempoEvent)note; tempo.Add(tempoE); } catch { } if (note.CommandCode == MidiCommandCode

How to write NAudio WaveStream to a Memory Stream?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-27 06:18:59
问题 I have a program that takes in mp3 data in a byte array. It has to convert that mp3 data into wav format and store it in a byte data. I am trying to use NAudio for this purpose. I am using the following code for this purpose. Stream inputStream = ...; Stream outputStream = ...; using (WaveStream waveStream = WaveFormatConversionStream.CreatePcmStream(new Mp3FileReader(inputStream))) using (WaveFileWriter waveFileWriter = new WaveFileWriter(outputStream, waveStream.WaveFormat)) { byte[] bytes

NAudio to split mp3 file

余生长醉 提交于 2019-11-27 03:20:43
问题 I am very new to audio or mp3 stuff, was looking for a way to have a feature to split an mp3 file in C#, asp.net. After googling for a good 3-day without much of a great help, I am hoping that somebody here can point me to a right direction. Can I use NAudio to accomplish this? Is there any sample code for that? Thanks in advance. 回答1: An MP3 File is made up of a sequence of MP3 frames (plus often ID3 tags on the beginning and end). The cleanest way to split an MP3 file then is to copy a

Detect headphones in Windows [duplicate]

拈花ヽ惹草 提交于 2019-11-27 03:06:00
问题 This question already has answers here : Detecting when head phones are plugged in (5 answers) Closed 5 years ago . I'm trying to detect if the headphones are plugged in on Windows. I've already tried DirectSound and the NAudio library and have not had any success. Does anyone have any suggestions? NOTE: this question is a duplicate of this question, but the answer to that question didn't contain any code samples or tutorials. 回答1: So...I think I might found something REALY obscure.. Can any

How to play a MP3 file using NAudio

為{幸葍}努か 提交于 2019-11-27 02:49:06
问题 WaveStream waveStream = new Mp3FileReader(mp3FileToPlay); var waveOut = new WaveOut(); waveOut.Init(waveStream); waveOut.Play(); This throws an exception: WaveBadFormat calling waveOutOpen The encoding type is "MpegLayer3" as NAudio. How can I play a mp3 file with NAudio? 回答1: Try like this: class Program { static void Main() { using (var ms = File.OpenRead("test.mp3")) using (var rdr = new Mp3FileReader(ms)) using (var wavStream = WaveFormatConversionStream.CreatePcmStream(rdr)) using (var