Compare commits
No commits in common. "master" and "dev" have entirely different histories.
|
|
@ -1,66 +0,0 @@
|
||||||
---
|
|
||||||
name: Bug report
|
|
||||||
about: Report something that does not work as intended
|
|
||||||
title: ''
|
|
||||||
labels: bug
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
<!--
|
|
||||||
Before opening an issue, check if your problem already has been solved by looking in:
|
|
||||||
- The existing issues: https://github.com/FortySevenEffects/arduino_midi_library/issues
|
|
||||||
- The discussions: https://github.com/FortySevenEffects/arduino_midi_library/discussions
|
|
||||||
|
|
||||||
Consider opening a discussion instead of an issue if you need help with your project:
|
|
||||||
https://github.com/FortySevenEffects/arduino_midi_library/discussions/new
|
|
||||||
-->
|
|
||||||
|
|
||||||
## Context
|
|
||||||
|
|
||||||
Please answer a few questions to help us understand your problem better and guide you to a solution:
|
|
||||||
|
|
||||||
<!-- Tip: place the letter x in the checkboxes to tick them:
|
|
||||||
- [ ] Unticked checkbox
|
|
||||||
- [x] Ticked checkbox
|
|
||||||
|
|
||||||
You can also tick them by clicking after you've submitted your issue.
|
|
||||||
-->
|
|
||||||
|
|
||||||
- What board are you using ?
|
|
||||||
- `example: Arduino Leonardo`
|
|
||||||
- _Please list any shields or other **relevant** hardware you're using_
|
|
||||||
- What version of the Arduino IDE are you using ?
|
|
||||||
- `example: 1.8.5`
|
|
||||||
- How are you using MIDI ?
|
|
||||||
- [ ] Hardware Serial (DIN plugs)
|
|
||||||
- [ ] USB
|
|
||||||
- [ ] Other (please specify)
|
|
||||||
- Is your problem related to:
|
|
||||||
- [ ] MIDI Input (reading messages from other devices)
|
|
||||||
- [ ] MIDI Output (sending messages to other devices)
|
|
||||||
- How comfortable are you with code ?
|
|
||||||
- [ ] Complete beginner
|
|
||||||
- [ ] I've done basic projects
|
|
||||||
- [ ] I know my way around C/C++
|
|
||||||
- [ ] Advanced / professional
|
|
||||||
|
|
||||||
## Describe your project and what you expect to happen:
|
|
||||||
|
|
||||||
<!--
|
|
||||||
Example: When I press a switch on my pedalboard, it sends a SysEx message that I'd like to receive on my Arduino.
|
|
||||||
|
|
||||||
Note: Attachments (circuit diagrams, code examples) are most welcome and will help us understand your needs better and find a suitable solution for your issue.
|
|
||||||
-->
|
|
||||||
|
|
||||||
## Describe your problem (what does not work):
|
|
||||||
|
|
||||||
<!--
|
|
||||||
Example: I cannot receive SysEx messages coming from my AxeFX 2
|
|
||||||
-->
|
|
||||||
|
|
||||||
## Steps to reproduce
|
|
||||||
|
|
||||||
<!--
|
|
||||||
Please list the steps you took to hit the problem, so we can try and reproduce it.
|
|
||||||
-->
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
blank_issues_enabled: false
|
|
||||||
contact_links:
|
|
||||||
- name: Discussions
|
|
||||||
url: https://github.com/FortySevenEffects/arduino_midi_library/discussions
|
|
||||||
about: Not a bug or a feature request ? Discuss your problem, ask for help or show what you've built in Discussions.
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
---
|
|
||||||
name: Feature request
|
|
||||||
about: Suggest an idea for this project
|
|
||||||
title: ''
|
|
||||||
labels: new feature
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**Is your feature request related to a problem? Please describe.**
|
|
||||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
||||||
|
|
||||||
**Describe the solution you'd like**
|
|
||||||
A clear and concise description of what you want to happen.
|
|
||||||
|
|
||||||
**Describe alternatives you've considered**
|
|
||||||
A clear and concise description of any alternative solutions or features you've considered.
|
|
||||||
|
|
||||||
**Additional context**
|
|
||||||
Add any other context or screenshots about the feature request here.
|
|
||||||
|
|
@ -1,59 +0,0 @@
|
||||||
name: CMake
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
pull_request:
|
|
||||||
branches: [ master ]
|
|
||||||
|
|
||||||
env:
|
|
||||||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
|
||||||
BUILD_TYPE: Debug
|
|
||||||
GENERATE_COVERAGE: true
|
|
||||||
LCOV_ROOT: ${{github.workspace}}/lcov
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
# The CMake configure and build commands are platform agnostic and should work equally
|
|
||||||
# well on Windows or Mac. You can convert this to a matrix build if you need
|
|
||||||
# cross-platform coverage.
|
|
||||||
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
submodules: recursive
|
|
||||||
|
|
||||||
- name: Install lcov
|
|
||||||
run: |
|
|
||||||
mkdir -p "$LCOV_ROOT"
|
|
||||||
wget https://github.com/linux-test-project/lcov/releases/download/v1.15/lcov-1.15.tar.gz --output-document="$LCOV_ROOT/lcov.tar.gz"
|
|
||||||
tar -xf "$LCOV_ROOT/lcov.tar.gz" --strip-components=1 -C "$LCOV_ROOT"
|
|
||||||
echo "$LCOV_ROOT/bin" >> $GITHUB_PATH
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
- name: Configure CMake
|
|
||||||
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
|
|
||||||
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
|
|
||||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILDER_ENABLE_PROFILING=true
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
# Build your program with the given configuration
|
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
|
||||||
|
|
||||||
- name: Run Unit Tests
|
|
||||||
working-directory: ${{github.workspace}}/build
|
|
||||||
run: ctest --verbose
|
|
||||||
|
|
||||||
- name: Generate code coverage report
|
|
||||||
working-directory: ${{github.workspace}}/build
|
|
||||||
run: |
|
|
||||||
lcov --directory . --capture --output-file coverage.info
|
|
||||||
lcov --remove coverage.info '/usr/*' "${{github.workspace}}/test/*" "${{github.workspace}}/external/*" --output-file coverage.info
|
|
||||||
lcov --list coverage.info
|
|
||||||
|
|
||||||
- uses: coverallsapp/github-action@9ba913c152ae4be1327bfb9085dc806cedb44057
|
|
||||||
name: Upload code coverage report to Coveralls
|
|
||||||
with:
|
|
||||||
path-to-lcov: ${{github.workspace}}/build/coverage.info
|
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
@ -1,62 +0,0 @@
|
||||||
name: PlatformIO
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [master]
|
|
||||||
pull_request:
|
|
||||||
branches: [ master ]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
platformio:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
example:
|
|
||||||
- AltPinSerial
|
|
||||||
- Basic_IO
|
|
||||||
- Bench
|
|
||||||
- Callbacks
|
|
||||||
- Chaining
|
|
||||||
- DualMerger
|
|
||||||
- ErrorCallback
|
|
||||||
- Input
|
|
||||||
- RPN_NRPN
|
|
||||||
- SimpleSynth
|
|
||||||
- CustomBaudRate
|
|
||||||
board:
|
|
||||||
- uno
|
|
||||||
- due
|
|
||||||
- zero
|
|
||||||
- leonardo
|
|
||||||
- micro
|
|
||||||
- nanoatmega328
|
|
||||||
- megaatmega2560
|
|
||||||
- teensy2
|
|
||||||
- teensy30
|
|
||||||
- teensy31
|
|
||||||
- teensylc
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Cache pip
|
|
||||||
uses: actions/cache@v2
|
|
||||||
with:
|
|
||||||
path: ~/.cache/pip
|
|
||||||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
|
|
||||||
restore-keys: ${{ runner.os }}-pip-
|
|
||||||
- name: Cache PlatformIO
|
|
||||||
uses: actions/cache@v2
|
|
||||||
with:
|
|
||||||
path: ~/.platformio
|
|
||||||
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
|
|
||||||
- name: Set up Python
|
|
||||||
uses: actions/setup-python@v2
|
|
||||||
- name: Install PlatformIO
|
|
||||||
run: |
|
|
||||||
python -m pip install --upgrade pip
|
|
||||||
pip install --upgrade platformio
|
|
||||||
pip install "click!=8.0.2" # See platformio/platformio-core#4078
|
|
||||||
- name: Run PlatformIO
|
|
||||||
run: pio ci --lib="." --board="${{matrix.board}}"
|
|
||||||
env:
|
|
||||||
PLATFORMIO_CI_SRC: examples/${{ matrix.example }}
|
|
||||||
|
|
@ -0,0 +1,104 @@
|
||||||
|
# Kudos to these guys:
|
||||||
|
# https://github.com/Return-To-The-Roots/s25client/blob/master/.travis.yml
|
||||||
|
# http://docs.platformio.org/en/stable/ci/travis.html
|
||||||
|
|
||||||
|
sudo: false
|
||||||
|
language: python
|
||||||
|
|
||||||
|
os:
|
||||||
|
- linux
|
||||||
|
|
||||||
|
python:
|
||||||
|
- "2.7"
|
||||||
|
|
||||||
|
# Cache PlatformIO packages using Travis CI container-based infrastructure
|
||||||
|
cache:
|
||||||
|
directories:
|
||||||
|
- "~/.platformio"
|
||||||
|
|
||||||
|
env:
|
||||||
|
global:
|
||||||
|
- BUILD_TYPE=Debug
|
||||||
|
matrix:
|
||||||
|
- BUILD_UNIT_TESTS=1
|
||||||
|
- PLATFORMIO_CI_SRC=examples/Basic_IO
|
||||||
|
- PLATFORMIO_CI_SRC=examples/Bench
|
||||||
|
- PLATFORMIO_CI_SRC=examples/Callbacks
|
||||||
|
- PLATFORMIO_CI_SRC=examples/DualMerger
|
||||||
|
- PLATFORMIO_CI_SRC=examples/ErrorCallback
|
||||||
|
- PLATFORMIO_CI_SRC=examples/Input
|
||||||
|
- PLATFORMIO_CI_SRC=examples/RPN_NRPN
|
||||||
|
- PLATFORMIO_CI_SRC=examples/SimpleSynth
|
||||||
|
- PLATFORMIO_CI_SRC=examples/AltPinSerial
|
||||||
|
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
sources:
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
packages:
|
||||||
|
- g++-4.8
|
||||||
|
- cmake
|
||||||
|
|
||||||
|
install:
|
||||||
|
- |
|
||||||
|
if [ "${BUILD_UNIT_TESTS}" ]; then
|
||||||
|
# GCov 4.6 cannot handle the file structure
|
||||||
|
export CXX="g++-4.8"
|
||||||
|
export GCOV="gcov-4.8"
|
||||||
|
|
||||||
|
# Install newer lcov (1.9 seems to fail: http://gronlier.fr/blog/2015/01/adding-code-coverage-to-your-c-project/)
|
||||||
|
export LCOV_ROOT="$HOME/lcov"
|
||||||
|
mkdir -p "$LCOV_ROOT"
|
||||||
|
wget http://ftp.de.debian.org/debian/pool/main/l/lcov/lcov_1.14.orig.tar.gz --output-document="$LCOV_ROOT/lcov.tar.gz"
|
||||||
|
tar xf "$LCOV_ROOT/lcov.tar.gz" --strip-components=1 -C $LCOV_ROOT
|
||||||
|
export PATH="$LCOV_ROOT/bin:$PATH"
|
||||||
|
which lcov
|
||||||
|
|
||||||
|
# Install coveralls tool
|
||||||
|
gem install coveralls-lcov
|
||||||
|
export GENERATE_COVERAGE=1
|
||||||
|
else
|
||||||
|
# Install PlatformIO
|
||||||
|
pip install -U platformio
|
||||||
|
fi
|
||||||
|
|
||||||
|
script:
|
||||||
|
# Build unit tests & generate code coverage
|
||||||
|
- |
|
||||||
|
if [ "${BUILD_UNIT_TESTS}" ]; then
|
||||||
|
mkdir build && cd build
|
||||||
|
cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DBUILDER_ENABLE_PROFILING=${GENERATE_COVERAGE} --generator="Unix Makefiles" ..
|
||||||
|
make all
|
||||||
|
ctest --verbose
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build current example
|
||||||
|
- |
|
||||||
|
if [ ! "${BUILD_UNIT_TESTS}" ]; then
|
||||||
|
platformio ci --lib="." \
|
||||||
|
--board="uno" \
|
||||||
|
--board="due" \
|
||||||
|
--board="zero" \
|
||||||
|
--board="leonardo" \
|
||||||
|
--board="micro" \
|
||||||
|
--board="nanoatmega328" \
|
||||||
|
--board="megaatmega2560" \
|
||||||
|
--board="teensy2" \
|
||||||
|
--board="teensy30" \
|
||||||
|
--board="teensy31" \
|
||||||
|
--board="teensylc"
|
||||||
|
fi
|
||||||
|
|
||||||
|
after_success:
|
||||||
|
- |
|
||||||
|
if [ "${GENERATE_COVERAGE}" ]; then
|
||||||
|
# Generate code coverage information & send to Coveralls
|
||||||
|
rm -rf ./external/google-test/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.gcda
|
||||||
|
lcov --gcov-tool $GCOV --directory . --capture --output-file coverage.info
|
||||||
|
lcov --gcov-tool $GCOV --remove coverage.info 'test/*' '/usr/*' 'external/*' --output-file coverage.info
|
||||||
|
lcov --list coverage.info
|
||||||
|
coveralls-lcov --repo-token ${COVERALLS_TOKEN} coverage.info
|
||||||
|
fi
|
||||||
|
|
||||||
|
notifications:
|
||||||
|
email: false
|
||||||
|
|
@ -3,15 +3,19 @@
|
||||||
{
|
{
|
||||||
"name": "Mac",
|
"name": "Mac",
|
||||||
"includePath": [
|
"includePath": [
|
||||||
|
"/Applications/Arduino.app/Contents/Java/tools/**",
|
||||||
|
"/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/**",
|
||||||
"/Applications/Arduino.app/Contents/Java/hardware/tools/avr/include",
|
"/Applications/Arduino.app/Contents/Java/hardware/tools/avr/include",
|
||||||
"/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino"
|
"/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino",
|
||||||
|
"${workspaceRoot}"
|
||||||
],
|
],
|
||||||
"browse": {
|
"browse": {
|
||||||
"limitSymbolsToIncludedHeaders": true,
|
"limitSymbolsToIncludedHeaders": true,
|
||||||
"databaseFilename": "",
|
"databaseFilename": "",
|
||||||
"path": [
|
"path": [
|
||||||
"/Applications/Arduino.app/Contents/Java/hardware/tools/avr/include",
|
"/Applications/Arduino.app/Contents/Java/hardware/tools/avr/include",
|
||||||
"/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino"
|
"/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino",
|
||||||
|
"${workspaceRoot}"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"intelliSenseMode": "clang-x64",
|
"intelliSenseMode": "clang-x64",
|
||||||
|
|
@ -19,43 +23,42 @@
|
||||||
"/System/Library/Frameworks",
|
"/System/Library/Frameworks",
|
||||||
"/Library/Frameworks"
|
"/Library/Frameworks"
|
||||||
],
|
],
|
||||||
"compilerPath": "/usr/bin/clang",
|
"forcedInclude": [
|
||||||
"cStandard": "c11",
|
"/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino/Arduino.h"
|
||||||
"cppStandard": "c++17"
|
],
|
||||||
|
"configurationProvider": "vector-of-bool.cmake-tools"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Linux",
|
"name": "Linux",
|
||||||
"includePath": [
|
"includePath": [
|
||||||
"/usr/include"
|
"/usr/include",
|
||||||
|
"${workspaceRoot}"
|
||||||
],
|
],
|
||||||
"browse": {
|
"browse": {
|
||||||
"limitSymbolsToIncludedHeaders": true,
|
"limitSymbolsToIncludedHeaders": true,
|
||||||
"databaseFilename": "",
|
"databaseFilename": "",
|
||||||
"path": [
|
"path": [
|
||||||
"/usr/include"
|
"/usr/include",
|
||||||
|
"${workspaceRoot}"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"intelliSenseMode": "clang-x64",
|
"intelliSenseMode": "clang-x64"
|
||||||
"compilerPath": "/usr/bin/clang",
|
|
||||||
"cStandard": "c11",
|
|
||||||
"cppStandard": "c++17"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Win32",
|
"name": "Win32",
|
||||||
"includePath": [
|
"includePath": [
|
||||||
"c:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include"
|
"c:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include",
|
||||||
|
"${workspaceRoot}"
|
||||||
],
|
],
|
||||||
"browse": {
|
"browse": {
|
||||||
"limitSymbolsToIncludedHeaders": true,
|
"limitSymbolsToIncludedHeaders": true,
|
||||||
"databaseFilename": "",
|
"databaseFilename": "",
|
||||||
"path": [
|
"path": [
|
||||||
"c:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include"
|
"c:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include",
|
||||||
|
"${workspaceRoot}"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"intelliSenseMode": "msvc-x64",
|
"intelliSenseMode": "msvc-x64"
|
||||||
"compilerPath": "/usr/bin/clang",
|
|
||||||
"cStandard": "c11",
|
|
||||||
"cppStandard": "c++17"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"version": 4
|
"version": 4
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@
|
||||||
"string": "cpp",
|
"string": "cpp",
|
||||||
"string_view": "cpp",
|
"string_view": "cpp",
|
||||||
"vector": "cpp",
|
"vector": "cpp",
|
||||||
"istream": "cpp",
|
"istream": "cpp"
|
||||||
"system_error": "cpp"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,29 +1,18 @@
|
||||||
# Contributing Guidelines
|
|
||||||
|
|
||||||
First, thanks for your help ! :+1:
|
|
||||||
|
|
||||||
## Branches
|
|
||||||
|
|
||||||
Please base your Pull Requests off the `master` branch.
|
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
Requirements to build and run the unit tests:
|
Requirements to build and run the unit tests:
|
||||||
|
- CMake 2.8 or later
|
||||||
- CMake 2.8 or later
|
- GCC / Clang with C++11 support
|
||||||
- GCC / Clang with C++11 support (GCC 4.8 or higher)
|
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
Pull Google Test / Google Mock subrepository:
|
Pull Google Test / Google Mock subrepository:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ git submodule init
|
$ git submodule init
|
||||||
$ git submodule update
|
$ git submodule update
|
||||||
```
|
```
|
||||||
|
|
||||||
Create build directory, run CMake, build and run unit tests:
|
Create build directory, run CMake, build and run unit tests:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ mkdir build && cd build
|
$ mkdir build && cd build
|
||||||
$ cmake ..
|
$ cmake ..
|
||||||
|
|
|
||||||
39
README.md
39
README.md
|
|
@ -1,17 +1,15 @@
|
||||||
# Arduino MIDI Library
|
# Arduino MIDI Library
|
||||||
|
|
||||||
|
[](https://travis-ci.org/FortySevenEffects/arduino_midi_library)
|
||||||
|
[](https://coveralls.io/github/FortySevenEffects/arduino_midi_library)
|
||||||
[](https://github.com/FortySevenEffects/arduino_midi_library/releases/latest)
|
[](https://github.com/FortySevenEffects/arduino_midi_library/releases/latest)
|
||||||
[](LICENSE)
|
[](LICENSE)
|
||||||
[](https://github.com/FortySevenEffects/arduino_midi_library/actions/workflows/cmake.yml)
|
|
||||||
[](https://github.com/FortySevenEffects/arduino_midi_library/actions/workflows/platformio.yml)
|
|
||||||
[](https://coveralls.io/github/FortySevenEffects/arduino_midi_library)
|
|
||||||
|
|
||||||
This library adds MIDI I/O communications to an Arduino board.
|
This library adds MIDI I/O communications to an Arduino board.
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
- **New** : MIDI over USB, Bluetooth, IP & AppleMIDI (see [Transports](#other-transport-mechanisms)).
|
- **New** : USB MIDI Device support with [`MIDIUSB`](https://github.com/arduino-libraries/MIDIUSB).
|
||||||
- **New** : Active Sensing support
|
|
||||||
- Compatible with all Arduino boards (and clones with an AVR processor).
|
- Compatible with all Arduino boards (and clones with an AVR processor).
|
||||||
- Simple and fast way to send and receive every kind of MIDI message (including all System messages, SysEx, Clock, etc..).
|
- Simple and fast way to send and receive every kind of MIDI message (including all System messages, SysEx, Clock, etc..).
|
||||||
- OMNI input reading (read all channels).
|
- OMNI input reading (read all channels).
|
||||||
|
|
@ -25,7 +23,7 @@ This library adds MIDI I/O communications to an Arduino board.
|
||||||
### Getting Started
|
### Getting Started
|
||||||
|
|
||||||
1. Use the Arduino Library Manager to install the library.
|
1. Use the Arduino Library Manager to install the library.
|
||||||

|

|
||||||
|
|
||||||
2. Start coding:
|
2. Start coding:
|
||||||
|
|
||||||
|
|
@ -79,7 +77,7 @@ MIDI_CREATE_INSTANCE(UsbTransport, sUsbTransport, MIDI);
|
||||||
// ...
|
// ...
|
||||||
```
|
```
|
||||||
|
|
||||||
now becomes in `5.x`:
|
now becomes in `5.0.0`:
|
||||||
|
|
||||||
```c++
|
```c++
|
||||||
#include <USB-MIDI.h>
|
#include <USB-MIDI.h>
|
||||||
|
|
@ -108,35 +106,12 @@ All these Transport layers use this library for all the underlying MIDI
|
||||||
work, making it easy to switch transport protocols or making transport
|
work, making it easy to switch transport protocols or making transport
|
||||||
protocol bridges.
|
protocol bridges.
|
||||||
|
|
||||||
### Differences between Serial & other transports
|
## Contact
|
||||||
|
|
||||||
- Software Thru is enabled by default on Serial, but not on other transports.
|
To report a bug, contribute, discuss on usage, or simply request support, please [create an issue here](https://github.com/FortySevenEffects/arduino_midi_library/issues/new).
|
||||||
|
|
||||||
## Contact & Contribution
|
|
||||||
|
|
||||||
To report a bug, contribute, discuss on usage, or request support, please [discuss it here](https://github.com/FortySevenEffects/arduino_midi_library/discussions/new).
|
|
||||||
|
|
||||||
You can also contact me on Twitter: [@fortysevenfx](https://twitter.com/fortysevenfx).
|
You can also contact me on Twitter: [@fortysevenfx](https://twitter.com/fortysevenfx).
|
||||||
|
|
||||||
## Contributors
|
|
||||||
|
|
||||||
Special thanks to all who have contributed to this open-source project !
|
|
||||||
|
|
||||||
- [@lathoub](https://github.com/lathoub)
|
|
||||||
- [@jarosz](https://github.com/jarosz)
|
|
||||||
- [@ivankravets](https://github.com/ivankravets)
|
|
||||||
- [@insolace](https://github.com/insolace)
|
|
||||||
- [@softegg](https://github.com/softegg)
|
|
||||||
- [@per1234](https://github.com/per1234)
|
|
||||||
- [@LnnrtS](https://github.com/LnnrtS)
|
|
||||||
- [@DavidMenting](https://github.com/DavidMenting)
|
|
||||||
- [@Rolel](https://github.com/Rolel)
|
|
||||||
- [@kant](https://github.com/kant)
|
|
||||||
- [@paul-emile-element](https://github.com/paul-emile-element)
|
|
||||||
- [@muxa](https://github.com/muxa)
|
|
||||||
|
|
||||||
You want to help ? Check out the [contribution guidelines](./CONTRIBUTING.md).
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
MIT © 2009 - present [Francois Best](https://francoisbest.com)
|
MIT © 2009 - present [Francois Best](https://francoisbest.com)
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,11 @@
|
||||||
#### Changelog
|
#### Changelog
|
||||||
|
* 11/06/2014 : Version 4.2 released. Bug fix for SysEx, overridable template settings.
|
||||||
- 20/04/2020 : Version 5.0 released. Separation of transports by [@lathoub](https://github.com/lathoub), adds Active Sensing.
|
* 16/04/2014 : Version 4.1 released. Bug fixes regarding running status.
|
||||||
- 11/06/2014 : Version 4.2 released. Bug fix for SysEx, overridable template settings.
|
* 13/02/2014 : Version 4.0 released. Moved to GitHub, added multiple instances & software serial support, and a few bug fixes.
|
||||||
- 16/04/2014 : Version 4.1 released. Bug fixes regarding running status.
|
* 29/01/2012 : Version 3.2 released. Release notes are [here](http://sourceforge.net/news/?group_id=265194).
|
||||||
- 13/02/2014 : Version 4.0 released. Moved to GitHub, added multiple instances & software serial support, and a few bug fixes.
|
* 06/05/2011 : Version 3.1 released. Added [callback](http://playground.arduino.cc/Main/MIDILibraryCallbacks) support.
|
||||||
- 29/01/2012 : Version 3.2 released. Release notes are [here](http://sourceforge.net/news/?group_id=265194).
|
* 06/03/2011 : Version 3.0 released. Project is now hosted on [SourceForge](http://sourceforge.net/projects/arduinomidilib).
|
||||||
- 06/05/2011 : Version 3.1 released. Added [callback](http://playground.arduino.cc/Main/MIDILibraryCallbacks) support.
|
* 14/12/2009 : Version 2.5 released.
|
||||||
- 06/03/2011 : Version 3.0 released. Project is now hosted on [SourceForge](http://sourceforge.net/projects/arduinomidilib).
|
* 28/07/2009 : Version 2.0 released.
|
||||||
- 14/12/2009 : Version 2.5 released.
|
* 28/03/2009 : Simplified version of MIDI.begin, Fast mode is now on by default.
|
||||||
- 28/07/2009 : Version 2.0 released.
|
* 08/03/2009 : Thru method operational. Added some features to enable thru.
|
||||||
- 28/03/2009 : Simplified version of MIDI.begin, Fast mode is now on by default.
|
|
||||||
- 08/03/2009 : Thru method operational. Added some features to enable thru.
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ PROJECT_NAME = "Arduino MIDI Library"
|
||||||
# could be handy for archiving the generated documentation or if some version
|
# could be handy for archiving the generated documentation or if some version
|
||||||
# control system is used.
|
# control system is used.
|
||||||
|
|
||||||
PROJECT_NUMBER = "Version 5.0.2"
|
PROJECT_NUMBER = "Version 4.4.0"
|
||||||
|
|
||||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||||
# for a project that appears at the top of each page and should give viewer a
|
# for a project that appears at the top of each page and should give viewer a
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
// Examples
|
// Examples
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\example Basic_IO.ino
|
\example MIDI_Basic_IO.ino
|
||||||
This example shows how to perform simple input and output MIDI. \n
|
This example shows how to perform simple input and output MIDI. \n
|
||||||
\n
|
\n
|
||||||
When any message arrives to the Arduino, the LED is turned on,
|
When any message arrives to the Arduino, the LED is turned on,
|
||||||
|
|
@ -29,15 +29,15 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\example Callbacks.ino
|
\example MIDI_Callbacks.ino
|
||||||
This example shows how to use callbacks for easier MIDI input handling. \n
|
This example shows how to use callbacks for easier MIDI input handling. \n
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\example Bench.ino
|
\example MIDI_Bench.ino
|
||||||
\example DualMerger.ino
|
\example MIDI_DualMerger.ino
|
||||||
\example Input.ino
|
\example MIDI_Input.ino
|
||||||
\example SimpleSynth.ino
|
\example MIDI_SimpleSynth.ino
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ becomes:
|
||||||
```
|
```
|
||||||
|
|
||||||
The order of the bits in the "header" byte is reversed.
|
The order of the bits in the "header" byte is reversed.
|
||||||
To follow this behaviour, set the inFlipHeaderBits argument to true.
|
To follow this beheaviour, set the inFlipHeaderBits argument to true.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
```c++
|
```c++
|
||||||
|
|
|
||||||
|
|
@ -1,36 +1,34 @@
|
||||||
#include <MIDI.h>
|
#include <MIDI.h>
|
||||||
|
|
||||||
// Simple tutorial on how to receive and send MIDI messages
|
// Simple tutorial on how to receive and send MIDI messages.
|
||||||
// on a different serial port, using SoftwareSerial.
|
|
||||||
// Here, when receiving any message on channel 4, the Arduino
|
// Here, when receiving any message on channel 4, the Arduino
|
||||||
// will blink a led and play back a note for 1 second.
|
// will blink a led and play back a note for 1 second.
|
||||||
|
|
||||||
#if defined(ARDUINO_SAM_DUE) || defined(SAMD_SERIES) || defined(_VARIANT_ARDUINO_ZERO_)
|
#if defined(ARDUINO_SAM_DUE) || defined(SAMD_SERIES)
|
||||||
/* example not relevant for this hardware (SoftwareSerial not supported) */
|
/* example not relevant for this hardware */
|
||||||
MIDI_CREATE_DEFAULT_INSTANCE();
|
MIDI_CREATE_DEFAULT_INSTANCE();
|
||||||
#else
|
#else
|
||||||
#include <SoftwareSerial.h>
|
#include <SoftwareSerial.h>
|
||||||
using Transport = MIDI_NAMESPACE::SerialMIDI<SoftwareSerial>;
|
|
||||||
int rxPin = 18;
|
int rxPin = 18;
|
||||||
int txPin = 19;
|
int txPin = 19;
|
||||||
SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);
|
SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);
|
||||||
Transport serialMIDI(mySerial);
|
MIDI_NAMESPACE::SerialMIDI<SoftwareSerial> serialMIDI(mySerial);
|
||||||
MIDI_NAMESPACE::MidiInterface<Transport> MIDI((Transport&)serialMIDI);
|
MIDI_NAMESPACE::MidiInterface<MIDI_NAMESPACE::SerialMIDI<SoftwareSerial>> MIDI((MIDI_NAMESPACE::SerialMIDI<SoftwareSerial>&)serialMIDI);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
pinMode(LED_BUILTIN, OUTPUT);
|
pinMode(LED_BUILTIN, OUTPUT);
|
||||||
MIDI.begin(4); // Launch MIDI and listen to channel 4
|
MIDI.begin(4); // Launch MIDI and listen to channel 4
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
if (MIDI.read()) // If we have received a message
|
if (MIDI.read()) // If we have received a message
|
||||||
{
|
{
|
||||||
digitalWrite(LED_BUILTIN, HIGH);
|
digitalWrite(LED_BUILTIN, HIGH);
|
||||||
MIDI.sendNoteOn(42, 127, 1); // Send a Note (pitch 42, velo 127 on channel 1)
|
MIDI.sendNoteOn(42, 127, 1); // Send a Note (pitch 42, velo 127 on channel 1)
|
||||||
delay(1000); // Wait for a second
|
delay(1000); // Wait for a second
|
||||||
MIDI.sendNoteOff(42, 0, 1); // Stop the note
|
MIDI.sendNoteOff(42, 0, 1); // Stop the note
|
||||||
digitalWrite(LED_BUILTIN, LOW);
|
digitalWrite(LED_BUILTIN, LOW);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ MIDI_CREATE_DEFAULT_INSTANCE();
|
||||||
// This function will be automatically called when a NoteOn is received.
|
// This function will be automatically called when a NoteOn is received.
|
||||||
// It must be a void-returning function with the correct parameters,
|
// It must be a void-returning function with the correct parameters,
|
||||||
// see documentation here:
|
// see documentation here:
|
||||||
// https://github.com/FortySevenEffects/arduino_midi_library/wiki/Using-Callbacks
|
// http://arduinomidilib.fortyseveneffects.com/a00022.html
|
||||||
|
|
||||||
void handleNoteOn(byte channel, byte pitch, byte velocity)
|
void handleNoteOn(byte channel, byte pitch, byte velocity)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
#include <MIDI.h>
|
|
||||||
|
|
||||||
MIDI_CREATE_DEFAULT_INSTANCE();
|
|
||||||
|
|
||||||
void setup()
|
|
||||||
{
|
|
||||||
pinMode(2, INPUT);
|
|
||||||
|
|
||||||
MIDI // chaining MIDI commands - order is from top to bottom (turnThruOff,... begin)
|
|
||||||
.turnThruOff()
|
|
||||||
// using a lamdba function for this callbacks
|
|
||||||
.setHandleNoteOn([](byte channel, byte note, byte velocity)
|
|
||||||
{
|
|
||||||
// Do whatever you want when a note is pressed.
|
|
||||||
|
|
||||||
// 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.
|
|
||||||
})
|
|
||||||
.setHandleNoteOff([](byte channel, byte note, byte velocity)
|
|
||||||
{
|
|
||||||
// Do something when the note is released.
|
|
||||||
// Note that NoteOn messages with 0 velocity are interpreted as NoteOffs.
|
|
||||||
})
|
|
||||||
.begin(MIDI_CHANNEL_OMNI); // Initiate MIDI communications, listen to all channels
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop()
|
|
||||||
{
|
|
||||||
// Call MIDI.read the fastest you can for real-time performance.
|
|
||||||
MIDI.read();
|
|
||||||
|
|
||||||
if (digitalRead(2))
|
|
||||||
MIDI // chained sendNoteOn commands
|
|
||||||
.sendNoteOn(42, 127, 1)
|
|
||||||
.sendNoteOn(40, 54, 1);
|
|
||||||
}
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
#include <MIDI.h>
|
|
||||||
|
|
||||||
// Override the default MIDI baudrate to
|
|
||||||
// a decoding program such as Hairless MIDI (set baudrate to 115200)
|
|
||||||
struct CustomBaudRateSettings : public MIDI_NAMESPACE::DefaultSerialSettings {
|
|
||||||
static const long BaudRate = 115200;
|
|
||||||
};
|
|
||||||
|
|
||||||
#if defined(ARDUINO_SAM_DUE) || defined(USBCON) || defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MKL26Z64__)
|
|
||||||
// Leonardo, Due and other USB boards use Serial1 by default.
|
|
||||||
MIDI_NAMESPACE::SerialMIDI<HardwareSerial, CustomBaudRateSettings> serialMIDI(Serial1);
|
|
||||||
MIDI_NAMESPACE::MidiInterface<MIDI_NAMESPACE::SerialMIDI<HardwareSerial, CustomBaudRateSettings>> MIDI((MIDI_NAMESPACE::SerialMIDI<HardwareSerial, CustomBaudRateSettings>&)serialMIDI);
|
|
||||||
#else
|
|
||||||
MIDI_NAMESPACE::SerialMIDI<HardwareSerial, CustomBaudRateSettings> serialMIDI(Serial);
|
|
||||||
MIDI_NAMESPACE::MidiInterface<MIDI_NAMESPACE::SerialMIDI<HardwareSerial, CustomBaudRateSettings>> MIDI((MIDI_NAMESPACE::SerialMIDI<HardwareSerial, CustomBaudRateSettings>&)serialMIDI);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void setup() {
|
|
||||||
pinMode(LED_BUILTIN, OUTPUT);
|
|
||||||
MIDI.begin(MIDI_CHANNEL_OMNI);
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop() {
|
|
||||||
if (MIDI.read()) // If we have received a message
|
|
||||||
{
|
|
||||||
digitalWrite(LED_BUILTIN, HIGH);
|
|
||||||
MIDI.sendNoteOn(42, 127, 1); // Send a Note (pitch 42, velo 127 on channel 1)
|
|
||||||
delay(1000); // Wait for a second
|
|
||||||
MIDI.sendNoteOff(42, 0, 1); // Stop the note
|
|
||||||
digitalWrite(LED_BUILTIN, LOW);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
11
keywords.txt
11
keywords.txt
|
|
@ -146,18 +146,7 @@ GeneralPurposeController1 LITERAL1
|
||||||
GeneralPurposeController2 LITERAL1
|
GeneralPurposeController2 LITERAL1
|
||||||
GeneralPurposeController3 LITERAL1
|
GeneralPurposeController3 LITERAL1
|
||||||
GeneralPurposeController4 LITERAL1
|
GeneralPurposeController4 LITERAL1
|
||||||
BankSelectLSB LITERAL1
|
|
||||||
ModulationWheelLSB LITERAL1
|
|
||||||
BreathControllerLSB LITERAL1
|
|
||||||
FootControllerLSB LITERAL1
|
|
||||||
PortamentoTimeLSB LITERAL1
|
|
||||||
DataEntryLSB LITERAL1
|
DataEntryLSB LITERAL1
|
||||||
ChannelVolumeLSB LITERAL1
|
|
||||||
BalanceLSB LITERAL1
|
|
||||||
PanLSB LITERAL1
|
|
||||||
ExpressionControllerLSB LITERAL1
|
|
||||||
EffectControl1LSB LITERAL1
|
|
||||||
EffectControl2LSB LITERAL1
|
|
||||||
Sustain LITERAL1
|
Sustain LITERAL1
|
||||||
Portamento LITERAL1
|
Portamento LITERAL1
|
||||||
Sostenuto LITERAL1
|
Sostenuto LITERAL1
|
||||||
|
|
|
||||||
49
library.json
49
library.json
|
|
@ -1,23 +1,28 @@
|
||||||
{
|
{
|
||||||
"name": "MIDI Library",
|
"name": "MIDI Library",
|
||||||
"version": "5.0.2",
|
"version": "5.0.0",
|
||||||
"keywords": "midi",
|
"keywords": "midi",
|
||||||
"description": "Enables MIDI I/O communications on the Arduino serial ports",
|
"description": "Enables MIDI I/O communications on the Arduino serial ports",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"authors": {
|
"authors":
|
||||||
"name": "Francois Best",
|
{
|
||||||
"email": "contact@francoisbest.com",
|
"name": "Francois Best",
|
||||||
"url": "https://github.com/Franky47",
|
"email": "francois.best@fortyseveneffects.com",
|
||||||
"maintainer": true
|
"url": "https://github.com/Franky47",
|
||||||
},
|
"maintainer": true
|
||||||
"repository": {
|
},
|
||||||
"type": "git",
|
"repository":
|
||||||
"url": "https://github.com/FortySevenEffects/arduino_midi_library.git",
|
{
|
||||||
"branch": "master"
|
"type": "git",
|
||||||
},
|
"url": "https://github.com/FortySevenEffects/arduino_midi_library.git",
|
||||||
"export": {
|
"branch": "master"
|
||||||
"include": ["src", "examples"]
|
},
|
||||||
},
|
"export": {
|
||||||
"frameworks": "arduino",
|
"include": [
|
||||||
"platforms": ["atmelavr", "atmelsam", "teensy"]
|
"src",
|
||||||
}
|
"examples"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"frameworks": "arduino",
|
||||||
|
"platforms": ["atmelavr", "atmelsam", "teensy"]
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
name=MIDI Library
|
name=MIDI Library
|
||||||
version=5.0.2
|
version=5.0.0
|
||||||
author=Francois Best, lathoub
|
author=Forty Seven Effects, lathoub
|
||||||
maintainer=Francois Best <contact@francoisbest.com>
|
maintainer=Francois Best <francois.best@fortyseveneffects.com>
|
||||||
sentence=MIDI I/Os for Arduino
|
sentence=MIDI I/Os for Arduino
|
||||||
paragraph=Read & send MIDI messages to interface with your controllers and synths
|
paragraph=Read & send MIDI messages to interface with your controllers and synths
|
||||||
category=Communication
|
category=Communication
|
||||||
|
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 72 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 18 KiB |
10
src/MIDI.cpp
10
src/MIDI.cpp
|
|
@ -37,9 +37,9 @@ BEGIN_MIDI_NAMESPACE
|
||||||
data you want to send.
|
data you want to send.
|
||||||
\param inData The data to encode.
|
\param inData The data to encode.
|
||||||
\param outSysEx The output buffer where to store the encoded message.
|
\param outSysEx The output buffer where to store the encoded message.
|
||||||
\param inLength The length of the input buffer.
|
\param inLength The lenght of the input buffer.
|
||||||
\param inFlipHeaderBits True for Korg and other who store MSB in reverse order
|
\param inFlipHeaderBits True for Korg and other who store MSB in reverse order
|
||||||
\return The length of the encoded output buffer.
|
\return The lenght of the encoded output buffer.
|
||||||
@see decodeSysEx
|
@see decodeSysEx
|
||||||
Code inspired from Ruin & Wesen's SysEx encoder/decoder - http://ruinwesen.com
|
Code inspired from Ruin & Wesen's SysEx encoder/decoder - http://ruinwesen.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -77,10 +77,10 @@ unsigned encodeSysEx(const byte* inData,
|
||||||
127 without breaking the MIDI protocol. Use this static method to reassemble
|
127 without breaking the MIDI protocol. Use this static method to reassemble
|
||||||
your received message.
|
your received message.
|
||||||
\param inSysEx The SysEx data received from MIDI in.
|
\param inSysEx The SysEx data received from MIDI in.
|
||||||
\param outData The output buffer where to store the decrypted message.
|
\param outData The output buffer where to store the decrypted message.
|
||||||
\param inLength The length of the input buffer.
|
\param inLength The lenght of the input buffer.
|
||||||
\param inFlipHeaderBits True for Korg and other who store MSB in reverse order
|
\param inFlipHeaderBits True for Korg and other who store MSB in reverse order
|
||||||
\return The length of the output buffer.
|
\return The lenght of the output buffer.
|
||||||
@see encodeSysEx @see getSysExArrayLength
|
@see encodeSysEx @see getSysExArrayLength
|
||||||
Code inspired from Ruin & Wesen's SysEx encoder/decoder - http://ruinwesen.com
|
Code inspired from Ruin & Wesen's SysEx encoder/decoder - http://ruinwesen.com
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
140
src/MIDI.h
140
src/MIDI.h
|
|
@ -62,94 +62,94 @@ public:
|
||||||
inline ~MidiInterface();
|
inline ~MidiInterface();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MidiInterface& begin(Channel inChannel = 1);
|
void begin(Channel inChannel = 1);
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// MIDI Output
|
// MIDI Output
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline MidiInterface& sendNoteOn(DataByte inNoteNumber,
|
inline void sendNoteOn(DataByte inNoteNumber,
|
||||||
DataByte inVelocity,
|
DataByte inVelocity,
|
||||||
Channel inChannel);
|
Channel inChannel);
|
||||||
|
|
||||||
inline MidiInterface& sendNoteOff(DataByte inNoteNumber,
|
inline void sendNoteOff(DataByte inNoteNumber,
|
||||||
DataByte inVelocity,
|
DataByte inVelocity,
|
||||||
Channel inChannel);
|
Channel inChannel);
|
||||||
|
|
||||||
inline MidiInterface& sendProgramChange(DataByte inProgramNumber,
|
inline void sendProgramChange(DataByte inProgramNumber,
|
||||||
Channel inChannel);
|
Channel inChannel);
|
||||||
|
|
||||||
inline MidiInterface& sendControlChange(DataByte inControlNumber,
|
inline void sendControlChange(DataByte inControlNumber,
|
||||||
DataByte inControlValue,
|
DataByte inControlValue,
|
||||||
Channel inChannel);
|
Channel inChannel);
|
||||||
|
|
||||||
inline MidiInterface& sendPitchBend(int inPitchValue, Channel inChannel);
|
inline void sendPitchBend(int inPitchValue, Channel inChannel);
|
||||||
inline MidiInterface& sendPitchBend(double inPitchValue, Channel inChannel);
|
inline void sendPitchBend(double inPitchValue, Channel inChannel);
|
||||||
|
|
||||||
inline MidiInterface& sendPolyPressure(DataByte inNoteNumber,
|
inline void sendPolyPressure(DataByte inNoteNumber,
|
||||||
DataByte inPressure,
|
DataByte inPressure,
|
||||||
Channel inChannel) __attribute__ ((deprecated));
|
Channel inChannel) __attribute__ ((deprecated));
|
||||||
|
|
||||||
inline MidiInterface& sendAfterTouch(DataByte inPressure,
|
inline void sendAfterTouch(DataByte inPressure,
|
||||||
Channel inChannel);
|
Channel inChannel);
|
||||||
inline MidiInterface& sendAfterTouch(DataByte inNoteNumber,
|
inline void sendAfterTouch(DataByte inNoteNumber,
|
||||||
DataByte inPressure,
|
DataByte inPressure,
|
||||||
Channel inChannel);
|
Channel inChannel);
|
||||||
|
|
||||||
inline MidiInterface& sendSysEx(unsigned inLength,
|
inline void sendSysEx(unsigned inLength,
|
||||||
const byte* inArray,
|
const byte* inArray,
|
||||||
bool inArrayContainsBoundaries = false);
|
bool inArrayContainsBoundaries = false);
|
||||||
|
|
||||||
inline MidiInterface& sendTimeCodeQuarterFrame(DataByte inTypeNibble,
|
inline void sendTimeCodeQuarterFrame(DataByte inTypeNibble,
|
||||||
DataByte inValuesNibble);
|
DataByte inValuesNibble);
|
||||||
inline MidiInterface& sendTimeCodeQuarterFrame(DataByte inData);
|
inline void sendTimeCodeQuarterFrame(DataByte inData);
|
||||||
|
|
||||||
inline MidiInterface& sendSongPosition(unsigned inBeats);
|
inline void sendSongPosition(unsigned inBeats);
|
||||||
inline MidiInterface& sendSongSelect(DataByte inSongNumber);
|
inline void sendSongSelect(DataByte inSongNumber);
|
||||||
inline MidiInterface& sendTuneRequest();
|
inline void sendTuneRequest();
|
||||||
|
|
||||||
inline MidiInterface& sendCommon(MidiType inType, unsigned = 0);
|
inline void sendCommon(MidiType inType, unsigned = 0);
|
||||||
|
|
||||||
inline MidiInterface& sendClock() { return sendRealTime(Clock); };
|
inline void sendClock() { sendRealTime(Clock); };
|
||||||
inline MidiInterface& sendStart() { return sendRealTime(Start); };
|
inline void sendStart() { sendRealTime(Start); };
|
||||||
inline MidiInterface& sendStop() { return sendRealTime(Stop); };
|
inline void sendStop() { sendRealTime(Stop); };
|
||||||
inline MidiInterface& sendTick() { return sendRealTime(Tick); };
|
inline void sendTick() { sendRealTime(Tick); };
|
||||||
inline MidiInterface& sendContinue() { return sendRealTime(Continue); };
|
inline void sendContinue() { sendRealTime(Continue); };
|
||||||
inline MidiInterface& sendActiveSensing() { return sendRealTime(ActiveSensing); };
|
inline void sendActiveSensing() { sendRealTime(ActiveSensing); };
|
||||||
inline MidiInterface& sendSystemReset() { return sendRealTime(SystemReset); };
|
inline void sendSystemReset() { sendRealTime(SystemReset); };
|
||||||
|
|
||||||
inline MidiInterface& sendRealTime(MidiType inType);
|
inline void sendRealTime(MidiType inType);
|
||||||
|
|
||||||
inline MidiInterface& beginRpn(unsigned inNumber,
|
inline void beginRpn(unsigned inNumber,
|
||||||
Channel inChannel);
|
Channel inChannel);
|
||||||
inline MidiInterface& sendRpnValue(unsigned inValue,
|
inline void sendRpnValue(unsigned inValue,
|
||||||
Channel inChannel);
|
Channel inChannel);
|
||||||
inline MidiInterface& sendRpnValue(byte inMsb,
|
inline void sendRpnValue(byte inMsb,
|
||||||
byte inLsb,
|
byte inLsb,
|
||||||
Channel inChannel);
|
Channel inChannel);
|
||||||
inline MidiInterface& sendRpnIncrement(byte inAmount,
|
inline void sendRpnIncrement(byte inAmount,
|
||||||
Channel inChannel);
|
Channel inChannel);
|
||||||
inline MidiInterface& sendRpnDecrement(byte inAmount,
|
inline void sendRpnDecrement(byte inAmount,
|
||||||
Channel inChannel);
|
Channel inChannel);
|
||||||
inline MidiInterface& endRpn(Channel inChannel);
|
inline void endRpn(Channel inChannel);
|
||||||
|
|
||||||
inline MidiInterface& beginNrpn(unsigned inNumber,
|
inline void beginNrpn(unsigned inNumber,
|
||||||
Channel inChannel);
|
Channel inChannel);
|
||||||
inline MidiInterface& sendNrpnValue(unsigned inValue,
|
inline void sendNrpnValue(unsigned inValue,
|
||||||
Channel inChannel);
|
Channel inChannel);
|
||||||
inline MidiInterface& sendNrpnValue(byte inMsb,
|
inline void sendNrpnValue(byte inMsb,
|
||||||
byte inLsb,
|
byte inLsb,
|
||||||
Channel inChannel);
|
Channel inChannel);
|
||||||
inline MidiInterface& sendNrpnIncrement(byte inAmount,
|
inline void sendNrpnIncrement(byte inAmount,
|
||||||
Channel inChannel);
|
Channel inChannel);
|
||||||
inline MidiInterface& sendNrpnDecrement(byte inAmount,
|
inline void sendNrpnDecrement(byte inAmount,
|
||||||
Channel inChannel);
|
Channel inChannel);
|
||||||
inline MidiInterface& endNrpn(Channel inChannel);
|
inline void endNrpn(Channel inChannel);
|
||||||
|
|
||||||
inline MidiInterface& send(const MidiMessage&);
|
|
||||||
|
|
||||||
|
inline void send(const MidiMessage&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MidiInterface& send(MidiType inType,
|
void send(MidiType inType,
|
||||||
DataByte inData1,
|
DataByte inData1,
|
||||||
DataByte inData2,
|
DataByte inData2,
|
||||||
Channel inChannel);
|
Channel inChannel);
|
||||||
|
|
@ -172,7 +172,7 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline Channel getInputChannel() const;
|
inline Channel getInputChannel() const;
|
||||||
inline MidiInterface& setInputChannel(Channel inChannel);
|
inline void setInputChannel(Channel inChannel);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static inline MidiType getTypeFromStatusByte(byte inStatus);
|
static inline MidiType getTypeFromStatusByte(byte inStatus);
|
||||||
|
|
@ -183,29 +183,29 @@ public:
|
||||||
// Input Callbacks
|
// Input Callbacks
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline MidiInterface& setHandleMessage(void (*fptr)(const MidiMessage&)) { mMessageCallback = fptr; return *this; };
|
inline void setHandleMessage(void (*fptr)(const MidiMessage&)) { mMessageCallback = fptr; };
|
||||||
inline MidiInterface& setHandleError(ErrorCallback fptr) { mErrorCallback = fptr; return *this; };
|
inline void setHandleError(ErrorCallback fptr) { mErrorCallback = fptr; }
|
||||||
inline MidiInterface& setHandleNoteOff(NoteOffCallback fptr) { mNoteOffCallback = fptr; return *this; };
|
inline void setHandleNoteOff(NoteOffCallback fptr) { mNoteOffCallback = fptr; }
|
||||||
inline MidiInterface& setHandleNoteOn(NoteOnCallback fptr) { mNoteOnCallback = fptr; return *this; };
|
inline void setHandleNoteOn(NoteOnCallback fptr) { mNoteOnCallback = fptr; }
|
||||||
inline MidiInterface& setHandleAfterTouchPoly(AfterTouchPolyCallback fptr) { mAfterTouchPolyCallback = fptr; return *this; };
|
inline void setHandleAfterTouchPoly(AfterTouchPolyCallback fptr) { mAfterTouchPolyCallback = fptr; }
|
||||||
inline MidiInterface& setHandleControlChange(ControlChangeCallback fptr) { mControlChangeCallback = fptr; return *this; };
|
inline void setHandleControlChange(ControlChangeCallback fptr) { mControlChangeCallback = fptr; }
|
||||||
inline MidiInterface& setHandleProgramChange(ProgramChangeCallback fptr) { mProgramChangeCallback = fptr; return *this; };
|
inline void setHandleProgramChange(ProgramChangeCallback fptr) { mProgramChangeCallback = fptr; }
|
||||||
inline MidiInterface& setHandleAfterTouchChannel(AfterTouchChannelCallback fptr) { mAfterTouchChannelCallback = fptr; return *this; };
|
inline void setHandleAfterTouchChannel(AfterTouchChannelCallback fptr) { mAfterTouchChannelCallback = fptr; }
|
||||||
inline MidiInterface& setHandlePitchBend(PitchBendCallback fptr) { mPitchBendCallback = fptr; return *this; };
|
inline void setHandlePitchBend(PitchBendCallback fptr) { mPitchBendCallback = fptr; }
|
||||||
inline MidiInterface& setHandleSystemExclusive(SystemExclusiveCallback fptr) { mSystemExclusiveCallback = fptr; return *this; };
|
inline void setHandleSystemExclusive(SystemExclusiveCallback fptr) { mSystemExclusiveCallback = fptr; }
|
||||||
inline MidiInterface& setHandleTimeCodeQuarterFrame(TimeCodeQuarterFrameCallback fptr) { mTimeCodeQuarterFrameCallback = fptr; return *this; };
|
inline void setHandleTimeCodeQuarterFrame(TimeCodeQuarterFrameCallback fptr) { mTimeCodeQuarterFrameCallback = fptr; }
|
||||||
inline MidiInterface& setHandleSongPosition(SongPositionCallback fptr) { mSongPositionCallback = fptr; return *this; };
|
inline void setHandleSongPosition(SongPositionCallback fptr) { mSongPositionCallback = fptr; }
|
||||||
inline MidiInterface& setHandleSongSelect(SongSelectCallback fptr) { mSongSelectCallback = fptr; return *this; };
|
inline void setHandleSongSelect(SongSelectCallback fptr) { mSongSelectCallback = fptr; }
|
||||||
inline MidiInterface& setHandleTuneRequest(TuneRequestCallback fptr) { mTuneRequestCallback = fptr; return *this; };
|
inline void setHandleTuneRequest(TuneRequestCallback fptr) { mTuneRequestCallback = fptr; }
|
||||||
inline MidiInterface& setHandleClock(ClockCallback fptr) { mClockCallback = fptr; return *this; };
|
inline void setHandleClock(ClockCallback fptr) { mClockCallback = fptr; }
|
||||||
inline MidiInterface& setHandleStart(StartCallback fptr) { mStartCallback = fptr; return *this; };
|
inline void setHandleStart(StartCallback fptr) { mStartCallback = fptr; }
|
||||||
inline MidiInterface& setHandleTick(TickCallback fptr) { mTickCallback = fptr; return *this; };
|
inline void setHandleTick(TickCallback fptr) { mTickCallback = fptr; }
|
||||||
inline MidiInterface& setHandleContinue(ContinueCallback fptr) { mContinueCallback = fptr; return *this; };
|
inline void setHandleContinue(ContinueCallback fptr) { mContinueCallback = fptr; }
|
||||||
inline MidiInterface& setHandleStop(StopCallback fptr) { mStopCallback = fptr; return *this; };
|
inline void setHandleStop(StopCallback fptr) { mStopCallback = fptr; }
|
||||||
inline MidiInterface& setHandleActiveSensing(ActiveSensingCallback fptr) { mActiveSensingCallback = fptr; return *this; };
|
inline void setHandleActiveSensing(ActiveSensingCallback fptr) { mActiveSensingCallback = fptr; }
|
||||||
inline MidiInterface& setHandleSystemReset(SystemResetCallback fptr) { mSystemResetCallback = fptr; return *this; };
|
inline void setHandleSystemReset(SystemResetCallback fptr) { mSystemResetCallback = fptr; }
|
||||||
|
|
||||||
inline MidiInterface& disconnectCallbackFromType(MidiType inType);
|
inline void disconnectCallbackFromType(MidiType inType);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void launchCallback();
|
void launchCallback();
|
||||||
|
|
@ -239,9 +239,9 @@ public:
|
||||||
inline Thru::Mode getFilterMode() const;
|
inline Thru::Mode getFilterMode() const;
|
||||||
inline bool getThruState() const;
|
inline bool getThruState() const;
|
||||||
|
|
||||||
inline MidiInterface& turnThruOn(Thru::Mode inThruFilterMode = Thru::Full);
|
inline void turnThruOn(Thru::Mode inThruFilterMode = Thru::Full);
|
||||||
inline MidiInterface& turnThruOff();
|
inline void turnThruOff();
|
||||||
inline MidiInterface& setThruFilterMode(Thru::Mode inThruFilterMode);
|
inline void setThruFilterMode(Thru::Mode inThruFilterMode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void thruFilter(byte inChannel);
|
void thruFilter(byte inChannel);
|
||||||
|
|
@ -254,7 +254,7 @@ private:
|
||||||
inline void handleNullVelocityNoteOnAsNoteOff();
|
inline void handleNullVelocityNoteOnAsNoteOff();
|
||||||
inline bool inputFilter(Channel inChannel);
|
inline bool inputFilter(Channel inChannel);
|
||||||
inline void resetInput();
|
inline void resetInput();
|
||||||
inline void updateLastSentTime();
|
inline void UpdateLastSentTime();
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// Transport
|
// Transport
|
||||||
|
|
@ -295,11 +295,11 @@ private:
|
||||||
|
|
||||||
unsigned encodeSysEx(const byte* inData,
|
unsigned encodeSysEx(const byte* inData,
|
||||||
byte* outSysEx,
|
byte* outSysEx,
|
||||||
unsigned inLength,
|
unsigned inLenght,
|
||||||
bool inFlipHeaderBits = false);
|
bool inFlipHeaderBits = false);
|
||||||
unsigned decodeSysEx(const byte* inSysEx,
|
unsigned decodeSysEx(const byte* inSysEx,
|
||||||
byte* outData,
|
byte* outData,
|
||||||
unsigned inLength,
|
unsigned inLenght,
|
||||||
bool inFlipHeaderBits = false);
|
bool inFlipHeaderBits = false);
|
||||||
|
|
||||||
END_MIDI_NAMESPACE
|
END_MIDI_NAMESPACE
|
||||||
|
|
|
||||||
240
src/MIDI.hpp
240
src/MIDI.hpp
|
|
@ -48,7 +48,7 @@ inline MidiInterface<Transport, Settings, Platform>::MidiInterface(Transport& in
|
||||||
, mReceiverActiveSensingActivated(false)
|
, mReceiverActiveSensingActivated(false)
|
||||||
, mLastError(0)
|
, mLastError(0)
|
||||||
{
|
{
|
||||||
mSenderActiveSensingPeriodicity = Settings::SenderActiveSensingPeriodicity;
|
mSenderActiveSensingPeriodicity = Settings::SenderActiveSensingPeriodicity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Destructor for MidiInterface.
|
/*! \brief Destructor for MidiInterface.
|
||||||
|
|
@ -69,7 +69,7 @@ inline MidiInterface<Transport, Settings, Platform>::~MidiInterface()
|
||||||
- Full thru mirroring
|
- Full thru mirroring
|
||||||
*/
|
*/
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::begin(Channel inChannel)
|
void MidiInterface<Transport, Settings, Platform>::begin(Channel inChannel)
|
||||||
{
|
{
|
||||||
// Initialise the Transport layer
|
// Initialise the Transport layer
|
||||||
mTransport.begin();
|
mTransport.begin();
|
||||||
|
|
@ -94,9 +94,7 @@ MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings,
|
||||||
mMessage.length = 0;
|
mMessage.length = 0;
|
||||||
|
|
||||||
mThruFilterMode = Thru::Full;
|
mThruFilterMode = Thru::Full;
|
||||||
mThruActivated = mTransport.thruActivated;
|
mThruActivated = true;
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
@ -117,38 +115,33 @@ MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings,
|
||||||
them thru.
|
them thru.
|
||||||
*/
|
*/
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::send(const MidiMessage& inMessage)
|
void MidiInterface<Transport, Settings, Platform>::send(const MidiMessage& inMessage)
|
||||||
{
|
{
|
||||||
if (!inMessage.valid)
|
if (!inMessage.valid)
|
||||||
return *this;
|
return;
|
||||||
|
|
||||||
if (mTransport.beginTransmission(inMessage.type))
|
if (mTransport.beginTransmission(inMessage.type))
|
||||||
{
|
{
|
||||||
if (inMessage.isSystemRealTime())
|
const StatusByte status = getStatus(inMessage.type, inMessage.channel);
|
||||||
|
mTransport.write(status);
|
||||||
|
|
||||||
|
if (inMessage.type != MidiType::SystemExclusive)
|
||||||
{
|
{
|
||||||
mTransport.write(inMessage.type);
|
|
||||||
} else if (inMessage.isChannelMessage())
|
|
||||||
{
|
|
||||||
const StatusByte status = getStatus(inMessage.type, inMessage.channel);
|
|
||||||
mTransport.write(status);
|
|
||||||
if (inMessage.length > 1) mTransport.write(inMessage.data1);
|
if (inMessage.length > 1) mTransport.write(inMessage.data1);
|
||||||
if (inMessage.length > 2) mTransport.write(inMessage.data2);
|
if (inMessage.length > 2) mTransport.write(inMessage.data2);
|
||||||
} else if (inMessage.type == MidiType::SystemExclusive)
|
} else
|
||||||
{
|
{
|
||||||
const unsigned size = inMessage.getSysExSize();
|
// sysexArray does not contain the start and end tags
|
||||||
for (size_t i = 0; i < size; i++)
|
mTransport.write(MidiType::SystemExclusiveStart);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < inMessage.getSysExSize(); i++)
|
||||||
mTransport.write(inMessage.sysexArray[i]);
|
mTransport.write(inMessage.sysexArray[i]);
|
||||||
} else // at this point, it it assumed to be a system common message
|
|
||||||
{
|
mTransport.write(MidiType::SystemExclusiveEnd);
|
||||||
mTransport.write(inMessage.type);
|
|
||||||
if (inMessage.length > 1) mTransport.write(inMessage.data1);
|
|
||||||
if (inMessage.length > 2) mTransport.write(inMessage.data2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mTransport.endTransmission();
|
mTransport.endTransmission();
|
||||||
updateLastSentTime();
|
UpdateLastSentTime();
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -164,20 +157,21 @@ MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings,
|
||||||
from your code, at your own risks.
|
from your code, at your own risks.
|
||||||
*/
|
*/
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::send(MidiType inType,
|
void MidiInterface<Transport, Settings, Platform>::send(MidiType inType,
|
||||||
DataByte inData1,
|
DataByte inData1,
|
||||||
DataByte inData2,
|
DataByte inData2,
|
||||||
Channel inChannel)
|
Channel inChannel)
|
||||||
{
|
{
|
||||||
|
// Then test if channel is valid
|
||||||
|
if (inChannel >= MIDI_CHANNEL_OFF ||
|
||||||
|
inChannel == MIDI_CHANNEL_OMNI ||
|
||||||
|
inType < 0x80)
|
||||||
|
{
|
||||||
|
return; // Don't send anything
|
||||||
|
}
|
||||||
|
|
||||||
if (inType <= PitchBend) // Channel messages
|
if (inType <= PitchBend) // Channel messages
|
||||||
{
|
{
|
||||||
// Then test if channel is valid
|
|
||||||
if (inChannel >= MIDI_CHANNEL_OFF ||
|
|
||||||
inChannel == MIDI_CHANNEL_OMNI ||
|
|
||||||
inType < 0x80)
|
|
||||||
{
|
|
||||||
return *this; // Don't send anything
|
|
||||||
}
|
|
||||||
// Protection: remove MSBs on data
|
// Protection: remove MSBs on data
|
||||||
inData1 &= 0x7f;
|
inData1 &= 0x7f;
|
||||||
inData2 &= 0x7f;
|
inData2 &= 0x7f;
|
||||||
|
|
@ -209,15 +203,13 @@ MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings,
|
||||||
}
|
}
|
||||||
|
|
||||||
mTransport.endTransmission();
|
mTransport.endTransmission();
|
||||||
updateLastSentTime();
|
UpdateLastSentTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (inType >= Clock && inType <= SystemReset)
|
else if (inType >= Clock && inType <= SystemReset)
|
||||||
{
|
{
|
||||||
sendRealTime(inType); // System Real-time and 1 byte.
|
sendRealTime(inType); // System Real-time and 1 byte.
|
||||||
}
|
}
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
@ -232,11 +224,11 @@ MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings,
|
||||||
http://www.phys.unsw.edu.au/jw/notes.html
|
http://www.phys.unsw.edu.au/jw/notes.html
|
||||||
*/
|
*/
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::sendNoteOn(DataByte inNoteNumber,
|
void MidiInterface<Transport, Settings, Platform>::sendNoteOn(DataByte inNoteNumber,
|
||||||
DataByte inVelocity,
|
DataByte inVelocity,
|
||||||
Channel inChannel)
|
Channel inChannel)
|
||||||
{
|
{
|
||||||
return send(NoteOn, inNoteNumber, inVelocity, inChannel);
|
send(NoteOn, inNoteNumber, inVelocity, inChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Send a Note Off message
|
/*! \brief Send a Note Off message
|
||||||
|
|
@ -251,11 +243,11 @@ MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings,
|
||||||
http://www.phys.unsw.edu.au/jw/notes.html
|
http://www.phys.unsw.edu.au/jw/notes.html
|
||||||
*/
|
*/
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::sendNoteOff(DataByte inNoteNumber,
|
void MidiInterface<Transport, Settings, Platform>::sendNoteOff(DataByte inNoteNumber,
|
||||||
DataByte inVelocity,
|
DataByte inVelocity,
|
||||||
Channel inChannel)
|
Channel inChannel)
|
||||||
{
|
{
|
||||||
return send(NoteOff, inNoteNumber, inVelocity, inChannel);
|
send(NoteOff, inNoteNumber, inVelocity, inChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Send a Program Change message
|
/*! \brief Send a Program Change message
|
||||||
|
|
@ -263,10 +255,10 @@ MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings,
|
||||||
\param inChannel The channel on which the message will be sent (1 to 16).
|
\param inChannel The channel on which the message will be sent (1 to 16).
|
||||||
*/
|
*/
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::sendProgramChange(DataByte inProgramNumber,
|
void MidiInterface<Transport, Settings, Platform>::sendProgramChange(DataByte inProgramNumber,
|
||||||
Channel inChannel)
|
Channel inChannel)
|
||||||
{
|
{
|
||||||
return send(ProgramChange, inProgramNumber, 0, inChannel);
|
send(ProgramChange, inProgramNumber, 0, inChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Send a Control Change message
|
/*! \brief Send a Control Change message
|
||||||
|
|
@ -276,11 +268,11 @@ MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings,
|
||||||
@see MidiControlChangeNumber
|
@see MidiControlChangeNumber
|
||||||
*/
|
*/
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::sendControlChange(DataByte inControlNumber,
|
void MidiInterface<Transport, Settings, Platform>::sendControlChange(DataByte inControlNumber,
|
||||||
DataByte inControlValue,
|
DataByte inControlValue,
|
||||||
Channel inChannel)
|
Channel inChannel)
|
||||||
{
|
{
|
||||||
return send(ControlChange, inControlNumber, inControlValue, inChannel);
|
send(ControlChange, inControlNumber, inControlValue, inChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Send a Polyphonic AfterTouch message (applies to a specified note)
|
/*! \brief Send a Polyphonic AfterTouch message (applies to a specified note)
|
||||||
|
|
@ -291,11 +283,11 @@ MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings,
|
||||||
library, @see sendAfterTouch to send polyphonic and monophonic AfterTouch messages.
|
library, @see sendAfterTouch to send polyphonic and monophonic AfterTouch messages.
|
||||||
*/
|
*/
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::sendPolyPressure(DataByte inNoteNumber,
|
void MidiInterface<Transport, Settings, Platform>::sendPolyPressure(DataByte inNoteNumber,
|
||||||
DataByte inPressure,
|
DataByte inPressure,
|
||||||
Channel inChannel)
|
Channel inChannel)
|
||||||
{
|
{
|
||||||
return send(AfterTouchPoly, inNoteNumber, inPressure, inChannel);
|
send(AfterTouchPoly, inNoteNumber, inPressure, inChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Send a MonoPhonic AfterTouch message (applies to all notes)
|
/*! \brief Send a MonoPhonic AfterTouch message (applies to all notes)
|
||||||
|
|
@ -303,10 +295,10 @@ MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings,
|
||||||
\param inChannel The channel on which the message will be sent (1 to 16).
|
\param inChannel The channel on which the message will be sent (1 to 16).
|
||||||
*/
|
*/
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::sendAfterTouch(DataByte inPressure,
|
void MidiInterface<Transport, Settings, Platform>::sendAfterTouch(DataByte inPressure,
|
||||||
Channel inChannel)
|
Channel inChannel)
|
||||||
{
|
{
|
||||||
return send(AfterTouchChannel, inPressure, 0, inChannel);
|
send(AfterTouchChannel, inPressure, 0, inChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Send a Polyphonic AfterTouch message (applies to a specified note)
|
/*! \brief Send a Polyphonic AfterTouch message (applies to a specified note)
|
||||||
|
|
@ -316,11 +308,11 @@ MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings,
|
||||||
@see Replaces sendPolyPressure (which is now deprecated).
|
@see Replaces sendPolyPressure (which is now deprecated).
|
||||||
*/
|
*/
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::sendAfterTouch(DataByte inNoteNumber,
|
void MidiInterface<Transport, Settings, Platform>::sendAfterTouch(DataByte inNoteNumber,
|
||||||
DataByte inPressure,
|
DataByte inPressure,
|
||||||
Channel inChannel)
|
Channel inChannel)
|
||||||
{
|
{
|
||||||
return send(AfterTouchPoly, inNoteNumber, inPressure, inChannel);
|
send(AfterTouchPoly, inNoteNumber, inPressure, inChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Send a Pitch Bend message using a signed integer value.
|
/*! \brief Send a Pitch Bend message using a signed integer value.
|
||||||
|
|
@ -330,11 +322,11 @@ MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings,
|
||||||
\param inChannel The channel on which the message will be sent (1 to 16).
|
\param inChannel The channel on which the message will be sent (1 to 16).
|
||||||
*/
|
*/
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::sendPitchBend(int inPitchValue,
|
void MidiInterface<Transport, Settings, Platform>::sendPitchBend(int inPitchValue,
|
||||||
Channel inChannel)
|
Channel inChannel)
|
||||||
{
|
{
|
||||||
const unsigned bend = unsigned(inPitchValue - int(MIDI_PITCHBEND_MIN));
|
const unsigned bend = unsigned(inPitchValue - int(MIDI_PITCHBEND_MIN));
|
||||||
return send(PitchBend, (bend & 0x7f), (bend >> 7) & 0x7f, inChannel);
|
send(PitchBend, (bend & 0x7f), (bend >> 7) & 0x7f, inChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -345,12 +337,12 @@ MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings,
|
||||||
\param inChannel The channel on which the message will be sent (1 to 16).
|
\param inChannel The channel on which the message will be sent (1 to 16).
|
||||||
*/
|
*/
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::sendPitchBend(double inPitchValue,
|
void MidiInterface<Transport, Settings, Platform>::sendPitchBend(double inPitchValue,
|
||||||
Channel inChannel)
|
Channel inChannel)
|
||||||
{
|
{
|
||||||
const int scale = inPitchValue > 0.0 ? MIDI_PITCHBEND_MAX : - MIDI_PITCHBEND_MIN;
|
const int scale = inPitchValue > 0.0 ? MIDI_PITCHBEND_MAX : MIDI_PITCHBEND_MIN;
|
||||||
const int value = int(inPitchValue * double(scale));
|
const int value = int(inPitchValue * double(scale));
|
||||||
return sendPitchBend(value, inChannel);
|
sendPitchBend(value, inChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Generate and send a System Exclusive frame.
|
/*! \brief Generate and send a System Exclusive frame.
|
||||||
|
|
@ -363,7 +355,7 @@ MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings,
|
||||||
with previous versions of the library.
|
with previous versions of the library.
|
||||||
*/
|
*/
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::sendSysEx(unsigned inLength,
|
void MidiInterface<Transport, Settings, Platform>::sendSysEx(unsigned inLength,
|
||||||
const byte* inArray,
|
const byte* inArray,
|
||||||
bool inArrayContainsBoundaries)
|
bool inArrayContainsBoundaries)
|
||||||
{
|
{
|
||||||
|
|
@ -381,13 +373,11 @@ MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings,
|
||||||
mTransport.write(MidiType::SystemExclusiveEnd);
|
mTransport.write(MidiType::SystemExclusiveEnd);
|
||||||
|
|
||||||
mTransport.endTransmission();
|
mTransport.endTransmission();
|
||||||
updateLastSentTime();
|
UpdateLastSentTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Settings::UseRunningStatus)
|
if (Settings::UseRunningStatus)
|
||||||
mRunningStatus_TX = InvalidType;
|
mRunningStatus_TX = InvalidType;
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Send a Tune Request message.
|
/*! \brief Send a Tune Request message.
|
||||||
|
|
@ -396,9 +386,9 @@ MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings,
|
||||||
it should tune its oscillators (if equipped with any).
|
it should tune its oscillators (if equipped with any).
|
||||||
*/
|
*/
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::sendTuneRequest()
|
void MidiInterface<Transport, Settings, Platform>::sendTuneRequest()
|
||||||
{
|
{
|
||||||
return sendCommon(TuneRequest);
|
sendCommon(TuneRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Send a MIDI Time Code Quarter Frame.
|
/*! \brief Send a MIDI Time Code Quarter Frame.
|
||||||
|
|
@ -408,11 +398,11 @@ MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings,
|
||||||
See MIDI Specification for more information.
|
See MIDI Specification for more information.
|
||||||
*/
|
*/
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::sendTimeCodeQuarterFrame(DataByte inTypeNibble,
|
void MidiInterface<Transport, Settings, Platform>::sendTimeCodeQuarterFrame(DataByte inTypeNibble,
|
||||||
DataByte inValuesNibble)
|
DataByte inValuesNibble)
|
||||||
{
|
{
|
||||||
const byte data = byte((((inTypeNibble & 0x07) << 4) | (inValuesNibble & 0x0f)));
|
const byte data = byte((((inTypeNibble & 0x07) << 4) | (inValuesNibble & 0x0f)));
|
||||||
return sendTimeCodeQuarterFrame(data);
|
sendTimeCodeQuarterFrame(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Send a MIDI Time Code Quarter Frame.
|
/*! \brief Send a MIDI Time Code Quarter Frame.
|
||||||
|
|
@ -422,25 +412,25 @@ MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings,
|
||||||
you can send the byte here.
|
you can send the byte here.
|
||||||
*/
|
*/
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::sendTimeCodeQuarterFrame(DataByte inData)
|
void MidiInterface<Transport, Settings, Platform>::sendTimeCodeQuarterFrame(DataByte inData)
|
||||||
{
|
{
|
||||||
return sendCommon(TimeCodeQuarterFrame, inData);
|
sendCommon(TimeCodeQuarterFrame, inData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Send a Song Position Pointer message.
|
/*! \brief Send a Song Position Pointer message.
|
||||||
\param inBeats The number of beats since the start of the song.
|
\param inBeats The number of beats since the start of the song.
|
||||||
*/
|
*/
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::sendSongPosition(unsigned inBeats)
|
void MidiInterface<Transport, Settings, Platform>::sendSongPosition(unsigned inBeats)
|
||||||
{
|
{
|
||||||
return sendCommon(SongPosition, inBeats);
|
sendCommon(SongPosition, inBeats);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Send a Song Select message */
|
/*! \brief Send a Song Select message */
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::sendSongSelect(DataByte inSongNumber)
|
void MidiInterface<Transport, Settings, Platform>::sendSongSelect(DataByte inSongNumber)
|
||||||
{
|
{
|
||||||
return sendCommon(SongSelect, inSongNumber);
|
sendCommon(SongSelect, inSongNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Send a Common message. Common messages reset the running status.
|
/*! \brief Send a Common message. Common messages reset the running status.
|
||||||
|
|
@ -451,7 +441,7 @@ MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings,
|
||||||
\param inData1 The byte that goes with the common message.
|
\param inData1 The byte that goes with the common message.
|
||||||
*/
|
*/
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::sendCommon(MidiType inType, unsigned inData1)
|
void MidiInterface<Transport, Settings, Platform>::sendCommon(MidiType inType, unsigned inData1)
|
||||||
{
|
{
|
||||||
switch (inType)
|
switch (inType)
|
||||||
{
|
{
|
||||||
|
|
@ -462,7 +452,7 @@ MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings,
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// Invalid Common marker
|
// Invalid Common marker
|
||||||
return *this;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mTransport.beginTransmission(inType))
|
if (mTransport.beginTransmission(inType))
|
||||||
|
|
@ -482,19 +472,15 @@ MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings,
|
||||||
break;
|
break;
|
||||||
case TuneRequest:
|
case TuneRequest:
|
||||||
break;
|
break;
|
||||||
// LCOV_EXCL_START - Coverage blind spot
|
|
||||||
default:
|
default:
|
||||||
break;
|
break; // LCOV_EXCL_LINE - Coverage blind spot
|
||||||
// LCOV_EXCL_STOP
|
|
||||||
}
|
}
|
||||||
mTransport.endTransmission();
|
mTransport.endTransmission();
|
||||||
updateLastSentTime();
|
UpdateLastSentTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Settings::UseRunningStatus)
|
if (Settings::UseRunningStatus)
|
||||||
mRunningStatus_TX = InvalidType;
|
mRunningStatus_TX = InvalidType;
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Send a Real Time (one byte) message.
|
/*! \brief Send a Real Time (one byte) message.
|
||||||
|
|
@ -504,7 +490,7 @@ MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings,
|
||||||
@see MidiType
|
@see MidiType
|
||||||
*/
|
*/
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::sendRealTime(MidiType inType)
|
void MidiInterface<Transport, Settings, Platform>::sendRealTime(MidiType inType)
|
||||||
{
|
{
|
||||||
// Do not invalidate Running Status for real-time messages
|
// Do not invalidate Running Status for real-time messages
|
||||||
// as they can be interleaved within any message.
|
// as they can be interleaved within any message.
|
||||||
|
|
@ -521,15 +507,13 @@ MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings,
|
||||||
{
|
{
|
||||||
mTransport.write((byte)inType);
|
mTransport.write((byte)inType);
|
||||||
mTransport.endTransmission();
|
mTransport.endTransmission();
|
||||||
updateLastSentTime();
|
UpdateLastSentTime();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// Invalid Real Time marker
|
// Invalid Real Time marker
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Start a Registered Parameter Number frame.
|
/*! \brief Start a Registered Parameter Number frame.
|
||||||
|
|
@ -537,7 +521,7 @@ MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings,
|
||||||
\param inChannel The channel on which the message will be sent (1 to 16).
|
\param inChannel The channel on which the message will be sent (1 to 16).
|
||||||
*/
|
*/
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
inline MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::beginRpn(unsigned inNumber,
|
inline void MidiInterface<Transport, Settings, Platform>::beginRpn(unsigned inNumber,
|
||||||
Channel inChannel)
|
Channel inChannel)
|
||||||
{
|
{
|
||||||
if (mCurrentRpnNumber != inNumber)
|
if (mCurrentRpnNumber != inNumber)
|
||||||
|
|
@ -548,8 +532,6 @@ inline MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Se
|
||||||
sendControlChange(RPNMSB, numMsb, inChannel);
|
sendControlChange(RPNMSB, numMsb, inChannel);
|
||||||
mCurrentRpnNumber = inNumber;
|
mCurrentRpnNumber = inNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Send a 14-bit value for the currently selected RPN number.
|
/*! \brief Send a 14-bit value for the currently selected RPN number.
|
||||||
|
|
@ -557,15 +539,13 @@ inline MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Se
|
||||||
\param inChannel The channel on which the message will be sent (1 to 16).
|
\param inChannel The channel on which the message will be sent (1 to 16).
|
||||||
*/
|
*/
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
inline MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::sendRpnValue(unsigned inValue,
|
inline void MidiInterface<Transport, Settings, Platform>::sendRpnValue(unsigned inValue,
|
||||||
Channel inChannel)
|
Channel inChannel)
|
||||||
{;
|
{;
|
||||||
const byte valMsb = 0x7f & (inValue >> 7);
|
const byte valMsb = 0x7f & (inValue >> 7);
|
||||||
const byte valLsb = 0x7f & inValue;
|
const byte valLsb = 0x7f & inValue;
|
||||||
sendControlChange(DataEntryMSB, valMsb, inChannel);
|
sendControlChange(DataEntryMSB, valMsb, inChannel);
|
||||||
sendControlChange(DataEntryLSB, valLsb, inChannel);
|
sendControlChange(DataEntryLSB, valLsb, inChannel);
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Send separate MSB/LSB values for the currently selected RPN number.
|
/*! \brief Send separate MSB/LSB values for the currently selected RPN number.
|
||||||
|
|
@ -574,38 +554,32 @@ inline MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Se
|
||||||
\param inChannel The channel on which the message will be sent (1 to 16).
|
\param inChannel The channel on which the message will be sent (1 to 16).
|
||||||
*/
|
*/
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
inline MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::sendRpnValue(byte inMsb,
|
inline void MidiInterface<Transport, Settings, Platform>::sendRpnValue(byte inMsb,
|
||||||
byte inLsb,
|
byte inLsb,
|
||||||
Channel inChannel)
|
Channel inChannel)
|
||||||
{
|
{
|
||||||
sendControlChange(DataEntryMSB, inMsb, inChannel);
|
sendControlChange(DataEntryMSB, inMsb, inChannel);
|
||||||
sendControlChange(DataEntryLSB, inLsb, inChannel);
|
sendControlChange(DataEntryLSB, inLsb, inChannel);
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* \brief Increment the value of the currently selected RPN number by the specified amount.
|
/* \brief Increment the value of the currently selected RPN number by the specified amount.
|
||||||
\param inAmount The amount to add to the currently selected RPN value.
|
\param inAmount The amount to add to the currently selected RPN value.
|
||||||
*/
|
*/
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
inline MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::sendRpnIncrement(byte inAmount,
|
inline void MidiInterface<Transport, Settings, Platform>::sendRpnIncrement(byte inAmount,
|
||||||
Channel inChannel)
|
Channel inChannel)
|
||||||
{
|
{
|
||||||
sendControlChange(DataIncrement, inAmount, inChannel);
|
sendControlChange(DataIncrement, inAmount, inChannel);
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* \brief Decrement the value of the currently selected RPN number by the specified amount.
|
/* \brief Decrement the value of the currently selected RPN number by the specified amount.
|
||||||
\param inAmount The amount to subtract to the currently selected RPN value.
|
\param inAmount The amount to subtract to the currently selected RPN value.
|
||||||
*/
|
*/
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
inline MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::sendRpnDecrement(byte inAmount,
|
inline void MidiInterface<Transport, Settings, Platform>::sendRpnDecrement(byte inAmount,
|
||||||
Channel inChannel)
|
Channel inChannel)
|
||||||
{
|
{
|
||||||
sendControlChange(DataDecrement, inAmount, inChannel);
|
sendControlChange(DataDecrement, inAmount, inChannel);
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Terminate an RPN frame.
|
/*! \brief Terminate an RPN frame.
|
||||||
|
|
@ -613,13 +587,11 @@ This will send a Null Function to deselect the currently selected RPN.
|
||||||
\param inChannel The channel on which the message will be sent (1 to 16).
|
\param inChannel The channel on which the message will be sent (1 to 16).
|
||||||
*/
|
*/
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
inline MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::endRpn(Channel inChannel)
|
inline void MidiInterface<Transport, Settings, Platform>::endRpn(Channel inChannel)
|
||||||
{
|
{
|
||||||
sendControlChange(RPNLSB, 0x7f, inChannel);
|
sendControlChange(RPNLSB, 0x7f, inChannel);
|
||||||
sendControlChange(RPNMSB, 0x7f, inChannel);
|
sendControlChange(RPNMSB, 0x7f, inChannel);
|
||||||
mCurrentRpnNumber = 0xffff;
|
mCurrentRpnNumber = 0xffff;
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -629,7 +601,7 @@ inline MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Se
|
||||||
\param inChannel The channel on which the message will be sent (1 to 16).
|
\param inChannel The channel on which the message will be sent (1 to 16).
|
||||||
*/
|
*/
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
inline MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::beginNrpn(unsigned inNumber,
|
inline void MidiInterface<Transport, Settings, Platform>::beginNrpn(unsigned inNumber,
|
||||||
Channel inChannel)
|
Channel inChannel)
|
||||||
{
|
{
|
||||||
if (mCurrentNrpnNumber != inNumber)
|
if (mCurrentNrpnNumber != inNumber)
|
||||||
|
|
@ -640,8 +612,6 @@ inline MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Se
|
||||||
sendControlChange(NRPNMSB, numMsb, inChannel);
|
sendControlChange(NRPNMSB, numMsb, inChannel);
|
||||||
mCurrentNrpnNumber = inNumber;
|
mCurrentNrpnNumber = inNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Send a 14-bit value for the currently selected NRPN number.
|
/*! \brief Send a 14-bit value for the currently selected NRPN number.
|
||||||
|
|
@ -649,15 +619,13 @@ inline MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Se
|
||||||
\param inChannel The channel on which the message will be sent (1 to 16).
|
\param inChannel The channel on which the message will be sent (1 to 16).
|
||||||
*/
|
*/
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
inline MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::sendNrpnValue(unsigned inValue,
|
inline void MidiInterface<Transport, Settings, Platform>::sendNrpnValue(unsigned inValue,
|
||||||
Channel inChannel)
|
Channel inChannel)
|
||||||
{
|
{;
|
||||||
const byte valMsb = 0x7f & (inValue >> 7);
|
const byte valMsb = 0x7f & (inValue >> 7);
|
||||||
const byte valLsb = 0x7f & inValue;
|
const byte valLsb = 0x7f & inValue;
|
||||||
sendControlChange(DataEntryMSB, valMsb, inChannel);
|
sendControlChange(DataEntryMSB, valMsb, inChannel);
|
||||||
sendControlChange(DataEntryLSB, valLsb, inChannel);
|
sendControlChange(DataEntryLSB, valLsb, inChannel);
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Send separate MSB/LSB values for the currently selected NRPN number.
|
/*! \brief Send separate MSB/LSB values for the currently selected NRPN number.
|
||||||
|
|
@ -666,38 +634,32 @@ inline MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Se
|
||||||
\param inChannel The channel on which the message will be sent (1 to 16).
|
\param inChannel The channel on which the message will be sent (1 to 16).
|
||||||
*/
|
*/
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
inline MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::sendNrpnValue(byte inMsb,
|
inline void MidiInterface<Transport, Settings, Platform>::sendNrpnValue(byte inMsb,
|
||||||
byte inLsb,
|
byte inLsb,
|
||||||
Channel inChannel)
|
Channel inChannel)
|
||||||
{
|
{
|
||||||
sendControlChange(DataEntryMSB, inMsb, inChannel);
|
sendControlChange(DataEntryMSB, inMsb, inChannel);
|
||||||
sendControlChange(DataEntryLSB, inLsb, inChannel);
|
sendControlChange(DataEntryLSB, inLsb, inChannel);
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* \brief Increment the value of the currently selected NRPN number by the specified amount.
|
/* \brief Increment the value of the currently selected NRPN number by the specified amount.
|
||||||
\param inAmount The amount to add to the currently selected NRPN value.
|
\param inAmount The amount to add to the currently selected NRPN value.
|
||||||
*/
|
*/
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
inline MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::sendNrpnIncrement(byte inAmount,
|
inline void MidiInterface<Transport, Settings, Platform>::sendNrpnIncrement(byte inAmount,
|
||||||
Channel inChannel)
|
Channel inChannel)
|
||||||
{
|
{
|
||||||
sendControlChange(DataIncrement, inAmount, inChannel);
|
sendControlChange(DataIncrement, inAmount, inChannel);
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* \brief Decrement the value of the currently selected NRPN number by the specified amount.
|
/* \brief Decrement the value of the currently selected NRPN number by the specified amount.
|
||||||
\param inAmount The amount to subtract to the currently selected NRPN value.
|
\param inAmount The amount to subtract to the currently selected NRPN value.
|
||||||
*/
|
*/
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
inline MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::sendNrpnDecrement(byte inAmount,
|
inline void MidiInterface<Transport, Settings, Platform>::sendNrpnDecrement(byte inAmount,
|
||||||
Channel inChannel)
|
Channel inChannel)
|
||||||
{
|
{
|
||||||
sendControlChange(DataDecrement, inAmount, inChannel);
|
sendControlChange(DataDecrement, inAmount, inChannel);
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Terminate an NRPN frame.
|
/*! \brief Terminate an NRPN frame.
|
||||||
|
|
@ -705,20 +667,11 @@ This will send a Null Function to deselect the currently selected NRPN.
|
||||||
\param inChannel The channel on which the message will be sent (1 to 16).
|
\param inChannel The channel on which the message will be sent (1 to 16).
|
||||||
*/
|
*/
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
inline MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::endNrpn(Channel inChannel)
|
inline void MidiInterface<Transport, Settings, Platform>::endNrpn(Channel inChannel)
|
||||||
{
|
{
|
||||||
sendControlChange(NRPNLSB, 0x7f, inChannel);
|
sendControlChange(NRPNLSB, 0x7f, inChannel);
|
||||||
sendControlChange(NRPNMSB, 0x7f, inChannel);
|
sendControlChange(NRPNMSB, 0x7f, inChannel);
|
||||||
mCurrentNrpnNumber = 0xffff;
|
mCurrentNrpnNumber = 0xffff;
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class Transport, class Settings, class Platform>
|
|
||||||
inline void MidiInterface<Transport, Settings, Platform>::updateLastSentTime()
|
|
||||||
{
|
|
||||||
if (Settings::UseSenderActiveSensing && mSenderActiveSensingPeriodicity)
|
|
||||||
mLastMessageSentTime = Platform::now();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! @} */ // End of doc group MIDI Output
|
/*! @} */ // End of doc group MIDI Output
|
||||||
|
|
@ -922,7 +875,7 @@ bool MidiInterface<Transport, Settings, Platform>::parse()
|
||||||
|
|
||||||
case SystemExclusiveStart:
|
case SystemExclusiveStart:
|
||||||
case SystemExclusiveEnd:
|
case SystemExclusiveEnd:
|
||||||
// The message can be any length
|
// The message can be any lenght
|
||||||
// between 3 and MidiMessage::sSysExMaxSize bytes
|
// between 3 and MidiMessage::sSysExMaxSize bytes
|
||||||
mPendingMessageExpectedLength = MidiMessage::sSysExMaxSize;
|
mPendingMessageExpectedLength = MidiMessage::sSysExMaxSize;
|
||||||
mRunningStatus_RX = InvalidType;
|
mRunningStatus_RX = InvalidType;
|
||||||
|
|
@ -1028,10 +981,9 @@ bool MidiInterface<Transport, Settings, Platform>::parse()
|
||||||
resetInput();
|
resetInput();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// LCOV_EXCL_START - Coverage blind spot
|
|
||||||
default:
|
default:
|
||||||
break;
|
break; // LCOV_EXCL_LINE - Coverage blind spot
|
||||||
// LCOV_EXCL_STOP
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1221,7 +1173,7 @@ inline const byte* MidiInterface<Transport, Settings, Platform>::getSysExArray()
|
||||||
return mMessage.sysexArray;
|
return mMessage.sysexArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Get the length of the System Exclusive array.
|
/*! \brief Get the lenght of the System Exclusive array.
|
||||||
|
|
||||||
It is coded using data1 as LSB and data2 as MSB.
|
It is coded using data1 as LSB and data2 as MSB.
|
||||||
\return The array's length, in bytes.
|
\return The array's length, in bytes.
|
||||||
|
|
@ -1252,11 +1204,9 @@ inline Channel MidiInterface<Transport, Settings, Platform>::getInputChannel() c
|
||||||
if you want to listen to all channels, and MIDI_CHANNEL_OFF to disable input.
|
if you want to listen to all channels, and MIDI_CHANNEL_OFF to disable input.
|
||||||
*/
|
*/
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
inline MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::setInputChannel(Channel inChannel)
|
inline void MidiInterface<Transport, Settings, Platform>::setInputChannel(Channel inChannel)
|
||||||
{
|
{
|
||||||
mInputChannel = inChannel;
|
mInputChannel = inChannel;
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
@ -1311,7 +1261,7 @@ bool MidiInterface<Transport, Settings, Platform>::isChannelMessage(MidiType inT
|
||||||
When a message of this type is received, no function will be called.
|
When a message of this type is received, no function will be called.
|
||||||
*/
|
*/
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::disconnectCallbackFromType(MidiType inType)
|
void MidiInterface<Transport, Settings, Platform>::disconnectCallbackFromType(MidiType inType)
|
||||||
{
|
{
|
||||||
switch (inType)
|
switch (inType)
|
||||||
{
|
{
|
||||||
|
|
@ -1337,8 +1287,6 @@ MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings,
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! @} */ // End of doc group MIDI Callbacks
|
/*! @} */ // End of doc group MIDI Callbacks
|
||||||
|
|
@ -1381,11 +1329,9 @@ void MidiInterface<Transport, Settings, Platform>::launchCallback()
|
||||||
|
|
||||||
case SystemReset: if (mSystemResetCallback != nullptr) mSystemResetCallback(); break;
|
case SystemReset: if (mSystemResetCallback != nullptr) mSystemResetCallback(); break;
|
||||||
|
|
||||||
// LCOV_EXCL_START - Unreacheable code, but prevents unhandled case warning.
|
|
||||||
case InvalidType:
|
case InvalidType:
|
||||||
default:
|
default:
|
||||||
break;
|
break; // LCOV_EXCL_LINE - Unreacheable code, but prevents unhandled case warning.
|
||||||
// LCOV_EXCL_STOP
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1405,12 +1351,10 @@ void MidiInterface<Transport, Settings, Platform>::launchCallback()
|
||||||
@see Thru::Mode
|
@see Thru::Mode
|
||||||
*/
|
*/
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
inline MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::setThruFilterMode(Thru::Mode inThruFilterMode)
|
inline void MidiInterface<Transport, Settings, Platform>::setThruFilterMode(Thru::Mode inThruFilterMode)
|
||||||
{
|
{
|
||||||
mThruFilterMode = inThruFilterMode;
|
mThruFilterMode = inThruFilterMode;
|
||||||
mThruActivated = mThruFilterMode != Thru::Off;
|
mThruActivated = mThruFilterMode != Thru::Off;
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
|
|
@ -1426,23 +1370,25 @@ inline bool MidiInterface<Transport, Settings, Platform>::getThruState() const
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
inline MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::turnThruOn(Thru::Mode inThruFilterMode)
|
inline void MidiInterface<Transport, Settings, Platform>::turnThruOn(Thru::Mode inThruFilterMode)
|
||||||
{
|
{
|
||||||
mThruActivated = true;
|
mThruActivated = true;
|
||||||
mThruFilterMode = inThruFilterMode;
|
mThruFilterMode = inThruFilterMode;
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Transport, class Settings, class Platform>
|
template<class Transport, class Settings, class Platform>
|
||||||
inline MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::turnThruOff()
|
inline void MidiInterface<Transport, Settings, Platform>::turnThruOff()
|
||||||
{
|
{
|
||||||
mThruActivated = false;
|
mThruActivated = false;
|
||||||
mThruFilterMode = Thru::Off;
|
mThruFilterMode = Thru::Off;
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class Transport, class Settings, class Platform>
|
||||||
|
inline void MidiInterface<Transport, Settings, Platform>::UpdateLastSentTime()
|
||||||
|
{
|
||||||
|
if (Settings::UseSenderActiveSensing && mSenderActiveSensingPeriodicity)
|
||||||
|
mLastMessageSentTime = Platform::now();
|
||||||
|
}
|
||||||
|
|
||||||
/*! @} */ // End of doc group MIDI Thru
|
/*! @} */ // End of doc group MIDI Thru
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -164,22 +164,8 @@ enum MidiControlChangeNumber: uint8_t
|
||||||
GeneralPurposeController2 = 17,
|
GeneralPurposeController2 = 17,
|
||||||
GeneralPurposeController3 = 18,
|
GeneralPurposeController3 = 18,
|
||||||
GeneralPurposeController4 = 19,
|
GeneralPurposeController4 = 19,
|
||||||
// CC20 to CC31 undefined
|
|
||||||
BankSelectLSB = 32,
|
|
||||||
ModulationWheelLSB = 33,
|
|
||||||
BreathControllerLSB = 34,
|
|
||||||
// CC35 undefined
|
|
||||||
FootControllerLSB = 36,
|
|
||||||
PortamentoTimeLSB = 37,
|
|
||||||
DataEntryLSB = 38,
|
DataEntryLSB = 38,
|
||||||
ChannelVolumeLSB = 39,
|
|
||||||
BalanceLSB = 40,
|
|
||||||
// CC41 undefined
|
|
||||||
PanLSB = 42,
|
|
||||||
ExpressionControllerLSB = 43,
|
|
||||||
EffectControl1LSB = 44,
|
|
||||||
EffectControl2LSB = 45,
|
|
||||||
// CC46 to CC63 undefined
|
|
||||||
|
|
||||||
// Switches ----------------------------------------------------------------
|
// Switches ----------------------------------------------------------------
|
||||||
Sustain = 64,
|
Sustain = 64,
|
||||||
|
|
@ -217,7 +203,6 @@ enum MidiControlChangeNumber: uint8_t
|
||||||
NRPNMSB = 99, ///< Non-Registered Parameter Number (MSB)
|
NRPNMSB = 99, ///< Non-Registered Parameter Number (MSB)
|
||||||
RPNLSB = 100, ///< Registered Parameter Number (LSB)
|
RPNLSB = 100, ///< Registered Parameter Number (LSB)
|
||||||
RPNMSB = 101, ///< Registered Parameter Number (MSB)
|
RPNMSB = 101, ///< Registered Parameter Number (MSB)
|
||||||
// CC102 to CC119 undefined
|
|
||||||
|
|
||||||
// Channel Mode messages ---------------------------------------------------
|
// Channel Mode messages ---------------------------------------------------
|
||||||
AllSoundOff = 120,
|
AllSoundOff = 120,
|
||||||
|
|
|
||||||
|
|
@ -54,20 +54,6 @@ struct Message
|
||||||
memset(sysexArray, 0, sSysExMaxSize * sizeof(DataByte));
|
memset(sysexArray, 0, sSysExMaxSize * sizeof(DataByte));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Message(const Message& inOther)
|
|
||||||
: channel(inOther.channel)
|
|
||||||
, type(inOther.type)
|
|
||||||
, data1(inOther.data1)
|
|
||||||
, data2(inOther.data2)
|
|
||||||
, valid(inOther.valid)
|
|
||||||
, length(inOther.length)
|
|
||||||
{
|
|
||||||
if (type == midi::SystemExclusive)
|
|
||||||
{
|
|
||||||
memcpy(sysexArray, inOther.sysexArray, sSysExMaxSize * sizeof(DataByte));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! The maximum size for the System Exclusive array.
|
/*! The maximum size for the System Exclusive array.
|
||||||
*/
|
*/
|
||||||
static const unsigned sSysExMaxSize = SysExMaxSize;
|
static const unsigned sSysExMaxSize = SysExMaxSize;
|
||||||
|
|
@ -108,24 +94,12 @@ struct Message
|
||||||
/*! Total Length of the message.
|
/*! Total Length of the message.
|
||||||
*/
|
*/
|
||||||
unsigned length;
|
unsigned length;
|
||||||
|
|
||||||
inline unsigned getSysExSize() const
|
inline unsigned getSysExSize() const
|
||||||
{
|
{
|
||||||
const unsigned size = unsigned(data2) << 8 | data1;
|
const unsigned size = unsigned(data2) << 8 | data1;
|
||||||
return size > sSysExMaxSize ? sSysExMaxSize : size;
|
return size > sSysExMaxSize ? sSysExMaxSize : size;
|
||||||
}
|
}
|
||||||
inline bool isSystemRealTime () const
|
|
||||||
{
|
|
||||||
return (type & 0xf8) == 0xf8;
|
|
||||||
}
|
|
||||||
inline bool isSystemCommon () const
|
|
||||||
{
|
|
||||||
return (type & 0xf8) == 0xf0;
|
|
||||||
}
|
|
||||||
inline bool isChannelMessage () const
|
|
||||||
{
|
|
||||||
return (type & 0xf0) != 0xf0;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
END_MIDI_NAMESPACE
|
END_MIDI_NAMESPACE
|
||||||
|
|
|
||||||
|
|
@ -38,12 +38,12 @@ BEGIN_MIDI_NAMESPACE
|
||||||
macro to create your instance. The settings you don't override will keep their
|
macro to create your instance. The settings you don't override will keep their
|
||||||
default value. Eg:
|
default value. Eg:
|
||||||
\code{.cpp}
|
\code{.cpp}
|
||||||
struct MySettings : public MIDI_NAMESPACE::DefaultSettings
|
struct MySettings : public midi::DefaultSettings
|
||||||
{
|
{
|
||||||
static const unsigned SysExMaxSize = 1024; // Accept SysEx messages up to 1024 bytes long.
|
static const unsigned SysExMaxSize = 1024; // Accept SysEx messages up to 1024 bytes long.
|
||||||
};
|
};
|
||||||
|
|
||||||
MIDI_CREATE_CUSTOM_INSTANCE(HardwareSerial, Serial2, MIDI, MySettings);
|
MIDI_CREATE_CUSTOM_INSTANCE(HardwareSerial, Serial2, midi, MySettings);
|
||||||
\endcode
|
\endcode
|
||||||
*/
|
*/
|
||||||
struct DefaultSettings
|
struct DefaultSettings
|
||||||
|
|
|
||||||
|
|
@ -51,9 +51,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const bool thruActivated = true;
|
void begin()
|
||||||
|
|
||||||
void begin()
|
|
||||||
{
|
{
|
||||||
// Initialise the Serial port
|
// Initialise the Serial port
|
||||||
#if defined(AVR_CAKE)
|
#if defined(AVR_CAKE)
|
||||||
|
|
@ -63,11 +61,6 @@ public:
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void end()
|
|
||||||
{
|
|
||||||
mSerial.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool beginTransmission(MidiType)
|
bool beginTransmission(MidiType)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -96,8 +89,6 @@ private:
|
||||||
SerialPort& mSerial;
|
SerialPort& mSerial;
|
||||||
};
|
};
|
||||||
|
|
||||||
END_MIDI_NAMESPACE
|
|
||||||
|
|
||||||
/*! \brief Create an instance of the library attached to a serial port.
|
/*! \brief Create an instance of the library attached to a serial port.
|
||||||
You can use HardwareSerial or SoftwareSerial for the serial port.
|
You can use HardwareSerial or SoftwareSerial for the serial port.
|
||||||
Example: MIDI_CREATE_INSTANCE(HardwareSerial, Serial2, midi2);
|
Example: MIDI_CREATE_INSTANCE(HardwareSerial, Serial2, midi2);
|
||||||
|
|
@ -120,11 +111,5 @@ END_MIDI_NAMESPACE
|
||||||
MIDI_CREATE_INSTANCE(HardwareSerial, Serial, MIDI);
|
MIDI_CREATE_INSTANCE(HardwareSerial, Serial, MIDI);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*! \brief Create an instance of the library attached to a serial port with
|
|
||||||
custom settings.
|
END_MIDI_NAMESPACE
|
||||||
@see DefaultSettings
|
|
||||||
@see MIDI_CREATE_INSTANCE
|
|
||||||
*/
|
|
||||||
#define MIDI_CREATE_CUSTOM_INSTANCE(Type, SerialPort, Name, Settings) \
|
|
||||||
MIDI_NAMESPACE::SerialMIDI<Type> serial##Name(SerialPort);\
|
|
||||||
MIDI_NAMESPACE::MidiInterface<MIDI_NAMESPACE::SerialMIDI<Type>, Settings> Name((MIDI_NAMESPACE::SerialMIDI<Type>&)serial##Name);
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue