Digital Sound & Music: Concepts, Applications, & Science, Chapter 3, last updated 6/25/2013
48
int getIndex()
{
int input;
cout
"Choose one of the following:\n"
"\t1) C\n"
"\t2) C sharp/D flat\n"
"\t3) D\n"
"\t4) D sharp/E flat\n"
"\t5) E\n"
"\t6) F\n"
"\t7) F sharp/G flat\n"
"\t8) G\n"
"\t9) G sharp/A flat\n"
"\t10) A\n"
"\t11) A sharp/B flat\n"
"\t12) B\n"
"\tor type quit to quit\n";
input = getInput();
if (! (input = BACK && input = 12))
return -1;
return input;
}
void writeToSoundDevice(short buf[], int buffSize, int deviceID) {
int status;
status = write(deviceID, buf, buffSize);
if (status != buffSize)
perror("Wrote wrong number of bytes\n");
status = ioctl(deviceID, SOUND_PCM_SYNC, 0);
if (status == -1)
perror("SOUND_PCM_SYNC failed\n");
}
int getScaleType(){
int input;
cout
"Choose one of the following:\n"
"\t" MAJOR ") for major\n"
"\t" MINOR ") for minor\n"
"\t" BACK ") to back up\n"
"\tor type quit to quit\n";
input = getInput();
return input;
}
void playScale(int deviceID){
int arraySize, note, steps, index, scaleType;
int break1; // only one half step to here
int break2; // only one half step to here
int t, off;
double f;
short *buf;
arraySize = 8 * LENGTH * RATE * CHANNELS;
buf = new short[arraySize];
while ((index = getIndex()) 0)
cout "Input out of bounds. Please try again.\n";
f = getFreq(index);
while ((scaleType = getScaleType()) 0)
cout "Input out of bounds. Please try again.\n";
Previous Page Next Page