Esempio n. 1
0
def filter(input, ratio=4, threshold=1, softness=1):
  import numpy as np
  output = np.zeros(input.shape, dtype=np.float64)

  input2 = input**2
  in2filter = DoubleInPointerFilter(input2, False)
  in2filter.set_input_sampling_rate(sample_rate)

  infilter = DoubleInPointerFilter(input, False)
  infilter.set_input_sampling_rate(sample_rate)

  gainfilter = DoubleGainCompressorFilter(1)
  gainfilter.set_input_sampling_rate(sample_rate)
  gainfilter.set_input_port(0, in2filter, 0)
  gainfilter.set_threshold(threshold)
  gainfilter.set_ratio(ratio)
  gainfilter.set_softness(softness)

  applygainfilter = DoubleApplyGainFilter(1)
  applygainfilter.set_input_sampling_rate(sample_rate)
  applygainfilter.set_input_port(0, gainfilter, 0)
  applygainfilter.set_input_port(1, infilter, 0)

  outfilter = DoubleOutPointerFilter(output, False)
  outfilter.set_input_sampling_rate(sample_rate)
  outfilter.set_input_port(0, applygainfilter, 0)
  outfilter.process(input.shape[1])

  return output
Esempio n. 2
0
def filter(input, ratio=4, threshold=1, softness=1):
  import numpy as np
  output = np.zeros(input.shape, dtype=np.float64)

  input2 = input**2
  in2filter = DoubleInPointerFilter(input2, False)
  in2filter.set_input_sampling_rate(sample_rate)

  infilter = DoubleInPointerFilter(input, False)
  infilter.set_input_sampling_rate(sample_rate)

  gainfilter = DoubleGainExpanderFilter(1)
  gainfilter.set_input_sampling_rate(sample_rate)
  gainfilter.set_input_port(0, in2filter, 0)
  gainfilter.set_threshold(threshold)
  gainfilter.set_ratio(ratio)
  gainfilter.set_softness(softness)

  applygainfilter = DoubleApplyGainFilter(1)
  applygainfilter.set_input_sampling_rate(sample_rate)
  applygainfilter.set_input_port(0, gainfilter, 0)
  applygainfilter.set_input_port(1, infilter, 0)

  outfilter = DoubleOutPointerFilter(output, False)
  outfilter.set_input_sampling_rate(sample_rate)
  outfilter.set_input_port(0, applygainfilter, 0)
  outfilter.process(input.shape[1])

  return output
def max_filter(input, ratio=4, threshold=1, softness=1, max_reduction=0.1):
    import numpy as np
    output = np.zeros(input.shape, dtype=np.float64)

    input2 = input**2
    in2filter = DoubleInPointerFilter(input2, False)
    in2filter.input_sampling_rate = sample_rate

    infilter = DoubleInPointerFilter(input, False)
    infilter.input_sampling_rate = sample_rate

    gainfilter = DoubleGainMaxCompressorFilter(1)
    gainfilter.input_sampling_rate = sample_rate
    gainfilter.set_input_port(0, in2filter, 0)
    gainfilter.threshold = threshold
    gainfilter.ratio = ratio
    gainfilter.softness = softness
    gainfilter.max_reduction = max_reduction

    applygainfilter = DoubleApplyGainFilter(1)
    applygainfilter.input_sampling_rate = sample_rate
    applygainfilter.set_input_port(0, gainfilter, 0)
    applygainfilter.set_input_port(1, infilter, 0)

    outfilter = DoubleOutPointerFilter(output, False)
    outfilter.input_sampling_rate = sample_rate
    outfilter.set_input_port(0, applygainfilter, 0)
    outfilter.process(input.shape[1])

    return output
def max_colored_filter(input, ratio=4, threshold=1, softness=1, quality=1, color=1, max_reduction=-10):
  import numpy as np
  output = np.zeros(input.shape, dtype=np.float64)
  
  input2 = input**2
  in2filter = DoubleInPointerFilter(input2, False)
  in2filter.set_input_sampling_rate(sample_rate)
  
  infilter = DoubleInPointerFilter(input, False)
  infilter.set_input_sampling_rate(sample_rate)
  
  gainfilter = DoubleGainMaxColoredExpanderFilter(1)
  gainfilter.set_input_sampling_rate(sample_rate)
  gainfilter.set_input_port(0, in2filter, 0)
  gainfilter.set_threshold(threshold)
  gainfilter.set_ratio(ratio)
  gainfilter.set_color(color)
  gainfilter.set_softness(softness)
  gainfilter.set_quality(quality)
  gainfilter.set_max_reduction_db(max_reduction)
  
  applygainfilter = DoubleApplyGainFilter(1)
  applygainfilter.set_input_sampling_rate(sample_rate)
  applygainfilter.set_input_port(0, gainfilter, 0)
  applygainfilter.set_input_port(1, infilter, 0)
  
  outfilter = DoubleOutPointerFilter(output, False)
  outfilter.set_input_sampling_rate(sample_rate)
  outfilter.set_input_port(0, applygainfilter, 0)
  outfilter.process(input.shape[1])
  
  return output
def colored_filter(input, ratio=4, threshold=1, softness=1, quality=1, color=1):
  import numpy as np
  output = np.zeros(input.shape, dtype=np.float64)
  
  input2 = input**2
  in2filter = DoubleInPointerFilter(input2, False)
  in2filter.input_sampling_rate = sample_rate
  
  infilter = DoubleInPointerFilter(input, False)
  infilter.input_sampling_rate = sample_rate
  
  gainfilter = DoubleGainColoredExpanderFilter(1)
  gainfilter.input_sampling_rate = sample_rate
  gainfilter.set_input_port(0, in2filter, 0)
  gainfilter.threshold = threshold
  gainfilter.ratio = ratio
  gainfilter.color = color
  gainfilter.softness = softness
  gainfilter.quality = quality
  
  applygainfilter = DoubleApplyGainFilter(1)
  applygainfilter.input_sampling_rate = sample_rate
  applygainfilter.set_input_port(0, gainfilter, 0)
  applygainfilter.set_input_port(1, infilter, 0)
  
  outfilter = DoubleOutPointerFilter(output, False)
  outfilter.input_sampling_rate = sample_rate
  outfilter.set_input_port(0, applygainfilter, 0)
  outfilter.process(input.shape[1])
  
  return output
def max_filter(input, ratio=4, threshold=1, softness=1, max_reduction=0.1):
  import numpy as np
  output = np.zeros(input.shape, dtype=np.float64)

  input2 = input**2
  in2filter = DoubleInPointerFilter(input2, False)
  in2filter.input_sampling_rate = sample_rate

  infilter = DoubleInPointerFilter(input, False)
  infilter.input_sampling_rate = sample_rate

  gainfilter = DoubleGainMaxExpanderFilter(1)
  gainfilter.input_sampling_rate = sample_rate
  gainfilter.set_input_port(0, in2filter, 0)
  gainfilter.threshold = threshold
  gainfilter.ratio = ratio
  gainfilter.softness = softness
  gainfilter.max_reduction = max_reduction

  applygainfilter = DoubleApplyGainFilter(1)
  applygainfilter.input_sampling_rate = sample_rate
  applygainfilter.set_input_port(0, gainfilter, 0)
  applygainfilter.set_input_port(1, infilter, 0)

  outfilter = DoubleOutPointerFilter(output, False)
  outfilter.input_sampling_rate = sample_rate
  outfilter.set_input_port(0, applygainfilter, 0)
  outfilter.process(input.shape[1])

  return output
def max_colored_filter(input,
                       ratio=4,
                       threshold=1,
                       softness=1,
                       quality=1,
                       color=1,
                       max_reduction=-10):
    import numpy as np
    output = np.zeros(input.shape, dtype=np.float64)

    input2 = input**2
    in2filter = DoubleInPointerFilter(input2, False)
    in2filter.set_input_sampling_rate(sample_rate)

    infilter = DoubleInPointerFilter(input, False)
    infilter.set_input_sampling_rate(sample_rate)

    gainfilter = DoubleGainMaxColoredExpanderFilter(1)
    gainfilter.set_input_sampling_rate(sample_rate)
    gainfilter.set_input_port(0, in2filter, 0)
    gainfilter.set_threshold(threshold)
    gainfilter.set_ratio(ratio)
    gainfilter.set_color(color)
    gainfilter.set_softness(softness)
    gainfilter.set_quality(quality)
    gainfilter.set_max_reduction_db(max_reduction)

    applygainfilter = DoubleApplyGainFilter(1)
    applygainfilter.set_input_sampling_rate(sample_rate)
    applygainfilter.set_input_port(0, gainfilter, 0)
    applygainfilter.set_input_port(1, infilter, 0)

    outfilter = DoubleOutPointerFilter(output, False)
    outfilter.set_input_sampling_rate(sample_rate)
    outfilter.set_input_port(0, applygainfilter, 0)
    outfilter.process(input.shape[1])

    return output
Esempio n. 8
0
def filter(input):
    import numpy as np
    output = np.zeros(input.shape, dtype=np.float64)

    infilter = DoubleInPointerFilter(input, False)
    infilter.set_input_sampling_rate(sample_rate)

    sinusfilter = DoubleCachedSinusGeneratorFilter(20, 5)
    sinusfilter.set_input_sampling_rate(sample_rate)
    sinusfilter.set_offset(0.5)
    sinusfilter.set_volume(0.5)

    gainfilter = DoubleApplyGainFilter(1)
    gainfilter.set_input_sampling_rate(sample_rate)
    gainfilter.set_input_port(0, infilter, 0)
    gainfilter.set_input_port(1, sinusfilter, 0)

    outfilter = DoubleOutPointerFilter(output, False)
    outfilter.set_input_sampling_rate(sample_rate)
    outfilter.set_input_port(0, gainfilter, 0)
    outfilter.process(input.shape[1])

    return output
Esempio n. 9
0
def filter(input):
  import numpy as np
  output = np.zeros(input.shape, dtype=np.float64)

  infilter = DoubleInPointerFilter(input, False)
  infilter.set_input_sampling_rate(sample_rate)

  powerfilter = DoublePowerFilter(1)
  powerfilter.set_input_sampling_rate(sample_rate)
  powerfilter.set_input_port(0, infilter, 0)
  powerfilter.set_memory(0)

  attackreleasefilter = DoubleAttackReleaseFilter(1)
  attackreleasefilter.set_input_sampling_rate(sample_rate)
  attackreleasefilter.set_input_port(0, powerfilter, 0)
  attackreleasefilter.set_attack(0)
  attackreleasefilter.set_release(np.exp(-1/(sample_rate*10e-3)))

  gainfilter = DoubleGainCompressorFilter(1)
  gainfilter.set_input_sampling_rate(sample_rate)
  gainfilter.set_input_port(0, attackreleasefilter, 0)
  gainfilter.set_threshold(0.0099)
  gainfilter.set_ratio(10000)
  gainfilter.set_softness(1)

  applygainfilter = DoubleApplyGainFilter(1)
  applygainfilter.set_input_sampling_rate(sample_rate)
  applygainfilter.set_input_port(0, gainfilter, 0)
  applygainfilter.set_input_port(1, infilter, 0)

  outfilter = DoubleOutPointerFilter(output, False)
  outfilter.set_input_sampling_rate(sample_rate)
  outfilter.set_input_port(0, applygainfilter, 0)
  outfilter.process(input.shape[1])

  return output
def max_colored_filter(input,
                       ratio=4,
                       threshold=1,
                       softness=1,
                       quality=1,
                       color=1,
                       max_reduction=-10):
    import numpy as np
    output = np.zeros(input.shape, dtype=np.float64)

    input2 = input**2
    in2filter = DoubleInPointerFilter(input2, False)
    in2filter.input_sampling_rate = sample_rate

    infilter = DoubleInPointerFilter(input, False)
    infilter.input_sampling_rate = sample_rate

    gainfilter = DoubleGainMaxColoredExpanderFilter(1)
    gainfilter.input_sampling_rate = sample_rate
    gainfilter.set_input_port(0, in2filter, 0)
    gainfilter.threshold = threshold
    gainfilter.ratio = ratio
    gainfilter.color = color
    gainfilter.softness = softness
    gainfilter.quality = quality
    gainfilter.max_reduction = 10**(max_reduction / 20.)

    applygainfilter = DoubleApplyGainFilter(1)
    applygainfilter.input_sampling_rate = sample_rate
    applygainfilter.set_input_port(0, gainfilter, 0)
    applygainfilter.set_input_port(1, infilter, 0)

    outfilter = DoubleOutPointerFilter(output, False)
    outfilter.input_sampling_rate = sample_rate
    outfilter.set_input_port(0, applygainfilter, 0)
    outfilter.process(input.shape[1])

    return output
Esempio n. 11
0
def filter(input):
  import numpy as np
  output = np.zeros(input.shape, dtype=np.float64)

  infilter = DoubleInPointerFilter(input, False)
  infilter.set_input_sampling_rate(sample_rate)

  sinusfilter = DoubleCachedSinusGeneratorFilter(20, 5)
  sinusfilter.set_input_sampling_rate(sample_rate)
  sinusfilter.set_offset(0.5)
  sinusfilter.set_volume(0.5)
  
  gainfilter = DoubleApplyGainFilter(1)
  gainfilter.set_input_sampling_rate(sample_rate)
  gainfilter.set_input_port(0, infilter, 0)
  gainfilter.set_input_port(1, sinusfilter, 0)
  
  outfilter = DoubleOutPointerFilter(output, False)
  outfilter.set_input_sampling_rate(sample_rate)
  outfilter.set_input_port(0, gainfilter, 0)
  outfilter.process(input.shape[1])

  return output
Esempio n. 12
0
def filter(input):
    import numpy as np
    output = np.zeros(input.shape, dtype=np.float64)

    infilter = DoubleInPointerFilter(input, False)
    infilter.input_sampling_rate = sample_rate

    sinusfilter = DoubleSinusGeneratorFilter()
    sinusfilter.input_sampling_rate = sample_rate
    sinusfilter.offset = 0.5
    sinusfilter.volume = 0.5
    sinusfilter.frequency = 10

    gainfilter = DoubleApplyGainFilter(1)
    gainfilter.input_sampling_rate = sample_rate
    gainfilter.set_input_port(0, infilter, 0)
    gainfilter.set_input_port(1, sinusfilter, 1)

    outfilter = DoubleOutPointerFilter(output, False)
    outfilter.input_sampling_rate = sample_rate
    outfilter.set_input_port(0, gainfilter, 0)
    outfilter.process(input.shape[0])

    return output
def filter(input):
    import numpy as np
    output = np.zeros(input.shape, dtype=np.float64)

    infilter = DoubleInPointerFilter(input, False)
    infilter.input_sampling_rate = sample_rate

    powerfilter = DoublePowerFilter(1)
    powerfilter.input_sampling_rate = sample_rate
    powerfilter.set_input_port(0, infilter, 0)
    powerfilter.memory = np.exp(-1 / (sample_rate * 1e-3))

    attackreleasefilter = DoubleAttackReleaseFilter(1)
    attackreleasefilter.input_sampling_rate = sample_rate
    attackreleasefilter.set_input_port(0, powerfilter, 0)
    attackreleasefilter.attack = np.exp(-1 / (sample_rate * 1e-3))
    attackreleasefilter.release = np.exp(-1 / (sample_rate * 100e-3))

    gainfilter = DoubleGainCompressorFilter(1)
    gainfilter.input_sampling_rate = sample_rate
    gainfilter.set_input_port(0, attackreleasefilter, 0)
    gainfilter.threshold = 0.5
    gainfilter.ratio = 4
    gainfilter.softness = 1

    applygainfilter = DoubleApplyGainFilter(1)
    applygainfilter.input_sampling_rate = sample_rate
    applygainfilter.set_input_port(0, gainfilter, 0)
    applygainfilter.set_input_port(1, infilter, 0)

    outfilter = DoubleOutPointerFilter(output, False)
    outfilter.input_sampling_rate = sample_rate
    outfilter.set_input_port(0, applygainfilter, 0)
    outfilter.process(input.shape[1])

    return output
def filter(input):
  import numpy as np
  output = np.zeros(input.shape, dtype=np.float64)

  infilter = DoubleInPointerFilter(input, False)
  infilter.input_sampling_rate = sample_rate

  powerfilter = DoublePowerFilter(1)
  powerfilter.input_sampling_rate = sample_rate
  powerfilter.set_input_port(0, infilter, 0)
  powerfilter.memory = np.exp(-1/(sample_rate*1e-3))

  attackreleasefilter = DoubleAttackReleaseFilter(1)
  attackreleasefilter.input_sampling_rate = sample_rate
  attackreleasefilter.set_input_port(0, powerfilter, 0)
  attackreleasefilter.attack = np.exp(-1/(sample_rate*1e-3))
  attackreleasefilter.release = np.exp(-1/(sample_rate*100e-3))

  gainfilter = DoubleGainCompressorFilter(1)
  gainfilter.input_sampling_rate = sample_rate
  gainfilter.set_input_port(0, attackreleasefilter, 0)
  gainfilter.threshold = 0.5
  gainfilter.ratio = 4
  gainfilter.softness = 1

  applygainfilter = DoubleApplyGainFilter(1)
  applygainfilter.input_sampling_rate = sample_rate
  applygainfilter.set_input_port(0, gainfilter, 0)
  applygainfilter.set_input_port(1, infilter, 0)

  outfilter = DoubleOutPointerFilter(output, False)
  outfilter.input_sampling_rate = sample_rate
  outfilter.set_input_port(0, applygainfilter, 0)
  outfilter.process(input.shape[1])

  return output
Esempio n. 15
0
def filter(input):
  import numpy as np
  output = np.zeros(input.shape, dtype=np.float64)

  infilter = DoubleInPointerFilter(input, False)
  infilter.input_sampling_rate = sample_rate

  sinusfilter = DoubleSinusGeneratorFilter()
  sinusfilter.input_sampling_rate = sample_rate
  sinusfilter.offset = 0.5
  sinusfilter.volume = 0.5
  sinusfilter.frequency = 10
  
  gainfilter = DoubleApplyGainFilter(1)
  gainfilter.input_sampling_rate = sample_rate
  gainfilter.set_input_port(0, infilter, 0)
  gainfilter.set_input_port(1, sinusfilter, 1)
  
  outfilter = DoubleOutPointerFilter(output, False)
  outfilter.input_sampling_rate = sample_rate
  outfilter.set_input_port(0, gainfilter, 0)
  outfilter.process(input.shape[0])

  return output
Esempio n. 16
0
def filter(input, blend=0, feedback=0, feedforward=1):
  import numpy as np
  output1 = np.zeros(input.shape, dtype=np.float64)
  output2 = np.zeros(input.shape, dtype=np.float64)

  infilter = DoubleInPointerFilter(input, False)
  infilter.set_input_sampling_rate(sample_rate)

  allpass1filter = DoubleCustomIIRFilter()
  allpass1filter.set_input_sampling_rate(sample_rate)
  allpass1filter.set_input_port(0, infilter, 0)
  allpass1filter.set_coefficients_in((0.0000, 0.3855, 0.0000, 1.3313, 0.0000, 1.0000)[::-1])
  allpass1filter.set_coefficients_out((-0.0000, -1.3313, 0.0000, -0.3855, 0)[::-1])

  allpass2filter = DoubleCustomIIRFilter()
  allpass2filter.set_input_sampling_rate(sample_rate)
  allpass2filter.set_input_port(0, infilter, 0)
  allpass2filter.set_coefficients_in((0.0947, 0.0000, 0.8335, 0.0000, 1.0000)[::-1])
  allpass2filter.set_coefficients_out((0.0000, -0.8335, 0.0000, -0.0947)[::-1])

  sinusfilter = DoubleCachedSinusGeneratorFilter(100, 1)
  sinusfilter.set_input_sampling_rate(sample_rate)

  cosinusfilter = DoubleCachedCosinusGeneratorFilter(100, 1)
  cosinusfilter.set_input_sampling_rate(sample_rate)
  
  applygainFilter = DoubleApplyGainFilter(2)
  applygainFilter.set_input_sampling_rate(sample_rate)
  applygainFilter.set_input_port(0, allpass1filter, 0)
  applygainFilter.set_input_port(1, sinusfilter, 0)
  applygainFilter.set_input_port(2, allpass2filter, 0)
  applygainFilter.set_input_port(3, cosinusfilter, 0)

  volumeFilter = DoubleVolumeFilter()
  volumeFilter.set_input_sampling_rate(sample_rate)
  volumeFilter.set_volume(-1)
  volumeFilter.set_input_port(0, applygainFilter, 1)

  sum1Filter = DoubleSumFilter()
  sum1Filter.set_input_sampling_rate(sample_rate)
  sum1Filter.set_input_port(0, applygainFilter, 0)
  sum1Filter.set_input_port(1, volumeFilter, 0)

  sum2Filter = DoubleSumFilter()
  sum2Filter.set_input_sampling_rate(sample_rate)
  sum2Filter.set_input_port(0, applygainFilter, 0)
  sum2Filter.set_input_port(1, applygainFilter, 1)

  out1filter = DoubleOutPointerFilter(output1, False)
  out1filter.set_input_sampling_rate(sample_rate)
  out1filter.set_input_port(0, sum1Filter, 0)

  out2filter = DoubleOutPointerFilter(output2, False)
  out2filter.set_input_sampling_rate(sample_rate)
  out2filter.set_input_port(0, sum2Filter, 0)

  pipelinesink = PipelineGlobalSinkFilter()
  pipelinesink.set_input_sampling_rate(sample_rate)
  pipelinesink.add_filter(out1filter)
  pipelinesink.add_filter(out2filter)
  pipelinesink.process(input.shape[1])

  return output1, output2
volumefilter.set_volume(-1)
volumefilter.set_input_port(0, slowattackreleasefilter, 0)

sumfilter = DoubleSumFilter()
sumfilter.set_input_sampling_rate(sampling_rate)
sumfilter.set_input_port(0, fastattackreleasefilter, 0)
sumfilter.set_input_port(1, volumefilter, 0)

gainfilter = DoubleGainCompressorFilter(1)
gainfilter.set_input_sampling_rate(sampling_rate)
gainfilter.set_input_port(0, sumfilter, 0)
gainfilter.set_threshold(.01)
gainfilter.set_ratio(.7)
gainfilter.set_softness(1)

applygainfilter = DoubleApplyGainFilter(1)
applygainfilter.set_input_sampling_rate(sampling_rate)
applygainfilter.set_input_port(0, gainfilter, 0)
applygainfilter.set_input_port(1, infilter, 0)

indata = np.zeros((processsize, 1), dtype=np.float32)
inputfilter = FloatOutPointerFilter(indata, True)
inputfilter.set_input_sampling_rate(sampling_rate)
inputfilter.set_input_port(0, infilter, 0)

outdata = np.zeros((processsize, 1), dtype=np.float32)
outfilter = FloatOutPointerFilter(outdata, True)
outfilter.set_input_sampling_rate(sampling_rate)
outfilter.set_input_port(0, applygainfilter, 0)

outdata_slow = np.zeros((processsize, 1), dtype=np.float32)
Esempio n. 18
0
def filter(input, blend=0, feedback=0, feedforward=1):
    import numpy as np
    output1 = np.zeros(input.shape, dtype=np.float64)
    output2 = np.zeros(input.shape, dtype=np.float64)

    infilter = DoubleInPointerFilter(input, False)
    infilter.set_input_sampling_rate(sample_rate)

    allpass1filter = DoubleCustomIIRFilter()
    allpass1filter.set_input_sampling_rate(sample_rate)
    allpass1filter.set_input_port(0, infilter, 0)
    allpass1filter.set_coefficients_in(
        (0.0000, 0.3855, 0.0000, 1.3313, 0.0000, 1.0000)[::-1])
    allpass1filter.set_coefficients_out(
        (-0.0000, -1.3313, 0.0000, -0.3855, 0)[::-1])

    allpass2filter = DoubleCustomIIRFilter()
    allpass2filter.set_input_sampling_rate(sample_rate)
    allpass2filter.set_input_port(0, infilter, 0)
    allpass2filter.set_coefficients_in(
        (0.0947, 0.0000, 0.8335, 0.0000, 1.0000)[::-1])
    allpass2filter.set_coefficients_out(
        (0.0000, -0.8335, 0.0000, -0.0947)[::-1])

    sinusfilter = DoubleCachedSinusGeneratorFilter(100, 1)
    sinusfilter.set_input_sampling_rate(sample_rate)

    cosinusfilter = DoubleCachedCosinusGeneratorFilter(100, 1)
    cosinusfilter.set_input_sampling_rate(sample_rate)

    applygainFilter = DoubleApplyGainFilter(2)
    applygainFilter.set_input_sampling_rate(sample_rate)
    applygainFilter.set_input_port(0, allpass1filter, 0)
    applygainFilter.set_input_port(1, sinusfilter, 0)
    applygainFilter.set_input_port(2, allpass2filter, 0)
    applygainFilter.set_input_port(3, cosinusfilter, 0)

    volumeFilter = DoubleVolumeFilter()
    volumeFilter.set_input_sampling_rate(sample_rate)
    volumeFilter.set_volume(-1)
    volumeFilter.set_input_port(0, applygainFilter, 1)

    sum1Filter = DoubleSumFilter()
    sum1Filter.set_input_sampling_rate(sample_rate)
    sum1Filter.set_input_port(0, applygainFilter, 0)
    sum1Filter.set_input_port(1, volumeFilter, 0)

    sum2Filter = DoubleSumFilter()
    sum2Filter.set_input_sampling_rate(sample_rate)
    sum2Filter.set_input_port(0, applygainFilter, 0)
    sum2Filter.set_input_port(1, applygainFilter, 1)

    out1filter = DoubleOutPointerFilter(output1, False)
    out1filter.set_input_sampling_rate(sample_rate)
    out1filter.set_input_port(0, sum1Filter, 0)

    out2filter = DoubleOutPointerFilter(output2, False)
    out2filter.set_input_sampling_rate(sample_rate)
    out2filter.set_input_port(0, sum2Filter, 0)

    pipelinesink = PipelineGlobalSinkFilter()
    pipelinesink.set_input_sampling_rate(sample_rate)
    pipelinesink.add_filter(out1filter)
    pipelinesink.add_filter(out2filter)
    pipelinesink.process(input.shape[1])

    return output1, output2
def filter(inputl, inputr):
  import numpy as np
  outputl = np.zeros(inputl.shape, dtype=np.float64)
  outputr = np.zeros(inputl.shape, dtype=np.float64)

  infilterL = DoubleInPointerFilter(inputl, False)
  infilterL.set_input_sampling_rate(sample_rate)
  infilterR = DoubleInPointerFilter(inputr, False)
  infilterR.set_input_sampling_rate(sample_rate)

  mssplitfilter = DoubleMiddleSideFilter()
  mssplitfilter.set_input_sampling_rate(sample_rate)
  mssplitfilter.set_input_port(0, infilterL, 0)
  mssplitfilter.set_input_port(1, infilterR, 0)

  adaptgainfilter = DoubleVolumeFilter(2)
  adaptgainfilter.set_input_sampling_rate(sample_rate)
  adaptgainfilter.set_input_port(0, mssplitfilter, 0)
  adaptgainfilter.set_input_port(1, mssplitfilter, 1)
  adaptgainfilter.set_volume(.5)

  powerfilter1 = DoublePowerFilter()
  powerfilter1.set_input_sampling_rate(sample_rate)
  powerfilter1.set_input_port(0, adaptgainfilter, 0)
  powerfilter1.set_memory(np.exp(-1/(sample_rate*.1e-3)))

  attackreleasefilter1 = DoubleAttackReleaseFilter()
  attackreleasefilter1.set_input_sampling_rate(sample_rate)
  attackreleasefilter1.set_input_port(0, powerfilter1, 0)
  attackreleasefilter1.set_attack(np.exp(-1/(sample_rate*1e-3)))
  attackreleasefilter1.set_release(np.exp(-1/(sample_rate*100e-3)))

  gainfilter1 = DoubleGainCompressorFilter()
  gainfilter1.set_input_sampling_rate(sample_rate)
  gainfilter1.set_input_port(0, attackreleasefilter1, 0)
  gainfilter1.set_threshold(thresholds)
  gainfilter1.set_ratio(ratios)
  gainfilter1.set_softness(1)

  applygainfilter = DoubleApplyGainFilter(2)
  applygainfilter.set_input_sampling_rate(sample_rate)
  applygainfilter.set_input_port(0, gainfilter1, 0)
  applygainfilter.set_input_port(1, mssplitfilter, 0)

  powerfilter2 = DoublePowerFilter(1)
  powerfilter2.set_input_sampling_rate(sample_rate)
  powerfilter2.set_input_port(0, adaptgainfilter, 1)
  powerfilter2.set_memory(np.exp(-1/(sample_rate*.1e-3)))

  attackreleasefilter2 = DoubleAttackReleaseFilter()
  attackreleasefilter2.set_input_sampling_rate(sample_rate)
  attackreleasefilter2.set_input_port(0, powerfilter1, 0)
  attackreleasefilter2.set_attack(np.exp(-1/(sample_rate*1e-3)))
  attackreleasefilter2.set_release(np.exp(-1/(sample_rate*100e-3)))

  gainfilter2 = DoubleGainCompressorFilter()
  gainfilter2.set_input_sampling_rate(sample_rate)
  gainfilter2.set_input_port(0, attackreleasefilter2, 0)
  gainfilter2.set_threshold(thresholds)
  gainfilter2.set_ratio(ratios)
  gainfilter2.set_softness(1)

  applygainfilter.set_input_port(2, gainfilter2, 0)
  applygainfilter.set_input_port(3, mssplitfilter, 1)

  msmergefilter = DoubleMiddleSideFilter()
  msmergefilter.set_input_sampling_rate(sample_rate)
  msmergefilter.set_input_port(0, applygainfilter, 0)
  msmergefilter.set_input_port(1, applygainfilter, 1)

  volumefilter = DoubleVolumeFilter(2)
  volumefilter.set_input_sampling_rate(sample_rate)
  volumefilter.set_volume(.5)
  volumefilter.set_input_port(0, msmergefilter, 0)
  volumefilter.set_input_port(1, msmergefilter, 1)
  
  outfilterl = DoubleOutPointerFilter(outputl, False)
  outfilterl.set_input_sampling_rate(sample_rate)
  outfilterl.set_input_port(0, volumefilter, 0)

  outfilterr = DoubleOutPointerFilter(outputr, False)
  outfilterr.set_input_sampling_rate(sample_rate)
  outfilterr.set_input_port(0, volumefilter, 1)
  
  pipelineend = PipelineGlobalSinkFilter()
  pipelineend.set_input_sampling_rate(sample_rate)
  pipelineend.add_filter(outfilterl)
  pipelineend.add_filter(outfilterr)
  pipelineend.process(inputl.shape[1])

  return outputl, outputr
sumfilter.set_input_sampling_rate(sampling_rate)
sumfilter.set_input_port(0, fastattackreleasefilter, 0)
sumfilter.set_input_port(1, volumefilter, 0)

gainfilter = DoubleGainSwellFilter(1)
gainfilter.set_input_sampling_rate(sampling_rate)
gainfilter.set_input_port(0, sumfilter, 0)
gainfilter.set_threshold(.1)
gainfilter.set_ratio(1)
gainfilter.set_softness(1)

oneminusfilter = DoubleOneMinusFilter(1)
oneminusfilter.set_input_sampling_rate(sampling_rate)
oneminusfilter.set_input_port(0, gainfilter, 0)

applygainfilter = DoubleApplyGainFilter(2)
applygainfilter.set_input_sampling_rate(sampling_rate)
applygainfilter.set_input_port(0, gainfilter, 0)
applygainfilter.set_input_port(1, infilter, 0)
applygainfilter.set_input_port(2, oneminusfilter, 0)
applygainfilter.set_input_port(3, infilter, 0)

indata = np.zeros((processsize, 1), dtype=np.float32)
inputfilter = FloatOutPointerFilter(indata, True)
inputfilter.set_input_sampling_rate(sampling_rate)
inputfilter.set_input_port(0, infilter, 0)

outdata = np.zeros((processsize, 1), dtype=np.float32)
outfilter = FloatOutPointerFilter(outdata, True)
outfilter.set_input_sampling_rate(sampling_rate)
outfilter.set_input_port(0, applygainfilter, 0)
Esempio n. 21
0
volumefilter.set_volume(-1)
volumefilter.set_input_port(0, slowattackreleasefilter, 0)

sumfilter = DoubleSumFilter()
sumfilter.set_input_sampling_rate(sampling_rate)
sumfilter.set_input_port(0, fastattackreleasefilter, 0)
sumfilter.set_input_port(1, volumefilter, 0)

gainfilter = DoubleGainCompressorFilter(1)
gainfilter.set_input_sampling_rate(sampling_rate)
gainfilter.set_input_port(0, sumfilter, 0)
gainfilter.set_threshold(.002)
gainfilter.set_ratio(.7)
gainfilter.set_softness(1)

applygainfilter = DoubleApplyGainFilter(1)
applygainfilter.set_input_sampling_rate(sampling_rate)
applygainfilter.set_input_port(0, gainfilter, 0)
applygainfilter.set_input_port(1, infilter, 0)

indata = np.zeros((processsize, 1), dtype=np.float32)
inputfilter = FloatOutPointerFilter(indata, True)
inputfilter.set_input_sampling_rate(sampling_rate)
inputfilter.set_input_port(0, infilter, 0)

inhfdata = np.zeros((processsize, 1), dtype=np.float32)
inputhffilter = FloatOutPointerFilter(inhfdata, True)
inputhffilter.set_input_sampling_rate(sampling_rate)
inputhffilter.set_input_port(0, hffilter, 0)

outdata = np.zeros((processsize, 1), dtype=np.float32)
attackreleasefilters = DoubleAttackReleaseFilter(1)
attackreleasefilters.set_input_sampling_rate(sampling_rate)
attackreleasefilters.set_input_port(0, powerfilter, 1)
attackreleasefilters.set_attack(np.exp(-1/(sampling_rate*10e-3)))
attackreleasefilters.set_release(np.exp(-1/(sampling_rate*1000e-3)))

gainfilter = DoubleGainCompressorFilter(2)
gainfilter.set_input_sampling_rate(sampling_rate)
gainfilter.set_input_port(0, attackreleasefilterm, 0)
gainfilter.set_input_port(1, attackreleasefilters, 0)
gainfilter.set_threshold(0.1)
gainfilter.set_ratio(10)
gainfilter.set_softness(1)

applygainfilter = DoubleApplyGainFilter(2)
applygainfilter.set_input_sampling_rate(sampling_rate)
applygainfilter.set_input_port(0, gainfilter, 0)
applygainfilter.set_input_port(1, msfilter, 0)
applygainfilter.set_input_port(2, gainfilter, 1)
applygainfilter.set_input_port(3, msfilter, 1)

msmergefilter = FloatMiddleSideFilter()
msmergefilter.set_input_sampling_rate(sampling_rate)
msmergefilter.set_input_port(0, applygainfilter, 0)
msmergefilter.set_input_port(1, applygainfilter, 1)
  
volumefilter2 = FloatVolumeFilter(2)
volumefilter2.set_input_sampling_rate(sampling_rate)
volumefilter2.set_input_port(0, msmergefilter, 0)
volumefilter2.set_input_port(1, msmergefilter, 1)