MIDI の演奏に関わるイベントを提供します。
Inheritance: Event
Esempio n. 1
0
        private void ProcessDrumEvent(MidiEvent @event)
        {
            switch (@event.Type)
            {
                case EventType.NoteOn:

                    int target = @event.Data1 % 8;

                    if (target == 0)
                        target = 10;
                    else
                        target += 16;

                    var preset = this.drumset.Find(p => p.Number == @event.Data1);

                    if (preset != null)
                    {
                        this.uxMaster.PushHandle(preset.InitHandles, target);
                        this.uxMaster.PushHandle(new Handle(target, HandleType.NoteOn, preset.Note, @event.Data2));
                    }
                    break;

                case EventType.ControlChange:
                    switch (@event.Data1)
                    {
                        case 0:
                            this.partMsb[@event.Channel] = @event.Data2;
                            break;

                        case 1:
                            if (@event.Data2 > 0)
                            {
                                this.uxMaster.PushHandle(this.drumTargets.Select(i => new Handle(i, HandleType.Vibrate, (int)VibrateOperate.On)));
                                this.uxMaster.PushHandle(this.drumTargets.Select(i => new Handle(i, HandleType.Vibrate, (int)VibrateOperate.Depth, @event.Data2 * 0.125f)));
                            }
                            else
                                this.uxMaster.PushHandle(this.drumTargets.Select(i => new Handle(i, HandleType.Vibrate, (int)VibrateOperate.Off)));
                            break;

                        case 7:
                            this.uxMaster.PushHandle(this.drumTargets.Select(i => new Handle(i, HandleType.Volume, @event.Data2 / 127f)));
                            break;

                        case 10:
                            this.uxMaster.PushHandle(this.drumTargets.Select(i => new Handle(i, HandleType.Panpot, @event.Data2 / 64f - 1f)));
                            break;

                        case 11:
                            this.uxMaster.PushHandle(this.drumTargets.Select(i => new Handle(i, HandleType.Volume, (int)VolumeOperate.Expression, @event.Data2 / 127f)));
                            break;

                        case 32:
                            this.partLsb[@event.Channel] = @event.Data2;
                            break;

                        case 120:
                            this.uxMaster.PushHandle(Enumerable.Range(1, 23).Select(i => new Handle(i, HandleType.Silence)));
                            break;

                        case 121:
                            this.Reset();
                            break;

                        case 123:
                            this.uxMaster.PushHandle(Enumerable.Range(1, 23).Select(i => new Handle(i, HandleType.NoteOff)));
                            break;

                        default:
                            break;
                    }

                    break;

                case EventType.Pitchbend:
                    this.uxMaster.PushHandle(this.drumTargets.Select(i => new Handle(i, HandleType.FineTune, ((((@event.Data2 << 7) | @event.Data1) - 8192) / 8192f) * 1.12246f / 8f + 1f)));
                    break;

                default:
                    break;
            }
        }
Esempio n. 2
0
        private void ChangeProgram(MidiEvent @event)
        {
            int channel = @event.Channel;
            int part = channel + 1;

            if (part == 10)
                return;

            if (this.nowPresets[channel] != null)
                this.uxMaster.PushHandle(this.nowPresets[channel].FinalHandles, part);

            ProgramPreset preset = this.presets.Find(p => p.Number == @event.Data1 && p.MSB == this.partMsb[channel] && p.LSB == this.partLsb[channel]) ??
                                   this.presets.Find(p => p.Number == @event.Data1);

            if (preset != null)
            {
                this.uxMaster.PushHandle(preset.InitHandles, part);
                Console.WriteLine("Matching Program: {0}", @event.Data1);
            }
            else
            {
                this.uxMaster.PushHandle(new Handle(part, HandleType.Waveform, (int)WaveformType.FM));
                Console.WriteLine("Matching no Program: {0}", @event.Data1);
            }

            this.nowPresets[channel] = preset;
        }