示例#1
0
        public bool Apply(MidiEvent inEvent, EventRuleArgs args)
        {
            bool match = false;

            if ((inEvent.CommandCode == MidiCommandCode.ChannelAfterTouch) &&
                (type == AfterTouchType.Channel))
            {
                if (inChannels.IsValueIncluded(inEvent.Channel))
                {
                    ChannelAfterTouchEvent afterTouchEvent = (ChannelAfterTouchEvent)inEvent;
                    afterTouchEvent.Channel            = outChannel.ProcessValue(inEvent.Channel);
                    afterTouchEvent.AfterTouchPressure = outValue.ProcessValue(afterTouchEvent.AfterTouchPressure);
                    match = true;
                }
            }
            else if ((inEvent.CommandCode == MidiCommandCode.KeyAfterTouch) && (type == AfterTouchType.Key))
            {
                if (inChannels.IsValueIncluded(inEvent.Channel))
                {
                    NoteEvent afterTouchEvent = (NoteEvent)inEvent;
                    afterTouchEvent.Channel  = outChannel.ProcessValue(inEvent.Channel);
                    afterTouchEvent.Velocity = outValue.ProcessValue(afterTouchEvent.Velocity);
                    match = true;
                }
            }

            return(match);
        }
示例#2
0
        public bool Apply(MidiEvent inEvent, EventRuleArgs args)
        {
            bool match = false;

            if (inEvent.CommandCode == MidiCommandCode.PitchWheelChange)
            {
                PitchWheelChangeEvent pitchWheelEvent = (PitchWheelChangeEvent)inEvent;
                if (inChannels.IsValueIncluded(pitchWheelEvent.Channel))
                {
                    pitchWheelEvent.Pitch   = outValue.ProcessValue(pitchWheelEvent.Pitch);
                    pitchWheelEvent.Channel = outChannel.ProcessValue(pitchWheelEvent.Channel);
                    match = true;
                }
            }
            return(match);
        }
示例#3
0
        public bool Apply(MidiEvent inEvent, EventRuleArgs args)
        {
            bool match = false;

            if (inEvent.CommandCode == MidiCommandCode.ControlChange)
            {
                ControlChangeEvent controlEvent = (ControlChangeEvent)inEvent;
                if (inControllers.IsValueIncluded((int)controlEvent.Controller) &&
                    inChannels.IsValueIncluded(controlEvent.Channel) &&
                    inValues.IsValueIncluded(controlEvent.ControllerValue))
                {
                    controlEvent.ControllerValue = outValue.ProcessValue(controlEvent.ControllerValue);
                    controlEvent.Controller      = (MidiController)outController.ProcessValue((int)controlEvent.Controller);
                    controlEvent.Channel         = outChannel.ProcessValue(controlEvent.Channel);
                    match = true;
                }
            }
            return(match);
        }
示例#4
0
        public bool Apply(MidiEvent inEvent, EventRuleArgs args)
        {
            bool        match       = false;
            NoteOnEvent noteOnEvent = inEvent as NoteOnEvent;

            if (noteOnEvent != null && noteOnEvent.Velocity > 0)
            {
                if (inChannels.IsValueIncluded(inEvent.Channel) &&
                    inNotes.IsValueIncluded(noteOnEvent.NoteNumber) &&
                    inVelocity.IsValueIncluded(noteOnEvent.Velocity)
                    )
                {
                    noteOnEvent.Channel    = outChannel.ProcessValue(noteOnEvent.Channel);
                    noteOnEvent.Velocity   = outVelocity.ProcessValue(noteOnEvent.Velocity);
                    noteOnEvent.NoteNumber = outNote.ProcessValue(noteOnEvent.NoteNumber);
                    //noteOnEvent.AbsoluteTime = outStartTime.ProcessValue(noteOnEvent.AbsoluteTime);
                    noteOnEvent.NoteLength = outDuration.ProcessValue(noteOnEvent.NoteLength);
                    match = true;
                }
            }

            return(match);
        }
示例#5
0
        public bool Apply(MidiEvent inEvent, EventRuleArgs args)
        {
            bool      exclude   = false;
            MetaEvent metaEvent = inEvent as MetaEvent;

            switch (eventType)
            {
            case ExcludeEventType.Controller:
                exclude = inEvent.CommandCode == MidiCommandCode.ControlChange;
                break;

            case ExcludeEventType.PitchWheel:
                exclude = inEvent.CommandCode == MidiCommandCode.PitchWheelChange;
                break;

            case ExcludeEventType.PatchChange:
                exclude = inEvent.CommandCode == MidiCommandCode.PatchChange;
                break;

            case ExcludeEventType.ChannelAfterTouch:
                exclude = inEvent.CommandCode == MidiCommandCode.ChannelAfterTouch;
                break;

            case ExcludeEventType.KeyAfterTouch:
                exclude = inEvent.CommandCode == MidiCommandCode.KeyAfterTouch;
                break;

            case ExcludeEventType.Sysex:
                exclude = inEvent.CommandCode == MidiCommandCode.Sysex;
                break;

            case ExcludeEventType.ContinueSequence:
                exclude = inEvent.CommandCode == MidiCommandCode.ContinueSequence;
                break;

            case ExcludeEventType.StopSequence:
                exclude = inEvent.CommandCode == MidiCommandCode.StopSequence;
                break;

            case ExcludeEventType.StartSequence:
                exclude = inEvent.CommandCode == MidiCommandCode.StartSequence;
                break;

            case ExcludeEventType.TimingClock:
                exclude = inEvent.CommandCode == MidiCommandCode.TimingClock;
                break;

            case ExcludeEventType.Copyright:
                exclude = (metaEvent != null) && (metaEvent.MetaEventType == MetaEventType.Copyright);
                break;

            case ExcludeEventType.Text:
                exclude = (metaEvent != null) && (metaEvent.MetaEventType == MetaEventType.TextEvent);
                break;

            case ExcludeEventType.Marker:
                exclude = (metaEvent != null) && (metaEvent.MetaEventType == MetaEventType.Marker);
                break;

            case ExcludeEventType.SequencerSpecific:
                exclude = (metaEvent != null) && (metaEvent.MetaEventType == MetaEventType.SequencerSpecific);
                break;

            case ExcludeEventType.SmpteOffset:
                exclude = (metaEvent != null) && (metaEvent.MetaEventType == MetaEventType.SmpteOffset);
                break;

            case ExcludeEventType.CuePoint:
                exclude = (metaEvent != null) && (metaEvent.MetaEventType == MetaEventType.CuePoint);
                break;

            case ExcludeEventType.Lyric:
                exclude = (metaEvent != null) && (metaEvent.MetaEventType == MetaEventType.Lyric);
                break;

            case ExcludeEventType.DeviceName:
                exclude = (metaEvent != null) && (metaEvent.MetaEventType == MetaEventType.DeviceName);
                break;

            case ExcludeEventType.ProgramName:
                exclude = (metaEvent != null) && (metaEvent.MetaEventType == MetaEventType.ProgramName);
                break;

            case ExcludeEventType.TrackInstrumentName:
                exclude = (metaEvent != null) && (metaEvent.MetaEventType == MetaEventType.TrackInstrumentName);
                break;

            case ExcludeEventType.TrackName:
                exclude = (metaEvent != null) && (metaEvent.MetaEventType == MetaEventType.SequenceTrackName);
                break;

            case ExcludeEventType.TrackSequenceNumber:
                exclude = (metaEvent != null) && (metaEvent.MetaEventType == MetaEventType.TrackSequenceNumber);
                break;

            case ExcludeEventType.KeySignature:
                // undocumented feature - key signature can be removed (not recommended)
                exclude = (metaEvent != null) && (metaEvent.MetaEventType == MetaEventType.KeySignature);
                break;

            case ExcludeEventType.NonStandard:
                if (metaEvent != null)
                {
                    exclude = !Enum.IsDefined(typeof(MetaEventType), metaEvent.MetaEventType);
                }
                else
                {
                    exclude = !Enum.IsDefined(typeof(MidiCommandCode), inEvent.CommandCode);
                }
                break;

            case ExcludeEventType.All:
                // End track and notes already excluded
                if (metaEvent != null)
                {
                    if ((metaEvent.MetaEventType != MetaEventType.SetTempo) &&
                        (metaEvent.MetaEventType != MetaEventType.KeySignature) &&
                        (metaEvent.MetaEventType != MetaEventType.TimeSignature))
                    {
                    }
                    else
                    {
                        exclude = true;
                    }
                }
                else
                {
                    exclude = true;
                }
                // TODO: support exclude all
                break;
            }
            if (exclude && metaEvent == null)
            {
                exclude = inChannels.IsValueIncluded(inEvent.Channel);
            }
            return(exclude);
        }