naudio

NAudio looping an audio file

本秂侑毒 提交于 2019-12-01 03:36:55
问题 I already have the code of the mp3/wma audio playing/stopping and browsing. I just need to know how can I loop the song? Thank you. 回答1: Here's a blog post I wrote on how to loop audio using NAudio. 回答2: Use an array for yours files name, then you can free to loop the song. 回答3: Just handle PlaybackStopped Event, then you can play again the audio. 来源: https://stackoverflow.com/questions/8792456/naudio-looping-an-audio-file

How to play an MP3 stream in C#

一笑奈何 提交于 2019-11-30 23:10:34
I want to play an MP3 stream in my C# application. I have a server application that captures wave audio and converts it into MP3, then writes it to a network stream. The client then reads this stream to play the MP3. I have tried NAudio with the following code example, but it results in exception: using (WaveStream blockAlignedStream = new BlockAlignReductionStream( WaveFormatConversionStream.CreatePcmStream( new Mp3FileReader(ms)))) { using (WaveOut waveOut = new WaveOut(WaveCallbackInfo.FunctionCallback())) { waveOut.Init(blockAlignedStream); waveOut.Play(); while (waveOut.PlaybackState ==

Hearing the Incoming audio from mic

こ雲淡風輕ζ 提交于 2019-11-30 16:56:21
i just want to hear what i say to microphone using NAudio and this is my code so far but the problem is i can't hear anything. any help would be appreciated. public partial class frmMain : Form { private WaveIn waveIn; // Gets an audio from microphone private WaveOut waveOut; // Sends audio to speaker private BufferedWaveProvider waveProvider; // Gets an audio from stream public frmMain() { InitializeComponent(); } private void frmMain_Load(object sender, EventArgs e) { waveOut = new WaveOut(); waveIn = new WaveIn(); waveProvider = new BufferedWaveProvider(waveIn.WaveFormat); waveOut.Init

Trimming mp3 files using NAudio

谁说胖子不能爱 提交于 2019-11-30 14:41:18
Is it possible to trim a MP3 file using NAudio? I am looking for a way to take a standard mp3 file and take a part of it and make it a seperate mp3. Install NAudio from Nuget: PM> Install-Package NAudio Add using NAudio.Wave; and use this code: void Main() { var mp3Path = @"C:\Users\Ronnie\Desktop\podcasts\hanselminutes_0350.mp3"; var outputPath = Path.ChangeExtension(mp3Path,".trimmed.mp3"); TrimMp3(mp3Path, outputPath, TimeSpan.FromMinutes(2), TimeSpan.FromMinutes(2.5)); } void TrimMp3(string inputPath, string outputPath, TimeSpan? begin, TimeSpan? end) { if (begin.HasValue && end.HasValue &

change format from wav to mp3 in memory stream in NAudio

好久不见. 提交于 2019-11-30 11:28:19
问题 Hi there iam trying to convert text to speech (wav) in the memorystream convert it to mp3 and then play it on the users page.so need i help what to do next? here is my asmx code : [WebMethod] public byte[] StartSpeak(string Word) { MemoryStream ms = new MemoryStream(); using (System.Speech.Synthesis.SpeechSynthesizer synhesizer = new System.Speech.Synthesis.SpeechSynthesizer()) { synhesizer.SelectVoiceByHints(System.Speech.Synthesis.VoiceGender.NotSet, System.Speech.Synthesis.VoiceAge.NotSet,

NAudio error: “NoDriver calling acmFormatSuggest”

こ雲淡風輕ζ 提交于 2019-11-30 08:36:05
问题 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

Fading sound in/out

佐手、 提交于 2019-11-30 06:01:14
问题 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? 回答1: 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

Trimming mp3 files using NAudio

自古美人都是妖i 提交于 2019-11-29 19:59:31
问题 Is it possible to trim a MP3 file using NAudio? I am looking for a way to take a standard mp3 file and take a part of it and make it a seperate mp3. 回答1: Install NAudio from Nuget: PM> Install-Package NAudio Add using NAudio.Wave; and use this code: void Main() { var mp3Path = @"C:\Users\Ronnie\Desktop\podcasts\hanselminutes_0350.mp3"; var outputPath = Path.ChangeExtension(mp3Path,".trimmed.mp3"); TrimMp3(mp3Path, outputPath, TimeSpan.FromMinutes(2), TimeSpan.FromMinutes(2.5)); } void TrimMp3

NAudio Asio Record and Playback

谁都会走 提交于 2019-11-29 16:26:06
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>(asio_DataAvailable); asioout.InitRecordAndPlayback(wavprov, 2, 25); asioout.Play(); ... void asio

How to get Exact Time of a MIDI event

守給你的承諾、 提交于 2019-11-29 14:45:49
I'm trying to read a MIDI file and I want to determine the exact time of a NoteOn event from it in C#. I tried to use absolute time, but the output was something like 256632. What is this number ? This is the line of my code that returns the time : (note as NoteOnEvent).AbsoluteTime A MIDI file only contains incremental times. Included as a variable length value between 1 and 4 bytes before each MIDI event. The library you are using is being helpful in providing you with the AbsoluteTime property. Simply calculated by summing the incremental times for each event. The unit is "delta ticks". The