MSc Project

A JavaME based metronome and instrument tuner

Links

Main Features

Technology used

Instrument tuner

The instrument tuner component should allow the user to play their instrument into the device and display whether the input tone is sharp or flat. It should automatically detect what note the user is trying to play. I think the most challenging part of the project will be the pitch recognition for the instrument tuner. This may involve Fast Fourier Transforms.

The general algorithm is:

  1. The user plays a tone into the device.
  2. The system determines the pitch (frequency) of the incoming sound and compares it to the reference frequencies of the seven diatonic notes [ABCDEFG].
  3. The system determines which note is the closest in frequency to the input frequency. For example, if the input frequency was 444Hz the closest note would be A (440Hz).
  4. The system displays an indication of whether the input tone is higher or lower than the correct pitch.

Problems:

Use ByteArrayInputStream to get an array of samples. Then run FFT on these.

   1 // Create the capture player
   2 capturePlayer = Manager.createPlayer("capture://audio");
   3 
   4 // Realize it
   5 capturePlayer.realize();
   6                 
   7 // get the RecordControl
   8 recordControl = (RecordControl) capturePlayer.getControl(
   9     "javax.microedition.media.control.RecordControl");
  10                 
  11 // Create the buffer for the recording
  12 bos = new ByteArrayOutputStream(1024);
  13                 
  14 // set this buffer as the destination for recording
  15 recordControl.setRecordStream(bos);
  16 
  17 // Start the Player
  18 capturePlayer.start();
  19 
  20 // Start recording
  21 recordControl.startRecord();
  22             
  23 // wait 1 sec
  24 Thread.sleep(1000);
  25             
  26 recordControl.stopRecord();
  27 recordControl.commit();
  28 capturePlayer.close();
  29 
  30 // Flush the buffer
  31 bos.flush();
  32             
  33 // Convert to array
  34 byte[] data = bos.toByteArray();
  35 
  36 // perform FFT on this array

FFT

Cooley-Tukey FFT algorithm


CategoryProgramming

MscProject (last edited 2006-06-24 17:08:11 by DavidKeen)