def filter(input):
  infilter = DoubleInPointerFilter(input)
  infilter.output_sampling_rate = sampling_rate
  
  attackreleasefilter = DoubleAttackReleaseFilter(1)
  attackreleasefilter.input_sampling_rate = sampling_rate
  attackreleasefilter.set_input_port(0, infilter, 0)
  attackreleasefilter.attack = np.exp(-1/(sampling_rate*1e-3))
  attackreleasefilter.release = np.exp(-1/(sampling_rate*10e-3))
  
  outdata = np.zeros(processsize, dtype=np.float64)
  outfilter = DoubleOutPointerFilter(outdata)
  outfilter.input_sampling_rate = sampling_rate
  outfilter.set_input_port(0, attackreleasefilter, 0)
  
  attackreleasefilter2 = DoubleAttackReleaseHysteresisFilter(1)
  attackreleasefilter2.input_sampling_rate = sampling_rate
  attackreleasefilter2.set_input_port(0, infilter, 0)
  attackreleasefilter2.attack = np.exp(-1/(sampling_rate*1e-3))
  attackreleasefilter2.release = np.exp(-1/(sampling_rate*10e-3))
  attackreleasefilter2.release_hysteresis = .5
  attackreleasefilter2.attack_hysteresis = .9
  
  outdata2 = np.zeros(processsize, dtype=np.float64)
  outfilter_hyst = DoubleOutPointerFilter(outdata2)
  outfilter_hyst.input_sampling_rate = sampling_rate
  outfilter_hyst.set_input_port(0, attackreleasefilter2, 0)
  
  pipelineend = PipelineGlobalSinkFilter()
  pipelineend.input_sampling_rate = sampling_rate
  pipelineend.add_filter(outfilter)
  pipelineend.add_filter(outfilter_hyst)
  pipelineend.process(processsize)
  
  return outdata, outdata2
def filter(input):
    infilter = DoubleInPointerFilter(input)
    infilter.output_sampling_rate = sampling_rate

    attackreleasefilter = DoubleAttackReleaseFilter(1)
    attackreleasefilter.input_sampling_rate = sampling_rate
    attackreleasefilter.set_input_port(0, infilter, 0)
    attackreleasefilter.attack = np.exp(-1 / (sampling_rate * 1e-3))
    attackreleasefilter.release = np.exp(-1 / (sampling_rate * 10e-3))

    outdata = np.zeros(processsize, dtype=np.float64)
    outfilter = DoubleOutPointerFilter(outdata)
    outfilter.input_sampling_rate = sampling_rate
    outfilter.set_input_port(0, attackreleasefilter, 0)

    attackreleasefilter2 = DoubleAttackReleaseHysteresisFilter(1)
    attackreleasefilter2.input_sampling_rate = sampling_rate
    attackreleasefilter2.set_input_port(0, infilter, 0)
    attackreleasefilter2.attack = np.exp(-1 / (sampling_rate * 1e-3))
    attackreleasefilter2.release = np.exp(-1 / (sampling_rate * 10e-3))
    attackreleasefilter2.release_hysteresis = .5
    attackreleasefilter2.attack_hysteresis = .9

    outdata2 = np.zeros(processsize, dtype=np.float64)
    outfilter_hyst = DoubleOutPointerFilter(outdata2)
    outfilter_hyst.input_sampling_rate = sampling_rate
    outfilter_hyst.set_input_port(0, attackreleasefilter2, 0)

    pipelineend = PipelineGlobalSinkFilter()
    pipelineend.input_sampling_rate = sampling_rate
    pipelineend.add_filter(outfilter)
    pipelineend.add_filter(outfilter_hyst)
    pipelineend.process(processsize)

    return outdata, outdata2
Example #3
0
def DoubleConvertFilter2_new_test():
  import numpy as np
  from ATK.Core import DoubleComplexToRealFilter, PipelineGlobalSinkFilter
  from ATK.Core import ComplexDoubleInPointerFilter, DoubleOutPointerFilter
  
  from numpy.testing import assert_equal
  input = np.ascontiguousarray(np.arange(1000, dtype=np.complex128))
  output = np.ascontiguousarray(np.zeros(1000, dtype=np.float64))
  output2 = np.ascontiguousarray(np.zeros(1000, dtype=np.float64))
  
  inputfilter = ComplexDoubleInPointerFilter(input)
  convertFilter = DoubleComplexToRealFilter()
  outputfilter = DoubleOutPointerFilter(output)
  output2filter = DoubleOutPointerFilter(output2)
  
  convertFilter.set_input_port(0, inputfilter, 0)
  outputfilter.set_input_port(0, convertFilter, 0)
  output2filter.set_input_port(0, convertFilter, 1)
  
  inputfilter.output_sampling_rate = 48000
  convertFilter.input_sampling_rate = 48000
  outputfilter.input_sampling_rate = 48000
  output2filter.input_sampling_rate = 48000
  
  sink = PipelineGlobalSinkFilter()
  sink.add_filter(outputfilter)
  sink.add_filter(output2filter)
  sink.input_sampling_rate = 48000
  sink.process(1000)

  assert_equal(input, output)
  assert_equal(0, output2)
Example #4
0
def process(input_l, input_r):
  # Populate the outputs
  output_l = np.zeros(size, dtype=np.float64)
  output_r = np.zeros(size, dtype=np.float64)

  # Create the inputs of the pipeline from the numpy arrays
  infilter_l = DoubleInPointerFilter(input_l, False)
  infilter_l.input_sampling_rate = sample_rate
  infilter_r = DoubleInPointerFilter(input_r, False)
  infilter_r.input_sampling_rate = sample_rate

  # Create the intermediate buffer and connect it to the inputs
  buffer = DoubleBufferFilter(2)
  buffer.input_sampling_rate = sample_rate
  buffer.set_input_port(0, infilter_l, 0)
  buffer.set_input_port(1, infilter_r, 0)

  # Create the outputs and connect them to the buffer
  outfilter_l = DoubleOutPointerFilter(output_l, False)
  outfilter_l.input_sampling_rate = sample_rate
  outfilter_l.set_input_port(0, buffer, 1)

  outfilter_r = DoubleOutPointerFilter(output_r, False)
  outfilter_r.input_sampling_rate = sample_rate
  outfilter_r.set_input_port(0, buffer, 0)

  # Create the sink of the pipeline
  sink = PipelineGlobalSinkFilter()
  sink.input_sampling_rate = sample_rate
  sink.add_filter(outfilter_l)
  sink.add_filter(outfilter_r)

  # Process the pipeline
  sink.process(size)
  return (output_l, output_r)
Example #5
0
def DoubleConvertFilter2_new_test():
    import numpy as np
    from ATK.Core import DoubleComplexToRealFilter, PipelineGlobalSinkFilter
    from ATK.Core import ComplexDoubleInPointerFilter, DoubleOutPointerFilter

    from numpy.testing import assert_equal
    input = np.ascontiguousarray(np.arange(1000, dtype=np.complex128))
    output = np.ascontiguousarray(np.zeros(1000, dtype=np.float64))
    output2 = np.ascontiguousarray(np.zeros(1000, dtype=np.float64))

    inputfilter = ComplexDoubleInPointerFilter(input)
    convertFilter = DoubleComplexToRealFilter()
    outputfilter = DoubleOutPointerFilter(output)
    output2filter = DoubleOutPointerFilter(output2)

    convertFilter.set_input_port(0, inputfilter, 0)
    outputfilter.set_input_port(0, convertFilter, 0)
    output2filter.set_input_port(0, convertFilter, 1)

    inputfilter.output_sampling_rate = 48000
    convertFilter.input_sampling_rate = 48000
    outputfilter.input_sampling_rate = 48000
    output2filter.input_sampling_rate = 48000

    sink = PipelineGlobalSinkFilter()
    sink.add_filter(outputfilter)
    sink.add_filter(output2filter)
    sink.input_sampling_rate = 48000
    sink.process(1000)

    assert_equal(input, output)
    assert_equal(0, output2)
Example #6
0
def filter(inputl,
           inputr,
           blend_ch1=0,
           blend_ch2=0,
           feedback_ch1_ch1=0,
           feedback_ch1_ch2=0,
           feedback_ch2_ch1=0,
           feedback_ch2_ch2=0,
           feedforward_ch1_ch1=1,
           feedforward_ch1_ch2=0,
           feedforward_ch2_ch1=0,
           feedforward_ch2_ch2=1):
    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.input_sampling_rate = sample_rate
    infilterR = DoubleInPointerFilter(inputr, False)
    infilterR.input_sampling_rate = sample_rate

    delayfilter = DoubleDualMultipleUniversalFixedDelayLineFilter(5000)
    delayfilter.input_sampling_rate = sample_rate
    delayfilter.set_input_port(0, infilterL, 0)
    delayfilter.set_input_port(1, infilterR, 0)
    delayfilter.set_delay(0, 4800)  #50ms
    delayfilter.set_delay(1, 3600)  #37.5ms
    delayfilter.set_blend(0, blend_ch1)
    delayfilter.set_blend(1, blend_ch2)
    delayfilter.set_feedback(0, 0, feedback_ch1_ch1)
    delayfilter.set_feedback(0, 1, feedback_ch1_ch2)
    delayfilter.set_feedback(1, 0, feedback_ch2_ch1)
    delayfilter.set_feedback(1, 1, feedback_ch2_ch2)
    delayfilter.set_feedforward(0, 0, feedforward_ch1_ch1)
    delayfilter.set_feedforward(0, 1, feedforward_ch1_ch2)
    delayfilter.set_feedforward(1, 0, feedforward_ch2_ch1)
    delayfilter.set_feedforward(1, 1, feedforward_ch2_ch2)

    outfilterl = DoubleOutPointerFilter(outputl, False)
    outfilterl.input_sampling_rate = sample_rate
    outfilterl.set_input_port(0, delayfilter, 0)

    outfilterr = DoubleOutPointerFilter(outputr, False)
    outfilterr.input_sampling_rate = sample_rate
    outfilterr.set_input_port(0, delayfilter, 1)

    pipelineend = PipelineGlobalSinkFilter()
    pipelineend.input_sampling_rate = sample_rate
    pipelineend.add_filter(outfilterl)
    pipelineend.add_filter(outfilterr)
    pipelineend.process(inputl.shape[1])

    return outputl, outputr
def filter(inputl,
           inputr,
           blend_ch1=0,
           blend_ch2=0,
           feedback_ch1_ch1=0,
           feedback_ch1_ch2=0,
           feedback_ch2_ch1=0,
           feedback_ch2_ch2=0,
           feedforward_ch1_ch1=1,
           feedforward_ch1_ch2=0,
           feedforward_ch2_ch1=0,
           feedforward_ch2_ch2=1):
    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)

    delayfilter = DoubleStereoUniversalFixedDelayLineFilter(100000)
    delayfilter.set_input_sampling_rate(sample_rate)
    delayfilter.set_input_port(0, infilterL, 0)
    delayfilter.set_input_port(1, infilterR, 0)
    delayfilter.set_delay_ch1(4800)  #50ms
    delayfilter.set_delay_ch2(3600)  #37.5ms
    delayfilter.set_blend_ch1(blend_ch1)
    delayfilter.set_blend_ch1(blend_ch2)
    delayfilter.set_feedback_ch1_ch1(feedback_ch1_ch1)
    delayfilter.set_feedback_ch1_ch2(feedback_ch1_ch2)
    delayfilter.set_feedback_ch2_ch1(feedback_ch2_ch1)
    delayfilter.set_feedback_ch2_ch2(feedback_ch2_ch2)
    delayfilter.set_feedforward_ch1_ch1(feedforward_ch1_ch1)
    delayfilter.set_feedforward_ch1_ch2(feedforward_ch1_ch2)
    delayfilter.set_feedforward_ch2_ch1(feedforward_ch2_ch1)
    delayfilter.set_feedforward_ch2_ch2(feedforward_ch2_ch2)

    outfilterl = DoubleOutPointerFilter(outputl, False)
    outfilterl.set_input_sampling_rate(sample_rate)
    outfilterl.set_input_port(0, delayfilter, 0)

    outfilterr = DoubleOutPointerFilter(outputr, False)
    outfilterr.set_input_sampling_rate(sample_rate)
    outfilterr.set_input_port(0, delayfilter, 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
Example #8
0
def PipelineGlobalSinkFilter_usage_test():
  import numpy as np
  from ATK.Core import DoubleInPointerFilter, DoubleOutPointerFilter, PipelineGlobalSinkFilter
  from numpy.testing import assert_equal
  input = np.ascontiguousarray(np.arange(1000, dtype=np.float64)[None,:])
  output = np.ascontiguousarray(np.zeros(1000, dtype=np.float64)[None,:])
  inputfilter = DoubleInPointerFilter(input, False)
  outputfilter = DoubleOutPointerFilter(output, False)
  outputfilter.set_input_port(0, inputfilter, 0)
  inputfilter.output_sampling_rate = 48000
  outputfilter.input_sampling_rate = 48000
  sink = PipelineGlobalSinkFilter()
  sink.add_filter(outputfilter)
  sink.input_sampling_rate = 48000
  sink.process(1000)
  assert_equal(input, output)
def filter(inputl, inputr, blend_ch1=0, blend_ch2=0,
    feedback_ch1_ch1=0, feedback_ch1_ch2=0, feedback_ch2_ch1=0, feedback_ch2_ch2=0,
    feedforward_ch1_ch1=1, feedforward_ch1_ch2=0, feedforward_ch2_ch1=0, feedforward_ch2_ch2=1):
  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)

  delayfilter = DoubleStereoUniversalFixedDelayLineFilter(5000)
  delayfilter.set_input_sampling_rate(sample_rate)
  delayfilter.set_input_port(0, infilterL, 0)
  delayfilter.set_input_port(1, infilterR, 0)
  delayfilter.set_delay_ch1(4800) #50ms
  delayfilter.set_delay_ch2(3600) #37.5ms
  delayfilter.set_blend_ch1(blend_ch1)
  delayfilter.set_blend_ch1(blend_ch2)
  delayfilter.set_feedback_ch1_ch1(feedback_ch1_ch1)
  delayfilter.set_feedback_ch1_ch2(feedback_ch1_ch2)
  delayfilter.set_feedback_ch2_ch1(feedback_ch2_ch1)
  delayfilter.set_feedback_ch2_ch2(feedback_ch2_ch2)
  delayfilter.set_feedforward_ch1_ch1(feedforward_ch1_ch1)
  delayfilter.set_feedforward_ch1_ch2(feedforward_ch1_ch2)
  delayfilter.set_feedforward_ch2_ch1(feedforward_ch2_ch1)
  delayfilter.set_feedforward_ch2_ch2(feedforward_ch2_ch2)
  
  outfilterl = DoubleOutPointerFilter(outputl, False)
  outfilterl.set_input_sampling_rate(sample_rate)
  outfilterl.set_input_port(0, delayfilter, 0)

  outfilterr = DoubleOutPointerFilter(outputr, False)
  outfilterr.set_input_sampling_rate(sample_rate)
  outfilterr.set_input_port(0, delayfilter, 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
Example #10
0
outdata_gain = np.zeros((processsize, 1), dtype=np.float32)
outfilter_gain = FloatOutPointerFilter(outdata_gain, True)
outfilter_gain.set_input_sampling_rate(sampling_rate)
outfilter_gain.set_input_port(0, gainfilter, 0)

pipelineend = PipelineGlobalSinkFilter()
pipelineend.set_input_sampling_rate(sampling_rate)
pipelineend.add_filter(inputfilter)
pipelineend.add_filter(inputhffilter)
pipelineend.add_filter(outfilter)
pipelineend.add_filter(outfilter_power)
pipelineend.add_filter(outfilter_gain)
pipelineend.add_filter(outfilter_slow)
pipelineend.add_filter(outfilter_fast)
pipelineend.process(processsize)

start = 0
stop = processsize

x = np.arange(stop, dtype=np.float32) / sampling_rate

plt.figure()
plt.suptitle("Transient Shaper (BP filtered derivative-based)")
plt.subplot(5, 1, 1)
plt.title("Input")
plt.plot(x[start:], indata[start:stop, 0])

plt.subplot(5, 1, 2)
plt.title("Filtered input")
plt.plot(x[start:], inhfdata[start:stop, 0])
attackreleasefilter2.set_input_port(0, infilter, 0)
attackreleasefilter2.set_attack(np.exp(-1/(sampling_rate*1e-3)))
attackreleasefilter2.set_release(np.exp(-1/(sampling_rate*10e-3)))
attackreleasefilter2.set_release_hysteresis(.5)
attackreleasefilter2.set_attack_hysteresis(.9)

outdata2 = np.zeros((processsize, 1), dtype=np.float64)
outfilter_hyst = DoubleOutPointerFilter(outdata2, True)
outfilter_hyst.set_input_sampling_rate(sampling_rate)
outfilter_hyst.set_input_port(0, attackreleasefilter2, 0)

pipelineend = PipelineGlobalSinkFilter()
pipelineend.set_input_sampling_rate(sampling_rate)
pipelineend.add_filter(outfilter)
pipelineend.add_filter(outfilter_hyst)
pipelineend.process(processsize)

start = 0
stop = processsize

x = np.arange(stop, dtype=np.float32) / sampling_rate

plt.figure()
plt.suptitle("Attack Release filters")
plt.plot(x[start:], data[start:stop, 0], label="Original")
plt.plot(x[start:], outdata[start:stop, 0], label="AR filter")
plt.plot(x[start:], outdata2[start:stop, 0], label="AR filter with hysteresis (0.9, 0.5)")

plt.legend(loc=4)
plt.show()
Example #12
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
Example #13
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
Example #14
0
def PipelineGlobalSinkFilter_new_test():
  from ATK.Core import PipelineGlobalSinkFilter
  sink = PipelineGlobalSinkFilter()
  sink.input_sampling_rate = 48000
  sink.process(100)
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
Example #16
0
outfilter_power.set_input_port(0, powerfilter, 0)
outfilter_power.set_input_port(1, powerfilter, 1)

outdata_gain = np.zeros((len(datal), 2), dtype=np.float32)
outfilter_gain = FloatOutPointerFilter(outdata_gain, True)
outfilter_gain.set_input_sampling_rate(sampling_rate)
outfilter_gain.set_input_port(0, gainfilter, 0)
outfilter_gain.set_input_port(1, gainfilter, 1)

pipelineend = PipelineGlobalSinkFilter()
pipelineend.set_input_sampling_rate(sampling_rate)
pipelineend.add_filter(infilter)
pipelineend.add_filter(outfilter)
pipelineend.add_filter(outfilter_power)
pipelineend.add_filter(outfilter_gain)
pipelineend.process(len(datal))

length = 10000

x = np.arange(length, dtype=np.float32) / sampling_rate

plt.figure()
plt.suptitle("Input")
plt.subplot(2, 1, 1)
plt.title("Left channel")
plt.plot(x, indata[:length, 0])
plt.subplot(2, 1, 2)
plt.title("Right channel")
plt.plot(x, indata[:length, 1])

plt.figure()