Esempio n. 1
0
 public void Stop(bool immediate)
 {
     playing    = false;
     sampleTime = 0;
     if (immediate)
     {
         synth.NoteOffAll(true);
     }
     else
     {
         synth.NoteOffAll(false);
     }
 }
        IEnumerator PlayMidi(string midiPath)
        {
            isPlaying = true;
            _midi     = new MidiFile(midiPath);
            midiSequencer.LoadMidi(_midi, false, 0);

            var t          = 0f;
            var eventIndex = 0;

            while (isPlaying)
            {
                var st = midiStreamSynthesizer.SampleRate * t;
                while (eventIndex < _midi.Tracks[0].EventCount && _midi.Tracks[0].MidiEvents[eventIndex].deltaTime < (st))
                {
                    midiSequencer.ProcessMidiEvent(_midi.Tracks[0].MidiEvents[eventIndex]);
                    eventIndex++;
                }

                yield return(null);

                t += Time.deltaTime;

                _metronome.SetElapsedTime(t);
            }
            midiStreamSynthesizer.NoteOffAll(true);
        }
Esempio n. 3
0
 public void StopAllMidiNotes(bool immediate = true)
 {
     InitIfNotDoneYet();
     midiStreamSynthesizer.NoteOffAll(immediate);
 }
Esempio n. 4
0
 public void stop()
 {
     midiStreamSynthesizer.NoteOffAll(true);
 }