コード例 #1
0
 void KeyUp(int aMidiIdx)
 {
     if (aMidiIdx >= 0 && aMidiIdx < byte.MaxValue / 2)
     {
         SendShortMessage(CommandEnum.NoteOff, aMidiIdx, MidiConversion.GetMidiVolume(MIDISettings.instance.keyboardSettings.customVolume));
     }
 }
コード例 #2
0
    public void ProcessMidiMessage(MidiMessage midiMessage)
    {
        if (midiMessage.dataSize == 3 && midiMessage.command != 0xF0)
        {
            if (midiMessage.command.ToMidiCommand() == 0x90 && midiMessage.data2 == 0)
            {
                midiMessage.command = (byte)(midiMessage.command.ToMidiChannel() + 0x80);
            }

            volume = 0;
            if (MIDISettings.instance.inputSettings.useCustomVolume)
            {
                volume = MidiConversion.GetMidiVolume(MIDISettings.instance.inputSettings.customVolume);
            }
            else
            {
                volume = (int)Mathf.Clamp(MIDISettings.instance.inputSettings.multiplyVolume * midiMessage.data2, 0, 127);
            }

            command = 0;
            if (MIDISettings.instance.inputSettings.midiChannel == ChannelEnum.None)
            {
                command = midiMessage.command;
            }
            else
            {
                command = (int)MIDISettings.instance.inputSettings.midiChannel + midiMessage.command.ToMidiCommand();
            }

            if (MIDISettings.instance.inputSettings.midiOut)
            {
                MidiOut.SendShortMessage(command, midiMessage.data1, volume, MIDISettings.instance.inputSettings.midiThrough);
            }

            if (ShortMessageEvent != null)
            {
                ShortMessageEvent(command, midiMessage.data1, volume);
            }
        }
        else
        {
            // SYS EX MESSAGE //
            if (midiMessage.command == 0xF0)
            {
                if (SysExMessageEvent != null)
                {
                    SysExMessageEvent(midiMessage);
                }
            }
        }
    }
コード例 #3
0
    public void MuteTones()
    {
        int startIndex = MIDISettings.instance.keyboardSettings.keyboardOctave * 12;

        MidiOut.fireMidiOutEvents = false;
        for (int i = startIndex; i < startIndex + 13; i++)
        {
            if (i >= 0 && i < byte.MaxValue / 2)
            {
                SendShortMessage(CommandEnum.NoteOff, i, MidiConversion.GetMidiVolume(MIDISettings.instance.keyboardSettings.customVolume));
            }
        }
        MidiOut.fireMidiOutEvents = true;
    }