1. Write a function pchcps in C++ (or any high-level language) that accepts as input a frequency in Hertz and returns a frequency in octave point pitch class notation (pch).
float pchcps(float freq)
{
float middle_c = 261.6;
float pch_value = 8.00;
if (freq > middle_c)
{
// translate freq to octave above middle c
while (freq > middle_c*2)
{
freq = freq / 2.0;
pch_value++;
}
pch_value = pch_value + log(freq/middle_c)/log(2.0)*12.0/100.0;
}
else if (freq < middle_c)
{
// translate freq to octave above middle c
while (freq < middle_c)
{
freq = freq * 2.0;
pch_value--;
}
pch_value = pch_value + log(freq/middle_c)/log(2.0)*12.0/100.0;
}
return pch_value;
}
2. Write a function octcps in C++ (or any high-level language) that accepts as input a frequency in Hertz and returns a frequency in octave point decimal notation (oct).
float octcps(float freq)
{
float middle_c = 261.6;
float oct_value = 8.00;
if (freq > middle_c)
{
// translate freq to octave above middle c
while (freq > middle_c*2)
{
freq = freq / 2.0;
oct_value++;
}
oct_value = oct_value + log(freq/middle_c)/log(2.0);
}
else if (freq < middle_c)
{
// translate freq to octave above middle c
while (freq < middle_c)
{
freq = freq * 2.0;
oct_value--;
}
oct_value = oct_value + log(freq/middle_c)/log(2.0);
}
return oct_value;
}
3. Use the functions above to write a program that prints out a table of each frequency on the piano keyboard in cps, pch and oct notation.
#include <iostream.h>
#include <math.h>
float pchcps(float freq);
float octcps(float freq);
void main()
{
float lowest_c = 261.6/16.0; // 4 octaves below middle c
float freq;
cout << "CPS PCH OCT" << endl;
cout.setf(ios::showpoint);
cout.setf(ios::fixed);
cout.precision(2);
for (int i=0; i<96; i++) // 96 notes in 8 octaves
{
freq = lowest_c * pow(2.0, i/12.0);
cout << freq << " " << pchcps(freq) << " " << octcps(freq)
<< endl;
}
}
4. A computer music instrument uses a tuning scale that assigns 20 pitches to each octave instead of the usual 12. Starting at the A note at 440 Hz, what would be the frequencies of the pitches between 440 Hz and the A note at 880 Hz, one octave higher?
440.00 455.52 471.58 488.21 505.43 523.25 541.70 560.81 580.58 601.06 622.25 644.20 666.92 690.43 714.78 739.99 766.08 793.10 821.07 850.02 880.00
5. Write the notes of the following composition using the Scot music language.

COURSE INFORMATION | HOMEWORK ASSIGNMENTS
COURSE PROJECT | CS240 HELP DESK