Jython/Python Programmers

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Solar^

    #1

    Jython/Python Programmers

    Greetings Group!
    I'm trying to do a project for my CS class. I'm using this program
    from Mark Guzdial Jython text:

    def echoes(snd, delay, factor):
    sound1 = makeSound(snd)
    sndlen1 = getLength(sound 1)
    sndlen2 = sndlen1 + (delay * factor)

    sound2 =decideLen(soun d1, sndlen2) # this function return the length
    # new sound canvas
    echoamp = 1.0 for echocount in range(1, factor + 1):
    echoamp = echoamp * 0.6
    for echoposition1 in range(1, sndlen1):
    echoposition2 = echoposition1 + (delay*echocoun t)
    value1 = getSampleValueA t(sound1, echoposition1) * echoamp
    #problem here# value2 = getSampleValueA t(sound2, echoposition2)
    setSampleValueA t(sound2, echoposition2, value1 + value2)
    play(sound2)
    return(sound2)

    def decideLen(snd1, len1):
    srate1 = getSamplingRate (snd1)
    time1 = len1/srate1
    time1 =int( ceil(time1))
    snd2 = makeEmptySound( time1)
    return snd2

    The problem I'm having is that this program will work for a sampling
    rate of 22050, but not for the higher quality 44000 rate.
    I keep getting an array out of bounds message where I marked it on the
    program. Can't seem to find out why. Too much of a NewBe programmer I
    guess. Any one help?
    Regards,
    Solar^
Working...