this project is my first android app and the submission for cs50 2020. thank you david and tommy !
created using
- TarsosDsp (TarsosDSP is a Java library for audio processing) .
- material.io for theming
- material-intro-screen for intro sequence.
- Tune standard 6 string guitar (E A D G B E).
- Note detection , so that you can do other tunings aswell.
- frequency detection , using which tuning can be more accurate.
- minimalistic simple ui .
-
The frequency is defined as the reciprocal of the period duration of an repeating event. For example, if we have a sinusoidal signal with a period length of 2ms, the frequency is 500Hz.
-
Pitch is the perceived frequency of a sound. Thus, in contrast to frequency which is physical measure, the pitch is a psychoacoustical measure. This distinction is needed as there are cases where we hear frequencies which are physically not there (or don't hear frequencies which are actually there).
-
A note is just a pitch with a name. For example, the well known A4 is a pitch at 440Hz. It can also carry temporal information like whole notes or half notes, but this is rather uninteresting for us.
let take a look at guitar and how it works.
I guess most of you know this but the "default" guitar has 6 strings which are usually tuned in the standard tuning EADGBE. Whereby each note refers to one of the strings.
now , guitar has raised bars over fretboard called as FRETS. the distance between 2 frets is called as a HALF STEP.
fn = f0 * (2)i/2
i- number of half steps between these two frequencies fn - current frequency f0 - standard frequecy now we use this formula to calculate HALF steps (i) from standard frequency f0.
for more info :- https://pages.mtu.edu/~suits/NoteFreqCalcs.html https://en.wikipedia.org/wiki/Equal_temperament
if we try to get i on one side , we get
12⋅log2(fn/fo) = i
Now we take audio from mic and process it to find the fundamental frequency. before that , lets look at fundamental frequencies and algorithms to find it. as you can see , an instrument produces multiple frequecies even tho there is silence . to find the fundamental frequecie , you need pitch detecting algorithms
we will be using FFT_YIN , which is already provided in TarsosDsp library i mentioned before.
now we got the fundamental frequency , now we can use the formula i mentioned before to calculate the half steps .
using half steps , we can simple find the note and ocatave as we already know the standard frequency or the standard note
here, 440hz , A4 note is the standard frequency . we can count the number of steps from there to find the current note.
now just match you current frequency to standard one to tune ;)