Exemplo n.º 1
0
        private void DispatchIMuseEvent(SystemExclusiveEvent e)
        {
            switch ((IMuseSysExType)e.Data[1])
            {
            case (IMuseSysExType.HookJump):
                var jump    = new Hooks.Jump(e);
                var enabled = HookJumpsEnabled.TryGetValue(jump.Id, out var persists);

                if (enabled)
                {
                    jump.Execute(this);
                }
                else
                {
                    break;
                }

                if (!persists)
                {
                    HookJumpsEnabled.Remove(jump.Id);
                }

                break;

            case IMuseSysExType.SetInstrument:
                // I think these would normally be translated into bank select commands depending on if the underlying synthesizer supports them.
                var channel = e.Data[2];
                var program = Util.ReadPackedByteBe(e.Data, 3);
                var bank    = channel == MidiHelper.DrumChannel ? (byte)PatchBank.DrumBank : Util.ReadPackedByteBe(e.Data, 5);
                if (Synthesizer.SoundBank.IsBankLoaded(bank) && !(Synthesizer.SoundBank.GetBank(bank)[program] is null))
                {
                    Synthesizer.synthChannels[channel].bankSelect = bank;
                    Synthesizer.synthChannels[channel].program    = program;
                }
                break;

            case IMuseSysExType.Marker:
                if (OnMarkerSequenced is null)
                {
                    goto default;
                }
                OnMarkerSequenced.Invoke(Util.ReadPackedByteBe(e.Data, 2));
                break;

            default:
                Debug.Log(String.Format("Unhandled iMUSE SysEx {0} at Track:{1} Event:{2}", ((IMuseSysExType)e.Data[1]).ToString(), HeadEventStream.PlayingTrack, HeadEventStream.PlayingEvent));
                break;
            }
        }
Exemplo n.º 2
0
 void Reset()
 {
     HeadEventStream = new EventStream(midiFile);
     HookJumpsEnabled.Clear();
     HookJumpsEnabled.Add(0, true);  // jump ID 0 is almost always needed.
 }