BLE MIDI

Dependencies:   BLE_API mbed nRF51822

Committer:
niklasjakob
Date:
Mon Jun 12 17:12:31 2017 +0000
Revision:
0:7de36d52cfef
BLE MIDI BRIDGE TEST

Who changed what in which revision?

UserRevisionLine numberNew contents of line
niklasjakob 0:7de36d52cfef 1
niklasjakob 0:7de36d52cfef 2 /*
niklasjakob 0:7de36d52cfef 3 * Copyright (c) 2016 Samuele Cornell
niklasjakob 0:7de36d52cfef 4 *
niklasjakob 0:7de36d52cfef 5 * Permission is hereby granted, free of charge, to any person obtaining a copy
niklasjakob 0:7de36d52cfef 6 * of this software and associated documentation files (the "Software"), to deal
niklasjakob 0:7de36d52cfef 7 * in the Software without restriction, including without limitation the rights
niklasjakob 0:7de36d52cfef 8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
niklasjakob 0:7de36d52cfef 9 * copies of the Software, and to permit persons to whom the Software is
niklasjakob 0:7de36d52cfef 10 * furnished to do so, subject to the following conditions:
niklasjakob 0:7de36d52cfef 11 *
niklasjakob 0:7de36d52cfef 12 * The above copyright notice and this permission notice shall be included in all
niklasjakob 0:7de36d52cfef 13 * copies or substantial portions of the Software.
niklasjakob 0:7de36d52cfef 14 *
niklasjakob 0:7de36d52cfef 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
niklasjakob 0:7de36d52cfef 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
niklasjakob 0:7de36d52cfef 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
niklasjakob 0:7de36d52cfef 18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
niklasjakob 0:7de36d52cfef 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
niklasjakob 0:7de36d52cfef 20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
niklasjakob 0:7de36d52cfef 21 * SOFTWARE.
niklasjakob 0:7de36d52cfef 22 *
niklasjakob 0:7de36d52cfef 23 */
niklasjakob 0:7de36d52cfef 24
niklasjakob 0:7de36d52cfef 25 #define UART_RX_PIN USBRX// RX UART Pin
niklasjakob 0:7de36d52cfef 26
niklasjakob 0:7de36d52cfef 27 #define UART_TX_PIN USBTX// TX UART Pin
niklasjakob 0:7de36d52cfef 28
niklasjakob 0:7de36d52cfef 29 // i have used DFRobot MIDI Shield but there are other commercially available similar products, also it is possible to interface directly a MIDI cable via an optocoupler (several projects are already available online )
niklasjakob 0:7de36d52cfef 30
niklasjakob 0:7de36d52cfef 31 #define LIGHT_SHOW 1 // 0 if visual feedback isn't needed (saves energy )
niklasjakob 0:7de36d52cfef 32
niklasjakob 0:7de36d52cfef 33 #define TX_LED D6 // the state of this led will change whenever a message is to be sent over ble-midi
niklasjakob 0:7de36d52cfef 34
niklasjakob 0:7de36d52cfef 35 #define RX_LED D7 // the state of this led will change whenever a message received over ble-midi
niklasjakob 0:7de36d52cfef 36
niklasjakob 0:7de36d52cfef 37
niklasjakob 0:7de36d52cfef 38 /*******************************************************************************************************
niklasjakob 0:7de36d52cfef 39 PERFORMANCE TWEAKS
niklasjakob 0:7de36d52cfef 40 *******************************************************************************************************/
niklasjakob 0:7de36d52cfef 41
niklasjakob 0:7de36d52cfef 42
niklasjakob 0:7de36d52cfef 43 #define BUFSERIAL_LENGHT 256 // define the software circular buffer lenght used for the UART.
niklasjakob 0:7de36d52cfef 44
niklasjakob 0:7de36d52cfef 45
niklasjakob 0:7de36d52cfef 46 #define ONLY_MIDI_to_BLEMIDI 1 // if only unidirectional MIDI to BLE-MIDI is desired set this to 1
niklasjakob 0:7de36d52cfef 47
niklasjakob 0:7de36d52cfef 48
niklasjakob 0:7de36d52cfef 49 #define ONLY_BLEMIDI_to_MIDI 1 // if only unidirectional BLE-MIDI to MIDI is desired set this to 1
niklasjakob 0:7de36d52cfef 50
niklasjakob 0:7de36d52cfef 51 // unidirectional operation allows to save energy. It also leads to better performance as if ONLY MIDI to BLE MIDI is required, for example it is possible to shorten the SENDBLE_INTERVAL
niklasjakob 0:7de36d52cfef 52 // without reliability issues (to a certain extent).
niklasjakob 0:7de36d52cfef 53
niklasjakob 0:7de36d52cfef 54 #define SENDBLEMIDI_INTERVAL 0.01 // this defines how frequently MIDI Events from the UART are polled, parsed and then sent via BLE-MIDI.
niklasjakob 0:7de36d52cfef 55 // a lower value means less latency but it also increase energy comsuption and if is set too low can cause reliability issues in MIDI to BLE-MIDI operation (especially for long SysEx messages).
niklasjakob 0:7de36d52cfef 56
niklasjakob 0:7de36d52cfef 57
niklasjakob 0:7de36d52cfef 58 /***************************************************************************************************************
niklasjakob 0:7de36d52cfef 59 CONNECTION PARAMETERS
niklasjakob 0:7de36d52cfef 60 ***************************************************************************************************************/
niklasjakob 0:7de36d52cfef 61
niklasjakob 0:7de36d52cfef 62 namespace Config {
niklasjakob 0:7de36d52cfef 63
niklasjakob 0:7de36d52cfef 64 //
niklasjakob 0:7de36d52cfef 65 const int minConnectionInterval = 6; // (1.25 ms units)
niklasjakob 0:7de36d52cfef 66 const int maxConnectionInterval = 15; // (1.25 ms units)
niklasjakob 0:7de36d52cfef 67 const int slaveLatency = 0;
niklasjakob 0:7de36d52cfef 68 const int supervisionTimeout = 500; // (10 ms units)
niklasjakob 0:7de36d52cfef 69
niklasjakob 0:7de36d52cfef 70
niklasjakob 0:7de36d52cfef 71
niklasjakob 0:7de36d52cfef 72 }