From 1d09cf3a0a4723b2b918d55d1a54be8f371f57ae Mon Sep 17 00:00:00 2001 From: Francois Best Date: Thu, 10 Apr 2014 14:32:08 +0200 Subject: [PATCH 1/5] USB defs. --- src/midi_USB.h | 106 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 src/midi_USB.h diff --git a/src/midi_USB.h b/src/midi_USB.h new file mode 100644 index 0000000..7ff7875 --- /dev/null +++ b/src/midi_USB.h @@ -0,0 +1,106 @@ +/*! + * @file midi_USB.h + * Project Arduino MIDI Library + * @brief MIDI Library for the Arduino - USB + * @version 4.1 + * @author Francois Best + * @date 24/02/11 + * @license GPL v3.0 - Copyright Forty Seven Effects 2014 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include "midi_Namespace.h" + +BEGIN_MIDI_NAMESPACE + +struct CodeIndexNumbers +{ + enum + { + reserved = 0x00, + misc = reserved, + + cableEvent = 0x01, + systemCommon2Bytes = 0x02, + systemCommon3Bytes = 0x03, + + sysExStart = 0x04, + sysExContinue = sysExStart, + + systemCommon1Byte = 0x05, + sysExEnds1Byte = systemCommon1Byte, + + sysExEnds2Bytes = 0x06, + sysExEnds3Bytes = 0x07, + noteOn = 0x08, + noteOff = 0x09, + polyKeyPress = 0x0A, + controlChange = 0x0B, + programChange = 0x0C, + channelPressure = 0x0D, + pitchBend = 0x0E, + singleByte = 0x0F, + }; + + inline byte getSize(byte inCIN) + { + switch (inCIN) + { + case noteOn: + case noteOff: + case controlChange: + case pitchBend: + case polyKeyPress: + case systemCommon3Bytes: + case sysExEnds3Bytes: + return 3; + + case programChange: + case channelPressure: + case systemCommon2Bytes: + case sysExEnds2Bytes: + return 2; + + case systemCommon1Byte: + case singleByte: + return 1; + + default: + break; + } + return 0; + } +}; + +// ----------------------------------------------------------------------------- + +struct UsbMidiEvent +{ + union + { + uint32_t mRawData; + struct + { + byte mCableNumber:4; + byte mCodeIndexNumber:4; + byte mMidi[3]; + }; + byte[4] mDataArray; + }; +}; + +END_MIDI_NAMESPACE From c17f2396cd963a1f9f3677f326ef19ed1354683e Mon Sep 17 00:00:00 2001 From: Francois Best Date: Wed, 12 Oct 2016 19:11:21 +0200 Subject: [PATCH 2/5] Fix syntax. --- src/midi_USB.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/midi_USB.h b/src/midi_USB.h index 7ff7875..14aaeed 100644 --- a/src/midi_USB.h +++ b/src/midi_USB.h @@ -99,7 +99,7 @@ struct UsbMidiEvent byte mCodeIndexNumber:4; byte mMidi[3]; }; - byte[4] mDataArray; + byte mDataArray[4]; }; }; From 63e8e515ad03dd5ad3f370326e8acffd7d4b9ce3 Mon Sep 17 00:00:00 2001 From: Francois Best Date: Wed, 12 Oct 2016 19:16:27 +0200 Subject: [PATCH 3/5] Rename midi_USB.h to midi_UsbDefs.h --- src/{midi_USB.h => midi_UsbDefs.h} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/{midi_USB.h => midi_UsbDefs.h} (100%) diff --git a/src/midi_USB.h b/src/midi_UsbDefs.h similarity index 100% rename from src/midi_USB.h rename to src/midi_UsbDefs.h From e84d12d9edc3ce3ddd56f4d251e8e253d7b7d64a Mon Sep 17 00:00:00 2001 From: Francois Best Date: Wed, 12 Oct 2016 19:18:29 +0200 Subject: [PATCH 4/5] Update license, renamed packet object. --- src/midi_UsbDefs.h | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/midi_UsbDefs.h b/src/midi_UsbDefs.h index 14aaeed..393ca35 100644 --- a/src/midi_UsbDefs.h +++ b/src/midi_UsbDefs.h @@ -1,24 +1,29 @@ /*! - * @file midi_USB.h + * @file midi_UsbDefs.h * Project Arduino MIDI Library - * @brief MIDI Library for the Arduino - USB - * @version 4.1 + * @brief MIDI Library for the Arduino - Definitions + * @version 4.2 * @author Francois Best * @date 24/02/11 - * @license GPL v3.0 - Copyright Forty Seven Effects 2014 + * @license MIT - Copyright (c) 2016 Francois Best * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. */ #pragma once @@ -88,7 +93,7 @@ struct CodeIndexNumbers // ----------------------------------------------------------------------------- -struct UsbMidiEvent +struct UsbMidiEventPacket { union { From 0252ce7ebe14594a2534760a89fc53f557997354 Mon Sep 17 00:00:00 2001 From: Francois Best Date: Wed, 12 Oct 2016 19:22:36 +0200 Subject: [PATCH 5/5] Fixed noteOn/Off CINs, coding style & fixes. --- src/midi_UsbDefs.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/midi_UsbDefs.h b/src/midi_UsbDefs.h index 393ca35..514c1a0 100644 --- a/src/midi_UsbDefs.h +++ b/src/midi_UsbDefs.h @@ -51,9 +51,9 @@ struct CodeIndexNumbers sysExEnds2Bytes = 0x06, sysExEnds3Bytes = 0x07, - noteOn = 0x08, - noteOff = 0x09, - polyKeyPress = 0x0A, + noteOff = 0x08, + noteOn = 0x09, + polyPressure = 0x0A, controlChange = 0x0B, programChange = 0x0C, channelPressure = 0x0D, @@ -61,9 +61,9 @@ struct CodeIndexNumbers singleByte = 0x0F, }; - inline byte getSize(byte inCIN) + static inline byte getSize(byte inCodeIndexNumber) { - switch (inCIN) + switch (inCodeIndexNumber) { case noteOn: case noteOff: