Go Down

Topic: Note Detector (Read 6140 times) previous topic - next topic

Okay! So, while I was thinking about  audio spectrum analyzers (which is another project I wish to do), I thought of a note detector! Now I know these already are a thing. But not the one I've thought up, I want to make a note detector, setup like an audio spectrum analyzer, ya know with the LED bars and everything. But instead of frequency's can it do notes? Say you plug it into your computer through the audio jack and you play a song, and it display's what notes are being played and the DB's as well. If you need me to clarify I would be glad to. And if you know how to make it work, please inform me! 

robtillaart

you can determine the frequency (google FFT) then you can use a lookup table to find the nearest note.

or read - http://www.instructables.com/id/Reliable-Frequency-Detection-Using-DSP-Techniques -
plus
Code: [Select]

//
//    FILE: nearestSearchInArray.ino
//  AUTHOR: Rob Tillaart
// VERSION: 0.1.00
// PURPOSE: demo
//    DATE: 2013-12-27
//     URL:
//
// Released to the public domain
//

int ar[5] = {
  100, 300, 500, 700, 900 };

void setup()
{
  Serial.begin(115200);
  Serial.println("Start ");
}

void loop()
{
  int x = analogRead(A0);

  int y = search(x);
  Serial.print(x);
  Serial.print(" -> ");
  Serial.println(y);
}

int search(int x)
{
  // initially the first one is the best.
  int idx = 0;
  int minDistance = abs(x - ar[0]);
  for (int i=0; i<5; i++)
  {
    int d = abs(x - ar[i]);
    if (d < minDistance)
    {
      idx = i;
      minDistance = d;
    }
  }
  return ar[idx]; // minDistance;  // or idx;  if you want the index
}



Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Awesome! thanks for the great code! now. All I need is to know how to build it. The arduino has only so many inputs for the LED's. If I would want to make LED bars with many segments per bar. how would I get them to all operate?

robtillaart

google multiplexer arduino

Or google arduino shiftOut()
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up