Summer 2004 Homework 3 Questions
Questions on Audio Collages?
right now i'm just trying to get a certain part of the sound to play. my code so far is
def hw3():
file = getMediaPath("Elliot-hello.wav");
sound = makeSound(file);
print(sound)
#sound length 54758
targetIndex = 1
for samp in range(1, 30772):
srcSample = getSampleValueAt(sound, samp)
setSampleValueAt(sound, targetIndex, srcSample)
targetIndex = targetIndex + 1
play(sound)
print(targetIndex)
return(sound)
The sound length is 54758, and i set the range (1, 30772) to play that specific part, but it just plays the whole thing. What am I doing wrong?
You're copy samples from 1 to 30772 from sound to...sound! You then play the sound sound, which is unchanged from the original. To get it to sound different, you could- Copy from the source sound to an empty target sound
- Zero out the samples that you don't want.
Either of these sould change what you hear. Mark Guzdial |
sounds good. :) now how do I do either of those?
| Check out the slides that were covered during lecture - you'll see that you need not just the sound files you want to use as sources, but also a "blank" wav file to lay the sounds down on as you do your processing. Think of it as a blank cassette tape - to record bits of this song and that, you need a tape to do the copying to. Monica Sweat |
So we should not only put the manipulated sound onto a blank wav file but also all the other sounds we're using too? If so, which file? Sec3silence.wav is only 3 seconds and our assignment requires a min of 5 seconds of sound. Should we add 2 of the silence files together to make the canvas then? Or are we supposed to use one of the files that shows up in media players as having nothing on there, 0 seconds?
| The way you do it is up to you. You can use a wav file that is blank and copy sounds onto that. Or you can use a file that already has one sound on it, copy the other sound(s) onto it, and then zero out the rest of the samples to make it silent. There are many ways to do it, it's your choice. Nicole Seekely |
how do i put two sounds onto one blank wav file?
| Check out some of the examples in the book such as on page 172-173. It's basically the same except of recopying over the same file, your target will be a blank file. Nicole Seekely |
def hw3():
canvas=makeSound(getMediaPath("35second.wav"))
greensource=makeSound(getMediaPath("greenhat.wav"))
bigdaysource=makeSound(getMediaPath("bigday.wav"))
for index in range(1, 212674):
setSampleValueAt (canvas,index,getSampleValueAt(greensource,index))
for index in range(1, 386470):
setSampleValueAt (canvas,index,getSampleValueAt(bigdaysource,index))
play (canvas)
i have my two sounds playing on the canvas, however they are playing extremely fast. the number of samples for the canvas is 771750. however i cant change the range on my sources past their lenght what should i do?
| I think you're missing something here. When you copy the second sound onto the canvas, are you not copying right over the first sound you copied? Nicole Seekely |
do we have to use a blank file and copy onto that? What if I am able to combine/blend 2 sound files into one instead?
| Then all the better! You don't have to copy onto a blank file. Nicole Seekely |
Why isn't this working? It's not playing my new sound . . .
def hw3():
sound1 = makeSound(getMediaPath("funnysound.wav"))
sound2 = makeSound(getMediaPath("gettysburg10.wav"))
for sample in range(1,getLength(sound1)):
sample1 = getSampleValueAt(sound1, sample)
sample2 = getSampleValueAt(sound2, sample)
setSampleValueAt(sound2, sample, sample1 + sample2)
return(sound2)
play(sound2)
writeSoundTo(sound2,"C:/JES/MediaSources/newfunnysound.wav")
Here it is with the indentions:
def hw3():
sound1 = makeSound(getMediaPath("funnysound.wav"))
sound2 = makeSound(getMediaPath("gettysburg10.wav"))
for sample in range(1,getLength(sound1)):
sample1 = getSampleValueAt(sound1, sample)
sample2 = getSampleValueAt(sound2, sample)
setSampleValueAt(sound2, sample, sample1 + sample2)
return(sound2)
play(sound2)
writeSoundTo(sound2,"C:/JES/MediaSources/newfunnysound.wav")
okay, nevermind with the indentions
| I fixed your code so it has the indentions. To do so, just place your code inside the code tags. Click on edit of this page to view what I did. Your sound probably isn't playing because you returned the sound first. Try putting play(sound2) before return(sound2). Nicole Seekely |
I have the same problem with my new sound not playing, but I did put my return outside of play.
def hw3():
hello=makeSound(getMediaPath("Elliot-hello.wav"))
print hello
aah=makeSound(getMediaPath("aah.wav"))
print aah
backward=makeSound(getMediaPath("Elliot-hello.wav"))
print backward
target=makeEmptySound(6)
index=1
for source in range(1,getLength(hello)):
value=getSampleValueAt(hello,source)
setSampleValueAt(target,index,value)
index=index+1
#0.1 second pause
for source in range(1,int(0.1*getSamplingRate(target))):
setSampleValueAt(target,index,0)
index=index+1
for source in range(1,getLength(aah)):
value=getSampleValueAt(aah,source)
setSampleValueAt(target,index,value)
index=index+1
#0.1 second pause
for source in range(1,int(0.1*getSamplingRate(target))):
setSampleValueAt(target,index,0)
index=index+1
#play hello backwards
index=getLength(backward)
for backwardIndex in range(getLength(target)+1,1):
value=getSampleValueAt(backward,index)
setSampleValueAt(target,backwardIndex,value)
index=index-1
#normalize(target)
play(target)
return target
| I ran your code on my computer using the same files and it worked and played for me. Are you sure the volume is up on your computer? Nicole Seekely |
It plays the first 2 files for me (hello and aah), it's just the manipulated backwards hello doesn't play. Unless that plays at a different volume than the other two sounds.
Okay, yeah the backwards part isn't playing for a couple reasons. First, I think you switched your range values. It should probably say for backwardIndex in range(1, getLength(target)+1): Also, when you set the sample value, you want to set it to "index" not "backwardIndex". Lastly, you want to set your index equal to the last sample in your blank sound so that when it copies backward, it will be at the end of your sound, not mixed up with the other two sounds. I know that may sound confusing, but for example, you could total up the three values that you have printed out (which is the sample length of each of the three sounds you want copied)and then set your index equal to that. Let me know if that's still totally confusing. Nicole Seekely |
I was trying to make the "test" part play after "hello" but this just plays "hello." What am i doing wrong?
def hw3():
source=makeSound(getMediaPath("thisisatest.wav"))
dest=makeSound(getMediaPath("Elliot-hello.wav"))
destSample=54758
for sample in range(1,getLength(source)):
sampleValue=getSampleValueAt(source,sample)
setSampleValueAt(dest,destSample,sampleValue)
play(dest)
def hw3():
wet=makeSound(getMediaPath("brakwet.wav"))
print wet
evil=makeSound(getMediaPath("be-evil.wav"))
print evil
loud=makeSound(getMediaPath("brakwet.wav"))
print loud
blank=makeEmptySound(18)
index=1
for s in range(1,getLength(wet)):
value=getSampleValueAt(wet,s)
setSampleValueAt(blank,index,value)
index=index+1
for s in range(1,getLength(evil)):
value=getSampleValueAt(evil,s)
setSampleValueAt(blank,index,value)
index=index+1
increaseVolume(wet)
for s in range(1,getLength(wet)):
value=getSampleValueAt(wet,s)
setSampleValueAt(blank,index,value)
index=index+1
play(blank)
return blank
def increaseVolume(sound):
for s in getSamples(sound):
value=getSample(s)
setSample(s,value1.6)
This is my code, and I know you don't have the files, but no matter what file i put in for "evil", for some reason it always comes out very fast. "wet" and "loud" come out fine every time, but I don't understand why "evil" is so messed up. Can anyone tell from looking at my code?
Link to this Page