Comments (4)
Look at the creation MACRO:
This prefixes the chosen name (BLUETOOTHMIDI
) with BLE
and becomes: BLEBLUETOOTHMIDI
Working sketch:
#include <BLEMIDI_Transport.h>
#include <hardware/BLEMIDI_ESP32_NimBLE.h>
//#include <hardware/BLEMIDI_ESP32.h>
//#include <hardware/BLEMIDI_nRF52.h>
//#include <hardware/BLEMIDI_ArduinoBLE.h>
//BLEMIDI_CREATE_DEFAULT_INSTANCE()
BLEMIDI_CREATE_INSTANCE("BLMIDIESP32", BLUETOOTHMIDI)
unsigned long t0 = millis();
bool BLMisConnected = true; //set it to yes to see it running
// -----------------------------------------------------------------------------
// When BLE connected, LED will turn on (indication that connection was successful)
// When receiving a NoteOn, LED will go out, on NoteOff, light comes back on.
// This is an easy and conveniant way to show that the connection is alive and working.
// -----------------------------------------------------------------------------
void setup()
{
BLUETOOTHMIDI.begin();
pinMode(4, OUTPUT);
digitalWrite(4, LOW);
// uncommented by me
BLEBLUETOOTHMIDI.setHandleConnected([]() {
BLMisConnected = true;
digitalWrite(4, HIGH);
});
// uncommented by me
// BLEMIDI.setHandleDisconnected([]() {
// BLMisConnected = false;
// digitalWrite(4, LOW);
// });
BLUETOOTHMIDI.setHandleNoteOn([](byte channel, byte note, byte velocity) {
digitalWrite(4, LOW);
});
BLUETOOTHMIDI.setHandleNoteOff([](byte channel, byte note, byte velocity) {
digitalWrite(4, HIGH);
});
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void loop()
{
BLUETOOTHMIDI.read();
if (BLMisConnected && (millis() - t0) > 1000)
{
t0 = millis();
BLUETOOTHMIDI.sendNoteOn (60, 100, 1); // note 60, velocity 100 on channel 1
}
}
Good luck!
from arduino-ble-midi.
The #include <hardware/BLEMIDI_ESP32.h>
indeed creates errors (ESP32 repo has recently changed, that may be the source of the error), but NimBLE
works fine.
Change the code to:
#include <BLEMIDI_Transport.h>
#include <hardware/BLEMIDI_ESP32_NimBLE.h>
//#include <hardware/BLEMIDI_ESP32.h>
//#include <hardware/BLEMIDI_nRF52.h>
//#include <hardware/BLEMIDI_ArduinoBLE.h>
from arduino-ble-midi.
Thanks for your fast reply, I feel honored. :)
I'd like to use the "BLMisConnected" variable so uncommented this:
BLEMIDI.setHandleConnected([]() { // 'class midi::MidiInterface<bleMidi::BLEMIDI_Transport<bleMidi::BLEMIDI_ESP32>,
// bleMidi::MySettings>' has no member named 'setHandleConnected'
BLMisConnected = true;
digitalWrite(4, HIGH);
});
It does not compile -
28:17: error: 'class midi::MidiInterface<bleMidi::BLEMIDI_TransportbleMidi::BLEMIDI_ESP32_NimBLE, bleMidi::MySettings>' has no member named 'setHandleConnected'
BLUETOOTHMIDI.setHandleConnected( { // 'class midi::MidiInterface<bleMidi::BLEMIDI_TransportbleMidi::BLEMIDI_ESP32,
and when renamed to BLEMIDI I get:
28:3: error: 'BLEMIDI' was not declared in this scope
BLEMIDI.setHandleConnected( { // 'class midi::MidiInterface<bleMidi::BLEMIDI_TransportbleMidi::BLEMIDI_ESP32,
:(
How can I achieve to use that variable?
Thanks!
from arduino-ble-midi.
Thank you very much. This worked perfectly!
from arduino-ble-midi.
Related Issues (20)
- Password when pairing. HOT 3
- esp32 BLE-Midi and BluetoothSerial in the same project HOT 2
- decuple from midi transport? HOT 1
- BLE MIDI Client, get servers list HOT 5
- BLE MIDI Client, ESP32-S3, keeps sending serial when not connected HOT 5
- Midi steps audible when sending a stream of CC messages for volume control HOT 8
- BLE-MIDI client: Changes in NimBLE version 1.4.1 HOT 3
- Compatibility with Arduino GIGA (Arduino-mbed)
- Wrong channel number on polyphony?
- Renaming it Self and loosing connection if either Serial.begin() or Serial1.begin() is used
- Renaming it self and loosing connection if Serial1 or Serial is used.
- Active Sensing HOT 2
- BLE Client Problem with Adafruit TinyUSB HOT 2
- Error compiling on Nano 33 BLE HOT 1
- Trying to get bluetooth midi for Arduino Nano 33 BLE sense rev2 HOT 2
- Issue with Ableton and midi "feedback" HOT 6
- Can't compile anymore on arduino 2.3 - conversion from 'String' to non-scalar type 'std::string' HOT 3
- Bluetooth pairing for Arduino nano 33 BLE // auto connect with macOS HOT 5
- Data is “swallowed”...?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arduino-ble-midi.