コード例 #1
0
ファイル: hw3pr1.py プロジェクト: cheshireAce/fluency-lab
def overlay(filename1, filename2):
    """ overlay creates a sound that overlays the two given sound files
        input: filename, the name of the original file
        output: no return value, but
                this creates the sound file 'out.wav'
                and plays it
    """
    print "Playing the original sound..."
    play(filename1)
    play(filename2)
    
    print "Reading in the sound data..."
    samps1, sr1 = readwav(filename1)
    samps2, sr2 = readwav(filename2)
    
    print "Computing new sound..."
    newsamps = add_scale_2(samps1, samps2, 0.5, 0.5)
    newsr = (sr1+sr2)/2                      # no change to the sr
    
    writewav( newsamps, newsr, "out.wav" )
    print "Playing new sound..."
    play( 'out.wav' )
コード例 #2
0
ファイル: hw3pr1.py プロジェクト: JustisAllen/fluency-lab
def changeSpeed(filename, newsr):
    """ changeSpeed allows the user to change an audio file's speed
        input: filename, the name of the original file
               newsr, the *new* sampling rate in samples per second
        output: no return value; creates and plays the file 'out.wav'
    """
    samps, sr = readwav(filename)

    print "The first 10 sound-pressure samples are\n", samps[:10]
    print "The original number of samples per second is", sr
    
    newsamps = samps                        # no change to the sound
    writewav( newsamps, newsr, "out.wav" )  # write data to out.wav
    print "\nPlaying new sound..."
    play( 'out.wav' )   # play the new file, 'out.wav'
コード例 #3
0
ファイル: hw3pr1.py プロジェクト: cheshireAce/fluency-lab
def static(filename, probability_of_static):
    """ static introduces random bits of static based on the probability given
        input: filename, the name of the original file
        output: no return value, but
                this creates the sound file 'out.wav'
                and plays it
    """
    print "Playing the original sound..."
    play(filename)
    
    print "Reading in the sound data..."
    samps, sr = readwav(filename)
    
    print "Computing new sound..."
    newsamps = replace_some(samps, probability_of_static)
    newsr = sr                       # no change to the sr
    
    writewav( newsamps, newsr, "out.wav" )
    print "Playing new sound..."
    play( 'out.wav' )
コード例 #4
0
ファイル: hw3pr1.py プロジェクト: cheshireAce/fluency-lab
def volume(filename, scale_factor):
    """ volume increases the volume by the floating-point value scale_value
        input: filename, the name of the original file
        output: no return value, but
                this creates the sound file 'out.wav'
                and plays it
    """
    print "Playing the original sound..."
    play(filename)
    
    print "Reading in the sound data..."
    samps, sr = readwav(filename)
    
    print "Computing new sound..."
    newsamps = [x * scale_factor for x in samps]
    newsr = sr                       # no change to the sr
    
    writewav( newsamps, newsr, "out.wav" )
    print "Playing new sound..."
    play( 'out.wav' )
コード例 #5
0
ファイル: hw3pr1.py プロジェクト: cheshireAce/fluency-lab
def reverse(filename):
    """ reverse reverses the original file
        input: filename, the name of the original file
        output: no return value, but
                this creates the sound file 'out.wav'
                and plays it
    """
    print "Playing the original sound..."
    play(filename)
    
    print "Reading in the sound data..."
    samps, sr = readwav(filename)
    
    print "Computing new sound..."
    newsamps = samps[::-1] # reverse
    newsr = sr                       # no change to the sr
    
    writewav( newsamps, newsr, "out.wav" )
    print "Playing new sound..."
    play( 'out.wav' )
コード例 #6
0
ファイル: hw3pr1.py プロジェクト: JustisAllen/fluency-lab
def flipflop(filename):
    """ flipflop swaps the halves of an audio file
        input: filename, the name of the original file
        output: no return value, but
                this creates the sound file 'out.wav'
                and plays it
    """
    print "Playing the original sound..."
    play(filename)
    
    print "Reading in the sound data..."
    samps, sr = readwav(filename)
    
    print "Computing new sound..."
    # this gets the midpoint and calls it x
    x = len(samps)/2
    newsamps = samps[x:] + samps[:x] # flip flop
    newsr = sr                       # no change to the sr
    
    writewav( newsamps, newsr, "out.wav" )
    print "Playing new sound..."
    play( 'out.wav' )
コード例 #7
0
ファイル: hw3pr1.py プロジェクト: cheshireAce/fluency-lab
def echo(filename, time_delay):
    """ echo takes in a filename and overlays the same sound on itself, shifted by time_delay
        input: filename, the name of the original file
        output: no return value, but
                this creates the sound file 'out.wav'
                and plays it
    """
    print "Playing the original sound..."
    play(filename)
    
    print "Reading in the sound data..."
    samps, sr = readwav(filename)
    
    print "Computing new sound..."
    echosamps = [0]*(time_delay*float(sr)) + samps
    echosamps = echosamps[:len(samps)]
    newsamps = [echosamps[i]+samps[i] for i in xrange(len(samps))]
    newsr = sr                      # no change to the sr
    
    writewav( newsamps, newsr, "out.wav" )
    print "Playing new sound..."
    play( 'out.wav' )
コード例 #8
0
ファイル: hw3pr1.py プロジェクト: ZoabKapoor/fluency-lab
 def __init__(self, filename):
     self.samps, self.sr = readwav(filename)
     return
コード例 #9
0
ファイル: hw3pr1.py プロジェクト: hmc-aozdemir/fluency-lab
 def __init__( self, filename = None):
     if filename:
         self.samps, self.sr = readwav(filename)
     else:
         self.samps, self.sr = None, None
コード例 #10
0
ファイル: hw3pr1.py プロジェクト: aputman/fluency-lab
def load(filename):
    samps, sr = readwav(filename)
    return (samps, sr)
コード例 #11
0
ファイル: hw3pr1.py プロジェクト: bwiedermann/fluency-lab
def overlay(filename1, filename2):
    '''overlays the sounds from two files and plays them'''

    sounds = [readwav(filename1), readwav(filename2)]
    newSound = overlayN(sounds)
    playNewSound(newSound)