I feel queasy about this one since I couldn't test it.
def increasingAmplitude(freq, ampl):
sound1=sineWave(freq,ampl)
sound2=sineWave(3*freq, 2*ampl)
sound3=sineWave(5*freq, 3*ampl)
sound4=sineWave(7*freq, 4*ampl)
addSounds(sound1, sound2)
addSounds(sound2, sound3)
addSounds(sound3, sound4)
play (sound4)
return sound4
By the way, I had to do html code to under the edit tab to get that to work, otherwise it looked like this when I put it in...
def increasingAmplitude(freq, ampl):
sound1=sineWave(freq,ampl)
sound2=sineWave(3
freq, 2ampl)
sound3=sineWave(5
freq, 3ampl)
sound4=sineWave(7
freq, 4ampl)
addSounds(sound1, sound2)
addSounds(sound2, sound3)
addSounds(sound3, sound4)
play (sound4)
return sound4
that looks good except i think that the addSounds part should be like this for it to add them all into one sound:
addSounds(sound2, sound1)
addSounds(sound3, sound1)
addSounds(sound4, sound1)
play(sound1)
return sound1
Katie Graybeal
| Actually, Katie, both orders of addSounds will work. The first one adds sound1+sound2 into sound2, then sound2 into sound3 (sound1+sound2+sound3), then finally sound3 into sound4 (sound1+sound2+sound3+sound4). Nicely done! Mark Guzdial |
REMOVEDw do you know from the question that you need to add them together?
| You're right. The problem doesn't say that. But because you attended lecture and read the chapter on creating sounds, you know that the "resultant sound" is the sum of the four partials. Mark Guzdial |
when spacing this program, do you make the "add sounds" lines indented REMOVED or the same as the sound1= lines? does it matter?
kelly farrell
| You indent it, REMOVED. It just doesn't look that way without HTML-ing in the CoWeb. BTW, you certainly can test this. I'll upload the sound code here that you can add your function to. Mark Guzdial |
Additive Synthesis code:
additive.py
would you play sound 1 or play sound 4? i think you would play sound 1
| Sound1 in Katie's version, Sound4 in the earlier version Mark Guzdial |
you play the sound that is your final product when you write YOUR program, right? not necessarily what is in someone else's.
Kelly Farrell
Link to this Page