Build the "REMI"
Recreational Electronic Music Instrument

A DIY Project by M.J. Bauer

REMI 'major' complete setup
REMI Handset v2 with original (mk1) Controller Module.
This handset supports a simplified recorder-like fingering scheme

Overview

The concept for the "REMI" came from a desire to create a simple but practical musical instrument which is easy to learn to play. An early design decision was to model the REMI loosely after existing “electronic wind instruments” (EWI's) using touch-sensitive pads for the “keys” to select the pitch of notes. A breath pressure sensor allows notes to be articulated by blowing into a mouth-piece. However, it was decided that the REMI should also be playable just by changing finger positions on the “keys” (touch-pads), without blowing. Played in this mode, the instrument allows the player to sing along.

The instrument consists of two main parts: a "handset" incorporating the touch-pads and other playing sensors and controls, plus a "controller module" housing a PIC32 micro-controller, MIDI and audio circuitry and (optionally) a front-panel user interface comprising an LCD screen and 16-button keypad.

The controller module incorporates a built-in sound synthesizer, so that the REMI can be used "stand-alone", i.e. without needing to be plugged into an external MIDI synthesizer or computer. A socket is provided for audio line output to an amplifier or headphones.

The controller module provides a MIDI output (5-pin DIN socket) for direct connection to a MIDI synthesizer or sound module, or to a personal computer via a MIDI/USB adapter.

A “modulation lever” operated by the thumb may be assigned to control one of a number of sound parameters, for example “pitch bend”, vibrato depth, noise level or filter corner frequency. If not assigned to "pitch bend", the modulation lever can be configured as a MIDI controller to send periodic MIDI Control Change messages.

A push-button switch on the under-side of the handset, operated in conjunction with the RH touch-pads, selects one of several instrument "presets". The selected Preset determines various instrument and MIDI configuration parameters. For example, a preset instrument sound is chosen from a collection of pre-defined synth patches built into the micro-controller firmware. The selected preset also selects one of a group of MIDI "programs" (instrument voices) for use with an external MIDI sound module. 

The cost of parts to build a REMI is much less than a commercial EWI.

REMI source code is freely available, allowing makers to tailor the firmware to suit their own design variants, or to add as many synth patches and wave-tables as will fit into the MCU flash memory.

MIDI Controller

The MIDI OUT (transmit) command set includes: Program (voice) Selection, Note-On/Velocity, Note-Off, Channel After-touch (pressure) or Expression or Channel Volume, Pitch Bend, Control Change (effect modulation), All Sound Off and System Reset. The REMI can be set up to use any one of the 16 basic MIDI channels.

In normal note trigger mode, the REMI will send a Note-On/Velocity command when the breath pressure exceeds a preset threshold. A corresponding Note-Off command will be sent when the breath pressure drops below the "note-off pressure level". After a new note is initiated, a change in fingering pattern will cause another Note-On/Velocity command to be transmitted without first sending a Note-Off. If the external MIDI sound module is set to Mono mode, this should cause the module to produce a different note, i.e. to change pitch, without "re-attacking" the amplitude envelope. The musical term for this is "legato".

In "touch trigger mode", a new note will be initiated whenever the fingering pattern changes, as long as (or when) one or more of the LH touch pads and at least one of the octave touch pads is also pressed. After the first note is triggered, a Note-Off command will be sent for each note change (before sending a new Note-On) to release the note already sounding. Hence, the envelope shaper will be forced to "attack" for every note played. However, the PRESET button can be configured to act as an "effect switch" to enable Legato keying. The Modulation Lever can be configured to control the loudness of the note, i.e. to determine MIDI "velocity" and "aftertouch" values.

While none of the octave touch-pads and none of the upper 3 (LH) pads is pressed, the PRESET button may be pressed in conjunction with one or more RH touch-pads to select one of eight instrument "Presets". A MIDI "Program Change" command will be transmitted. The Program Number sent depends on the user-defined Preset configuration.

While a note is being played, the PRESET button can function as an "effect switch". The controlled effect is dependent on the external synth or MIDI sound module, for example to turn vibrato on and off. In addition, the PRESET button has a special function while none of the touch-pads is touched. In this case, pressing the PRESET button will cause the REMI to transmit a MIDI "All Sound Off" command followed by a "System Reset" command.

Built-In Sound Synthesizer

REMI's built-in sound synth is implemented largely in firmware, requiring minimal additional electronic circuitry -- just a PWM-controlled filter and PWM-controlled signal attenuator in the audio output circuit. To generate audio tones, REMI uses a "wave-table oscillator" algorithm offering a variety of waveforms which can range from simple to rich and complex sounds, some resembling acoustic instruments. 

A PIC32MX processor clocked at 80MHz makes possible a sample rate of 40 kHz with 11-bit sample values, resulting in high-quality audio output. Not quite CD quality, but comparable to MP3 audio at a high bit-rate.

The basic synth model includes, in addition to the wave-table oscillator, a low-frequency oscillator (LFO) used to modulate pitch (for a vibrato effect), a noise generator with variable output level mixed with the oscillator output, plus an analog filter with a roll-off slope of -12dB per octave. The filter can be switched to low-pass or band-pass mode. The corner/centre frequency is variable over a three decade range (10Hz ~ 10kHz) by means of a PWM signal generated by the MCU. The filter can be made to track the pitch of the oscillator, or it can be set to a fixed frequency. The filter has a dedicated envelope shaper allowing the timbre (harmonic content) of the sound to be varied in time as the note progresses.

The amplitude (loudness) of the note-in-progress can be varied with time in a variety of ways depending on the instrument patch. A five-segment envelope shaper provides an "attack, peak-hold, decay, sustain, release" (APDSR) amplitude profile. In addition to the envelope shaper, amplitude can be controlled by the breath pressure sensor, or by the "modulation lever", or by MIDI IN Control Change messages. Audio output level is determined by a PWM-controlled attenuator with 11-bit resolution, giving a dynamic range of 66 dB.

The firmware includes several "pre-defined" synth patches providing a selection of instrument sounds, most resembling familiar instruments. Any pre-defined patch may be assigned to any of the 8 Presets.

The REMI synth can be programmed (patched) by the user to create a new sound, without needing to modify and re-compile the firmware. Instead of using knobs and switches like a "real" synthesizer, however, the REMI synth is patched by means of a set of numeric parameters. A CLI command "patch" is provided for the purpose of setting patch parameter values. A user-created patch can be saved in non-volatile memory (EEPROM) for later recall. The stored "user patch" may also be assigned to any of the 8 instrument Presets.

Table 1: REMI Patch Parameters

Oscillator + LFONoise EffectsFilterAttenuator
Wave-Table SelectNoise FM DepthFilter Tracking ModeAmplitude Env Attack
Pitch Bend RangeNoise Mix RatioFilter Freq. Offset Amplitude Env Peak
Vibrato Ctrl Source Noise Control Source
Filter Control SourceAmplitude Env Decay
Vibrato Ramp TimeNoise Env Attack Filter Mod RangeAmplitude Env Sustain
Vibrato DepthNoise Env DecayFilter Env PolarityAmplitude Env Release
Vibrato FrequencyNoise Env SustainFilter Env AttackAmplitude Ctrl Source
Noise Env ReleaseFilter Env Decay

One of the patch parameters specifies which one out of a collection of wave-tables will be used by the synth oscillator. The assigned wave-table determines the waveform and hence the harmonic content of the oscillator output. The "user patch" can specify any pre-compiled wave-table (stored in MCU program memory) or it can specify a "user wavetable" which, as the name suggests, may be created by the user. A CLI command "wav" is provided for this purpose. The "user wavetable" is also stored in non-volatile memory for later recall

REMI makers who are prepared to re-compile the firmware can add their own patches and wave-tables, limited only by the amount of MCU flash program memory remaining. CLI commands "patch" and "wav" include options to dump patch parameters and wave-table data (resp.) as C source code definitions.


Fingering Scheme

The original REMI article proposed a unique “binary” fingering scheme designed to minimise the number of “keys” (touch-pads), hence finger combinations, required to select notes on the chromatic scale. Some readers have commented that this scheme may be “counter-intuitive” and therefore might defeat the objective of being “easy to learn to play”. Moreover, I acknowledge that the “binary” keying scheme is unlikely to appeal to players of traditional wind instruments.

In response to these concerns, I have devised an alternative fingering scheme based on a traditional wind instrument, i.e. the descant recorder, albeit with some (justifiable) simplifications. This scheme uses eight touch-pads on the upper surface, i.e. one pad (hole) fewer than the recorder. Three pads are operated by fingers on the left hand while five pads are operated by fingers on the right hand. The 4th and 5th RH pads are both operated by the 4th finger.

Two pads on the underside of the handset, operated by the left-hand thumb, select one of three octave ranges. The octave pads are constructed so that both can be activated together by the thumb. At least one octave pad, and at least one of the 3 upper (left-hand) pads, must be activated for a note to sound. This requirement allows the “Touch Trigger Mode” to be implemented.

Referring to the “Bauer EWI Fingering Chart” below, it can be seen that the fingering combinations cover two octaves, without changing the octave selection by the LH thumb. The octave pads extend the overall range to four octaves. Selection of notes in the first octave follows quite closely the fingering patterns of the recorder, including C (Alt.) above the lowest C. Contrary to the recorder, however, the second octave simply repeats the fingering pattern of the first octave, but with the top pad (LH1) released, up to G". Above G", there is a discontinuity in fingering pattern, of necessity, but it keeps to a consistent progression, unlike the recorder which becomes inconsistent beyond the first octave.

Although there are many more finger combinations with 8 touch-pads than there are semitones covering the two octaves, every finger combination produces a note pitched on the chromatic scale. The redundant finger combinations are designed to be musically intuitive.

Bauer EWI fingering

Two octave pads are positioned on the underside of the handset, such that one or other or both pads together may be selected by the left thumb. The octave pads extend the range of available notes to four octaves, for example C3 to C7.

If two or more pads marked with a diamond symbol () are touched, the effect is the same as if any one of the pads is touched, i.e. the note is flattened by one semitone.

The 4th finger on the right hand can select either pad RH4 or RH5, which are close together.

Pads RH4 and RH5 should be located so that both can be touched at once by the 4th finger, but this fingering oddity is needed only for selection of the alternate B note in each octave.

The alternate C" is designed to maintain semblance to recorder fingering in the first octave.

Controller Module Design & Construction

The author's first prototype REMI controller module (pictured) was built around a PIC32-MX460 development board made by Olimex plus an I/O extension board implementing the handset interface, MIDI output driver and audio signal processing circuitry. The MCU module also incorporates a "local user interface" (LUI) consisting of a low-cost monochrome LCD screen and 16-button keypad. The LUI provides facilities for instrument preset/patch configuration (built-in sounds), MIDI controller setup (channel and preset/program selection) and so on.

The firmware also includes a command-line user interface (CLI), accessible via the "RS-232" serial port provided on the MCU board. The CLI was originally intended mainly for firmware development, diagnostic and testing purposes, but the CLI provides equivalent functions for all operations performed by the local UI -- and more.


Alpha Prototype Controller Module based on Olimex PIC32-MX460 Development Board

The recommended board for making the REMI controller module is a PIC32-MX340 proto board from Olimex, priced at 19.95 (US$22 approx). This board has a PIC32MX340 micro-controller, which has much the same spec's as the 'MX460 except that the 'MX340 has no USB peripheral. If needed, MIDI-USB device capability can be achieved easily using a low-cost MIDI-USB adapter/cable.

The LCD module chosen for the prototype uses an ST7920 display controller chip with a monochrome back-lit graphical LCD screen of 128 x 64 pixels. Equivalent types are readily available at low cost from online suppliers, e.g. Ali-Express. Be aware that LCD manufacturers make design variations in, for example, supply voltage (3.3V or 5V), connector pin-outs and external wiring requirements. A contrast adjust trim-pot may or may not be needed. Follow the application example for 8-bit parallel bus operation in the data-sheet.

A 16-button numeric keypad (wired in a 4x4 matrix) is interfaced to the micro-controller using only four wires. This scheme works by using ADC voltage readings to determine the row and column addresses of a key when pressed, in similar manner to reading a resistive touch-screen. The 4-wire keypad interface requires six resistors to be wired between the external keypad terminals, as shown in the diagram.

Currently under development is an alternative controller module which simplifies construction by omitting non-essential parts, for example the high-pass filter, LCD screen and keypad. All components will fit on the Olimex PIC32MX proto board. This is called the "REMI Minor" build variant. All setup operations can be done using the command-line user interface. (See REMI version 2 preview.)

The fully-optioned build of the REMI including LCD screen, keypad and audio high-pass filter, is called the "REMI Major" variant. There is not enough space on the PIC32MX340 proto board to fit all components and connectors needed. However, the audio circuitry can be built on a separate prototyping board, requiring only 7 wires to connect to the main board. All other components and connectors will fit easily on the main board.


Handset Design & Construction

The "Bauer EWI" handset comprises 10 touch-pads, an air-pressure sensor (Freescale MPXV4006-GP), plus a push-button switch for PRESET selection, etc. The touch-pads are wired to a Freescale MPR121 capacitive touch sensor IC breakout board from SparkFun, interfaced to the MCU via an I2C serial bus. The handset is connected to the MCU via a 6-wire cable (including +5V DC power, 2-wire I2C bus and 2 analog sensor signals).

The prototype handset was made from two pieces of PVC plastic cut from a scrap of drain pipe, 110mm outside diameter, 3mm wall thickness. A suitable scrap may be found perhaps on a building site. The curved surface makes the plastic covers very rigid and strong. The upper piece has 3 wooden "ribs" (8~12mm thick) glued to it, allowing the bottom cover to be attached with self-tapping screws. Side strips of fibre laminate or timber veneer may be glued to the ribs. The plastic surfaces were not painted, but rubbed with fine abrasive cloth (P400) to give a smooth matte finish. The result is a very "retro" (1950's) look and feel. For a more modern look, the plastic covers may be spray-painted and the side strips made from brushed aluminium.

Handset v2 top view
Handset top surface - 3 LH touch-pads, 5 RH pads and status LED

Bottom View
Bottom cover - Two octave pads and PRESET button
(A Modulation Lever of some sort may be added later.)

Side view
Side view (with sides detached) showing construction method

Handset v2 internals
Handset (v2)  Internal view -- bottom cover off

The touch-pads are self-tapping screws with a broad flat head, cadmium-plated (I think). These are inserted through holes in the handset playing surface, fastened on the inside with aluminium retainers (~9mm square). Machine screws with hex nuts would be better if you can find a variety with a broad flat head, plated with a corrosion-resistant metal. Solder lugs are fitted under the retainers (nuts) for wiring to the MPR121 board. A drill template and cross-section drawing are available for download -- see links at bottom of page.

The mouth-piece is carved out of soft-wood with a 6mm hole drilled through the middle. It should be coated with a water-based sealer* to prevent moisture absorption in the wood. The nylon tubing is inserted into the 6mm hole, all the way through to the tip, sealed in place with Silicone sealant compound. The mouth-piece is attached to the upper plastic cover with 4 self-tappers, so that it is easily removeable.

*Warning: Do not use a paint or laquer with oil-based solvent on the mouthpiece, for 3 reasons... (1) it tastes terrible, (2) it could cause a health hazard, and (3) the vapours given off by the solvent could damage the Fluoro-silicone membrane in the pressure sensor. Recommended coatings for the mouthpiece are water-based polyurethane, PVA wood-working glue (dries clear), or some other safe product used to paint wooden toys.


Handset Circuit Board
(Old prototype shown -- don't copy the wiring -- refer to schematic.)

Pitch-Bend / Modulation Lever

A Modulation Lever mechanism may be fitted on the handset, located so that it can be operated by the right-hand thumb, or it may be omitted altogether. The linear slider pot used in the original handset was found to be less than ideal. There was too much friction, making it difficult to move the lever quickly. A different type of sensor could be substituted to make the Modulation Lever. It could be worthwhile experimenting with a Hall-effect proximity sensor (e.g. Allegro A1301-2) or a resistive force transducer (FSR). Other home-brew EWI designs I have seen on the web use low-profile joystick mechanisms, as found in hand-held game controllers. 

Makers with adequate workshop skills and plenty of spare time may opt for a DIY solution to build a suitable lever mechanism. The technique I decided on was to use an optical position sensor. A shutter or vane moving between a LED and a photo-cell gives a variable output voltage. More details here.

mod lever rocker pic

DIY Modulation Lever (Rocker)

Pressure Sensor “plumbing”

Tubing and other bits and pieces needed to make the airways inside the handset may be sourced from the garden irrigation section of your local hardware store. The prototype handsets (pictured) used clear nylon tubing (3mm ID, approx 5.5mm OD) for the internal airways linking the mouth-piece, pressure sensor IC and the "drain tube”. The T-joiner needed the barbs cut off to fit the 3mm tubing.

It is not essential to make a special mouth-piece. For simplicity, it suffices to blow directly into a length of nylon tubing extending out of the top end of the handset. It is left to the maker's ingenuity to devise a more stylish mouth-piece arrangement, if desired.

The sensor air inlet barb is slightly less than 3mm in diameter, which is a wee bit too small to make a good seal with the 3mm ID nylon tube. An easy solution is to fit a short bit of 2.5mm (nominal diameter) heat-shrink tubing over the barb, shrink it with a hot air blower or whatever (taking care not to melt the sensor!), then fit the 3mm nylon tube over it.

A drain tube is recommended because moisture condensation occurs inside the airways and it is probably sensible to provide an exit for the moisture rather than let it accumulate. Also, the drain tube allows air-flow, which is preferable to a sealed system for playability. However, the exit air flow needs to be restricted somewhat to produce a sufficient range of pressure inside the sensor. This can be achieved by fitting into the end of the drain-tube a small plug with a 2mm hole through it, perhaps cut from a bit of plastic insulation sleeving if you can find some of suitable size (3mm OD, 2mm ID).


Firmware

The current firmware release is v0.8.xx. 

This update provides new UI and CLI functions to configure MIDI parameters associated with breath pressure, pitch bend and modulation lever messages. For example, pressure sensor data may be transmitted in Aftertouch (Pressure), or Channel Volume, or Expression messages. Modulation Lever position data may be transmitted in any Control Change message (default CC# = 01), depending on requirements of the external MIDI synthesizer.

The built-in sound synthesizer is operational, but it's still in a preliminary stage of development. The wave-table oscillator and amplitude envelope shaper are implemented. A choice of 8 basic patches is available. The sound quality might surprise you (one way or another)! Pitch Bend is now supported using the Mod Lever.

For more details, refer to the Firmware Release Notes (.txt) in the download package.

The next firmware release (v0.9.xx) will include the changes and additions outlined below. These have been implemented already and are currently being tested.

  • Modified the PIC32 initialization code to enable the CPU Kseg0 Prefetch Cache. This mod eliminates wait states from the CPU instruction cycle, resulting in (approx) 2.3 times faster CPU execution speed!
  • Added a compile-time option to set the audio sample rate to 40kHz or 20kHz. This and subsequent firmware releases will have the sample rate set to 40kHz.
  • Tested wave-table oscillator at 40kHz with significant enhancement of sound quality, especially at the high end of the spectrum, with no audible aliasing artifacts. At 40kHz, the resolution of waveform samples and output attenuator level are reduced to 11 bits. The 1-bit reduction in dynamic range of the audio level has negligible effect. (11 bits => 66 dB)
  • Added Vibrato effects to the built-in synth... Vibrato can be configured to be controlled by the Modulation Lever (variable depth) or by the PRESET button which acts as an "Effect Switch" when a note is sounding. In the latter case, the Preset button when pressed will start a "vibrato ramp", i.e. the vibrato depth will increase with time. The time to ramp up to maximum vibrato depth is a Patch parameter. Vibrato frequency and maximum depth are also user-settable Patch param's.
  • Revised method of storing wave-tables in flash program memory... Instead of storing the actual wave sample values in an array of size equal to the wave-table size (number of samples), a set of wave-table parameters necessary to regenerate the wave-table are stored in flash. Waveforms are defined as a sum of sinusoidal partials, up to 12th order. Only the partial amplitudes need to be stored, resulting in a huge saving in memory space. There is only one "active" wave-table, located in data memory (RAM), containing waveform samples. Whenever a Preset/Patch is selected, the assigned wave-table is regenerated.
Planned to be implemented in future revisions:
  • Add noise generator, mixer and PWM filter operation to the built-in synth (v0.9)
  • Add more patches, wave-tables, noise FM*, filter modulation, etc, to built-in synth (v1.x)
    -- Version 1.0 will implement all features originally planned for the REMI, plus more.
  • Support REMI 'Minor' (v2) UEXT/SPI front panel 7-seg LED display and button (v2.0)
  • Support MIDI IN comm's (UART RX data) to control built-in synth (v2.x)
* If the audio ISR execution time can be kept below about 50% of the sampling interval = 0.5 x 25us = 12.5us (approx. 1000 instruction cycles at Fsys = 80MHz), it is planned to implement "noise modulation" in the wave oscillator, i.e. to modulate the frequency of the note with a noise signal. The noise generator will supply psuedo-random numbers with a Gaussian probability distribution. Waveform sample points will be deviated from the mean value according to the random noise. The magnitude of noise deviation will determine the effective modulation depth and hence the spectral distribution of noise artifacts in the output signal.

Programming Tools

A PIC programming tool, e.g. Microchip PICkit-3, is required to install the REMI application firmware.
Low-cost PICkit-3 clones are available from online suppliers via AliExpress, eBay, etc.

REMI firmware is built using Microchip PIC development tools - MPLAB.X IDE with XC32 compiler - free to download from Microchip's website. If you intend to modify or extend the firmware, you will need these tools. Otherwise, you just need to install the PIC programmer application (IPE) on your computer. The IPE comes with MPLAB.X.

If you are already familiar with another embedded IDE (integrated development environment), e.g. Atmel AVR Studio, you will find MPLAB.X IDE just as easy (or difficult) to use.


___
Send comments, suggestions and inquiries to:

Last revised: 20-MAR-2017

MJB Resources for Embedded Firmware Development

___