コード例 #1
0
        private void CopyControl(MidiControl src, MidiControl dst, bool updateGuid)
        {
            // Copy MidiControl members.
            // Is there any smarter way to do this?
            dst.enabled      = src.enabled;
            dst.mode         = src.mode;
            dst.noteFilter   = src.noteFilter;
            dst.envelope     = src.envelope;
            dst.curve        = new AnimationCurve(src.curve.keys);
            dst.propertyName = src.propertyName;
            dst.fieldName    = src.fieldName;
            dst.ccController = src.ccController;
            dst.vector0      = src.vector0;
            dst.vector1      = src.vector1;

            if (updateGuid)
            {
                // Copy targetComponent as a new reference.
                var guid = GUID.Generate().ToString();
                dst.targetComponent.exposedName = guid;
                var resolver = serializedObject.context as IExposedPropertyTable;
                resolver?.SetReferenceValue(guid, src.targetComponent.Resolve(resolver));
            }
            else
            // Simply copy targetComponent.
            {
                dst.targetComponent = src.targetComponent;
            }
        }
コード例 #2
0
ファイル: ShortMsg.cs プロジェクト: yugsh/PianoGame
 /// <summary>
 /// Decodes a MidiControl Change short message.
 /// </summary>
 /// <param name="dwParam1">The dwParam1 arg passed to MidiInProc.</param>
 /// <param name="dwParam2">The dwParam2 arg passed to MidiInProc.</param>
 /// <param name="channel">Filled in with the channel.</param>
 /// <param name="control">Filled in with the control.</param>
 /// <param name="value">Filled in with the value, 0-127.</param>
 /// <param name="timestamp">Filled in with the timestamp in microseconds since
 /// midiInStart().</param>
 public static void DecodeControlChange(UIntPtr dwParam1, UIntPtr dwParam2,
     out Channel channel, out MidiControl control, out int value, out UInt32 timestamp)
 {
     if (!IsControlChange(dwParam1, dwParam2))
     {
         throw new ArgumentException("Not a control message.");
     }
     channel = (Channel)((int)dwParam1 & 0x0f);
     control = (MidiControl)(((int)dwParam1 & 0xff00) >> 8);
     value = (((int)dwParam1 & 0xff0000) >> 16);
     timestamp = (UInt32)dwParam2;
 }
コード例 #3
0
ファイル: Mate.cs プロジェクト: mabe-at/PowerMateMIDI
        public Mate(HidDevice d, MidiDevice md, MidiControl mc, MidiChannel mchan)
        {
            mateManager = new MateManager();
            mateManager.OpenDevice(d);
            mateManager.ButtonDown += new EventHandler<PowerMateEventArgs>(ButtonDown);
            mateManager.ButtonUp += new EventHandler<PowerMateEventArgs>(ButtonUp);

            Dark();
            counter++;
            id = counter;
            Name = "Powermate " + id;
            SelectedDevice = md;
            SelectedControl = mc;
            SelectedChannel = mchan;
        }
コード例 #4
0
        public float GetValue(Playable playable, MidiControl control)
        {
            if (events == null)
            {
                return(0);
            }
            var t = (float)playable.GetTime() % DurationInSecond;

            if (control.mode == MidiControl.Mode.NoteEnvelope)
            {
                return(GetNoteEnvelopeValue(control, t));
            }
            else if (control.mode == MidiControl.Mode.NoteCurve)
            {
                return(GetNoteCurveValue(control, t));
            }
            else // CC
            {
                return(GetCCValue(control, t));
            }
        }
コード例 #5
0
ファイル: Messages.cs プロジェクト: yugsh/PianoGame
 /// <summary>
 /// Construts a MidiControl Change message.
 /// </summary>
 /// <param name="device">The device associated with this message.</param>
 /// <param name="channel">Channel, 0..15, 10 reserved for percussion.</param>
 /// <param name="control">MidiControl, 0..119</param>
 /// <param name="value">Value, 0..127.</param>
 /// <param name="time">The timestamp for this message.</param>
 public ControlChangeMessage(DeviceBase device, Channel channel, MidiControl control, int value,
     float time)
     : base(device, channel, time)
 {
     control.Validate();
     if (value < 0 || value > 127)
     {
         throw new ArgumentOutOfRangeException("control");
     }
     this.control = control;
     this.value = value;
 }
コード例 #6
0
ファイル: ShortMsg.cs プロジェクト: yugsh/PianoGame
 /// <summary>
 /// Encodes a MidiControl Change short message.
 /// </summary>
 /// <param name="channel">The channel.</param>
 /// <param name="control">The control.</param>
 /// <param name="value">The new value 0..127.</param>
 /// <returns>A value that can be passed to midiOutShortMsg.</returns>
 public static UInt32 EncodeControlChange(Channel channel, MidiControl control, int value)
 {
     channel.Validate();
     control.Validate();
     if (value < 0 || value > 127)
     {
         throw new ArgumentOutOfRangeException("Value is out of range.");
     }
     return (UInt32)(0xB0 | (int)(channel) | ((int)control << 8) | (value << 16));
 }
コード例 #7
0
ファイル: OutputDevice.cs プロジェクト: yugsh/PianoGame
 /// <summary>
 /// Sends a MidiControl Change message to this MIDI output device.
 /// </summary>
 /// <param name="channel">The channel.</param>
 /// <param name="control">The control.</param>
 /// <param name="value">The new value 0..127.</param>
 /// <exception cref="ArgumentOutOfRangeException">channel, control, or value is
 /// out-of-range.</exception>
 /// <exception cref="InvalidOperationException">The device is not open.</exception>
 /// <exception cref="DeviceException">The message cannot be sent.</exception>
 public void SendControlChange(Channel channel, MidiControl control, int value)
 {
     lock (this)
     {
         CheckOpen();
         CheckReturnCode(Win32API.midiOutShortMsg(handle, ShortMsg.EncodeControlChange(
             channel, control, value)));
     }
 }