Beispiel #1
0
        /******************** OUTPUT HELPERS ************************/
        private void OscOutput(MidiCommand command)
        {
            var osc = new Osc.MessageEncoder(OSC_PATH);

            osc.Add(JsonUtility.ToJson(command));
            socket.Send(osc);
        }
Beispiel #2
0
        public virtual void NoteOff(int noteNum)
        {
            switch (outputMode)
            {
            case OutputMode.OSC:
                MidiCommand com = MidiCommandHelper.NoteOffCommand(midiChannelOut, noteNum);
                OscOutput(com);
                break;


            case OutputMode.MIDI:
                MidiOut.SendNoteOff(MidiChannel.Ch1, noteNum);
                break;

            default:
                break;
            }
        }
Beispiel #3
0
        public virtual void MidiReceive(Osc.OscPort.Capsule c)
        {
            MidiCommand com         = (MidiCommand)JsonUtility.FromJson((string)c.message.data[0], typeof(MidiCommand));
            byte        midiCommand = (byte)(com.status & 0xf0);
            byte        channel     = (byte)(com.status & 0x0f);

            print("received command: " + midiCommand);
            midiChannelOut = (int)channel;
            switch (midiCommand)
            {
            // Note On Command
            case 0x80:
                NoteOn(com.data1, com.data2);
                break;

            // Note Off Command
            case 0x90:
                NoteOff(com.data1);
                break;
            }
        }
Beispiel #4
0
        public virtual void NoteOn(int noteNum, int velocity = 127)
        {
            switch (outputMode)
            {
            case OutputMode.OSC:

                MidiCommand com = MidiCommandHelper.NoteOnCommand(midiChannelOut, noteNum, velocity);
                OscOutput(com);

                break;


            case OutputMode.MIDI:

                MidiOut.SendNoteOn((MidiChannel)midiChannelOut, noteNum, velocity / 127.0f);
                break;

            default:
                break;
            }
        }