Take any song you want and play it by using the recorded bassoon notes in the media folder, shifting them up and down in frequency to create the right notes.

What will be an ideal response?


Note: The best way to answer this challenge is to make use of the shift function from earlier in the chapter, but to rewrite it to translate to the required frequency. Additionally, one cannot simply call “play” as they will play all at once. A proof of concept is below:

```
def hotCrossBuns():
c4 = makeSound("bassoon-c4.wav")
cFreq = 261.63
dFreq = 293.67
eFreq = 329.63

quarterNote = getLength(c4)/4

eQuarter = shift2(c4, cFreq, eFreq, quarterNote)
dQuarter = shift2(c4, cFreq, dFreq, quarterNote)

target = makeEmptySoundBySeconds(10)
targetIndex = 0

#Measure 1
for index in range(0, quarterNote):
sourceValue = getSampleValueAt(eQuarter,int(index))
setSampleValueAt(target , targetIndex , sourceValue)
targetIndex+=1

for index in range(0, quarterNote):
sourceValue = getSampleValueAt(dQuarter,int(index))
setSampleValueAt(target , targetIndex , sourceValue)
targetIndex+=1
for index in range(0, quarterNote*2):
sourceValue = getSampleValueAt(c4,int(index))
setSampleValueAt(target , targetIndex , sourceValue)
targetIndex+=1

#Measure 2
for index in range(0, quarterNote):
sourceValue = getSampleValueAt(eQuarter,int(index))
setSampleValueAt(target , targetIndex , sourceValue)
targetIndex+=1

for index in range(0, quarterNote):
sourceValue = getSampleValueAt(dQuarter,int(index))
setSampleValueAt(target , targetIndex , sourceValue)
targetIndex+=1

for index in range(0, quarterNote*2):
sourceValue = getSampleValueAt(c4,int(index))
setSampleValueAt(target , targetIndex , sourceValue)
targetIndex+=1

#Measure 3
for index in range(0, quarterNote/2):
sourceValue = getSampleValueAt(dQuarter,int(index))
setSampleValueAt(target , targetIndex , sourceValue)
targetIndex+=1
for index in range(0, quarterNote/2):
sourceValue = getSampleValueAt(dQuarter,int(index))
setSampleValueAt(target , targetIndex , sourceValue)
targetIndex+=1
for index in range(0, quarterNote/2):
sourceValue = getSampleValueAt(dQuarter,int(index))
setSampleValueAt(target , targetIndex , sourceValue)
targetIndex+=1
for index in range(0, quarterNote/2):
sourceValue = getSampleValueAt(dQuarter,int(index))
setSampleValueAt(target , targetIndex , sourceValue)
targetIndex+=1

for index in range(0, quarterNote/2):
sourceValue = getSampleValueAt(eQuarter,int(index))
setSampleValueAt(target , targetIndex , sourceValue)
targetIndex+=1
for index in range(0, quarterNote/2):
sourceValue = getSampleValueAt(eQuarter,int(index))
setSampleValueAt(target , targetIndex , sourceValue)
targetIndex+=1
for index in range(0, quarterNote/2):
sourceValue = getSampleValueAt(eQuarter,int(index))
setSampleValueAt(target , targetIndex , sourceValue)
targetIndex+=1
for index in range(0, quarterNote/2):
sourceValue = getSampleValueAt(eQuarter,int(index))
setSampleValueAt(target , targetIndex , sourceValue)
targetIndex+=1

#Measure 4
for index in range(0, quarterNote):
sourceValue = getSampleValueAt(eQuarter,int(index))
setSampleValueAt(target , targetIndex , sourceValue)
targetIndex+=1

for index in range(0, quarterNote):
sourceValue = getSampleValueAt(dQuarter,int(index))
setSampleValueAt(target , targetIndex , sourceValue)
targetIndex+=1

for index in range(0, quarterNote*2):
sourceValue = getSampleValueAt(c4,int(index))
setSampleValueAt(target , targetIndex , sourceValue)
targetIndex+=1

play(target)
return target
def shift2(source, startFrequency, goalFrequency, length):
target = makeEmptySound(length)
sourceIndex = 0
factor = (goalFrequency/startFrequency)

for targetIndex in range(0, getLength(target)):
sourceValue = getSampleValueAt(source,int(sourceIndex))
setSampleValueAt(target , targetIndex , sourceValue)
sourceIndex = sourceIndex + factor
if (sourceIndex >= getLength(source)):
sourceIndex = sourceIndex - getLength(source)

return target
```

Computer Science & Information Technology

You might also like to view...

Declare (give a prototype for) a function named average_grade. This function returns a double and has four double arguments, test1, test2, test3, test4. The return value should be the average, or arithmetic mean of the four arguments. Be sure to include a "prototype comment" that tells briefly what the function does.

What will be an ideal response?

Computer Science & Information Technology

Briefly describe 6to4 tunneling.

What will be an ideal response?

Computer Science & Information Technology

The ____ command on the Start button in the Audio Options group on the Format Audio tab sound to play while other slides in the presentation are displayed.

A. Play Across Slides B. On Click C. Automatically D. none of the above

Computer Science & Information Technology

MIME stands for Multipurpose Internet Mail ____.?

A. ?Entities B. ?Envelopes C. ?Extensions D. ?Encryption

Computer Science & Information Technology