naudio

How to convert amr files to mp3 using C#

杀马特。学长 韩版系。学妹 提交于 2019-12-11 02:55:18
问题 I am using NAudio MFT to convert different audio formats to MP3. Now i want to convert amr file to MP3 using Naudio MFT. But, when i given amr file as input to MFT, it has thrown following exception "Exception from HRESULT: 0xC00D36C4". Is there any way to achieve this? My C# code: public byte[] ConvertAMRToMP3( ) { var data = new MediaFoundationReader("..\\amr\\test.amr"); MediaFoundationEncoder.EncodeToMP3(data, "..\\test.mp3", 128000); ...... } I am working on windows server 2012 64-bit

How Can I Play without file?

本秂侑毒 提交于 2019-12-11 00:45:44
问题 I would like to play a ring alert without loading/streaming it from file. Can I embed it's signal or tone in code? I am using NAudio . My purpose is improving performance by removing IO actions. I don't want to use embedded resources. Only I want generate ring alert in code. 回答1: With NAudio you have these options to do that: To play a file from a stream (in memory). You have code for this in other answers, actually you do not even need NAudio for this task 'cause System.Media.SoundPlayer is

Naudio NoDriver error in .NET

こ雲淡風輕ζ 提交于 2019-12-11 00:44:17
问题 I get the exception "NoDriver calling acmFormatSuggest" when executing this function: private static WaveChannel32 OpenMp3Stream(string fileName) { WaveChannel32 inputStream; WaveStream mp3Reader = new Mp3FileReader(fileName); WaveStream pcmStream = WaveFormatConversionStream.CreatePcmStream(mp3Reader); WaveStream blockAlignedStream = new BlockAlignReductionStream(pcmStream); inputStream = new WaveChannel32(blockAlignedStream); return inputStream; } On this line: WaveStream pcmStream =

Resample loopback capture

梦想与她 提交于 2019-12-10 19:03:22
问题 I successfully captured sound from Wasapi using the following code: IWaveIn waveIn = new WasapiLoopbackCapture(); waveIn.DataAvailable += OnDataReceivedFromWaveOut; What I need to do now, is to resample the in-memory data to pcm with a sample rate of 8000 and 16 bits per sample mono. I can't use ACMStream to resample the example, because the recorded audio is 32 bits per second. I have tried this code to convert bytes from 32 to 16 bits, but all I get every time is just blank audio. byte[]

How to record audio using naudio onto byte[] rather than file

馋奶兔 提交于 2019-12-10 18:26:09
问题 I am able to capture audio using naudio into file, now i want it on byte[] or Stream in c#. this.writer = new WaveFileWriter(this.outputFilename, this.waveIn.WaveFormat); What i tried so far is instead of passing output filename in WaveFileWriter constructor, passed MemoryStream object. With reference to stream object i try to play it using Soundplayer once recording gets over. private IWaveIn waveIn; private WaveFileWriter writer; private string outputFilename; private Stream memoryStream;

Storing a wav file in an array

[亡魂溺海] 提交于 2019-12-10 15:23:40
问题 I need a fast method to store all samples of a wav file in an array. I am currently working around this problem by playing the music and storing the values from the Sample Provider, but this is not very elegant. From the NAudio Demo I have the Audioplayer Class with this Method: private ISampleProvider CreateInputStream(string fileName) { if (fileName.EndsWith(".wav")) { fileStream = OpenWavStream(fileName); } throw new InvalidOperationException("Unsupported extension"); } var inputStream =

Play multiple .wav files simultaniously with Naudio or Win API

半腔热情 提交于 2019-12-10 14:00:01
问题 Hi All I have an application which receives simultaneously wav data through multiple threads from different UDP ports: Is it possible to play all received wav data at same time, simultaneously, using Wave Out API? Is it possible to play all received wav data at same time, simultaneously, using NAudio? does NAudio objects thread safe? saying play simultaneously I mean case when a file played in media player and something in YouTube played at the same time and you can hear both sound from your

NAudio pitch shifting

不打扰是莪最后的温柔 提交于 2019-12-10 12:36:04
问题 I am using the NAudio DLL and I am looking for example code for pitch shifting sound. 回答1: There is an example of using NAudio for pitch shifting in the open source Skype Voice Changer project. See my article on Coding4Fun for more information on the project. The pitch shifter code itself is found in the SuperPitch class. 来源: https://stackoverflow.com/questions/5843413/naudio-pitch-shifting

High Memory Usage playing MP3's with NAudio on Key Press

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 12:21:26
问题 I'm using C#, WPF, and NAudio. I play an embedded resource mp3 in the application exe when a key is pressed. If a key is pressed repeatedly, RAM usage continues to climb past 400MB and never drops. Using Flush() and Dispose() on the objects doesn't seem to free memory even when GC is called. This did not used to happen when I played from external resource on the hard drive using string path instead of MemoryStream . It used to stay around 50MB RAM. public static MemoryStream ms = null; public

C# how to record general audio from output device ( speaker ) with NAudio API

拟墨画扇 提交于 2019-12-10 11:46:55
问题 I'm trying to record the Speaker Output to detect volume and BPM from any playing music with C# and NAudio API. The problem is, i don't know how to do that :/ i have a sample code from http://opensebj.blogspot.de/2009/04/naudio-tutorial-5-recording-audio.html where they record simple input with less code... waveInStream = new WaveIn(44100,2); what does the "44100, 2" means ? does that targets the device to record from ??? how can i target speaker output ? does anyone can help me out ? or even