Beispiel #1
0
        public static void SetMusic(string musicFile)
        {
            if (!File.Exists(musicFile))
            {
                Console.WriteLine("file not found: " + musicFile);
                return;
            }
            if (music != null)
            {
                mixer.RemoveInputStream(music);
                music.Dispose();
            }
            var audioFileReader = new AudioFileReader(musicFile);

            if (audioFileReader.WaveFormat.SampleRate != mixer.WaveFormat.SampleRate)
            {
                audioFileReader.Dispose();
                musicCompatible = false;
                return;
            }
            musicCompatible = true;
            music           = new WaveChannel32(audioFileReader)
            {
                Volume = 0.2f
            };
            mixer.AddInputStream(music);
            sw.Restart();
            //music.CurrentTime = new TimeSpan(0, 0, 30);
        }
Beispiel #2
0
 public void StopPlaying()
 {
     if (last != null)
     {
         mixer?.RemoveInputStream(last);
         last = null;
     }
 }
        public static void StopNote(Note note)
        {
            var result = WaveList.Where(x => x.Frequency == (float)note.GetFrequencyInHz()); //Pakt de SineWaveProvider uit de lijst.

            foreach (SineWaveProvider32 i in result)
            {
                mixingWaveProvider.RemoveInputStream(i); //Verwijdert de SineWave uit de mixer.
            }
            WaveList.Remove(result.FirstOrDefault());    //Verwijdert de resultaten van de bovenstaand query.
        }
Beispiel #4
0
 /// <summary>
 /// Stops playing currently played chord.
 /// </summary>
 public void StopChord()
 {
     if (lastChord != null)
     {
         foreach (Pitch pitch in lastChord.Tones)
         {
             harmonyProvider.RemoveInputStream(PitchSelector.GetWavePlayer(pitch, session.WaveForm).Channel);
         }
     }
     lastChord = null;
 }
Beispiel #5
0
 private Task CleanupAsync()
 {
     model.Connection.VoiceReceived -= Connection_VoiceReceived;
     output.Stop();
     foreach (var input in waveProviders.Values)
     {
         mixer.RemoveInputStream(input);
     }
     recorder.Dispose();
     output.Dispose();
     return(Task.CompletedTask);
 }
        public void FadeInOut(WavePlayer fadein, WavePlayer fadeout, int milliSeconds)
        {
            var fadeInProvider  = fadein._reader.ToSampleProvider();
            var fadeOutProvider = fadeout._reader.ToSampleProvider();

            _mixer.RemoveInputStream(fadeout._channels);
            _mixer.RemoveInputStream(fadein._channels);

            var fadeOutObject = new FadeInOutSampleProvider(fadeOutProvider);
            var fadeInObject  = new FadeInOutSampleProvider(fadeInProvider);

            var waveStream  = new WaveProviderToWaveStream(fadeOutObject.ToWaveProvider());
            var waveStream2 = new WaveProviderToWaveStream(fadeInObject.ToWaveProvider());

            fadeout._channels = new WaveChannel32(waveStream);
            fadein._channels  = new WaveChannel32(waveStream2);

            _mixer.AddInputStream(fadeout._channels);
            _mixer.AddInputStream(fadein._channels);

            fadeOutObject.BeginFadeOut(milliSeconds);
            fadeInObject.BeginFadeIn(milliSeconds);
        }
Beispiel #7
0
 public static void RemoveWaveProvider(IWaveProvider waveprovider)
 {
     mixer.RemoveInputStream(waveprovider);
 }