private void Play()
 {
     startTimeOffset = AudioSettings.dspTime * 1000;
     for (int i = 0; i < midiFile.getNumTracks(); i++)
     {
         MidiPlayer.PlayTrack(midiFile.getMidiTrack(i), this);
     }
     MidiPlayer.reorderQueue();
 }
Example #2
0
 void Awake()
 {
     if (!Application.isPlaying)
     {
         return;
     }
     MidiPlayer.deviceNum = midiOutputDevice;
     MidiPlayer.Start();
     Metronome.setBPM(bpm);
     previousBpm = bpm;
 }
Example #3
0
        private void Update()
        {
            if (AudioSettings.dspTime > (startTime + nextScheduledTimeMs + (timeOffsetMs - Time.deltaTime * 2)))
            {
                nextScheduledTimeMs += timeOffsetMs;
                MidiPlayer.PlayScheduled(noteOn, startTime + nextScheduledTimeMs);
                MidiPlayer.PlayScheduled(noteOff, startTime + nextScheduledTimeMs + 0.1);

                Debug.Log("Delay until event: " + (int)(((startTime + nextScheduledTimeMs) - AudioSettings.dspTime) * 1000.0) + " ms");
            }
        }
Example #4
0
        private void Start()
        {
            startTime = AudioSettings.dspTime;
            noteOn    = new MidiMessage(0x90, 60, 127);
            noteOff   = new MidiMessage(0x80, 60, 0);
            noteOn.setChannel(1);
            noteOff.setChannel(1);
            MidiPlayer.PlayScheduled(noteOn, startTime);
            MidiPlayer.PlayScheduled(noteOff, startTime + 0.1);

            Debug.Log("Delay until event: " + (int)(((startTime + nextScheduledTimeMs) - AudioSettings.dspTime) * 1000.0) + " ms");
        }
Example #5
0
        void Update()
        {
            if (!Application.isPlaying)
            {
                return;
            }
            MidiPlayer.Update();

            if (bpm != previousBpm)
            {
                Metronome.setBPM(bpm);
                previousBpm = bpm;
            }
        }
Example #6
0
 private void OnApplicationQuit()
 {
     MidiPlayer.Shutdown();
 }
Example #7
0
 private void Start()
 {
     MidiPlayer.resetMidiEventClock();
 }