private void Play() { startTimeOffset = AudioSettings.dspTime * 1000; for (int i = 0; i < midiFile.getNumTracks(); i++) { MidiPlayer.PlayTrack(midiFile.getMidiTrack(i), this); } MidiPlayer.reorderQueue(); }
void Awake() { if (!Application.isPlaying) { return; } MidiPlayer.deviceNum = midiOutputDevice; MidiPlayer.Start(); Metronome.setBPM(bpm); previousBpm = bpm; }
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"); } }
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"); }
void Update() { if (!Application.isPlaying) { return; } MidiPlayer.Update(); if (bpm != previousBpm) { Metronome.setBPM(bpm); previousBpm = bpm; } }
private void OnApplicationQuit() { MidiPlayer.Shutdown(); }
private void Start() { MidiPlayer.resetMidiEventClock(); }