/// <summary> /// Play a list of midi events with a thread so the call return immediately. /// @snippet TestMidiStream.cs Example MPTK_PlayNotes /// </summary> public void MPTK_PlayEvent(List <MPTKEvent> events) { try { if (MidiPlayerGlobal.MPTK_SoundFontLoaded) { if (!MPTK_CorePlayer) { Timing.RunCoroutine(TheadPlay(events)); } else { foreach (MPTKEvent evnt in events) { QueueSynthCommand.Enqueue(new SynthCommand() { Command = SynthCommand.enCmd.StartEvent, MidiEvent = evnt }); } } } } catch (System.Exception ex) { MidiPlayerGlobal.ErrorDetail(ex); } }
/// <summary> /// Stop playing the note. All waves associated to the note are stop by sending a noteoff. /// </summary> /// <param name="pnote"></param> public void MPTK_StopEvent(MPTKEvent pnote) { if (!MPTK_CorePlayer) { StopEvent(pnote); } else { QueueSynthCommand.Enqueue(new SynthCommand() { Command = SynthCommand.enCmd.StopEvent, MidiEvent = pnote }); } //try //{ // if (pnote != null && pnote.Voices != null) // { // foreach (fluid_voice voice in pnote.Voices) // if (voice.volenv_section != fluid_voice_envelope_index.FLUID_VOICE_ENVRELEASE && // voice.status != fluid_voice_status.FLUID_VOICE_OFF) // voice.fluid_voice_noteoff(); // } //} //catch (System.Exception ex) //{ // MidiPlayerGlobal.ErrorDetail(ex); //} }
/// <summary> /// Play one midi event with a thread so the call return immediately. ///! @snippet MusicView.cs Example PlayNote /// </summary> public void MPTK_PlayEvent(MPTKEvent evnt) { try { if (MidiPlayerGlobal.MPTK_SoundFontLoaded) { if (!MPTK_CorePlayer) { Timing.RunCoroutine(TheadPlay(evnt)); } else { QueueSynthCommand.Enqueue(new SynthCommand() { Command = SynthCommand.enCmd.StartEvent, MidiEvent = evnt }); } } else { Debug.LogWarningFormat("SoundFont not yet loaded, Midi Event cannot be processed Code:{0} Channel:{1}", evnt.Command, evnt.Channel); } } catch (System.Exception ex) { MidiPlayerGlobal.ErrorDetail(ex); } }
/// <summary> /// Play a list of midi events with a thread so the call return immediately. /// @snippet TestMidiStream.cs Example MPTK_PlayEvent /// </summary> public void MPTK_PlayEvent(List <MPTKEvent> events) { try { if (MidiPlayerGlobal.MPTK_SoundFontLoaded) { if (!MPTK_CorePlayer) { Timing.RunCoroutine(TheadPlay(events)); } else { lock (this) //V2.83 { foreach (MPTKEvent evnt in events) { QueueSynthCommand.Enqueue(new SynthCommand() { Command = SynthCommand.enCmd.StartEvent, MidiEvent = evnt }); } } } } else { Debug.LogWarningFormat("SoundFont not yet loaded, Midi Events cannot be processed"); } } catch (System.Exception ex) { MidiPlayerGlobal.ErrorDetail(ex); } }