Hi,
I remember in my good old days of programming in C that you could create sound and send it to the speaker at the millisecond level. I put down an example below.
Is there a way to do this with an iPhone App, at the MICROSECOND level?
As in, I program how long in microseconds I want a certain sound.
Thanks for the help.
__________
I remember in my good old days of programming in C that you could create sound and send it to the speaker at the millisecond level. I put down an example below.
Is there a way to do this with an iPhone App, at the MICROSECOND level?
As in, I program how long in microseconds I want a certain sound.
Thanks for the help.
__________
Code:
void play(int octave,int note,int duration)
/* play note (C=1 to B=12), in octave (1-8), and duration (msec)
include NOTE.H for note values */
{
int k;
double frequency;
if (note == 0) { /* pause */
delay(duration);
return;
}
frequency = 32.625;
for (k = 0; k < octave; k++) /* compute C in octave */
frequency *= 2;
for (k = 0; k < note; k++) /* frequency of note */
frequency *= 1.059463094; /* twelve root of 2 */
delay(5); /* delay between keys */
sound((int) frequency); /* sound the note */
delay(duration); /* for correct duration */
nosound();
}
Last edited by a moderator: