Showing posts with label Maple board. Show all posts
Showing posts with label Maple board. Show all posts

Thursday, May 9, 2013

OpenPipe and breath control


I have been playing around with the OpenPipe Breakout, the electronic pipe/flute control, for a few weeks now, trying to revive some old and mostly forgottens skills on how to play a flute or Irish tinwhistle.

The pipe is connected through a I2C interface to a Maple clone, the Olimexino STM32 and then with MIDI to Garageband on my iMac. Its a fun instrument but I find it a bit hard to balance, holding it and playing some fast fingering at the same time, using a thumb for note on/off is also a bit unusal.

So I decided to try and make a breath control so that the pipe can be played almost like a real flute.



The breath control sensor is a BMP085 breakout board, this atmospheric pressure sensor
connects to the Maple board over I2C. The mouthpiece is made from two pieces of nylon tubing. A cork from a bottle of good Italian wine holds things in place. The sensor is placed inside the tube and the end is sealed with the cork, a small ventilation hole lets some air pass thrugh the mouthpiece.






The sketch reads the BMP085 and the touch sensor in the OpenPipe Breakout and starts a note if the pressure is more than 50Pa above ambient. Some early tests shows that the basic setup works but theres a lot more to do before the sound can be controlled by breath like in a real flute.

Selecting a pressure sensor

BMP085 is an absolute pressure sensor accessed using the I2C protocol. No extra components are needed. The drawbacks are that the breath only represents a small fraction of the sensors range and the baseline pressure, ambient pressure, must me calibrated for.. Price is ___

The other major type of pressure sensor is a MEMS bridge giving a small voltage representing the difference between measured pressure and ambient. The problem here is that the small sensor output must be amplified before the signal is input to a AD converter. No calibration for changing ambient temperature is needed.

Saturday, April 6, 2013

MIDI USB Class for the Maple board



I got myself an OpenPipe breakout board and want to use a Maple board to connect it to a soft synth on my computer or a hardware synth. For this I want the Maple to implement a MIDI USB class device.

The Maple has as standard a USB serial device that gets setup and loaded as part of building a sketch and its then available as SerialUSB object. The MIDI USB will replace the Serial USB, and register the device as a MIDI class compliant device. The Maple bootloader is not affected, but the remote reset into bootloader is not implemented, so a manual reset is needed to get into the bootloader, I can live with that.

The MIDI USB needs a few things to setup

  • USB Setup and handling of Control Requests
  • A MIDI USB device descriptor to present itself to a host computer as a MIDI USB device
  • Bulk IN and OUT endpoints for MIDI USB packets, 32 bit/4 byte blocks of data
  • Code that interprets the MIDI USB packets as standard MIDI events.

Building the MIDI USB class as a variant of the existing USB serial code, the first and third parts are almost identical for MIDI and Serial, actually easier for MIDI since no modem control line handling is necessary and no management endpoint is needed.
The device descriptor is bit harder, but its a static datastructure and just following the MIDI USB documentation carefully will get you through this.
The USB MIDI package handling is standard MIDI code, and does not depend on the details of the USB transport layer.  

The code has been tested and registers as a MIDI device both under OSX and Android, and seems to be working.

A git repository can be found at    https://github.com/mlu/maple-ide

The MIDI USB is built from the following files:
High level device object, Wirish style, replaces usb_serial.cpp
  • usb_midi.cpp
  • include/wirish/usb_midi.h
Low level USB driver, replaces usb_cdcacm.c
  • stm32f1/usb_midi_device.c
  • include/libmaple/usb_midi_device.h
The process of setting up a sketch to use MIDI instead of Serial is still clumsy and needs some manual editing of the boards.h file.

The development is done on a modified Maple-IDE that uses a current arm toolchain and a libmaple layout that is closer to the present libmaple layout so the files are placed in different locations than the standard Maple-IDE file layout.

UPDATE 2013/0412

The descriptor definitions have been factored out of usb_midi_device and placed into usb_midi_descr.c/h . A working copy of the libmaple git repository with the midi usb files placed in their proper place in the hierarchy can be found at https://github.com/mlu/libmaple .