From 240cd22021f98302167a1b206b8a27d5d22b310e Mon Sep 17 00:00:00 2001 From: Francois Best Date: Tue, 1 Apr 2014 09:03:44 +0200 Subject: [PATCH 01/22] Added explicit license header and starting 4.1 branch. --- src/MIDI.cpp | 17 +++++++++++++++-- src/MIDI.h | 17 +++++++++++++++-- src/MIDI.hpp | 17 +++++++++++++++-- src/midi_Defs.h | 17 +++++++++++++++-- src/midi_Namespace.h | 17 +++++++++++++++-- src/midi_Settings.h | 19 ++++++++++++++++--- 6 files changed, 91 insertions(+), 13 deletions(-) diff --git a/src/MIDI.cpp b/src/MIDI.cpp index a01beb4..4d55be0 100644 --- a/src/MIDI.cpp +++ b/src/MIDI.cpp @@ -2,10 +2,23 @@ * @file MIDI.cpp * Project Arduino MIDI Library * @brief MIDI Library for the Arduino - * @version 4.0 + * @version 4.1 * @author Francois Best * @date 24/02/11 - * license GPL Forty Seven Effects - 2011 + * @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 . */ #include "MIDI.h" diff --git a/src/MIDI.h b/src/MIDI.h index 2a92b80..fb8c0b4 100644 --- a/src/MIDI.h +++ b/src/MIDI.h @@ -2,10 +2,23 @@ * @file MIDI.h * Project Arduino MIDI Library * @brief MIDI Library for the Arduino - * @version 4.0 + * @version 4.1 * @author Francois Best * @date 24/02/11 - * license GPL Forty Seven Effects - 2011 + * @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 diff --git a/src/MIDI.hpp b/src/MIDI.hpp index 084daaa..3b375bf 100644 --- a/src/MIDI.hpp +++ b/src/MIDI.hpp @@ -2,10 +2,23 @@ * @file midi_Inline.hpp * Project Arduino MIDI Library * @brief MIDI Library for the Arduino - Inline implementations - * @version 4.0 + * @version 4.1 * @author Francois Best * @date 24/02/11 - * license GPL Forty Seven Effects - 2011 + * @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 diff --git a/src/midi_Defs.h b/src/midi_Defs.h index 6739e1d..324f361 100644 --- a/src/midi_Defs.h +++ b/src/midi_Defs.h @@ -2,10 +2,23 @@ * @file midi_Defs.h * Project Arduino MIDI Library * @brief MIDI Library for the Arduino - Definitions - * @version 4.0 + * @version 4.1 * @author Francois Best * @date 24/02/11 - * license GPL Forty Seven Effects - 2011 + * @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 diff --git a/src/midi_Namespace.h b/src/midi_Namespace.h index c72e334..c99629e 100644 --- a/src/midi_Namespace.h +++ b/src/midi_Namespace.h @@ -2,10 +2,23 @@ * @file midi_Namespace.h * Project Arduino MIDI Library * @brief MIDI Library for the Arduino - Namespace declaration - * @version 4.0 + * @version 4.1 * @author Francois Best * @date 24/02/11 - * license GPL Forty Seven Effects - 2011 + * @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 diff --git a/src/midi_Settings.h b/src/midi_Settings.h index eae8555..cd2d021 100644 --- a/src/midi_Settings.h +++ b/src/midi_Settings.h @@ -2,10 +2,23 @@ * @file midi_Settings.h * Project Arduino MIDI Library * @brief MIDI Library for the Arduino - Settings - * @version 4.0 + * @version 4.1 * @author Francois Best * @date 24/02/11 - * license GPL Forty Seven Effects - 2011 + * @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 @@ -48,13 +61,13 @@ // Set the default port to use for MIDI. #if MIDI_AUTO_INSTANCIATE # ifdef ARDUINO +# include "Arduino.h" # ifdef USBCON # define MIDI_DEFAULT_SERIAL_PORT Serial1 // For Leonardo # else # define MIDI_DEFAULT_SERIAL_PORT Serial // For other Arduinos # endif # define MIDI_DEFAULT_SERIAL_CLASS HardwareSerial -# include "Arduino.h" # include "HardwareSerial.h" # else # error Auto-instanciation disabled. Use MIDI_CREATE_INSTANCE macro. From b041abaca3b0d0a9613d995139f086b23f007389 Mon Sep 17 00:00:00 2001 From: Francois Best Date: Tue, 1 Apr 2014 09:04:31 +0200 Subject: [PATCH 02/22] Helper method. --- src/MIDI.h | 1 + src/MIDI.hpp | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/MIDI.h b/src/MIDI.h index fb8c0b4..5575e32 100644 --- a/src/MIDI.h +++ b/src/MIDI.h @@ -130,6 +130,7 @@ public: public: static inline MidiType getTypeFromStatusByte(byte inStatus); + static inline Channel getChannelFromStatusByte(byte inStatus); static inline bool isChannelMessage(MidiType inType); private: diff --git a/src/MIDI.hpp b/src/MIDI.hpp index 3b375bf..641f706 100644 --- a/src/MIDI.hpp +++ b/src/MIDI.hpp @@ -550,9 +550,9 @@ bool MidiInterface::parse() if (mPendingMessageIndex >= (mPendingMessageExpectedLenght - 1)) { - mMessage.type = getTypeFromStatusByte(mPendingMessage[0]); - mMessage.channel = (mPendingMessage[0] & 0x0f) + 1; - mMessage.data1 = mPendingMessage[1]; + mMessage.type = getTypeFromStatusByte(mPendingMessage[0]); + mMessage.channel = getChannelFromStatusByte(mPendingMessage[0]); + mMessage.data1 = mPendingMessage[1]; // Save data2 only if applicable if (mPendingMessageExpectedLenght == 3) @@ -725,7 +725,7 @@ bool MidiInterface::parse() mMessage.type = getTypeFromStatusByte(mPendingMessage[0]); if (isChannelMessage(mMessage.type)) - mMessage.channel = (mPendingMessage[0] & 0x0f) + 1; + mMessage.channel = getChannelFromStatusByte(mPendingMessage[0]); else mMessage.channel = 0; @@ -948,6 +948,14 @@ MidiType MidiInterface::getTypeFromStatusByte(byte inStatus) return (MidiType)inStatus; } +/*! \brief Returns channel in the range 1-16 + */ +template +inline Channel MidiInterface::getChannelFromStatusByte(byte inStatus) +{ + return (inStatus & 0x0f) + 1; +} + template bool MidiInterface::isChannelMessage(MidiType inType) { From f197d9f439a11ee2625b9e0e2de4e1b1fbbc2fb3 Mon Sep 17 00:00:00 2001 From: Francois Best Date: Tue, 1 Apr 2014 09:05:30 +0200 Subject: [PATCH 03/22] Doc & coding style. --- src/MIDI.cpp | 2 ++ src/MIDI.hpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/MIDI.cpp b/src/MIDI.cpp index 4d55be0..b8f1c0c 100644 --- a/src/MIDI.cpp +++ b/src/MIDI.cpp @@ -57,6 +57,7 @@ BEGIN_MIDI_NAMESPACE \param inLength The lenght of the input buffer. \return The lenght of the encoded output buffer. @see decodeSysEx + Code inspired from Ruin & Wesen's SysEx encoder/decoder - http://ruinwesen.com */ unsigned encodeSysEx(const byte* inData, byte* outSysEx, unsigned inLength) { @@ -93,6 +94,7 @@ unsigned encodeSysEx(const byte* inData, byte* outSysEx, unsigned inLength) \param inLength The lenght of the input buffer. \return The lenght of the output buffer. @see encodeSysEx @see getSysExArrayLength + Code inspired from Ruin & Wesen's SysEx encoder/decoder - http://ruinwesen.com */ unsigned decodeSysEx(const byte* inSysEx, byte* outData, unsigned inLength) { diff --git a/src/MIDI.hpp b/src/MIDI.hpp index 641f706..2d1ed85 100644 --- a/src/MIDI.hpp +++ b/src/MIDI.hpp @@ -711,7 +711,7 @@ bool MidiInterface::parse() mPendingMessage[mPendingMessageIndex] = extracted; // Now we are going to check if we have reached the end of the message - if (mPendingMessageIndex >= (mPendingMessageExpectedLenght-1)) + if (mPendingMessageIndex >= (mPendingMessageExpectedLenght - 1)) { // "FML" case: fall down here with an overflown SysEx.. // This means we received the last possible data byte that can fit From f8511a9591f47c6576ee645925ff19e9282831c6 Mon Sep 17 00:00:00 2001 From: Francois Best Date: Tue, 1 Apr 2014 19:38:36 +0200 Subject: [PATCH 04/22] Added validation script using Arduino 1.5 CLI. --- .gitignore | 1 + res/validate.sh | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 res/validate.sh diff --git a/.gitignore b/.gitignore index a5bd9cc..d44cbfe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.sublime-workspace *.pyc +logs/ diff --git a/res/validate.sh b/res/validate.sh new file mode 100644 index 0000000..bb05194 --- /dev/null +++ b/res/validate.sh @@ -0,0 +1,59 @@ +#!/bin/sh + +cd "`dirname "${0}"`" + +root="`pwd`/.." +logsDir="$root/logs" +libDir="$HOME/Documents/Arduino/libraries/MIDI" +arduino="/Applications/Arduino.app/Contents/MacOS/JavaApplicationStub" + +# ------------------------------------------------------------------------------ + +function cleanup +{ + # Parameter: + # $1: working directory + mkdir -p "$1" + rm -rf "$/*" +} + +function installTo +{ + # Parameter: + # $1: install directory + cp -rf "$root/src/*" "$1/" + cp -rf "$root/res/examples" "$1/" + cp -rf "$root/res/keywords.txt" "$1/" +} + +function verify +{ + # Parameter: + # $1: path to .ino file + # $2: board option + "$arduino" \ + --verify "$1" \ + --verbose-build \ + #--board arduino:avr:leonardo +} + +function checkExamples +{ + cwd=`pwd` + cd "$libDir/examples" + for d in *; + do + verify "$libDir/examples/$d/$d.ino" \ + > "$logsDir/$d.build.log" \ + 2> "$logsDir/$d.build.err.log" + done + cd "$cwd" +} + +# ------------------------------------------------------------------------------ +# Main + +#cleanup "$libDir" +#installTo "$libDir" + +checkExamples From e39f6a7b9927e975a4f333a27e471e991e094046 Mon Sep 17 00:00:00 2001 From: Francois Best Date: Wed, 2 Apr 2014 08:55:45 +0200 Subject: [PATCH 05/22] Always better in Python. --- res/validate.py | 116 ++++++++++++++++++++++++++++++++++++++++++++++++ res/validate.sh | 59 ------------------------ 2 files changed, 116 insertions(+), 59 deletions(-) create mode 100644 res/validate.py delete mode 100644 res/validate.sh diff --git a/res/validate.py b/res/validate.py new file mode 100644 index 0000000..52ebbc7 --- /dev/null +++ b/res/validate.py @@ -0,0 +1,116 @@ +# -*- coding: utf-8 -*- + +import sys +import os +import shutil +import subprocess +from pprint import pprint + +# ------------------------------------------------------------------------------ + +rootDir = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), '..')) +logsDir = os.path.join(rootDir, 'logs') +resDir = os.path.join(rootDir, 'res') +srcDir = os.path.join(rootDir, 'src') + +# ------------------------------------------------------------------------------ + +class Arduino: + if sys.platform == 'darwin': + binary = '/Applications/Arduino.app/Contents/MacOS/JavaApplicationStub' + home = os.path.expanduser('~/Documents/Arduino') + elif sys.platform == 'win32': + binary = 'arduino.exe' + home = os.path.expanduser('~/My Documents/Arduino') + elif sys.platform == 'linux': + binary = 'arduino' + home = os.path.expanduser('~/Arduino') + else: + print('Unsupported platform %s' % str(sys.platform)) + sys.exit(1) + + libraryDir = os.path.join(home, 'libraries') + + boards = { + 'Uno': 'arduino:avr:uno', + 'Leonardo': 'arduino:avr:leonardo', + 'Mega': 'arduino:avr:mega', + } + + def checkReturnCode(code): + if code == 0: + return True + if code == 1: + print("Operation failed.") + if code == 2: + print("File not found") + if code == 3: + print("Invalid argument") + return False + + def verify(sketch, board): + return Arduino.checkReturnCode(subprocess.call([ + Arduino.binary, + '--verify', sketch, + '--board', board, + #'--verbose-build', + ])) + +# ------------------------------------------------------------------------------ + +class ArduinoMidiLibrary: + def __init__(self): + self.path = os.path.join(Arduino.libraryDir, 'MIDI') + self.sources = self.getSources() + self.resources = self.getResources() + + def getSources(self): + sources = dict() + for root, dirs, files in os.walk(srcDir): + for name, ext in [os.path.splitext(f) for f in files]: + if ext in ('.cpp', '.hpp', '.h'): + source = os.path.join(root, name + ext) + dest = os.path.join(self.path, os.path.relpath(source, srcDir)) + sources[source] = dest + return sources + + def getResources(self): + return { + os.path.join(resDir, 'keywords.txt'): os.path.join(self.path, 'keywords.txt'), + os.path.join(resDir, 'examples/'): os.path.join(self.path, 'examples/'), + } + + def install(self): + payloads = dict(list(self.sources.items()) + list(self.resources.items())) + for s,d in payloads.items(): + if not os.path.exists(os.path.dirname(d)): + os.makedirs(os.path.dirname(d)) + if os.path.isfile(s): + shutil.copy2(s, d) + elif os.path.isdir(s): + if os.path.exists(d): + shutil.rmtree(d) + shutil.copytree(s, d) + + def getInstalledExamples(self): + exDir = os.path.join(self.path, 'examples') + return [os.path.join(exDir, x, x + '.ino') for x in os.listdir(exDir)] + + def validate(self): + for boardName, boardId in Arduino.boards.items(): + # Validate examples + print('Validation for Arduino %s' % boardName) + for example in self.getInstalledExamples(): + Arduino.verify(example, boardId) + +# ------------------------------------------------------------------------------ + +def main(): + lib = ArduinoMidiLibrary() + lib.install() + lib.validate() + +# ------------------------------------------------------------------------------ + +if __name__ == '__main__': + main() diff --git a/res/validate.sh b/res/validate.sh deleted file mode 100644 index bb05194..0000000 --- a/res/validate.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/sh - -cd "`dirname "${0}"`" - -root="`pwd`/.." -logsDir="$root/logs" -libDir="$HOME/Documents/Arduino/libraries/MIDI" -arduino="/Applications/Arduino.app/Contents/MacOS/JavaApplicationStub" - -# ------------------------------------------------------------------------------ - -function cleanup -{ - # Parameter: - # $1: working directory - mkdir -p "$1" - rm -rf "$/*" -} - -function installTo -{ - # Parameter: - # $1: install directory - cp -rf "$root/src/*" "$1/" - cp -rf "$root/res/examples" "$1/" - cp -rf "$root/res/keywords.txt" "$1/" -} - -function verify -{ - # Parameter: - # $1: path to .ino file - # $2: board option - "$arduino" \ - --verify "$1" \ - --verbose-build \ - #--board arduino:avr:leonardo -} - -function checkExamples -{ - cwd=`pwd` - cd "$libDir/examples" - for d in *; - do - verify "$libDir/examples/$d/$d.ino" \ - > "$logsDir/$d.build.log" \ - 2> "$logsDir/$d.build.err.log" - done - cd "$cwd" -} - -# ------------------------------------------------------------------------------ -# Main - -#cleanup "$libDir" -#installTo "$libDir" - -checkExamples From fc1ba210489bc9ced1a8832d9380c6df21d53cbe Mon Sep 17 00:00:00 2001 From: Francois Best Date: Wed, 2 Apr 2014 09:15:45 +0200 Subject: [PATCH 06/22] Better printout. --- res/validate.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/res/validate.py b/res/validate.py index 52ebbc7..e3f56a8 100644 --- a/res/validate.py +++ b/res/validate.py @@ -41,11 +41,11 @@ class Arduino: if code == 0: return True if code == 1: - print("Operation failed.") + print('Operation failed.') if code == 2: - print("File not found") + print('File not found') if code == 3: - print("Invalid argument") + print('Invalid argument') return False def verify(sketch, board): @@ -54,7 +54,7 @@ class Arduino: '--verify', sketch, '--board', board, #'--verbose-build', - ])) + ], stdout = open(os.devnull, 'wb'))) # ------------------------------------------------------------------------------ @@ -101,14 +101,22 @@ class ArduinoMidiLibrary: # Validate examples print('Validation for Arduino %s' % boardName) for example in self.getInstalledExamples(): - Arduino.verify(example, boardId) + if not Arduino.verify(example, boardId): + print('{0:40} {1}'.format(os.path.basename(example), 'FAILED')) + return False + else: + print('{0:40} {1}'.format(os.path.basename(example), 'PASSED')) + return True # ------------------------------------------------------------------------------ def main(): lib = ArduinoMidiLibrary() lib.install() - lib.validate() + if lib.validate(): + print('Validation passed') + else: + print('Validation failed') # ------------------------------------------------------------------------------ From f551ff7bbd34789ddb06d1a90eddc7661513b4f2 Mon Sep 17 00:00:00 2001 From: Francois Best Date: Wed, 2 Apr 2014 10:37:24 +0200 Subject: [PATCH 07/22] Dictate. --- res/validate.py | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/res/validate.py b/res/validate.py index e3f56a8..a2bad32 100644 --- a/res/validate.py +++ b/res/validate.py @@ -15,6 +15,13 @@ srcDir = os.path.join(rootDir, 'src') # ------------------------------------------------------------------------------ +class Dict(dict): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.__dict__ = self + +# ------------------------------------------------------------------------------ + class Arduino: if sys.platform == 'darwin': binary = '/Applications/Arduino.app/Contents/MacOS/JavaApplicationStub' @@ -31,11 +38,28 @@ class Arduino: libraryDir = os.path.join(home, 'libraries') - boards = { - 'Uno': 'arduino:avr:uno', - 'Leonardo': 'arduino:avr:leonardo', - 'Mega': 'arduino:avr:mega', - } + boards = [ + Dict({ + 'name': 'Uno', + 'id': 'arduino:avr:uno', + 'port': None, + }), + Dict({ + 'name': 'Leonardo', + 'id': 'arduino:avr:leonardo', + 'port': None, + }), + Dict({ + 'name': 'Mega', + 'id': 'arduino:avr:mega', + 'port': None, + }), + Dict({ + 'name': 'Due', + 'id': 'arduino:sam:due', + 'port': None, + }), + ] def checkReturnCode(code): if code == 0: @@ -48,11 +72,11 @@ class Arduino: print('Invalid argument') return False - def verify(sketch, board): + def verify(sketch, boardId): return Arduino.checkReturnCode(subprocess.call([ Arduino.binary, '--verify', sketch, - '--board', board, + '--board', boardId, #'--verbose-build', ], stdout = open(os.devnull, 'wb'))) @@ -97,11 +121,11 @@ class ArduinoMidiLibrary: return [os.path.join(exDir, x, x + '.ino') for x in os.listdir(exDir)] def validate(self): - for boardName, boardId in Arduino.boards.items(): + for board in Arduino.boards: # Validate examples - print('Validation for Arduino %s' % boardName) + print('Validation for Arduino %s' % board.name) for example in self.getInstalledExamples(): - if not Arduino.verify(example, boardId): + if not Arduino.verify(example, board.id): print('{0:40} {1}'.format(os.path.basename(example), 'FAILED')) return False else: From b4b39a9e5f1877caa1047eeefa6b75f8492737bb Mon Sep 17 00:00:00 2001 From: Francois Best Date: Wed, 9 Apr 2014 19:59:33 +0200 Subject: [PATCH 08/22] Added validation from Sublime Text. --- arduino_midi_library.sublime-project | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/arduino_midi_library.sublime-project b/arduino_midi_library.sublime-project index 24db303..68198ce 100644 --- a/arduino_midi_library.sublime-project +++ b/arduino_midi_library.sublime-project @@ -4,5 +4,13 @@ { "path": "." } - ] + ], + "build_systems": + [ + { + "name": "Arduino MIDI Library Validator", + "cmd": ["python3", "${project_path}/res/validate.py"], + "path": "/usr/local/bin:/usr/bin:/bin" + } + ] } From 50d32da96e646ef9010b95f35026d2805cbd729d Mon Sep 17 00:00:00 2001 From: Francois Best Date: Wed, 9 Apr 2014 20:00:26 +0200 Subject: [PATCH 09/22] Updated examples to work on Leo, Uno, Mega & Due. --- res/Examples/MIDI_Bench/MIDI_Bench.ino | 66 ++++++++++--------- .../MIDI_Callbacks/MIDI_Callbacks.ino | 31 ++++----- .../MIDI_DualMerger/MIDI_DualMerger.ino | 16 +++-- 3 files changed, 61 insertions(+), 52 deletions(-) diff --git a/res/Examples/MIDI_Bench/MIDI_Bench.ino b/res/Examples/MIDI_Bench/MIDI_Bench.ino index 0b3061b..a97eaaf 100644 --- a/res/Examples/MIDI_Bench/MIDI_Bench.ino +++ b/res/Examples/MIDI_Bench/MIDI_Bench.ino @@ -1,17 +1,23 @@ -#include -#define MIDI_AUTO_INSTANCIATE 0 #include -// This program demonstrates how to use two serial ports at a time, -// the hardware serial being used for sending messages to the computer, -// while MIDI is handled on a software serial port. -// This program measures the time spent to receive and parse a message. +// This program will measure the time needed to receive, parse and process a +// NoteOn message. +// For it to work, please connect RX and TX on the MIDI port: +// Due, Leonardo and other USB-native Arduinos: Serial1 +// All other Arduinos: Connect pins 2 and 3. +// The program will then wait for 100 loops and print the results. + +#if defined(ARDUINO_SAM_DUE) || defined(USBCON) + // Print through USB and bench with Hardware serial + MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, midiBench); +#else + #include + SoftwareSerial midiSerial(2,3); + MIDI_CREATE_INSTANCE(SoftwareSerial, midiSerial, midiBench); +#endif // ----------------------------------------------------------------------------- -SoftwareSerial midiSerial(2,3); -MIDI_CREATE_INSTANCE(SoftwareSerial, midiSerial, softMidi); - unsigned long gTime_start = 0; unsigned long gTime_stop = 0; unsigned gCounter = 0; @@ -24,39 +30,37 @@ unsigned long gTime_max = 0; void handleNoteOn(byte inChannel, byte inNote, byte inVelocity) { gTime_stop = micros(); - + const unsigned long diff = gTime_stop - gTime_start; gTime_sum += diff; - + if (diff > gTime_max) gTime_max = diff; if (diff < gTime_min) gTime_min = diff; - - gCounter++; - - if (gCounter >= 100) + + if (gCounter++ >= 1000) { const unsigned long average = gTime_sum / (float)gCounter; - + Serial.println("Time to receive NoteOn: "); - + Serial.print("Average: "); Serial.print(average); Serial.println(" microsecs"); - + Serial.print("Min: "); Serial.print(gTime_min); Serial.println(" microsecs"); - + Serial.print("Max: "); Serial.print(gTime_max); Serial.println(" microsecs"); - + gCounter = 0; gTime_sum = 0; gTime_max = 0; gTime_min = -1; - - softMidi.turnThruOff(); + + midiBench.turnThruOff(); } } @@ -64,18 +68,18 @@ void handleNoteOn(byte inChannel, byte inNote, byte inVelocity) void setup() { - softMidi.begin(); - - Serial.begin(38400); - Serial.print("Arduino Ready"); - - softMidi.sendNoteOn(69,127,1); -} + midiBench.setHandleNoteOn(handleNoteOn); + midiBench.begin(); + while(!Serial); + Serial.begin(115200); + Serial.println("Arduino Ready"); + + midiBench.sendNoteOn(69,127,1); +} void loop() { gTime_start = micros(); - softMidi.read(); + midiBench.read(); } - diff --git a/res/Examples/MIDI_Callbacks/MIDI_Callbacks.ino b/res/Examples/MIDI_Callbacks/MIDI_Callbacks.ino index 475c177..b8043e7 100644 --- a/res/Examples/MIDI_Callbacks/MIDI_Callbacks.ino +++ b/res/Examples/MIDI_Callbacks/MIDI_Callbacks.ino @@ -2,20 +2,22 @@ // This function will be automatically called when a NoteOn is received. // It must be a void-returning function with the correct parameters, -// see documentation here: -// http://arduinomidilib.sourceforge.net/class_m_i_d_i___class.html +// see documentation here: +// http://arduinomidilib.fortyseveneffects.com/a00022.html void HandleNoteOn(byte channel, byte pitch, byte velocity) { // Do whatever you want when you receive a Note On. - + if (velocity == 0) { - // This acts like a NoteOff. + // This acts like a NoteOff. You can ask the library to call the NoteOff + // callback when receiving null-velocity NoteOn messages. + // See MIDI_HANDLE_NULL_VELOCITY_NOTE_ON_AS_NOTE_OFF in midi_Settings.h } - - // Try to keep your callbacks short (no delays ect) - // otherwise it would slow down the loop() and have a bad impact + + // Try to keep your callbacks short (no delays ect) + // otherwise it would slow down the loop() and have a bad impact // on real-time performance. } @@ -23,22 +25,21 @@ void HandleNoteOn(byte channel, byte pitch, byte velocity) void setup() { - // Initiate MIDI communications, listen to all channels - MIDI.begin(MIDI_CHANNEL_OMNI); - - // Connect the HandleNoteOn function to the library, + // Connect the HandleNoteOn function to the library, // so it is called upon reception of a NoteOn. MIDI.setHandleNoteOn(HandleNoteOn); // Put only the name of the function -} + // Initiate MIDI communications, listen to all channels + MIDI.begin(MIDI_CHANNEL_OMNI); +} void loop() { // Call MIDI.read the fastest you can for real-time performance. MIDI.read(); - - // There is no need to check if there are messages incoming + + // There is no need to check if there are messages incoming // if they are bound to a Callback function. - // The attached method will be called automatically + // The attached method will be called automatically // when the corresponding message has been received. } diff --git a/res/Examples/MIDI_DualMerger/MIDI_DualMerger.ino b/res/Examples/MIDI_DualMerger/MIDI_DualMerger.ino index edff690..740fa5b 100644 --- a/res/Examples/MIDI_DualMerger/MIDI_DualMerger.ino +++ b/res/Examples/MIDI_DualMerger/MIDI_DualMerger.ino @@ -1,4 +1,3 @@ -#include #include // This example shows how to create two instances of the library to create a merger. @@ -7,10 +6,15 @@ // A out = A in + B in // B out = B in + A in -SoftwareSerial softSerial(2,3); - -MIDI_CREATE_INSTANCE(HardwareSerial, Serial, midiA); -MIDI_CREATE_INSTANCE(SoftwareSerial, softSerial, midiB); +#ifdef ARDUINO_SAM_DUE + MIDI_CREATE_INSTANCE(HardwareSerial, Serial, midiA); + MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, midiB); +#else + #include + SoftwareSerial softSerial(2,3); + MIDI_CREATE_INSTANCE(HardwareSerial, Serial, midiA); + MIDI_CREATE_INSTANCE(SoftwareSerial, softSerial, midiB); +#endif void setup() { @@ -30,7 +34,7 @@ void loop() midiA.getData2(), midiA.getChannel()); } - + if (midiB.read()) { // Thru on B has already pushed the input message to out B. From 14a2ff9ea0703777468e6394675f7e3488e587a7 Mon Sep 17 00:00:00 2001 From: Francois Best Date: Wed, 9 Apr 2014 20:01:02 +0200 Subject: [PATCH 10/22] Fix: list directories only. --- res/validate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/validate.py b/res/validate.py index a2bad32..3c84e5e 100644 --- a/res/validate.py +++ b/res/validate.py @@ -118,7 +118,7 @@ class ArduinoMidiLibrary: def getInstalledExamples(self): exDir = os.path.join(self.path, 'examples') - return [os.path.join(exDir, x, x + '.ino') for x in os.listdir(exDir)] + return [os.path.join(exDir, x, x + '.ino') for x in next(os.walk(exDir))[1]] def validate(self): for board in Arduino.boards: From 49b109b4a2d0cc9e6692374477120ef65c919dd3 Mon Sep 17 00:00:00 2001 From: Francois Best Date: Thu, 10 Apr 2014 14:30:53 +0200 Subject: [PATCH 11/22] Added MIDI to validator (requires python-rtmidi). --- res/validator/midi.py | 101 ++++++++++++++++++++++++++++++++ res/{ => validator}/validate.py | 7 ++- 2 files changed, 105 insertions(+), 3 deletions(-) create mode 100644 res/validator/midi.py rename res/{ => validator}/validate.py (97%) diff --git a/res/validator/midi.py b/res/validator/midi.py new file mode 100644 index 0000000..764c09a --- /dev/null +++ b/res/validator/midi.py @@ -0,0 +1,101 @@ +# -*- coding: utf-8 -*- + +import rtmidi +import random + +# ------------------------------------------------------------------------------ + +class Midi: + InvalidType = 0x00 # For notifying errors + NoteOff = 0x80 # Note Off + NoteOn = 0x90 # Note On + AfterTouchPoly = 0xA0 # Polyphonic AfterTouch + ControlChange = 0xB0 # Control Change / Channel Mode + ProgramChange = 0xC0 # Program Change + AfterTouchChannel = 0xD0 # Channel (monophonic) AfterTouch + PitchBend = 0xE0 # Pitch Bend + SystemExclusive = 0xF0 # System Exclusive + TimeCodeQuarterFrame = 0xF1 # System Common - MIDI Time Code Quarter Frame + SongPosition = 0xF2 # System Common - Song Position Pointer + SongSelect = 0xF3 # System Common - Song Select + TuneRequest = 0xF6 # System Common - Tune Request + Clock = 0xF8 # System Real Time - Timing Clock + Start = 0xFA # System Real Time - Start + Continue = 0xFB # System Real Time - Continue + Stop = 0xFC # System Real Time - Stop + ActiveSensing = 0xFE # System Real Time - Active Sensing + SystemReset = 0xFF # System Real Time - System Reset + + @staticmethod + def getChannel(statusByte): + return statusByte & 0x0f; + + @staticmethod + def getType(statusByte): + if statusByte >= 0xf0: + # System messages + return statusByte + else: + # Channel messages + return statusByte & 0xf0; + + +# ------------------------------------------------------------------------------ + +class MidiInterface: + def __init__(self, listenerCallback = None): + self.interface = rtmidi.MidiIn() + self.listenerCallback = listenerCallback + self.ports = self.getAvailablePorts() + self.port = self.connect(self.choosePort()) + + # -------------------------------------------------------------------------- + + def read(self): + pass + + def handleMidiInput(self, message, timestamp): + midiData = message[0] + print(midiData) + if self.listenerCallback: + self.listenerCallback(midiData) + + # -------------------------------------------------------------------------- + + def getAvailablePorts(self): + return self.interface.get_ports() + + def choosePort(self): + if not self.ports: + print('No MIDI ports available, bailing out.') + return None + + if len(self.ports) == 1: + return (0, self.ports[0]) + + else: + # Give a choice + print('Multiple ports available, please make a choice:') + choices = [] + for port, i in zip(self.ports, range(0, len(self.ports))): + choices.append((i, port)) + print(' [%d]' % i, port) + choiceIndex = int(input('-> ')) + return choices[choiceIndex] + + # -------------------------------------------------------------------------- + + def connect(self, port): + if not port: + return None + print(port) + print('Connecting to %s' % port[1]) + self.interface.set_callback(self.handleMidiInput) + self.interface.open_port(port[0]) + return port + + +midi = MidiInterface() + +while True: + midi.read() diff --git a/res/validate.py b/res/validator/validate.py similarity index 97% rename from res/validate.py rename to res/validator/validate.py index 3c84e5e..25b386d 100644 --- a/res/validate.py +++ b/res/validator/validate.py @@ -8,7 +8,7 @@ from pprint import pprint # ------------------------------------------------------------------------------ -rootDir = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), '..')) +rootDir = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), '../..')) logsDir = os.path.join(rootDir, 'logs') resDir = os.path.join(rootDir, 'res') srcDir = os.path.join(rootDir, 'src') @@ -77,8 +77,9 @@ class Arduino: Arduino.binary, '--verify', sketch, '--board', boardId, - #'--verbose-build', - ], stdout = open(os.devnull, 'wb'))) + '--verbose-build', + ])) + #], stdout = open(os.devnull, 'wb'))) # ------------------------------------------------------------------------------ From d0523b3fc17f42011e5ba1c7196991a98f648c42 Mon Sep 17 00:00:00 2001 From: Francois Best Date: Thu, 10 Apr 2014 14:31:24 +0200 Subject: [PATCH 12/22] Cleanup old validator --- .../MIDI_LibValidator/MIDI_LibValidator.ino | 39 --- .../fritzing/MIDI_LibValidator.fzz | Bin 11760 -> 0 bytes .../midi_ValidatorInstances.h | 10 - .../midi_ValidatorInstances.ino | 20 -- .../MIDI_LibValidator/midi_ValidatorLCD.h | 14 -- .../MIDI_LibValidator/midi_ValidatorLCD.ino | 47 ---- .../MIDI_LibValidator/midi_ValidatorLEDs.h | 44 ---- .../MIDI_LibValidator/midi_ValidatorLEDs.ino | 10 - .../midi_ValidatorSerialDebug.h | 3 - .../midi_ValidatorSerialDebug.ino | 12 - .../MIDI_LibValidator/midi_ValidatorTester.h | 4 - .../midi_ValidatorTester.ino | 109 --------- .../MIDI_LibValidator/midi_ValidatorTests.h | 62 ----- .../MIDI_LibValidator/midi_ValidatorTests.ino | 229 ------------------ 14 files changed, 603 deletions(-) delete mode 100644 res/Examples/MIDI_LibValidator/MIDI_LibValidator.ino delete mode 100644 res/Examples/MIDI_LibValidator/fritzing/MIDI_LibValidator.fzz delete mode 100644 res/Examples/MIDI_LibValidator/midi_ValidatorInstances.h delete mode 100644 res/Examples/MIDI_LibValidator/midi_ValidatorInstances.ino delete mode 100644 res/Examples/MIDI_LibValidator/midi_ValidatorLCD.h delete mode 100644 res/Examples/MIDI_LibValidator/midi_ValidatorLCD.ino delete mode 100644 res/Examples/MIDI_LibValidator/midi_ValidatorLEDs.h delete mode 100644 res/Examples/MIDI_LibValidator/midi_ValidatorLEDs.ino delete mode 100644 res/Examples/MIDI_LibValidator/midi_ValidatorSerialDebug.h delete mode 100644 res/Examples/MIDI_LibValidator/midi_ValidatorSerialDebug.ino delete mode 100644 res/Examples/MIDI_LibValidator/midi_ValidatorTester.h delete mode 100644 res/Examples/MIDI_LibValidator/midi_ValidatorTester.ino delete mode 100644 res/Examples/MIDI_LibValidator/midi_ValidatorTests.h delete mode 100644 res/Examples/MIDI_LibValidator/midi_ValidatorTests.ino diff --git a/res/Examples/MIDI_LibValidator/MIDI_LibValidator.ino b/res/Examples/MIDI_LibValidator/MIDI_LibValidator.ino deleted file mode 100644 index a1f63e6..0000000 --- a/res/Examples/MIDI_LibValidator/MIDI_LibValidator.ino +++ /dev/null @@ -1,39 +0,0 @@ - -#include -#include -#include - -#include -#include "midi_ValidatorSerialDebug.h" -#include "midi_ValidatorLCD.h" -#include "midi_ValidatorLEDs.h" -#include "midi_ValidatorInstances.h" -#include "midi_ValidatorTester.h" - -// ----------------------------------------------------------------------------- - -void setup() -{ - setupSerialDebug(); - setupLCD(); - setupLEDs(); - setupTesters(); - Serial.println("Tester ready"); -} - -// ----------------------------------------------------------------------------- - -void loop() -{ - if (launchTests() == true) - { - setLedsFinal(true); - Serial.println("All tests passed."); - } - else - { - setLedsFinal(false); - Serial.println("Some tests failed!"); - } - while (true); -} diff --git a/res/Examples/MIDI_LibValidator/fritzing/MIDI_LibValidator.fzz b/res/Examples/MIDI_LibValidator/fritzing/MIDI_LibValidator.fzz deleted file mode 100644 index d344b8e453593a2d14c2145fad2ae11f12da9d75..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 11760 zcmZv?WmFtZv^9(dcXu1y-GbZT&fvk_Ey07k4ess)3lIqI9)bmTx8M%po#eUSx9*QS zvsTYkcdzd1>Qnpd+WV*}!ouM~K|vux#TrUTi1d~7Td_hx@if9g{oSi9FD?H;$<|EA z)WO!m)Wg}0&C2I2_YAx(kapiarH$#JG$2Z$cDyztt?hi{p*nweb2CdaFVf!dTuSpH zXGxki5!yoAa&0;w#~=gcQ|(cbgA_3b463f2q=z&Jrja#%FaJhNPRQrl`Gagir|P2z zUry}C9a7(`v1nKBD%voH^K;E zs=lO>tXtoHgJ*ajVzHaz-)!*TSd{=#EmRx3i9i>hu>3TsqkI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Bi%_!udY5eDpR5VoiLB>JeSQ?-DB~AQog{nM4K>6Lit&gm z$d^Uc5Cd@PKLfCRQ(v}* z2d~0)Hb6i(GlwHL&6jxShSBe1M3dp(NI=<_(G|$XS^98krtoAq#Xtb9=VZN-_UGeR zi-VUu; zSZhq9iCqc+RcdR4&Oz%QE}9pfrurtX+ZYWSxWElJ4j2C?S|>5qI6Yr zh}STFUltx-OR1LnPrAeg+m@PZMkMBhf$R4;UyOGcLQ`)S857Bcb!VcTz#&{EBci)M zm%B>k^@6D6G<4FH;#HbbRZRf@u#Z4q--wCndkRP6f41x%Qu*@a!jJpw%PQSJz3BdHzxf2Y~WC79Sh0{$3KkyqaKii-`=j z7MaU-k-4_a&)+tjgRiP@#rj1PPEkjBe -#include - -extern midi::MidiInterface midiHW; -extern midi::MidiInterface midiSW; - -void setupMidi(); diff --git a/res/Examples/MIDI_LibValidator/midi_ValidatorInstances.ino b/res/Examples/MIDI_LibValidator/midi_ValidatorInstances.ino deleted file mode 100644 index 31db157..0000000 --- a/res/Examples/MIDI_LibValidator/midi_ValidatorInstances.ino +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include "midi_ValidatorInstances.h" - -// ----------------------------------------------------------------------------- - -SoftwareSerial softSerial(10, 11); - -#if defined(__AVR_ATmega32U4__) // Leonardo uses Serial1 as hardware serial. - MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, midiHW); - MIDI_CREATE_INSTANCE(SoftwareSerial, softSerial, midiSW); -#else - MIDI_CREATE_INSTANCE(HardwareSerial, Serial, midiHW); - MIDI_CREATE_INSTANCE(SoftwareSerial, softSerial, midiSW); -#endif - -void setupMidi() -{ - while (!softSerial.isListening()) - softSerial.listen(); -} diff --git a/res/Examples/MIDI_LibValidator/midi_ValidatorLCD.h b/res/Examples/MIDI_LibValidator/midi_ValidatorLCD.h deleted file mode 100644 index a6319ce..0000000 --- a/res/Examples/MIDI_LibValidator/midi_ValidatorLCD.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include - -// ----------------------------------------------------------------------------- - -extern LiquidCrystal lcd; - -// ----------------------------------------------------------------------------- - -void setupLCD(); - -// ----------------------------------------------------------------------------- - -void setProgressBar(unsigned inProgress, unsigned inTotal); diff --git a/res/Examples/MIDI_LibValidator/midi_ValidatorLCD.ino b/res/Examples/MIDI_LibValidator/midi_ValidatorLCD.ino deleted file mode 100644 index 85e8265..0000000 --- a/res/Examples/MIDI_LibValidator/midi_ValidatorLCD.ino +++ /dev/null @@ -1,47 +0,0 @@ -#include -#include "midi_ValidatorLCD.h" - -#define LCD_D4 8 -#define LCD_D5 9 -#define LCD_D6 10 -#define LCD_D7 11 -#define LCD_RS 12 -#define LCD_EN 13 - -// ----------------------------------------------------------------------------- - -byte progressChar[6][8] = -{ - { B00000, B00000, B00000, B00000, B00000, B00000, B00000, B00000 }, - { B10000, B10000, B10000, B10000, B10000, B10000, B10000, B10000 }, - { B11000, B11000, B11000, B11000, B11000, B11000, B11000, B11000 }, - { B11100, B11100, B11100, B11100, B11100, B11100, B11100, B11100 }, - { B11110, B11110, B11110, B11110, B11110, B11110, B11110, B11110 }, - { B11111, B11111, B11111, B11111, B11111, B11111, B11111, B11111 }, -}; - -// ----------------------------------------------------------------------------- - -LiquidCrystal lcd(LCD_RS, LCD_EN, LCD_D4, LCD_D5, LCD_D6, LCD_D7); - -void setupLCD() -{ - for (byte i = 0; i < 6; ++i) - lcd.createChar(i, progressChar[i]); - - lcd.begin(16,2); -} - -// ----------------------------------------------------------------------------- - -void setProgressBar(unsigned inProgress, unsigned inTotal) -{ - const byte numCols = 16; - const byte numPix = 5; - const unsigned progress = (inProgress * numCols* numPix) / inTotal; - const byte cursorX = progress / numPix; - const byte charIndex = progress % numPix; - - lcd.setCursor(cursorX, 1); - lcd.write(charIndex); -} diff --git a/res/Examples/MIDI_LibValidator/midi_ValidatorLEDs.h b/res/Examples/MIDI_LibValidator/midi_ValidatorLEDs.h deleted file mode 100644 index be7deaa..0000000 --- a/res/Examples/MIDI_LibValidator/midi_ValidatorLEDs.h +++ /dev/null @@ -1,44 +0,0 @@ -#pragma once - -#define LED_PASS 4 -#define LED_FAIL 5 - -// ----------------------------------------------------------------------------- - -void setupLEDs(); - -// ----------------------------------------------------------------------------- - -inline void blinkLed(byte inLedNum) -{ - digitalWrite(inLedNum, HIGH); - delay(100); - digitalWrite(inLedNum, LOW); -} - -inline void blinkPass() -{ - blinkLed(LED_PASS); -} - -inline void blinkFail() -{ - blinkLed(LED_FAIL); -} - -inline void setLedsFinal(bool inSuccess) -{ - if (inSuccess) - { - digitalWrite(LED_PASS, HIGH); - digitalWrite(LED_FAIL, LOW); - } - else - { - digitalWrite(LED_FAIL, HIGH); - digitalWrite(LED_PASS, LOW); - } -} - -// ----------------------------------------------------------------------------- - diff --git a/res/Examples/MIDI_LibValidator/midi_ValidatorLEDs.ino b/res/Examples/MIDI_LibValidator/midi_ValidatorLEDs.ino deleted file mode 100644 index 616d72c..0000000 --- a/res/Examples/MIDI_LibValidator/midi_ValidatorLEDs.ino +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include "midi_ValidatorLEDs.h" - -// ----------------------------------------------------------------------------- - -void setupLEDs() -{ - pinMode(LED_PASS, OUTPUT); - pinMode(LED_FAIL, OUTPUT); -} diff --git a/res/Examples/MIDI_LibValidator/midi_ValidatorSerialDebug.h b/res/Examples/MIDI_LibValidator/midi_ValidatorSerialDebug.h deleted file mode 100644 index 1d8c3c0..0000000 --- a/res/Examples/MIDI_LibValidator/midi_ValidatorSerialDebug.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -void setupSerialDebug(); diff --git a/res/Examples/MIDI_LibValidator/midi_ValidatorSerialDebug.ino b/res/Examples/MIDI_LibValidator/midi_ValidatorSerialDebug.ino deleted file mode 100644 index 844fbe3..0000000 --- a/res/Examples/MIDI_LibValidator/midi_ValidatorSerialDebug.ino +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include "midi_ValidatorSerialDebug.h" - -void setupSerialDebug() -{ - Serial.begin(9600); - while (!Serial) - { - ; // wait for serial port to connect. Needed for Leonardo only - } -} - diff --git a/res/Examples/MIDI_LibValidator/midi_ValidatorTester.h b/res/Examples/MIDI_LibValidator/midi_ValidatorTester.h deleted file mode 100644 index 9098ee7..0000000 --- a/res/Examples/MIDI_LibValidator/midi_ValidatorTester.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -void setupTesters(); -bool launchTests(); diff --git a/res/Examples/MIDI_LibValidator/midi_ValidatorTester.ino b/res/Examples/MIDI_LibValidator/midi_ValidatorTester.ino deleted file mode 100644 index cf06660..0000000 --- a/res/Examples/MIDI_LibValidator/midi_ValidatorTester.ino +++ /dev/null @@ -1,109 +0,0 @@ -#include -#include "midi_ValidatorTester.h" -#include "midi_ValidatorInstances.h" -#include "midi_ValidatorTests.h" - -// ----------------------------------------------------------------------------- - -template -class Tester -{ -public: - typedef bool (*Functor) (MIDI_CLASS(SerialClass)&); - -public: - explicit Tester(MIDI_CLASS(SerialClass)& inInstance) - : mMidiInstance(inInstance) - , mProgress(0) - { - } - - void setup() - { - mProgress = 0; - mMidiInstance.begin(MIDI_CHANNEL_OMNI); - mMidiInstance.turnThruOff(); - } - -public: - inline bool performTest(Functor inTestMethod) - { - if (inTestMethod != 0) - { - const bool result = expect((*inTestMethod)(mMidiInstance)); - setProgressBar(++mProgress, NUM_TESTS); - return result; - } - return false; - } - - inline bool expect(bool inCondition) const - { - Serial.print(testNames[mProgress]); - Serial.print(": "); - if (inCondition == false) - { - Serial.println("Failed /!\\"); - blinkFail(); - } - else - { - Serial.println("Passed"); - blinkPass(); - } - return inCondition; - } - - bool run() - { - bool result = true; - result &= performTest(testNoteOn); - result &= performTest(testNoteOff); - result &= performTest(testControlChange); - result &= performTest(testProgramChange); - result &= performTest(testAftertouchMono); - result &= performTest(testAftertouchPoly); - result &= performTest(testPitchBend); - result &= performTest(testSysEx); - result &= performTest(testClock); - result &= performTest(testStart); - result &= performTest(testStop); - result &= performTest(testContinue); - result &= performTest(testActiveSensing); - result &= performTest(testTimeCode); - result &= performTest(testSongSelect); - result &= performTest(testSongPosition); - result &= performTest(testTuneRequest); - result &= performTest(testSystemReset); - return result; - } - -private: - MIDI_CLASS(SerialClass)& mMidiInstance; - unsigned mProgress; -}; - -// ----------------------------------------------------------------------------- - -Tester testerHW(midiHW); -Tester testerSW(midiSW); - -// ----------------------------------------------------------------------------- - -void setupTesters() -{ - testerHW.setup(); - testerSW.setup(); - setupMidi(); -} - -bool launchTests() -{ - Serial.println("Testing HW:"); - if (testerHW.run() == false) - return false; - Serial.println("Testing SW:"); - if (testerSW.run() == false) - return false; - return true; -} diff --git a/res/Examples/MIDI_LibValidator/midi_ValidatorTests.h b/res/Examples/MIDI_LibValidator/midi_ValidatorTests.h deleted file mode 100644 index 6319cfe..0000000 --- a/res/Examples/MIDI_LibValidator/midi_ValidatorTests.h +++ /dev/null @@ -1,62 +0,0 @@ -#pragma once - -// ----------------------------------------------------------------------------- - -#define NUM_TESTS 18 - -// ----------------------------------------------------------------------------- - -#define DECLARE_MIDI_TEST(Name) \ - template \ - bool Name(MIDI_CLASS(SerialClass)& inMidi) - -#define IMPLEMENT_MIDI_TEST(Name, Instance) \ - template \ - bool Name(MIDI_CLASS(SerialClass)& Instance) - -// ----------------------------------------------------------------------------- - -static const char * testNames[] = -{ - // 0123456789ABCDEF - "NoteOn ", - "NoteOff ", - "ControlChange ", - "ProgramChange ", - "AftertouchMono ", - "AftertouchPoly ", - "PitchBend ", - "SysEx ", - "Clock ", - "Start ", - "Stop ", - "Continue ", - "ActiveSensing ", - "TimeCode ", - "SongSelect ", - "SongPosition ", - "TuneRequest ", - "SystemReset ", -}; - -// ----------------------------------------------------------------------------- - -DECLARE_MIDI_TEST(testNoteOn); -DECLARE_MIDI_TEST(testNoteOff); -DECLARE_MIDI_TEST(testControlChange); -DECLARE_MIDI_TEST(testProgramChange); -DECLARE_MIDI_TEST(testAftertouchMono); -DECLARE_MIDI_TEST(testAftertouchPoly); -DECLARE_MIDI_TEST(testPitchBend); -DECLARE_MIDI_TEST(testSysEx); -DECLARE_MIDI_TEST(testClock); -DECLARE_MIDI_TEST(testStart); -DECLARE_MIDI_TEST(testStop); -DECLARE_MIDI_TEST(testContinue); -DECLARE_MIDI_TEST(testActiveSensing); -DECLARE_MIDI_TEST(testTimeCode); -DECLARE_MIDI_TEST(testSongSelect); -DECLARE_MIDI_TEST(testSongPosition); -DECLARE_MIDI_TEST(testTuneRequest); -DECLARE_MIDI_TEST(testSystemReset); - diff --git a/res/Examples/MIDI_LibValidator/midi_ValidatorTests.ino b/res/Examples/MIDI_LibValidator/midi_ValidatorTests.ino deleted file mode 100644 index e15b325..0000000 --- a/res/Examples/MIDI_LibValidator/midi_ValidatorTests.ino +++ /dev/null @@ -1,229 +0,0 @@ -#include -#include "midi_ValidatorTests.h" - -// ----------------------------------------------------------------------------- - -IMPLEMENT_MIDI_TEST(testNoteOn, inMidi) -{ - inMidi.sendNoteOn(12, 42, 3); - while (inMidi.read() == false) { } - - bool result = inMidi.getType() == midi::NoteOn && - inMidi.getData1() == 12 && - inMidi.getData2() == 42 && - inMidi.getChannel() == 3; - return result; -} - -IMPLEMENT_MIDI_TEST(testNoteOff, inMidi) -{ - inMidi.sendNoteOff(12, 42, 3); - while (inMidi.read() == false) { } - - bool result = inMidi.getType() == midi::NoteOff && - inMidi.getData1() == 12 && - inMidi.getData2() == 42 && - inMidi.getChannel() == 3; - return result; -} - -IMPLEMENT_MIDI_TEST(testControlChange, inMidi) -{ - inMidi.sendControlChange(12, 42, 3); - while (inMidi.read() == false) { } - - bool result = inMidi.getType() == midi::ControlChange && - inMidi.getData1() == 12 && - inMidi.getData2() == 42 && - inMidi.getChannel() == 3; - return result; -} - -IMPLEMENT_MIDI_TEST(testProgramChange, inMidi) -{ - inMidi.sendProgramChange(12, 3); - while (inMidi.read() == false) { } - - bool result = inMidi.getType() == midi::ProgramChange && - inMidi.getData1() == 12 && - inMidi.getData2() == 0 && - inMidi.getChannel() == 3; - return result; -} - -IMPLEMENT_MIDI_TEST(testAftertouchMono, inMidi) -{ - inMidi.sendAfterTouch(12, 3); - while (inMidi.read() == false) { } - - bool result = inMidi.getType() == midi::AfterTouchChannel && - inMidi.getData1() == 12 && - inMidi.getData2() == 0 && - inMidi.getChannel() == 3; - return result; -} - -IMPLEMENT_MIDI_TEST(testAftertouchPoly, inMidi) -{ - inMidi.sendPolyPressure(12, 42, 3); - while (inMidi.read() == false) { } - - bool result = inMidi.getType() == midi::AfterTouchPoly && - inMidi.getData1() == 12 && - inMidi.getData2() == 42 && - inMidi.getChannel() == 3; - return result; -} - -// ----------------------------------------------------------------------------- - -volatile int pitchBendMemory = 0; - -void pitchBendCallback(byte inChannel, int inValue) -{ - pitchBendMemory = inValue; -} - -IMPLEMENT_MIDI_TEST(testPitchBend, inMidi) -{ - inMidi.setHandlePitchBend(pitchBendCallback); - pitchBendMemory = 0; - inMidi.sendPitchBend((int)1234, 3); - while (inMidi.read() == false) { } - - bool result = inMidi.getType() == midi::PitchBend && - pitchBendMemory == 1234 && - inMidi.getChannel() == 3; - return result; -} - -// ----------------------------------------------------------------------------- - -IMPLEMENT_MIDI_TEST(testSysEx, inMidi) -{ - static const byte testData[13] = - { - 'H', 'e', 'l', 'l', 'o', ',', ' ', - 'w', 'o', 'r', 'l', 'd', 0 - }; - - inMidi.sendSysEx(13, testData); - - while (inMidi.read() == false) { } - - bool result = inMidi.getSysExArrayLength() == 15 && // 13 + F0 + F7 - memcmp((const char*)inMidi.getSysExArray()+1, - (const char*)testData, - 13) == 0; - return result; -} - -IMPLEMENT_MIDI_TEST(testClock, inMidi) -{ - inMidi.sendRealTime(midi::Clock); - while (inMidi.read() == false) { } - return inMidi.getType() == midi::Clock; -} - -IMPLEMENT_MIDI_TEST(testStart, inMidi) -{ - inMidi.sendRealTime(midi::Start); - while (inMidi.read() == false) { } - return inMidi.getType() == midi::Start; -} - -IMPLEMENT_MIDI_TEST(testStop, inMidi) -{ - inMidi.sendRealTime(midi::Stop); - while (inMidi.read() == false) { } - return inMidi.getType() == midi::Stop; -} - -IMPLEMENT_MIDI_TEST(testContinue, inMidi) -{ - inMidi.sendRealTime(midi::Continue); - while (inMidi.read() == false) { } - return inMidi.getType() == midi::Continue; -} - -IMPLEMENT_MIDI_TEST(testActiveSensing, inMidi) -{ - inMidi.sendRealTime(midi::ActiveSensing); - while (inMidi.read() == false) { } - return inMidi.getType() == midi::ActiveSensing; -} - -// ----------------------------------------------------------------------------- - -// \todo Add callback to process parsed value - -volatile byte timeCodeMemory = 0; - -void timeCodeCallback(byte inData) -{ - timeCodeMemory = inData; -} - -IMPLEMENT_MIDI_TEST(testTimeCode, inMidi) -{ - timeCodeMemory = 0; - inMidi.setHandleTimeCodeQuarterFrame(timeCodeCallback); - inMidi.sendTimeCodeQuarterFrame(0x07, 0x0F); - while (inMidi.read() == false) { } - bool result = inMidi.getType() == midi::TimeCodeQuarterFrame && - timeCodeMemory == 0x7F && - inMidi.getChannel() == 0; - return result; -} - -// ----------------------------------------------------------------------------- - -IMPLEMENT_MIDI_TEST(testSongSelect, inMidi) -{ - inMidi.sendSongSelect(12); - while (inMidi.read() == false) { } - - bool result = inMidi.getType() == midi::SongSelect && - inMidi.getData1() == 12 && - inMidi.getData2() == 0 && - inMidi.getChannel() == 0; - return result; -} - -// ----------------------------------------------------------------------------- - -volatile int songPositionMemory = 0; - -void songPositionCallback(unsigned int inPosition) -{ - songPositionMemory = inPosition; -} - -IMPLEMENT_MIDI_TEST(testSongPosition, inMidi) -{ - songPositionMemory = 0; - inMidi.setHandleSongPosition(songPositionCallback); - inMidi.sendSongPosition(12345); - while (inMidi.read() == false) { } - - bool result = inMidi.getType() == midi::SongPosition && - songPositionMemory == 12345 && - inMidi.getChannel() == 0; - return result; -} - -// ----------------------------------------------------------------------------- - -IMPLEMENT_MIDI_TEST(testTuneRequest, inMidi) -{ - inMidi.sendTuneRequest(); - while (inMidi.read() == false) { } - return inMidi.getType() == midi::TuneRequest; -} - -IMPLEMENT_MIDI_TEST(testSystemReset, inMidi) -{ - inMidi.sendRealTime(midi::SystemReset); - while (inMidi.read() == false) { } - return inMidi.getType() == midi::SystemReset; -} From 8541a2af1b8908c98aa7ee43b30e2ae6ed70c13c Mon Sep 17 00:00:00 2001 From: Francois Best Date: Thu, 10 Apr 2014 23:36:52 +0200 Subject: [PATCH 13/22] Bidirectionnal MIDI. --- res/validator/midi.py | 67 ++++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 27 deletions(-) diff --git a/res/validator/midi.py b/res/validator/midi.py index 764c09a..200f167 100644 --- a/res/validator/midi.py +++ b/res/validator/midi.py @@ -44,58 +44,71 @@ class Midi: class MidiInterface: def __init__(self, listenerCallback = None): - self.interface = rtmidi.MidiIn() + self.input = rtmidi.MidiIn() + self.output = rtmidi.MidiOut() self.listenerCallback = listenerCallback self.ports = self.getAvailablePorts() - self.port = self.connect(self.choosePort()) + self.port = self.connect(self.choosePorts()) # -------------------------------------------------------------------------- - def read(self): - pass - def handleMidiInput(self, message, timestamp): midiData = message[0] - print(midiData) if self.listenerCallback: self.listenerCallback(midiData) + def send(self, message): + print('Sending', message) + self.output.send_message(message) + # -------------------------------------------------------------------------- def getAvailablePorts(self): - return self.interface.get_ports() + return { + 'input' : self.input.get_ports(), + 'output': self.output.get_ports(), + } - def choosePort(self): - if not self.ports: + def choosePorts(self): + return { + 'input' : self.choosePort(self.ports['input'], 'input'), + 'output': self.choosePort(self.ports['output'], 'output') + } + + def choosePort(self, ports, direction): + if not ports: print('No MIDI ports available, bailing out.') return None - if len(self.ports) == 1: - return (0, self.ports[0]) + if len(ports) == 1: + return { + 'id': 0, + 'name': ports[0] + } else: # Give a choice - print('Multiple ports available, please make a choice:') - choices = [] - for port, i in zip(self.ports, range(0, len(self.ports))): - choices.append((i, port)) + print('Multiple %s ports available, please make a choice:' % direction) + choices = dict() + for port, i in zip(ports, range(0, len(ports))): + choices[i] = port print(' [%d]' % i, port) choiceIndex = int(input('-> ')) - return choices[choiceIndex] + return { + 'id': choiceIndex, + 'name': choices[choiceIndex] + } # -------------------------------------------------------------------------- - def connect(self, port): - if not port: + def connect(self, ports): + if not ports: return None - print(port) - print('Connecting to %s' % port[1]) - self.interface.set_callback(self.handleMidiInput) - self.interface.open_port(port[0]) - return port + print('Connecting input to %s' % ports['input']['name']) + print('Connecting output to %s' % ports['output']['name']) -midi = MidiInterface() - -while True: - midi.read() + self.input.set_callback(self.handleMidiInput) + self.input.open_port(ports['input']['id']) + self.output.open_port(ports['output']['id']) + return ports From dc30524b336781e08c52b130e14acc61f776ab2f Mon Sep 17 00:00:00 2001 From: Francois Best Date: Thu, 10 Apr 2014 23:37:09 +0200 Subject: [PATCH 14/22] Added tester object with thru check. --- res/validator/tester.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 res/validator/tester.py diff --git a/res/validator/tester.py b/res/validator/tester.py new file mode 100644 index 0000000..f360b80 --- /dev/null +++ b/res/validator/tester.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- + + +# ------------------------------------------------------------------------------ + +class Tester: + def __init__(self, interface): + self.interface = interface + self.sent = None + self.expected = None + self.received = None + + def handleMidiInput(self, data): + print('Recived data:', data) + self.received = data + + def checkThru(self, message): + self.interface.send(message) + self.sent = message + self.expected = message + self.received = None + while not self.received: + pass + return self.expected == self.received From e3dd2272e2d91fc9eedb90bb4a865dae20bd5a46 Mon Sep 17 00:00:00 2001 From: Francois Best Date: Thu, 10 Apr 2014 23:37:21 +0200 Subject: [PATCH 15/22] Testing. --- res/validator/validate.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/res/validator/validate.py b/res/validator/validate.py index 25b386d..bef9f9e 100644 --- a/res/validator/validate.py +++ b/res/validator/validate.py @@ -4,7 +4,9 @@ import sys import os import shutil import subprocess -from pprint import pprint +from pprint import pprint +from midi import * +from tester import * # ------------------------------------------------------------------------------ @@ -136,12 +138,20 @@ class ArduinoMidiLibrary: # ------------------------------------------------------------------------------ def main(): - lib = ArduinoMidiLibrary() - lib.install() - if lib.validate(): - print('Validation passed') - else: - print('Validation failed') + midiInterface = MidiInterface() + tester = Tester(midiInterface) + midiInterface.listenerCallback = tester.handleMidiInput + + tester.checkThru([Midi.NoteOn, 64, 80]) + + #lib = ArduinoMidiLibrary() + #lib.install() + #if lib.validate(): + # print('Validation passed') + #else: + # print('Validation failed') + + # ------------------------------------------------------------------------------ From 63517510b8d241d424e7b01136ade1594ad67d80 Mon Sep 17 00:00:00 2001 From: Francois Best Date: Wed, 16 Apr 2014 08:23:10 +0200 Subject: [PATCH 16/22] Fixed 1byte running status bug (GitHub issue #12) --- src/MIDI.hpp | 51 +++++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/src/MIDI.hpp b/src/MIDI.hpp index 264eeaa..f6995de 100644 --- a/src/MIDI.hpp +++ b/src/MIDI.hpp @@ -547,29 +547,11 @@ bool MidiInterface::parse() // Else: well, we received another status byte, // so the running status does not apply here. // It will be updated upon completion of this message. - - if (mPendingMessageIndex >= (mPendingMessageExpectedLenght - 1)) - { - mMessage.type = getTypeFromStatusByte(mPendingMessage[0]); - mMessage.channel = getChannelFromStatusByte(mPendingMessage[0]); - mMessage.data1 = mPendingMessage[1]; - - // Save data2 only if applicable - if (mPendingMessageExpectedLenght == 3) - mMessage.data2 = mPendingMessage[2]; - else - mMessage.data2 = 0; - - mPendingMessageIndex = 0; - mPendingMessageExpectedLenght = 0; - mMessage.valid = true; - return true; - } } switch (getTypeFromStatusByte(mPendingMessage[0])) { - // 1 byte messages + // 1 byte messages case Start: case Continue: case Stop: @@ -629,17 +611,38 @@ bool MidiInterface::parse() break; } - // Then update the index of the pending message. - mPendingMessageIndex++; + if (mPendingMessageIndex >= (mPendingMessageExpectedLenght - 1)) + { + // Reception complete + mMessage.type = getTypeFromStatusByte(mPendingMessage[0]); + mMessage.channel = getChannelFromStatusByte(mPendingMessage[0]); + mMessage.data1 = mPendingMessage[1]; -#if USE_1BYTE_PARSING + // Save data2 only if applicable + if (mPendingMessageExpectedLenght == 3) + mMessage.data2 = mPendingMessage[2]; + else + mMessage.data2 = 0; + + mPendingMessageIndex = 0; + mPendingMessageExpectedLenght = 0; + mMessage.valid = true; + return true; + } + else + { + // Waiting for more data + mPendingMessageIndex++; + } + + #if USE_1BYTE_PARSING // Message is not complete. return false; -#else + #else // Call the parser recursively // to parse the rest of the message. return parse(); -#endif + #endif } else From 18130947350b1a1b8c9ce2f47bbf47dbc3c4c6d9 Mon Sep 17 00:00:00 2001 From: Francois Best Date: Wed, 16 Apr 2014 08:33:38 +0200 Subject: [PATCH 17/22] Cleanup --- src/MIDI.hpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/MIDI.hpp b/src/MIDI.hpp index 264eeaa..bb315eb 100644 --- a/src/MIDI.hpp +++ b/src/MIDI.hpp @@ -509,9 +509,7 @@ inline bool MidiInterface::read(Channel inChannel) template bool MidiInterface::parse() { - const byte bytes_available = mSerial.available(); - - if (bytes_available == 0) + if (mSerial.available() == 0) // No data available. return false; @@ -779,9 +777,6 @@ bool MidiInterface::parse() #endif } } - - // What are our chances to fall here? - return false; } // Private method, see midi_Settings.h for documentation From 217d0838baeab29802f96783f1c91b6331075298 Mon Sep 17 00:00:00 2001 From: Francois Best Date: Wed, 16 Apr 2014 08:34:02 +0200 Subject: [PATCH 18/22] Ignoring python stuff. --- arduino_midi_library.sublime-project | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arduino_midi_library.sublime-project b/arduino_midi_library.sublime-project index 68198ce..2778d82 100644 --- a/arduino_midi_library.sublime-project +++ b/arduino_midi_library.sublime-project @@ -2,7 +2,9 @@ "folders": [ { - "path": "." + "path": ".", + "folder_exclude_patterns": [".*", "__pycache__"], + "file_exclude_patterns": [".*"] } ], "build_systems": From d458dac71ab54f7b3b560a7228dd07d0c24bbdec Mon Sep 17 00:00:00 2001 From: Francois Best Date: Wed, 16 Apr 2014 08:34:21 +0200 Subject: [PATCH 19/22] Testing for the 1byte running status bug. --- res/validator/validate.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/res/validator/validate.py b/res/validator/validate.py index bef9f9e..72c97d8 100644 --- a/res/validator/validate.py +++ b/res/validator/validate.py @@ -143,6 +143,14 @@ def main(): midiInterface.listenerCallback = tester.handleMidiInput tester.checkThru([Midi.NoteOn, 64, 80]) + tester.checkThru([Midi.AfterTouchChannel, 1]) + tester.checkThru([2]) + tester.checkThru([3]) + tester.checkThru([Midi.NoteOn, 64, 0]) + tester.checkThru([65, 127]) + tester.checkThru([65, 0]) + tester.checkThru([66, 127]) + tester.checkThru([66, 0]) #lib = ArduinoMidiLibrary() #lib.install() From a615b53b1b7513e8d0ea340382a94dad78cc4d50 Mon Sep 17 00:00:00 2001 From: Francois Best Date: Wed, 16 Apr 2014 08:40:49 +0200 Subject: [PATCH 20/22] Updated docs. --- README.md | 7 ++++--- arduino-playground.md | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 60b6311..d256d7a 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -#Arduino MIDI Library v4.0 +#Arduino MIDI Library v4.1 This library enables MIDI I/O communications on the Arduino serial ports. The purpose of this library is not to make a big synthetizer out of an Arduino board, the application remains yours. However, it will help you interfacing it with other MIDI devices. -Download the latest version [here](https://github.com/FortySevenEffects/arduino_midi_library/releases/download/4.0/Arduino_MIDI_Library_v4.0.zip). +Download the latest version [here](https://github.com/FortySevenEffects/arduino_midi_library/releases/download/4.1/Arduino_MIDI_Library_v4.1.zip). ### Features * Compatible with all Arduino boards (and clones with an AVR processor) @@ -18,6 +18,7 @@ Download the latest version [here](https://github.com/FortySevenEffects/arduino_ #### Changelog +* 16/04/2014 : Version 4.1 released. Bug fixes regarding running status. * 13/02/2014 : Version 4.0 released. Moved to GitHub, added multiple instances & software serial support, and a few bug fixes. * 29/01/2012 : Version 3.2 released. Release notes are [here](http://sourceforge.net/news/?group_id=265194) * 06/05/2011 : Version 3.1 released. Added [callback](http://playground.arduino.cc/Main/MIDILibraryCallbacks) support. @@ -34,7 +35,7 @@ Download the latest version [here](https://github.com/FortySevenEffects/arduino_ ### What do I need to do? -* Download the library ([link](https://github.com/FortySevenEffects/arduino_midi_library/releases/download/4.0/Arduino_MIDI_Library_v4.0.zip)) +* Download the library ([link](https://github.com/FortySevenEffects/arduino_midi_library/releases/download/4.1/Arduino_MIDI_Library_v4.1.zip)) * Follow the installation instructions there: http://arduino.cc/en/Guide/Libraries * Include the library in your sketch using the menu in the IDE, or type `#include ` diff --git a/arduino-playground.md b/arduino-playground.md index 4f5228a..b68cd95 100644 --- a/arduino-playground.md +++ b/arduino-playground.md @@ -1,8 +1,8 @@ -!!MIDI Library v4.0 +!!MIDI Library v4.1 This library enables MIDI I/O communications on the Arduino serial ports. You can send and receive messages of all kinds (including System Exclusive, RealTime etc..). The purpose of this library is not to make a big synthetizer out of an Arduino board, the application remains yours. However, it will help you interfacing it with other MIDI devices. -Download the latest version [[ https://github.com/FortySevenEffects/arduino_midi_library/releases/download/4.0/Arduino_MIDI_Library_v4.0.zip | here ]]. +Download the latest version [[ https://github.com/FortySevenEffects/arduino_midi_library/releases/download/4.1/Arduino_MIDI_Library_v4.1.zip | here ]]. You can now follow the developments on [[ http://github.com/FortySevenEffects/arduino_midi_library/ | GitHub]]. @@ -20,6 +20,7 @@ You can now follow the developments on [[ http://github.com/FortySevenEffects/ar !!!!Changelog: +* 16/04/2014 : Version 4.1 released. Bug fixes regarding running status. * 13/02/2014 : Version 4.0 released. Moved to GitHub, added multiple instances & software serial support, and a few bug fixes. * 29/01/2012 : Version 3.2 released. Release notes are [[ http://sourceforge.net/news/?group_id=265194 | here ]] * 06/05/2011 : Version 3.1 released. Added [[ http://playground.arduino.cc/Main/MIDILibraryCallbacks | callback]] support. @@ -34,7 +35,7 @@ You can now follow the developments on [[ http://github.com/FortySevenEffects/ar !!!What do I need to do? -* Download the library ([[ https://github.com/FortySevenEffects/arduino_midi_library/releases/download/4.0/Arduino_MIDI_Library_v4.0.zip | link ]]) +* Download the library ([[ https://github.com/FortySevenEffects/arduino_midi_library/releases/download/4.1/Arduino_MIDI_Library_v4.1.zip | link ]]) * Follow the installation instructions there: http://arduino.cc/en/Guide/Libraries * Include the library in your sketch using the menu in the IDE, or type [@#include @] From c6537872b09ab78ffcbb3756649372866ff8cc75 Mon Sep 17 00:00:00 2001 From: Francois Best Date: Wed, 16 Apr 2014 08:52:33 +0200 Subject: [PATCH 21/22] Reworked packaging script. --- .gitignore | 1 + res/packaging | 50 ------------------------------------------- res/packaging.command | 36 +++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 50 deletions(-) delete mode 100755 res/packaging create mode 100755 res/packaging.command diff --git a/.gitignore b/.gitignore index d44cbfe..6681cf4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.sublime-workspace *.pyc logs/ +build/ diff --git a/res/packaging b/res/packaging deleted file mode 100755 index 33ee9c3..0000000 --- a/res/packaging +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash -# -# Generate an archive with packaged content for easier delivery. -# The generated archive contains: -# - Source files (MIDI.cpp / MIDI.h) -# - Resources (keywords.txt) -# - Documentation (Doxygen) -# - Examples for Arduino IDE -# - Installation scripts - - -# Create a temporary destination folder -mkdir -p temp/doc -mkdir -p temp/examples - -# Copy sources -cp ../src/* temp - -# Copy resources -cp keywords.txt temp -cp install_* temp -rm temp/install_local_* - -# Copy examples -cp -r examples/* temp/examples - -# Generate & copy doc -cd ../doc -/Applications/Doxygen.app/Contents/Resources/doxygen Doxyfile -rm -rf latex -cd ../res - -cp -r ../doc/* temp/doc - -# Generate package -mv temp MIDI -zip -r MIDI.zip MIDI - - -# Remove temp folder -rm -rf MIDI - -# Archive generated packaged - -if [[ !( -d ../bin ) ]] -then - mkdir ../bin # Create archives location -fi - -mv MIDI.zip ../bin/Arduino_MIDI_Library.zip diff --git a/res/packaging.command b/res/packaging.command new file mode 100755 index 0000000..5f6a7e8 --- /dev/null +++ b/res/packaging.command @@ -0,0 +1,36 @@ +#!/bin/sh +# +# Generate an archive with packaged content for easier delivery. +# The generated archive contains: +# - Source files (MIDI.cpp / MIDI.h) +# - Resources (keywords.txt) +# - Examples for Arduino IDE +# - Installation scripts + +cd "`dirname "${0}"`" + +root="${PWD}/.." +build="$root/build/MIDI" + +echo root $root +echo build $build + +# Create a temporary destination folder +mkdir -p "$build" +mkdir -p "$build/examples" + +# Copy sources +cd "$root/src/" +cp * "$build/" + +# Copy resources +cd "$root/res/" +cp keywords.txt "$build/" + +# Copy examples +cd "$root/res/examples/" +cp -r * "$build/examples" + +# Generate package +cd "$build/.." +zip -r Arduino_MIDI_Library.zip MIDI From d13353a5b637b6d2082351271a7dae52a481e652 Mon Sep 17 00:00:00 2001 From: Francois Best Date: Wed, 16 Apr 2014 08:53:43 +0200 Subject: [PATCH 22/22] Removed outdated scripts. --- res/install_local_mac | 41 ----------------------------------------- res/install_mac | 37 ------------------------------------- 2 files changed, 78 deletions(-) delete mode 100755 res/install_local_mac delete mode 100755 res/install_mac diff --git a/res/install_local_mac b/res/install_local_mac deleted file mode 100755 index cf72e3a..0000000 --- a/res/install_local_mac +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -# Use this script to install the library directy from the git clone. - - -if [[ -d /Applications/Arduino.app ]] -then - - # Define locations - - lib_path=/Applications/Arduino.app/Contents/Resources/Java/libraries/MIDI - - if [[ -d $lib_path ]] - then - # Remove old lib - rm -rf $lib_path - fi - - # Create folder - mkdir $lib_path - - # Copy sources - cp ../src/MIDI.cpp $lib_path - cp ../src/MIDI.h $lib_path - cp ../src/midi_* $lib_path - - # Copy resources - cp ../res/keywords.txt $lib_path - - # Copy examples - mkdir $lib_path/examples - - cp -r examples/* $lib_path/examples - - # Copy doc - mkdir $lib_path/doc - - cp -r ../doc/* $lib_path/doc - -else - echo "Arduino application not found." -fi diff --git a/res/install_mac b/res/install_mac deleted file mode 100755 index b94a610..0000000 --- a/res/install_mac +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash -# This script installs the Arduino MIDI Library into the Arduino application, -# so that every sketch can include it directly, without having to copy anything. -# -# To install the library, run this script by double-clicking it, -# it should be directly executable and seen as such by Mac OS X. -# If not, open a terminal, cd to the script location, and run ./install_mac -# -# Open the Arduino IDE, and you're ready to go! - -# The script assumes the Arduino application -# is installed in the default location. - -if [[ -d /Applications/Arduino.app ]] -then - - # Define locations - lib_path=/Applications/Arduino.app/Contents/Resources/Java/libraries/MIDI - - if [[ -d $lib_path ]] - then - # Remove old lib - rm -rf $lib_path - fi - - # Create folder - mkdir $lib_path - - # Install contents - cp -r * $lib_path - - # Cleanup - rm $lib_path/install_mac - -else - echo "Arduino application not found." -fi