
G Unit is an application that turns your iPod Touch/iPhone into a G Force measurement unit that can measure the force being applied to the device in all directional vectors. Using G Unit you can measure the strength of your turns in a vehicle (like a G Meter in an aerobatic aircraft), the G Force in a rollercoaster or elevator or even the maximum G Force you can generate by shaking the device.
It features a unique display that tells you the maximum (red needle), minimum (blue needle) and current (white needle) total G Force applied to the device, while showing which direction is applying the most force, and applying a small trail so you can see the change in directional force. It also provides a graph display at the bottom that lets you track the X (red), Y (green), Z (blue) axis's and total G force (white) applied to the device.
G Unit lets you set your own gauges for maximum G Force and the memory limit for the graph view, allowing you to see more information in the graph. Calibration is also easy, simply push the calibrate button and G Unit will detect whether to use the Y or Z axis to display the force pull on.
Support: admin@iwillapps.com
Status:
On Sale
Version: 1.0
Screenshots:

G Unit Main View

G Unit Settings View
OK last tutorial I covered how to get a fundamental frequency from an array of audio samples by using autocorrelation, but now we will begin to look at how we can convert these frequency values to a musical note. It is actually very simple, given that notes are just incrementing frequencies, all we really need are 2 loops, an octave loop and a note loop. In the octave loop we times our base frequency by 2 every loop, because each octave denotes a doubling of pitch, and in our note loop we times our testing frequency by 1.05946, which is the equal temperament of western music, it is also the twelfth root of 2, which is important considering there are essential '12' frequencies we are looking for in each octave (inclusive of accidentals):
-(BOOL) getNote:(double)fundamentalFrequency
{
double baseFreq = 65.406; // C2
for(int i=2;i<6;i++)
{
double testFreq = baseFreq;
for(int j=0;j<12;j++)
{
double nextFreq = testFreq * 1.05946; // Equal Temperment;
double lastFreq = testFreq / 1.05946;
if(fundamentalFrequency > lastFreq && fundamentalFrequency < nextFreq)
{
double nextPercDif = (fundamentalFrequency - testFreq) / (nextFreq - testFreq);
double lastPercDif = (fundamentalFrequency - lastFreq) / (testFreq - lastFreq);
if(nextPercDif <= 0.5 && lastPercDif >= 0.5)
{
octave = i;
natural = 0;
switch(j)
{
case 0: note = 0; natural = 0; break;
case 1: note = 0; natural = 1; break;
case 2: note = 1; natural = 0; break;
case 3: note = 1; natural = 1; break;
case 4: note = 2; natural = 0; break;
case 5: note = 3; natural = 0; break;
case 6: note = 3; natural = 1; break;
case 7: note = 4; natural = 0; break;
case 8: note = 4; natural = 1; break;
case 9: note = 5; natural = 0; break;
case 10: note = 5; natural = 1; break;
case 11: note = 6; natural = 0; break;
}
return true;
}
}
testFreq = nextFreq;
}
baseFreq *= 2.0;
}
return false;
}
This code is assuming octave, note and natural are global variables in whatever class this function is included in. If we look at Wikipedia's Musical Note page under the heading "Note designation in accordance with octave name" we can see the frequency values of each note, this gives us an idea of how our loop is working. To convert the note number to it's formal musical name, we just simple have to have a lookup table (I use defines personally):
#define A 5
#define B 6
#define C 0
#define D 1
#define E 2
#define F 3
#define G 4
And now we have converted our fundamental frequency into musical notation information, giving us the octave, the note name and whether or not it is a sharp (or accidental).
One of the major confusions surrounding digital signal processing is the assumption that the peak frequency in the frequency domain will give you an indication of the fundamental frequency (or pitch) of the signal. This is wrong, and in fact no Fourier Transform should be done at all for the best results (at least in my opinion). Wikipedia gives you some idea of the kinds of pitch detection algorithms that can be used on sound (http://en.wikipedia.org/wiki/Pitch_detection_algorithm), and although many ideas are discussed there we will only focus on one, Autocorrelation.
Autocorrelation can be best explained by the cross correlation of the signal itself, and is used to weed out randomization in seemingly random data sets (such as an audio signal). To put it basically I've made some C code that calculates the fundamental frequency based on a minimum/maximum frequency lookup, a signal array and its length plus the constant sample rate of the signal (44.1kHz):
#define MIN_FREQ (1.0/(65.406/44100.0))
#define MAX_FREQ (1.0/(1046.502/44100.0))
double autoCorrelation(SInt16* samples,int length)
{
if(length >= MIN_FREQ)
{
int lookupCount = MIN_FREQ - MAX_FREQ;
double* results = (double*) malloc(sizeof(double)*lookupCount);
for(int p=MAX_FREQ;p<MIN_FREQ;p++)
{
double psum = 0.0;
for(int i=0;i<length-p;i++)
{
psum += samples[i]*samples[i+p];
}
results[p-MAX_FREQ] = psum / ((double)length);
}
double maxFreq = -1.79769313486231E+308;
int maxIdx = -1;
for(int i=0;i<lookupCount;i++)
{
if(results[i] > maxFreq)
{
maxFreq = results[i];
maxIdx = i;
}
}
free(results);
return 1.0/((double)(maxIdx+MAX_FREQ)/44100.0);
}
return 0.0;
}
I do not recommend calling this function inside a RemoteIO callback, as you will encounter extreme lag towards the start of the application. Instead store the samples from that callback somewhere globally accessible, and then poll a process function using an NSTimer to return you your frequency results.

iHearYou is an application that allows you to gain a musical representation of your surrounding sound via a traditional music staff or a standard guitar tablature. It supports accidentals, and allow you to set the beats per minute and the decibel sensitivity of the note pickup. It picks up notes in between the 3rd octave and the 6th octave.
At the moment it has no concept of different instruments, and treats every frequency as played by the same instrument, it also monitors the sound monophonically, meaning that it will fail to pick up the harmonics in chords, just the fundamental frequency of the chord.
Note to iPod Touch users: You will need the microphone device addition to use audio recording on this application.
Note to 1st Generation iPhone users: Due to the cap on sampling rate on the 1st Generation iPhone's this application will not work on these devices.
Support: admin@iwillapps.com
Status:
On Sale
Version: 1.0
Screenshots:

iHearYou - Music Transcriber (Staff View)

iHearYou - Music Transcriber (Tablature View)

iHearYou - Music Transcriber (Settings View)