buffer0[k] = Ga0 * input_tuple[0] + Gb0 * (output_value1 - input_tuple[1])
    buffer1[m] = Ga1 * input_tuple[1] + Gb1 * (output_value0 - input_tuple[0])

    # Increment buffer index
    k = k + 1
    if k == buffer_length0:
        # We have reached the end of the buffer. Circle back to front.
        k = 0

    m = m + 1
    if m == buffer_length1:
        # We have reached the end of the buffer. Circle back to front.
        m= 0

    # Clip output value to 16 bits and convert to binary string
    output_value0 = clip16(output_value0)
    output_value1 = clip16(output_value1)
    output_string = struct.pack('hh', output_value0, output_value1)

    # Write output value to audio stream
    stream.write(output_string)

    # Get next frame (sample)
    input_string = wf.readframes(1) 

while echoleft != 0 and (counter0 > 0 or counter1 > 0) :
    
    output_value0 = Gc0 * buffer0[k]
    output_value1 = Gc1 * buffer1[m]

    buffer0[k] = Gb0 * output_value1
Exemplo n.º 2
0
    # Update buffer
    buffer[k] = input_value + Gfb * buffer[k]

    # Update buffer indices
    k = k + 1
    m1 = m1 + 1
    #m2 = m2 + 1
    if k == buffer_length:
        k = 0
    if m1 >= buffer_length:
        m1 = 0
    # if m2 >= buffer_length:
    #     m2 = 0

    # Clip output value and convert to binary string
    output_string = struct.pack('h', clip16(output_value))

    # Write output value to audio stream
    stream.write(output_string)

    # Get next frame (sample)
    input_string = wf.readframes(1)     

while echoleft != 0:
        # Compute output value
    output_value = g1 * buffer[m1] + g2 * buffer[k];

    # Update buffer
    buffer[k] = Gfb * buffer[k]

    # Update buffer indices
                rate        = Fs,
                input       = False,
                output      = True )

input_string = wf.readframes(1)          # Get first frame

if num_channels == 1:
    while input_string != '':

        if bitformat == 16:
            # Convert string to number
            input_tuple = struct.unpack('h', input_string)  # One-element tuple
            input_value = input_tuple[0]                    # Number

            # Compute output value
            output_value = clipping.clip16(gain * input_value)    # Number

            # Convert output value to binary string
            output_string = struct.pack('h', output_value) 

        elif bitformat == 32:
            input_tuple = struct.unpack('f', input_string)  # One-element tuple
            input_value = input_tuple[0]                    # Number
            output_value = clipping.clip32(gain * input_value)    # Number
            output_string = struct.pack('f', output_value)  # Convert output value to binary string
        # Write output value to audio stream
        stream.write(output_string)

        # Get next frame
        input_string = wf.readframes(1)
elif num_channels == 2:
Exemplo n.º 4
0
                rate=Fs,
                input=False,
                output=True)

input_string = wf.readframes(1)  # Get first frame

if num_channels == 1:
    while input_string != '':

        if bitformat == 16:
            # Convert string to number
            input_tuple = struct.unpack('h', input_string)  # One-element tuple
            input_value = input_tuple[0]  # Number

            # Compute output value
            output_value = clipping.clip16(gain * input_value)  # Number

            # Convert output value to binary string
            output_string = struct.pack('h', output_value)

        elif bitformat == 32:
            input_tuple = struct.unpack('f', input_string)  # One-element tuple
            input_value = input_tuple[0]  # Number
            output_value = clipping.clip32(gain * input_value)  # Number
            output_string = struct.pack(
                'f', output_value)  # Convert output value to binary string
        # Write output value to audio stream
        stream.write(output_string)

        # Get next frame
        input_string = wf.readframes(1)