Example #1
0
def distortionDemo():

    jfk = ut.readWaveFile(dirIn + "jfk.wav")
    jfkDist = distortion(jfk)
    ut.writeWaveFile(dirOut + "JFK_Distortion.wav", jfkDist)

    piano = ut.readWaveFile(dirIn + "piano.wav")
    pianoDist = distortion(piano)
    ut.writeWaveFile(dirOut + "Piano_Distortion.wav", pianoDist)

    print("Distortion Demo Complete.")
def distortionDemo():
    
    
    jfk     = ut.readWaveFile(dirIn + "jfk.wav")
    jfkDist = distortion(jfk)
    ut.writeWaveFile(dirOut + "JFK_Distortion.wav", jfkDist)

    piano     = ut.readWaveFile(dirIn+"piano.wav")
    pianoDist = distortion(piano)    
    ut.writeWaveFile(dirOut + "Piano_Distortion.wav", pianoDist)
    
    print("Distortion Demo Complete.")
Example #3
0
def flangerDemo():

    jfk = ut.readWaveFile(dirIn + "jfk.wav")
    jfkFlanger = flanger(jfk)
    ut.writeWaveFile(dirOut + "JFK_Flanger.wav", jfkFlanger)

    piano = ut.readWaveFile(dirIn + "piano.wav")
    pianoFlanger = flanger(piano)
    ut.writeWaveFile(dirOut + "Piano_Flanger.wav", pianoFlanger)

    violin = ut.readWaveFile(dirIn + "Violin2.wav")
    violinFlanger = flanger(violin)
    ut.writeWaveFile(dirOut + "Violin_Flanger.wav", violinFlanger)

    print("Flanger Demo Complete.")
def phaserDemo():

    jfk = ut.readWaveFile(dirIn + "jfk.wav")
    jfkPhaser = phaser(jfk)
    ut.writeWaveFile(dirOut + "JFK_Phaser.wav", jfkPhaser)

    piano = ut.readWaveFile(dirIn + "piano.wav")
    pianoPhaser = phaser(piano)
    ut.writeWaveFile(dirOut + "Piano_Phaser.wav", pianoPhaser)

    violin = ut.readWaveFile(dirIn + "Violin2.wav")
    violinPhaser = phaser(violin)
    ut.writeWaveFile(dirOut + "Violin_Phaser.wav", violinPhaser)

    print("Phaser Demo Complete.")
def phaserDemo():
 
    jfk       = ut.readWaveFile(dirIn+"jfk.wav")
    jfkPhaser = phaser(jfk)
    ut.writeWaveFile(dirOut + "JFK_Phaser.wav", jfkPhaser)
 
    piano       = ut.readWaveFile(dirIn+"piano.wav")
    pianoPhaser = phaser(piano)
    ut.writeWaveFile(dirOut + "Piano_Phaser.wav", pianoPhaser)
      
    violin = ut.readWaveFile(dirIn+"Violin2.wav")
    violinPhaser = phaser(violin)
    ut.writeWaveFile(dirOut + "Violin_Phaser.wav", violinPhaser)
    
    print("Phaser Demo Complete.")
def flangerDemo():
    
    jfk = ut.readWaveFile(dirIn+"jfk.wav")
    jfkFlanger = flanger(jfk)
    ut.writeWaveFile(dirOut + "JFK_Flanger.wav", jfkFlanger)
    
    piano       = ut.readWaveFile(dirIn+"piano.wav")
    pianoFlanger = flanger(piano)
    ut.writeWaveFile(dirOut + "Piano_Flanger.wav", pianoFlanger)
    
    violin = ut.readWaveFile(dirIn+"Violin2.wav")
    violinFlanger = flanger(violin)
    ut.writeWaveFile(dirOut + "Violin_Flanger.wav", violinFlanger)
    
    
    print("Flanger Demo Complete.")
Example #7
0
def convReverbDemo():

    #     obama       = ut.readWaveFile(dirIn+"ObamaAcceptanceSpeech.wav")
    #     obamaReverb = reverb(obama)
    #     ut.writeWaveFile(dirOut + "Obama_Distortion.wav", obamaDist)

    #     jfk        = ut.readWaveFile(dirIn + "jfk.wav")
    #     jfkReverb  = reverb(jfk)
    #     ut.writeWaveFile(dirOut + "JFK_Distortion.wav", jfkDist)

    piano = ut.readWaveFile(dirIn + "piano.wav")
    Cas = ut.readWaveFile(dirIn + "Reverb_Samples/Cas.wav")
    print("files read, now running convReverb")
    pianoConvReverb = convReverb(piano, Cas)
    ut.writeWaveFile(dirOut + "Piano_Conv_Reverb.wav", pianoConvReverb)

    print("Convolution Reverb Demo Complete.")
def convReverbDemo():
    
        
#     obama       = ut.readWaveFile(dirIn+"ObamaAcceptanceSpeech.wav")
#     obamaReverb = reverb(obama)
#     ut.writeWaveFile(dirOut + "Obama_Distortion.wav", obamaDist)
    
#     jfk        = ut.readWaveFile(dirIn + "jfk.wav")
#     jfkReverb  = reverb(jfk)
#     ut.writeWaveFile(dirOut + "JFK_Distortion.wav", jfkDist)

    piano       = ut.readWaveFile(dirIn+"piano.wav")
    Cas = ut.readWaveFile(dirIn+"Reverb_Samples/Cas.wav")
    print("files read, now running convReverb")
    pianoConvReverb = convReverb(piano, Cas)
    ut.writeWaveFile(dirOut + "Piano_Conv_Reverb.wav", pianoConvReverb)
    
    print("Convolution Reverb Demo Complete.")
def reverbDemo():

    #     jfk = ut.readWaveFile(dirIn + "jfk.wav")
    #     jfkReverb = reverb(jfk)
    #     ut.writeWaveFile(dirOut + "JFK_Distortion.wav", jfkDist)

    piano = ut.readWaveFile(dirIn + "piano.wav")
    pianoReverb = reverb(piano)
    ut.writeWaveFile(dirOut + "Piano_Reverb.wav", pianoReverb)

    print("Reverb Demo Complete.")
Example #10
0
def reverbDemo():
    
#     jfk = ut.readWaveFile(dirIn + "jfk.wav")
#     jfkReverb = reverb(jfk)
#     ut.writeWaveFile(dirOut + "JFK_Distortion.wav", jfkDist)

    piano = ut.readWaveFile(dirIn+"piano.wav")
    pianoReverb = reverb(piano)
    ut.writeWaveFile(dirOut + "Piano_Reverb.wav", pianoReverb)
    
    print("Reverb Demo Complete.")
def convReverbDemo(case=1):

    if case == 1:    
        CAS          = ut.readWaveFile(dirIn+"Reverb_Samples/Cas.wav")
        CASmodel     = kernelGenerator(CAS)
#         print(CASmodel)
        
        guitar = ut.readWaveFile(dirIn + "Guitar1.wav")
        guitarConvReverb = convReverb(guitar, CASmodel, trim=False)
        ut.writeWaveFile(dirOut + "Guitar_Conv_Reverb_casModel.wav", guitarConvReverb)
         
        piano = ut.readWaveFile(dirIn+"piano.wav")
        pianoConvReverb = convReverb(piano, CASmodel, trim=False)
        ut.writeWaveFile(dirOut + "Piano_Conv_Reverb_casModel.wav", pianoConvReverb)
    
    
    
    elif case == 2:
        warren = ut.readWaveFile(dirIn + "Reverb_Samples/Warren.wav")
        warrenModel = kernelGenerator(warren)
#         print(warrenModel)
        
        guitar = ut.readWaveFile(dirIn + "Guitar1.wav")
        guitarConvReverb = convReverb(guitar, warrenModel, trim=False)
        ut.writeWaveFile(dirOut + "Guitar_Conv_Reverb_GuitarModel.wav", guitarConvReverb)
         
        piano = ut.readWaveFile(dirIn+"piano.wav")
        pianoConvReverb = convReverb(piano, warrenModel, trim=False)
        ut.writeWaveFile(dirOut + "Piano_Conv_Reverb_GuitarModel.wav", pianoConvReverb)
     
     
    print("Convolution Reverb Demo Complete.")
def sineFlangerDemo():

    jfk = ut.readWaveFile(dirIn + "jfk.wav")
    jfksFlanger = sineFlanger(jfk, plot=True)
    ut.writeWaveFile(dirOut + "JFK_SineFlanger.wav", jfksFlanger)

    #    piano = ut.readWaveFile(dirIn+"piano.wav")
    #    pianosFlanger = sineFlanger(piano)
    #    ut.writeWaveFile(dirOut + "Piano_SineFlanger.wav", pianosFlanger)
    #
    #    violin = ut.readWaveFile(dirIn+"Violin2.wav")
    #    violinsFlanger = sineFlanger(violin)
    #    ut.writeWaveFile(dirOut + "Violin_SineFlanger.wav", violinsFlanger)

    print("Sine_Flanger Demo Complete.")
def sineFlangerDemo():
    
    jfk = ut.readWaveFile(dirIn+"jfk.wav")
    jfksFlanger = sineFlanger(jfk, plot=True)
    ut.writeWaveFile(dirOut + "JFK_SineFlanger.wav", jfksFlanger)
    
#    piano = ut.readWaveFile(dirIn+"piano.wav")
#    pianosFlanger = sineFlanger(piano)
#    ut.writeWaveFile(dirOut + "Piano_SineFlanger.wav", pianosFlanger)
#    
#    violin = ut.readWaveFile(dirIn+"Violin2.wav")
#    violinsFlanger = sineFlanger(violin)
#    ut.writeWaveFile(dirOut + "Violin_SineFlanger.wav", violinsFlanger)
    
    
    print("Sine_Flanger Demo Complete.")
Example #14
0
def convReverb(signal, location, preDelay=0, Decay=1, trim=True):
    """fileName: name of file in string form
        preDelay: delay befor reverb begins (seconds)
        Decay: hang time of signal (seconds)        
    """
    signal = [int(x) for x in signal]

    print("signal acquired")

    location = location[6610:]

    pdSamples = preDelay * sampleRate
    dSamples = Decay * sampleRate

    if trim:  #trim to 10 seconds
        signal = signal[:441000]
        print("trimmed")

    clap = ut.readWaveFile(dirIn + "Reverb_Samples/Clap.wav")
    clap = clap[6610:]

    kernel1 = np.fft.fft(location)  #use FFT on location sound
    kernel2 = convolve(clap, location)
    kernel3 = []
    for i in range(0, len(clap) - 1):
        kernel3 += [clap[i] * location[i]]
    kernel4 = []
    for i in range(0, len(clap) - 1):
        kernel4 += [location[i] - clap[i]]

    print("got kernel")
    '''
    new = []
    for i in signal:
        new += [int(signal[i] * kernel1[i])]
    
        
    new2 = []
    for i in signal:
        new2 += [int(signal[i] * kernel2[i])]
        
    new3 = []
    for i in signal:
        new3 += [int(signal[i] * kernel3[i])]

    #return new? is new needed?

    print("got new")
    '''
    #according to https://en.wikipedia.org/wiki/Overlap%E2%80%93add_method#The_algorithm
    #this is the way Overlap-add should work,which is an efficient way of convolving

    L = 44100 // 2
    M = int(L * 1.5)
    N = 32768
    Nx = int(len(signal))
    H = FFT(kernel4, N)  #is this right?
    #H = kernel4
    i = 1

    y = [0 for x in range(1, M + Nx - 1)]

    while i <= Nx:
        il = min((i + L) - 1, Nx)
        #p = len(FFT(signal[i:il], N))
        yt = IFFT(FFT(signal[i:il], N) * H, N)
        k = min(i + N - 1, M + Nx - 1)
        y[i:k] = y[i:k] + yt[1:(k - i +
                                1)]  # (add the overlapped output blocks)
        i = i + L

    #convert back to ints
    y = np.convolve(signal, location)
    y = [int(x) for x in y]

    #ensure values are within short int range
    for i in range(len(y)):
        if y[i] > maxAmp:
            y[i] = maxAmp - 1

        elif y[i] < minAmp:
            y[i] = minAmp + 1

    return y
def convReverb(signal, location, preDelay = 0, Decay = 1, trim = True):
    """fileName: name of file in string form
        preDelay: delay befor reverb begins (seconds)
        Decay: hang time of signal (seconds)        
    """    
    signal = [int(x) for x in signal]
    
    print("signal acquired")
        
    location = location[6610:]
    
    pdSamples = preDelay * sampleRate
    dSamples = Decay * sampleRate
    
    if trim: #trim to 10 seconds
        signal = signal[:441000]
        print("trimmed")
    
    clap = ut.readWaveFile(dirIn+"Reverb_Samples/Clap.wav")
    clap = clap[6610:]
    
    kernel1 = np.fft.fft(location) #use FFT on location sound
    kernel2 = convolve(clap,location)
    kernel3 = []
    for i in range(0, len(clap)-1):
        kernel3 += [clap[i] * location[i]]
    kernel4 = []
    for i in range(0, len(clap)-1):
        kernel4 += [location[i]-clap[i]]
    
    print("got kernel")
    '''
    new = []
    for i in signal:
        new += [int(signal[i] * kernel1[i])]
    
        
    new2 = []
    for i in signal:
        new2 += [int(signal[i] * kernel2[i])]
        
    new3 = []
    for i in signal:
        new3 += [int(signal[i] * kernel3[i])]

    #return new? is new needed?

    print("got new")
    '''
    #according to https://en.wikipedia.org/wiki/Overlap%E2%80%93add_method#The_algorithm
    #this is the way Overlap-add should work,which is an efficient way of convolving
    
    L = 44100//2
    M = int(L*1.5)
    N = 32768
    Nx = int(len(signal));
    H = FFT(kernel4,N)     #is this right?
    #H = kernel4
    i = 1

    y = [0 for x in range(1, M+Nx-1)]

    while i <= Nx:
        il = min((i+L)-1,Nx)
        #p = len(FFT(signal[i:il], N))
        yt = IFFT(FFT(signal[i:il], N) * H, N)
        k  = min(i+N-1,M+Nx-1)
        y[i:k] = y[i:k] + yt[1:(k-i+1)]   # (add the overlapped output blocks)
        i = i+L
    
    #convert back to ints
    y = np.convolve(signal, location)
    y = [int(x) for x in y]
    
    #ensure values are within short int range
    for i in range(len(y)):
        if y[i] > maxAmp:
            y[i] = maxAmp-1
        
        elif y[i] < minAmp:
            y[i] = minAmp+1    
    
    return y
Example #16
0
    for i in range(len(outputSignal)):
        if outputSignal[i] > maxAmp:
            outputSignal[i] = maxAmp - 1

        elif outputSignal[i] < minAmp:
            outputSignal[i] = minAmp + 1

    outputSignal = [int(x) for x in outputSignal]

    return outputSignal


def convReverbDemo(case=1):

    if case == 1:
        CAS = ut.readWaveFile(dirIn + "Reverb_Samples/Cas.wav")
        CASmodel = kernelGenerator(CAS)
        #         print(CASmodel)

        guitar = ut.readWaveFile(dirIn + "Guitar1.wav")
        guitarConvReverb = convReverb(guitar, CASmodel, trim=False)
        ut.writeWaveFile(dirOut + "Guitar_Conv_Reverb_casModel.wav",
                         guitarConvReverb)

        piano = ut.readWaveFile(dirIn + "piano.wav")
        pianoConvReverb = convReverb(piano, CASmodel, trim=False)
        ut.writeWaveFile(dirOut + "Piano_Conv_Reverb_casModel.wav",
                         pianoConvReverb)

    elif case == 2:
        warren = ut.readWaveFile(dirIn + "Reverb_Samples/Warren.wav")