mbed Keypad Piano with Recording Capabilities

Project Description

By Jingming Hu and Yuanda Zhu from ECE 4180 B, Fall 2015

This is the page for the Keypad Piano 4180 final project. The project utilizes two MPR121 capacitive touchpads as the "keys" of the piano, with each button having a capability to play a tone spanning a total of 24 notes chromatically. The notes start from 262 Hz middle c all the way up to 987 Hz for B5. A Sparkfun microSD breakout board was used to record and save the songs in a .wav format, which can then be replayed by the mbed. An audio jack is used in lieu of a standard speaker for better sound quality. In addition, a uLCD 144 G2 128x128 is used for the user to know when a song is recording, when a song is finished recording, when a song starts playing, and when a song stops playing. Additional information on the peripherals can be found in below links:

Two key features of the project are the ability to record audio and the ability to produce overtones (multiple notes simultaneously). To accomplish this, the mbed has to be programmed to be able to write to I/O in a .wav format. Wavefile.c is used to help implement this, which helps to write a header in a .wav format (which defines aspects such as channels, smapling rate, byte rate, etc.) From there data can be written by sampling through a sine wave and writing each individual bit onto the file. The code is made such that different sine waves of different frequencies are sampled through depending on which note is played (or which key is pressed, for that matter). Every note is put through an array which is looped and processed as a sine wave of a period. Wait() is put through the main loop during "rests" so the rhythm stays as accurate as possible.

Overtones is accomplished through adding multiple signals together. From a recording perspective, multiple sine waves added together were used for sampling purposes, to decent results. To accomplish this, multiple arrays had to be created to simultaneous record the two notes. For real time playing, the illusion of polyphony was created through cycling two notes using PWM with a very small wait time in between, as unfortunately all PWM's have to share the same period on the mbed. This results in a somewhat distorted sound, but it is polyphonic nonetheless.

Design and Pinout

http://i.imgur.com/KXo6zJt.png

http://i.imgur.com/t6EhxCr.png

Code

Import programKeypadPiano

keypad piano project

Video


Please log in to post comments.