From c4a4db9de7e19a3a03cb9d3b0aba40988d82b32c Mon Sep 17 00:00:00 2001 From: Francois Best Date: Wed, 23 May 2012 00:32:56 +0200 Subject: [PATCH 1/4] Added doc. --- res/install_local_mac | 2 ++ res/install_mac | 12 +++++++++++- res/packaging | 9 +++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/res/install_local_mac b/res/install_local_mac index bf517cc..5f9376c 100755 --- a/res/install_local_mac +++ b/res/install_local_mac @@ -1,4 +1,6 @@ #!/bin/bash +# Use this script to install the library directy from the git clone. + if [[ -d /Applications/Arduino.app ]] then diff --git a/res/install_mac b/res/install_mac index 9eaeac1..4e6659a 100755 --- a/res/install_mac +++ b/res/install_mac @@ -1,10 +1,20 @@ #!/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 ]] diff --git a/res/packaging b/res/packaging index dbad4b8..33ee9c3 100755 --- a/res/packaging +++ b/res/packaging @@ -1,4 +1,13 @@ #!/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 From 7a59d08f5528fd927a0ca899f7a74823bc663975 Mon Sep 17 00:00:00 2001 From: Francois Best Date: Wed, 23 May 2012 01:03:59 +0200 Subject: [PATCH 2/4] Fixed directory copy for doc. --- res/install_local_mac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/install_local_mac b/res/install_local_mac index 5f9376c..9b870bf 100755 --- a/res/install_local_mac +++ b/res/install_local_mac @@ -33,7 +33,7 @@ then # Copy doc mkdir $lib_path/doc - cp ../doc/* $lib_path/doc + cp -r ../doc/* $lib_path/doc else echo "Arduino application not found." From 65b5db2362cbde4679c67c8bec99da9627df370a Mon Sep 17 00:00:00 2001 From: Francois Best Date: Wed, 23 May 2012 01:51:12 +0200 Subject: [PATCH 3/4] Fixed script name. --- res/install_mac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/install_mac b/res/install_mac index 4e6659a..b94a610 100755 --- a/res/install_mac +++ b/res/install_mac @@ -30,7 +30,7 @@ then cp -r * $lib_path # Cleanup - rm $lib_path/install_mac.sh + rm $lib_path/install_mac else echo "Arduino application not found." From cfe39e04aad660f4019bc3c2f84a0da827922e88 Mon Sep 17 00:00:00 2001 From: Francois Best Date: Fri, 25 May 2012 14:32:55 +0200 Subject: [PATCH 4/4] Removed pitchBend method using unsigned interface, as it conflicted with the signed. Added macros for min and max, so that it's easier to use. --- src/MIDI.cpp | 24 +++++------------------- src/MIDI.h | 5 ++++- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/src/MIDI.cpp b/src/MIDI.cpp index 9517f99..5908157 100644 --- a/src/MIDI.cpp +++ b/src/MIDI.cpp @@ -299,31 +299,17 @@ void MIDI_Class::sendAfterTouch(byte Pressure, /*! \brief Send a Pitch Bend message using a signed integer value. \param PitchValue The amount of bend to send (in a signed integer format), - between -8192 (maximum downwards bend) - and 8191 (max upwards bend), center value is 0. + between MIDI_PITCHBEND_MIN and MIDI_PITCHBEND_MAX, + center value is 0. \param Channel The channel on which the message will be sent (1 to 16). */ void MIDI_Class::sendPitchBend(int PitchValue, byte Channel) { - unsigned int bend = PitchValue + 8192; - sendPitchBend(bend,Channel); + unsigned int bend = PitchValue - MIDI_PITCHBEND_MIN; -} - - -/*! \brief Send a Pitch Bend message using an unsigned integer value. - \param PitchValue The amount of bend to send (in a signed integer format), - between 0 (maximum downwards bend) - and 16383 (max upwards bend), center value is 8192. - \param Channel The channel on which the message will be sent (1 to 16). - */ -void MIDI_Class::sendPitchBend(unsigned int PitchValue, - byte Channel) -{ - - send(PitchBend,(PitchValue & 0x7F),(PitchValue >> 7) & 0x7F,Channel); + send(PitchBend,(bend & 0x7F),(bend >> 7) & 0x7F,Channel); } @@ -1047,7 +1033,7 @@ void MIDI_Class::launchCallback() // Continuous controllers case ControlChange: if (mControlChangeCallback != NULL) mControlChangeCallback(mMessage.channel,mMessage.data1,mMessage.data2); break; - case PitchBend: if (mPitchBendCallback != NULL) mPitchBendCallback(mMessage.channel,(int)((mMessage.data1 & 0x7F) | ((mMessage.data2 & 0x7F)<< 7)) - 8192); break; // TODO: check this + case PitchBend: if (mPitchBendCallback != NULL) mPitchBendCallback(mMessage.channel,(int)((mMessage.data1 & 0x7F) | ((mMessage.data2 & 0x7F)<< 7)) + MIDI_PITCHBEND_MIN); break; // TODO: check this case AfterTouchPoly: if (mAfterTouchPolyCallback != NULL) mAfterTouchPolyCallback(mMessage.channel,mMessage.data1,mMessage.data2); break; case AfterTouchChannel: if (mAfterTouchChannelCallback != NULL) mAfterTouchChannelCallback(mMessage.channel,mMessage.data1); break; diff --git a/src/MIDI.h b/src/MIDI.h index 58ea2f2..6263d90 100644 --- a/src/MIDI.h +++ b/src/MIDI.h @@ -63,6 +63,10 @@ #define MIDI_SYSEX_ARRAY_SIZE 255 // Maximum size is 65535 bytes. +#define MIDI_PITCHBEND_MIN -8192 +#define MIDI_PITCHBEND_MAX 8191 + + /*! Type definition for practical use (because "unsigned char" is a bit long to write.. ) @@ -179,7 +183,6 @@ public: void sendProgramChange(byte ProgramNumber,byte Channel); void sendControlChange(byte ControlNumber, byte ControlValue,byte Channel); void sendPitchBend(int PitchValue,byte Channel); - void sendPitchBend(unsigned int PitchValue,byte Channel); void sendPitchBend(double PitchValue,byte Channel); void sendPolyPressure(byte NoteNumber,byte Pressure,byte Channel); void sendAfterTouch(byte Pressure,byte Channel);