DIY - Wireless MIDI BLE

Started by admin, April 03, 2017, 09:12:25 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

admin




admin

https://www.adafruit.com/product/2829

http://www.ebay.com/itm/Adafruit-Feather-32u4-Bluefruit-LE-Bluetooth-Dev-Board-ATmega32u4-w-Arduino-IDE-/181950076095?hash=item2a5d11d4bf:g:bpgAAOSwcBhWYB-c




Description
Feather is the new development board from Adafruit, and like it's namesake it is thin, light, and lets you fly! Feather was designed to be a new standard for portable microcontroller cores.

This is the Adafruit Feather 32u4 Bluefruit - our take on an 'all-in-one' Arduino-compatible + Bluetooth Low Energy with built in USB and battery charging. Its an Adafruit Feather 32u4 with a BTLE module, ready to rock! We have other boards in the Feather family, check'em out here.

Bluetooth Low Energy is the hottest new low-power, 2.4GHz spectrum wireless protocol. In particular, its the only wireless protocol that you can use with iOS without needing special certification and it's supported by all modern smart phones. This makes it excellent for use in portable projects that will make use of an iOS or Android phone or tablet. It also is supported in Mac OS X and Windows 8+.

At the Feather 32u4's heart is at ATmega32u4 clocked at 8 MHz and at 3.3V logic, a chip setup we've had tons of experience with as it's the same as the Flora. This chip has 32K of flash and 2K of RAM, with built in USB so not only does it have a USB-to-Serial program & debug capability built in with no need for an FTDI-like chip, it can also act like a mouse, keyboard, USB MIDI device, etc.

To make it easy to use for portable projects, there is a connector for any of our 3.7V Lithium polymer batteries and built in battery charging. You don't need a battery, it will run just fine straight from the micro USB connector. But, if you do have a battery, you can take it on the go, then plug in the USB to recharge. The Feather will automatically switch over to USB power when its available. We also tied the battery thru a divider to an analog pin, so you can measure and monitor the battery voltage to detect when you need a recharge.

Here's some handy specs! Like all Feather 32u4's you get:

Measures 2.0" x 0.9" x 0.28" (51mm x 23mm x 8mm) without headers soldered in
Light as a (large?) feather - 5.7 grams
ATmega32u4 @ 8MHz with 3.3V logic/power
3.3V regulator with 500mA peak current output
USB native support, comes with USB bootloader and serial port debugging
You also get tons of pins - 20 GPIO pins
Hardware Serial, hardware I2C, hardware SPI support
8 x PWM pins
10 x analog inputs
Built in 100mA lipoly charger with charging status indicator LED
Pin #13 red LED for general purpose blinking
Power/enable pin
4 mounting holes
Reset button
The Feather 32u4 Bluefruit LE uses the extra space left over to add our excellent Bluefruit BTLE module + two status indicator LEDs.

The Power of Bluefruit LE

The Bluefruit LE module is an nRF51822 chipset from Nordic, programmed with multi-function code that can do quite a lot! For most people, they'll be very happy to use the standard Nordic UART RX/TX connection profile. In this profile, the Bluefruit acts as a data pipe, that can 'transparently' transmit back and forth from your iOS or Android device. You can use the Adafruit iOS App or Android App, or write your own to communicate with the UART service.

The board is capable of much more than just sending strings over the air! Thanks to an easy to learn AT command set, you have full control over how the device behaves, including the ability to define and manipulate your own GATT Services and Characteristics, or change the way that the device advertises itself for other Bluetooth Low Energy devices to see. You can also use the AT commands to query the die temperature, check the battery voltage, and more, check the connection RSSI or MAC address, and tons more. Really, way too long to list here!

Use the Bluefruit App to get your project started

Using our Bluefruit iOS App or Android App, you can quickly get your project prototyped by using your iOS or Android phone/tablet as a controller. We have a color picker, quaternion/accelerometer/gyro/magnetometer or location (GPS), and an 8-button control game pad. This data can be read over BLE and piped into the ATmega32u4 chip for processing & control

You can do a lot more too!

The Bluefruit can also act like an HID Keyboard (for devices that support BLE HID)
Can become a BLE Heart Rate Monitor (a standard profile for BLE) - you just need to add the pulse-detection circuitry
Turn it into a UriBeacon, the Google standard for Bluetooth LE beacons. Just power it and the 'Friend will bleep out a URL to any nearby devices with the UriBeacon app installed.
Built in over-the-air bootloading capability so we can keep you updated with the hottest new firmware. Use any Android or iOS device to get updates and install them. This will update the native code on the BLE module, to add new wireless capabilities, not program the ATmega chip.
Comes fully assembled and tested, with a USB bootloader that lets you quickly use it with the Arduino IDE. We also toss in some header so you can solder it in and plug into a solderless breadboard. This listing is for the Adafruit Feather Bluefruit LE board only, Lipoly battery not included.

Check out the Adafruit Learning System tutorial for all sorts of details, including schematics, files, IDE instructions, and more!

admin




Simple application to test the speed of sending MIDI NOTE with velocity info over Bluetooth LE (BLE or Bluetooth Smart). A small MIDI DIN plug with BLE transmitter draws it's power from the MIDI OUT jack. The received data is displayed on a simple histogram style plot. The x-axis is the keynote. The y-axis is the velocity value indicating how hard the key was pressed. More information as it develops at... http://thomasolson.com/PROJECTS/MIDI/BLE_MIDI/
























admin

#5
http://projects.gonzos.net/ble-midi-adapter-ud-bt01/

BLE Midi Adapter – UD-BT01

udbt01

Update 10 June 2016

Background:

Early in 2016 Yamaha released a couple of Bluetooth Low Energy MIDI adapters. The one that interested me was the USB model (UD-BT01) – I hoped it could be used with my USB-connected Akai EWI-USB wind controller. The EWI has a cable that powers it from a USB port and carries the MIDI messages to and from the synthesiser. The UD-BT01 is advertised as being only compatible with Apple MIDI products, but the attraction of being able to cut the cord to the synth was too strong – I bought one.

Problems:

Bluetooth peripherals are coded to tell the computer they connect to what type of device they are (e.g. mouse, keyboard, heart monitor). To date, only Apple has published a standard for sending MIDI over Bluetooth, and it applies to only Apple products, which means that MIDI Bluetooth peripherals will not be recognised by non-Apple equipment. This is because the TYPE of device (MIDI) is not recognised in the general Bluetooth standard (as opposed to the Apple spec). The UD-BT01 can be SEEN by other systems (Windows, Linux), but it won't connect automatically. A custom program to connect is required.
Bluetooth LE is still fairly young, and, while programming languages exist to handle the connections, the documentation is thin, and there aren't many examples available to use as models.
The details of how to connect to and get data from a "Designed-For-Apple" peripheral are not readily available, so there's a lot of trial-and-error involved if you don't have the information on this page.
Solutions:

I have worked out a way of connecting the Yamaha UD-BT01 to a Raspberry-Pi. It works pretty well. My EWI-PI project has all the programs, but here I want to just give the key ideas for others attempting to do the same.

You need to refer to:

The Apple Bluetooth Low Energy MIDI Specification.
https://developer.apple.com/bluetooth/Apple-Bluetooth-Low-Energy-MIDI-Specification.pdf

This gives the details of how the MIDI messages, including Sysex messages, are packaged.
Ian Harvey's BluePy.
https://github.com/IanHarvey/bluepy

This is the python interface for Bluetooth LE on Linux.
To connect to the UD-BT01 you will need the Bluetooth address for your unit. They are all different. You can find out what the address is by using a computer or phone to do a LE scan when the adapter is powered up. When you have discovered the address you can then connect using BluePy. You need to connect in "random" mode. There are examples of how to connect in the BluePy on-line docs.

To send to and receive data from the UD-BT01, you need information about the Bluetooth "handles". A GATT scan will show that the handle for the MIDI data is decimal 26. What it won't show you is that data needs to be sent to handle 27, and the handle for enabling notifications is 28. I don't know if these are "standards" for BLE (sending is at data+1 and notifications is at data+2), but that's what I found. To enable notifications, after connecting you need to send 0x01 0x00 to handle 27. When that is done the peripheral (server) will send a notification to the computer (client) each time new data arrives, and the computer then asks the peripheral for the data. BluePy/Bluez does this automatically for you.

During the connection negotiation process, the peripheral sends the computer "Peripheral Preferred Connection Parameters". These are suggestions, and the computer can ignore them. In practice I discovered that the RPi produced high latency with the default set of parameters. I was unable to discover what those parameters were, but when I re-configured the connection using the Linux hcitool I got a good result. The command I used was:

sudo hcitool lecup – -handle $HANDLE – -min 6 – -max 6 – -latency 0 – -timeout 500

Where $HANDLE is the number of the computer's connection handle (NOT the UD-BT01's connection handle – they are different), – -min is the minimum connection interval (6 x 1.25msec = 7.5msec, the minimum for BLE), – -max is the maximum connection interval, – -latency is the number of intervals the peripheral can delay replying to the computer's message, and – -timeout is the time that must elapse before a dead connection is re-established by the computer (500 x 10msec = 5sec). The min/max/latency settings I have used here give the minimum latency.

To get the computer's handle number, use:

sudo hcitool con

The UD-BT01 appears to have a 20-byte maximum message length. I don't know if this is configurable during the "negotiation" process, but that's what mine defaulted to. The Apple spec implies it can be changed. MIDI commands are 3 bytes long, and with the additional header and timestamp bytes (see the Apple spec), it means that a maximum of 4 MIDI commands can be sent per message. Your program will have to determine how many commands are contained in each message (it varies). In addition, Sysex commands can be sent. These can be long, and may be broken up into multiple messages, so as not to exceed the 20-char limit. See the Apple spec for details. Your program will have to determine if each message is a Sysex (third character is 0xF0).

Header and timestamp bytes are added to the messages. For my particular application (live performance) they are not important, however, when sending header and timing bytes TO the UD-BT01, they need to meet the specification. The header byte actually contains part of the timing information (see the Apple spec), but has a minimum value of 0x80 (with a timestamp of zero), likewise the timing byte has a minimum value of 0x80. Successive timing bytes need to be increasing, so for the Sysex commands I have used the following sequence: 0x80 0x81 0x82 0x83 ... This series need to be consistent only within each "batch" of Sysex commands. You can start from 0x080 again for the next "batch".

Interesting Stuff:

The Bluetooth connection to the computer is completely independent from the USB connection between the adapter and the instrument (EWI-USB in my case). You can unplug the instrument from the adapter, while keeping the adapter powered up, and then re-connect the instrument. It won't affect the Bluetooth connection.

The power required to run the adapter and my EWI-USB is really small. I have left the instrument powered up for a 24-hour period and used only 1/4 of a 8000mAh battery pack

The Bluetooth connection needs to be re-configured each time it starts. So, if the connection is lost for some reason, and then re-made, you will have to run the hcitool command (above) again. I have put this command in a batch file which checks the handle number to see if it has changed, and if it has (the connection has been re-made) it runs the command again.











Elantric