## 4. Actively Augmenting Mobile Devices
### Active Augmentation Framework  
In our view, mobile device augmentations should supplement existing built-in sensors (e.g., touchscreen, motion sensors, etc.) and remain as lightweight and confined as possible. Indeed, there's often not much to add to a mobile device to turn it into a truly expressive musical instrument. Nuance[55] is a good example of that since it adds a whole new level of expressivity to the touchscreen, simply by using a few sensors. On the other hand, unlike passive augmentations, active augmentations can be used to add an infinite number of features. In this section, we introduce a framework for designing active mobile device augmentations supplementing sensors already available on the device. This allows us to keep our augmentations lightweight and powered by the device, preserving the standalone aspect and partly the physical coherence of the instrument. To keep our augmentations simple, we propose to use a wired solution for transmitting sensor data to the mobile device, which also allows us to power the augmentation. Augmentations requiring an external power supply (e.g., battery) are discarded and are not considered in the frame of this work. MIDI is a standard universal way to transmit real-time musical (and non-musical) control data to mobile devices, so we opted for this solution. Teensys such the Teensy 3.2 ([[https://www.pirc.com/store/teensy32.html](https://www.pirc.com/store/teensy32.html)]([https://www.pirc.com/store/teensy32.html](https://www.pirc.com/store/teensy32.html))) are micro-controllers providing built-in USB MIDI support, making them particularly well suited to be used in our framework. Teensyduino ([[https://www.pirc.com/teensy/teensyduino.html](https://www.pirc.com/teensy/teensyduino.html)]([https://www.pirc.com/teensy/teensyduino.html](https://www.pirc.com/teensy/teensyduino.html))) (Teensy's IDE), comes with a high level library part of Bounce.h for sending MIDI over USB. The code presented in Listing 3 demonstrates how to use this library to send sensor values on a MIDI \"Continuous Controller\" (CC). #include <Bounce.h> void setup() { } void loop() {  int sensorValue = analogRead(A0);  int midiCC = 10; // must match the faust configuration  int midiValue = sensorValue*127/1024; // value between 0-127  int midiChannel = 0;  usbMIDI.sendControlChange(midiC,midValue,midChannel); // send! delay(30); // wait for 30 ms } ```
Listing 3: Simple Teensy code sending sensor data in MIDI format over USB. Once uploaded to the microcontroller, the Teensy board can be connected via USB to any MIDI-compatible mobile device (iOS and Android) to control some of the parameters of a faust2 smartkeyb app (see Section 2). This will require the use of a USB adapter, depending on the type of USB plug available on the device. MIDI is enabled by default in faust2 smartkeyb apps and parameters in the Faust code can be mapped to a specific MIDI CC by using a metadata (see Section 2.2):
``` frequency=nentry(\"frequency[midi:ctrl10]\",1000,20,2000,0.01);Here, the frequency parameter will be controlled by MIDI messages coming from MIDI CC 10 and mapped to the minimum (20 Hz for MIDI CC 10 = 0) and maximum (2000 Hz for MIDI CC 10 = 127) values defined in the nentry declaration. Thus, if this parameter was controlling the frequency of an oscillator and that the Teensy board running the code presented in Listing 3 was connected to the mobile device running the corresponding faust2 smartkeyb app, the sensor connected to the A0 pin of the Teensy would be able to control the frequency of the generated sound. Other types of MIDI messages (e.g., sendNoteOn()) can be sent to a faust2 smartkeyb app using the same technique. Most of the parameters controlled by elements on the touchscreen or by built-in sensors of the app presented in Section 2.8 could be substituted by external sensors or custom interfaces using the technique described above.