Example #1
0
        ///////////////////////////////////////////////////////////////////////////////////////////////
        // static Constructor

        static Synth()
        {
            onPlaybacking += (void_ptr data, fluid_midi_event_t evt) => {
                Enumerable.Range(0, 16).ToList().ForEach(x => {
                    var _data = EventQueue.Dequeue(x);
                    if (!(_data is null))
                    {
                        fluid_synth_program_change(synth, x, _data.Prog);
                        fluid_synth_cc(synth, x, (int)ControlChange.Pan, _data.Pan);
                        fluid_synth_cc(synth, x, (int)ControlChange.Volume, _data.Vol);
                    }
                });
                var _type    = fluid_midi_event_get_type(evt);
                var _channel = fluid_midi_event_get_channel(evt);
                var _control = fluid_midi_event_get_control(evt);
                var _value   = fluid_midi_event_get_value(evt);
                var _program = fluid_midi_event_get_program(evt);
                if (_type != 128 && _type != 144)   // not note on or note off
                {
                    Log.Info($"_type: {_type} _channel: {_channel} _control: {_control} _value: {_value} _program: {_program}");
                }
                Task.Run(() => {
                    if (_type == 144)   // NOTE_ON = 144
                    {
                        Multi.ApplyNoteOn(_channel);
                    }
                    else if (_type == 128)     // NOTE_OFF = 128
                    {
                        Multi.ApplyNoteOff(_channel);
                    }
                    else if (_type == 192)     // PROGRAM_CHANGE = 192
                    {
                        Multi.ApplyProgramChange(_channel, _program);
                    }
                    else if (_type == 176)     // CONTROL_CHANGE = 176
                    {
                        Multi.ApplyControlChange(_channel, _control, _value);
                    }
                });
                return(fluid_synth_handle_midi_event(data, evt));
            };
        }