示例#1
0
        private void SetSingleMidiChordSlider(ChordSliderType chordSliderType, int channel, byte value)
        {
            MidiSliderTime midiSliderTime = null;

            switch (chordSliderType)
            {
            case ChordSliderType.Pitchwheel:
                midiSliderTime =
                    new MidiSliderTime(new PitchWheel(channel, value, ControlContinuation.NoChange), 0);
                break;

            case ChordSliderType.Pan:
                midiSliderTime =
                    new MidiSliderTime(new Pan(channel, value, ControlContinuation.NoChange), 0);
                break;

            case ChordSliderType.ModulationWheel:
                midiSliderTime =
                    new MidiSliderTime(new ModulationWheel(channel, value, ControlContinuation.NoChange), 0);
                break;

            case ChordSliderType.Expression:
                midiSliderTime =
                    new MidiSliderTime(new Expression(channel, value, ControlContinuation.NoChange), 0);
                break;

            default:
                break;
            }
            if (midiSliderTime != null)
            {
                MidiSliderTimes.Add(midiSliderTime);
            }
        }
示例#2
0
        public Tenuto(int channel, byte channelExpressionState, int noteDurationMilliseconds)
            : base()
        {
            int tenutoDuration = 0;

            if (noteDurationMilliseconds > 1000)
            {
                tenutoDuration = noteDurationMilliseconds - 200;
            }
            else
            {
                tenutoDuration = noteDurationMilliseconds * 8 / 10;
            }

            int crescDuration = tenutoDuration / 2;

            int  msPosition    = 0;
            byte expression    = channelExpressionState; // initial value for tenuto
            byte maxExpression = MidiByte((int)(expression * 1.3f));

            SetMidiChordSlider(ChordSliderType.Expression, channel, msPosition, crescDuration, expression, maxExpression);

            // fix expression for the rest of the tenuto
            MidiSliderTime eTe = new MidiSliderTime(
                new Expression(channel, maxExpression, ControlContinuation.NoChange), tenutoDuration - crescDuration);

            MidiSliderTimes.Add(eTe);

            // set expression to zero
            MidiSliderTime eTz = new MidiSliderTime(
                new Expression(channel, 0, ControlContinuation.NoChange), 0);

            MidiSliderTimes.Add(eTz);
        }
示例#3
0
        /// <summary>
        /// Creates MidiSliderTime objects and adds them to MidiSliderTimes list so as to create a slide from
        /// currentValue to endValue from msStartPosition up to (but not including) msEndPosition.
        /// </summary>
        protected void SetMidiChordSlider(ChordSliderType chordSliderType, int channel, int currentMsPosition, int endMsPosition,
                                          byte currentValue, byte endValue)
        {
            Debug.Assert(endMsPosition >= currentMsPosition);

            float slideValueDelta   = 0f;
            float slideDuration     = endMsPosition - currentMsPosition;
            float floatCurrentValue = (float)currentValue;
            float floatEndValue     = (float)endValue;

            if (slideDuration != 0)
            {
                slideValueDelta = (floatEndValue - floatCurrentValue) / (slideDuration / _defaultSleepTime);
            }

            do
            {
                int sleepTime = endMsPosition - currentMsPosition;
                sleepTime = (sleepTime > _defaultSleepTime) ? _defaultSleepTime : sleepTime;
                MidiSliderTime midiSliderTime = null;
                switch (chordSliderType)
                {
                case ChordSliderType.Pitchwheel:
                    midiSliderTime =
                        new MidiSliderTime(new PitchWheel(channel, (byte)floatCurrentValue, ControlContinuation.NoChange), sleepTime);
                    break;

                case ChordSliderType.Pan:
                    midiSliderTime =
                        new MidiSliderTime(new Pan(channel, (byte)floatCurrentValue, ControlContinuation.NoChange), sleepTime);
                    break;

                case ChordSliderType.ModulationWheel:
                    midiSliderTime =
                        new MidiSliderTime(new ModulationWheel(channel, (byte)floatCurrentValue, ControlContinuation.NoChange), sleepTime);
                    break;

                case ChordSliderType.Expression:
                    midiSliderTime =
                        new MidiSliderTime(new Expression(channel, (byte)floatCurrentValue, ControlContinuation.NoChange), sleepTime);
                    break;

                default:
                    break;
                }
                if (midiSliderTime == null)
                {
                    break;
                }
                MidiSliderTimes.Add(midiSliderTime);
                currentMsPosition += sleepTime;
                floatCurrentValue += slideValueDelta;
            } while(currentMsPosition < endMsPosition);
        }
示例#4
0
        public HardStaccato(int channel, byte channelExpressionState, int noteDurationMilliseconds)
            : base()
        {
            int hardStaccatoDuration = noteDurationMilliseconds / 2;

            hardStaccatoDuration = (hardStaccatoDuration > 900) ? 900 : hardStaccatoDuration;

            // set expression to 100 for hardStaccatoDuration
            MidiSliderTime eT = new MidiSliderTime(
                new Expression(channel, 127, ControlContinuation.NoChange), hardStaccatoDuration);

            MidiSliderTimes.Add(eT);

            // set expression to zero
            MidiSliderTime eTz = new MidiSliderTime(
                new Expression(channel, 0, ControlContinuation.NoChange), 0);

            MidiSliderTimes.Add(eTz);
        }
示例#5
0
        public StrongAccent(int channel, byte channelExpressionState, int noteDurationMilliseconds)
            : base()
        {
            int accentDuration = noteDurationMilliseconds / 3;

            accentDuration = (accentDuration > 900) ? 900 : accentDuration;

            int loudDuration = accentDuration / 2;

            // set expression to maximum for loudDuration
            byte           expression = 127; // initial value for accent
            MidiSliderTime eTz        = new MidiSliderTime(
                new Expression(channel, expression, ControlContinuation.NoChange), loudDuration);

            MidiSliderTimes.Add(eTz);

            int  msPosition  = loudDuration;
            int  dimEndTime  = msPosition * 2;
            byte sustainExpr = MidiByte((channelExpressionState + 127) / 2);

            SetMidiChordSlider(ChordSliderType.Expression, channel, msPosition, dimEndTime, expression, sustainExpr);
            SetMidiChordSlider(ChordSliderType.Expression, channel, dimEndTime, noteDurationMilliseconds, sustainExpr, channelExpressionState);
        }