naudio

How can I play byte array of audio raw data using NAudio?

懵懂的女人 提交于 2019-11-29 13:51:42
byte[] bytes = new byte[1024]; Assume bytes is an array filled with audio raw data. How can I play this byte array using a WaveOut object? _waveOut.Init(bytes); // <- Error: cannot resolve method. _waveOut.Play(); I figured it out, here is the solution: byte[] bytes = new byte[1024]; IWaveProvider provider = new RawSourceWaveStream( new MemoryStream(bytes), new WaveFormat()); _waveOut.Init(provider); _waveOut.Play(); The accepted answer assumes the byte stream is 44,1kHz, 16 bit, stereo. If you have something else you have to provide the coding in the WaveFormat byte[] bytes = new byte[1024];

Is Media Foundation supported on Windows 2012 64 bit server? [closed]

岁酱吖の 提交于 2019-11-29 10:44:11
Is Media Foundation supported on Windows 2012 64 bit server? We can not have Windows 7 or Windows 8 as the server and that's the reason we are opting for Windows 2012 server. As NAudio 1.7 is released now, we would like to utilize the new functionality with Media Foundation. Any suggestions greatly appreciated. Yes, you can install the Media Foundation components on Windows Server 2012. Use the Add Roles and Features wizard from the Server Manager. Skip through to Features and select Media Foundation . Also if you are using Windows Server 2008 R2 you can Add Features from Server Manager and

NAudio playing a sine wave for x milliseconds using C#

家住魔仙堡 提交于 2019-11-29 10:39:33
I am using NAudio to play a sinewave of a given frequency as in the blog post Playback of Sine Wave in NAudio . I just want the sound to play() for x milliseconds and then stop. I tried a thread.sleep, but the sound stops straightaway. I tried a timer, but when the WaveOut is disposed there is a cross-thread exception. I tried this code, but when I call beep the program freezes. public class Beep { public Beep(int freq, int ms) { SineWaveProvider32 sineWaveProvider = new SineWaveProvider32(); sineWaveProvider.Amplitude = 0.25f; sineWaveProvider.Frequency = freq; NAudio.Wave.WaveOut waveOut =

AlreadyAllocated calling waveOutOpen error

谁都会走 提交于 2019-11-29 07:48:49
private void receiveAudio(object sender) { IPEndPoint senderEP = new IPEndPoint(IPAddress.Any, 0); MemoryStream audioDataStream; BufferedWaveProvider bufferedWaveProvider; //RawSourceWaveStream receivedRawAudioData; byte[] receivedAudioData; waveOutStream = new WaveOut(); while (IsAudioTransferActive) { receivedAudioData = audioUDPClient.Receive(ref senderEP); audioDataStream = new MemoryStream(receivedAudioData); //receivedRawAudioData = new RawSourceWaveStream(audioDataStream, audioFormat); bufferedWaveProvider = new BufferedWaveProvider(audioFormat); //How can I feed "audioDataStream " to

Saving each WAV channel as a mono-channel WAV file using Naudio

可紊 提交于 2019-11-29 07:29:26
I'm trying to convert a WAV file(PCM,48kHz, 4-Channel, 16 bit) into mono-channel WAV files. I tried splittiing the WAV file into 4 byte-arrays like this answer and created a WaveMemoryStream like shown below but does not work. byte[] chan1ByteArray = new byte[channel1Buffer.Length]; Buffer.BlockCopy(channel1Buffer, 0, chan1ByteArray, 0, chan1ByteArray.Length); WaveMemoryStream chan1 = new WaveMemoryStream(chan1ByteArray, sampleRate, (ushort)bitsPerSample, 1); Am I missing something in creating the WAVE headers ? Or is there more to splitting a WAV into mono channel WAV files ? The basic idea

NAudio error: “NoDriver calling acmFormatSuggest”

余生颓废 提交于 2019-11-29 06:58:30
I've got a project that uses NAudio to convert from mp3 to wav. (using the WaveFormatConversionStream.CreatePcmStream() method) It worked fine on my development machine but now I'm trying it on a fresh new server and its throwing this error: NAudio.MmException: NoDriver calling acmFormatSuggest at NAudio.MmException.Try(MmResult result, String function) at NAudio.Wave.Compression.AcmStream.SuggestPcmFormat(WaveFormat compressedFormat) at NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(WaveStream sourceStream) I assume there is some dependency that NAudio needs here that isn't on the new

Record input from NAudio WaveIn, and output to NAudio WaveOut

房东的猫 提交于 2019-11-29 00:00:30
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? 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 class Form4 : Form { private BufferedWaveProvider bwp; WaveIn wi; WaveOut wo; public Form4() {

Fading sound in/out

只愿长相守 提交于 2019-11-28 13:36:59
I have a background sound playing in an endless loop. I want it to fade out when the user does press a button. I tried the following: A DirectSoundOut is initiated with the WaveStream A Timer changes the volume of the WaveChannel32. The Problem: Changing the volume while the sound is playing produces noises. Does anyone knows a better solution? To perform a smooth fade-in or fade-out, you need to do so at the sample level. You then multiply each sample by a gradually increasing or decreasing number. You are using WaveChannel32, so your audio has already been converted to 32 bit float. I would

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

人走茶凉 提交于 2019-11-28 12:23:39
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 The problem turns out to be that the native DLLs ( libmp3lame.32.dll and libmp3lame.64.dll ) cannot be found because the current directory that the web server process is executing

NAudio Asio Record and Playback

喜你入骨 提交于 2019-11-28 11:33:46
问题 I'm trying to write my own VST Host and for that i need to record and play audio from an Asio Driver (in my case for an audio interface). That's why i'm trying to use NAudio's AsioOut. For testing purposes i'm currently just trying to record the input, copy and play it to the output. My code looks like this: var asioout = new AsioOut(); BufferedWaveProvider wavprov = new BufferedWaveProvider(new WaveFormat(44100, 2)); asioout.AudioAvailable += new EventHandler<AsioAudioAvailableEventArgs>