void OnControlChange(MidiJack.MidiChannel channel, int knobNumber, float knobValue)
    {
        // MasterGain
        if (knobNumber == 7)
        {
            _front.SetMasterGain(knobValue);
            _rear.SetMasterGain(knobValue);
            return;
        }

        int i = knobNumber + 1;

        if (knobNumber == 6)
        {
            i = 0;
        }                               // Use last fader for video input
        if (_value.Length <= i)
        {
            return;
        }

        _value[i] = knobValue;

        if ((_sceneState[i] & 1) == 1)
        {
            _front.SetChannelGain(i, knobValue);
        }
        if ((_sceneState[i] & 2) == 2)
        {
            _rear.SetChannelGain(i, knobValue);
        }
    }
Beispiel #2
0
 //Animates a key as pushed, changing its color
 public void animateNoteOn(MidiJack.MidiChannel channel, int note, float velocity)
 {
     //Backup material to restore on noteOff
     Piano._instance.playKey(note, velocity);
     // plainKeyMaterial[note] = Piano._instance.getPianoKey(note).associated3DObject.GetComponent<Renderer>().material;
     //Change material to defined one
     // Piano._instance.getPianoKey(note).associated3DObject.GetComponent<Renderer>().material = pushedKeyMaterial;
 }
Beispiel #3
0
 void OnMidiNoteOn(MidiJack.MidiChannel channel, int note, float velocity)
 {
     if (note >= 48 && note <= 63)
     {
         int clipPadIndex = note - 48;
         _ClipPads[clipPadIndex].OnPadTrigger();
     }
 }
Beispiel #4
0
    void OnNoteOn(MidiJack.MidiChannel channel, int note, float velocity)
    {
        int     index         = note - keyNote;
        int     numOctavs     = index / 12;
        int     particleIndex = 7 * numOctavs + inverseMajorScale[(index + 60) % inverseMajorScale.Length];
        Vector3 direction     = new Vector3(Random.Range(-1.0f, 1.0f), Random.Range(-1.0f, 1.0f), Random.Range(-1.0f, 1.0f));
        float   strength      = velocity < 0.95f ? Mathf.Min(Mathf.Max(2 * velocity, 0.5f), 1.5f) : Mathf.Pow(2 * velocity, 2.0f);

        Ruratae.ImpulseParticle(movables[particleIndex % movables.Count], 0.05f * direction * strength);//2 * Vector3.one * Mathf.Pow(velocity, 2.0f));
    }
 private async void CheckKnobUpdated(MidiJack.MidiChannel channel, int knobNo, float value)
 {
     if (doKeySend == false)
     {
         return;
     }
     if (lastKnobUpdatedSendTime[knobNo] + 3f < Time.realtimeSinceStartup)
     {
         lastKnobUpdatedSendTime[knobNo] = Time.realtimeSinceStartup;
         await controlWPFWindow.server?.SendCommandAsync(new PipeCommands.MidiCCKnobUpdate {
             channel = (int)channel, knobNo = knobNo, value = value
         });
     }
 }
    void OnControlChange(MidiJack.MidiChannel channel, int knobNumber, float knobValue)
    {
        if (16 <= knobNumber && knobNumber <= 22)
        {
            _knobs[knobNumber - 16] = knobValue;
            _material.SetFloatArray("_Knob", _knobs);
        }

        // Use last knob for volume ratio
        if (knobNumber == 23)
        {
            _volumeRatio = knobValue * 3;
        }
    }
Beispiel #7
0
    public void KnobUpdated(MidiJack.MidiChannel channel, int knobNo, float value)
    {
        if (knobDelegateProxy != null)
        {
            knobDelegateProxy.Invoke(channel, knobNo, value);
        }

        //範囲内かチェック
        if (0 <= knobNo && knobNo < KNOBS)
        {
            //値を記録する
            CCValue[knobNo]     = value;
            CCUpdateBit[knobNo] = true;
            CCAnyUpdate         = true;
        }
    }
 void OnControlChange(MidiJack.MidiChannel channel, int knobNumber, float knobValue)
 {
     Debug.Log(">> CC: " + channel.ToString() + ": " + knobNumber + ": " + knobValue);
 }
 void OnNoteOff(MidiJack.MidiChannel channel, int noteNumber, float velocity)
 {
     Debug.Log(">> Note Off: " + channel.ToString() + ": " + noteNumber);
 }
Beispiel #10
0
 //Key goes back to the original status
 public void animateNoteOff(MidiJack.MidiChannel channel, int note)
 {
     Piano._instance.shutKey(note);
     // Piano._instance.getPianoKey(note).associated3DObject.GetComponent<Renderer>().material = plainKeyMaterial[note];
 }
        private void Start()
        {
            context = System.Threading.SynchronizationContext.Current;

            controlWPFWindow.server.ReceivedEvent += Server_Received;

            steamVR2Input.KeyDownEvent     += ControllerAction_KeyDown;
            steamVR2Input.KeyUpEvent       += ControllerAction_KeyUp;
            steamVR2Input.AxisChangedEvent += ControllerAction_AxisChanged;

            KeyboardAction.KeyDownEvent += KeyboardAction_KeyDown;
            KeyboardAction.KeyUpEvent   += KeyboardAction_KeyUp;


            midiCCWrapper.noteOnDelegateProxy += async(channel, note, velocity) =>
            {
                Debug.Log("MidiNoteOn:" + channel + "/" + note + "/" + velocity);

                var config = new KeyConfig();
                config.type       = KeyTypes.Midi;
                config.actionType = KeyActionTypes.Face;
                config.keyCode    = (int)channel;
                config.keyIndex   = note;
                config.keyName    = MidiName(channel, note);
                if (doKeyConfig || doKeySend)
                {
                    await controlWPFWindow.server.SendCommandAsync(new PipeCommands.KeyDown {
                        Config = config
                    });
                }
                if (!doKeyConfig)
                {
                    CheckKey(config, true);
                }
            };

            midiCCWrapper.noteOffDelegateProxy += (channel, note) =>
            {
                Debug.Log("MidiNoteOff:" + channel + "/" + note);

                var config = new KeyConfig();
                config.type       = KeyTypes.Midi;
                config.actionType = KeyActionTypes.Face;
                config.keyCode    = (int)channel;
                config.keyIndex   = note;
                config.keyName    = MidiName(channel, note);
                if (doKeyConfig || doKeySend)
                {
                }                                //  await server.SendCommandAsync(new PipeCommands.KeyUp { Config = config });
                if (!doKeyConfig)
                {
                    CheckKey(config, false);
                }
            };
            midiCCWrapper.knobUpdateBoolDelegate += async(int knobNo, bool value) =>
            {
                MidiJack.MidiChannel channel = MidiJack.MidiChannel.Ch1; //仮でCh1
                Debug.Log("MidiCC:" + channel + "/" + knobNo + "/" + value);

                var config = new KeyConfig();
                config.type       = KeyTypes.MidiCC;
                config.actionType = KeyActionTypes.Face;
                config.keyCode    = (int)channel;
                config.keyIndex   = knobNo;
                config.keyName    = MidiName(channel, knobNo);

                if (value)
                {
                    if (doKeyConfig || doKeySend)
                    {
                        await controlWPFWindow.server.SendCommandAsync(new PipeCommands.KeyDown {
                            Config = config
                        });
                    }
                }
                else
                {
                    if (doKeyConfig || doKeySend)
                    {
                    }                                //  await server.SendCommandAsync(new PipeCommands.KeyUp { Config = config });
                }
                if (!doKeyConfig)
                {
                    CheckKey(config, value);
                }
            };

            midiCCWrapper.knobDelegateProxy += (MidiJack.MidiChannel channel, int knobNo, float value) =>
            {
                CheckKnobUpdated(channel, knobNo, value);
            };
        }
 private string MidiName(MidiJack.MidiChannel channel, int note)
 {
     return($"MIDI Ch{(int)channel + 1} {note}");
 }
Beispiel #13
0
    void OnMidiControlChange(MidiJack.MidiChannel channel, int ccNumber, float ccValue)
    {
        if (_ClipEditorUI._TargetClipPad != null)
        {
            if (ccNumber >= 8 && ccNumber < 22)
            {
                float alpha, H, S, V;
                int   controlIndex = ccNumber - 8;
                switch (controlIndex)
                {
                //Clip Speed
                case 0:
                    _ClipEditorUI._TargetClipPad._ClipData._ClipPlaybackSpeed = Mathf.Lerp(0.1f, 4f, ccValue);
                    _ClipEditorUI.Refresh();
                    break;

                //Clip Colour H
                case 1:
                    alpha = _ClipEditorUI._TargetClipPad._ClipData._TintColor.a;
                    Color.RGBToHSV(_ClipEditorUI._TargetClipPad._ClipData._TintColor, out H, out S, out V);
                    H = ccValue;
                    _ClipEditorUI._TargetClipPad._ClipData._TintColor   = Color.HSVToRGB(H, S, V);
                    _ClipEditorUI._TargetClipPad._ClipData._TintColor.a = alpha;
                    _ClipEditorUI.Refresh();
                    break;

                //Clip Colour S
                case 2:
                    alpha = _ClipEditorUI._TargetClipPad._ClipData._TintColor.a;
                    Color.RGBToHSV(_ClipEditorUI._TargetClipPad._ClipData._TintColor, out H, out S, out V);
                    S = ccValue;
                    _ClipEditorUI._TargetClipPad._ClipData._TintColor   = Color.HSVToRGB(H, S, V);
                    _ClipEditorUI._TargetClipPad._ClipData._TintColor.a = alpha;
                    _ClipEditorUI.Refresh();
                    break;

                //Clip Colour V
                case 3:
                    alpha = _ClipEditorUI._TargetClipPad._ClipData._TintColor.a;
                    Color.RGBToHSV(_ClipEditorUI._TargetClipPad._ClipData._TintColor, out H, out S, out V);
                    V = ccValue;
                    _ClipEditorUI._TargetClipPad._ClipData._TintColor   = Color.HSVToRGB(H, S, V);
                    _ClipEditorUI._TargetClipPad._ClipData._TintColor.a = alpha;
                    _ClipEditorUI.Refresh();
                    break;

                //Clip Alpha
                case 4:
                    _ClipEditorUI._TargetClipPad._ClipData._TintColor.a = ccValue;
                    _ClipEditorUI.Refresh();
                    break;

                //Luma Key
                case 5:
                    _ClipEditorUI._TargetClipPad._ClipData._LumaKey = ccValue;
                    _ClipEditorUI.Refresh();
                    break;

                //Luma Blend
                case 6:
                    _ClipEditorUI._TargetClipPad._ClipData._LumaBlend = ccValue;
                    _ClipEditorUI.Refresh();
                    break;

                //Colour Mask
                case 7:
                    _ClipEditorUI._TargetClipPad._ClipData._ColorMask = Mathf.Lerp(1f, 15f, ccValue);
                    _ClipEditorUI.Refresh();
                    break;

                //Vid Start Point;
                case 8:
                    _ClipEditorUI._TargetClipPad._ClipData._VideoStartMs = Mathf.Lerp(0, _ClipEditorUI._TargetClipPad._ClipData._VideoEndMs - 1, ccValue);
                    _ClipEditorUI.Refresh();
                    break;

                //Vid End Point;
                case 9:
                    _ClipEditorUI._TargetClipPad._ClipData._VideoEndMs = Mathf.Lerp(_ClipEditorUI._TargetClipPad._ClipData._VideoStartMs + 1, _ClipEditorUI._TargetClipPad._ClipData._VideoLengthMs, ccValue);
                    _ClipEditorUI.Refresh();
                    break;

                //Vid XPos;
                case 10:
                    _ClipEditorUI._TargetClipPad._ClipData._XPos = Mathf.Lerp(-3, 3, ccValue);
                    _ClipEditorUI.Refresh();
                    break;

                //Vid YPos;
                case 11:
                    _ClipEditorUI._TargetClipPad._ClipData._YPos = Mathf.Lerp(-3, 3, ccValue);
                    _ClipEditorUI.Refresh();
                    break;

                //Vid Width;
                case 12:
                    _ClipEditorUI._TargetClipPad._ClipData._Width = Mathf.Lerp(0, 3, ccValue);
                    _ClipEditorUI.Refresh();
                    break;

                //Vid Height;
                case 13:
                    _ClipEditorUI._TargetClipPad._ClipData._Height = Mathf.Lerp(0, 3, ccValue);
                    _ClipEditorUI.Refresh();
                    break;
                }
            }
        }
    }