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
Пример #3
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 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
Пример #6
0
hffilter = DoubleButterworthBandPassFilter()
hffilter.set_input_sampling_rate(sampling_rate)
hffilter.set_cut_frequencies(1000, 5000)
hffilter.set_order(5)
hffilter.set_input_port(0, infilter, 0)

derivativefilter = DoubleDerivativeFilter()
derivativefilter.set_input_sampling_rate(sampling_rate)
derivativefilter.set_input_port(0, hffilter, 0)

powerfilter = DoublePowerFilter(1)
powerfilter.set_input_sampling_rate(sampling_rate)
powerfilter.set_input_port(0, derivativefilter, 0)
powerfilter.set_memory(np.exp(-1 / (sampling_rate * 1e-3)))

fastattackreleasefilter = DoubleAttackReleaseFilter(1)
fastattackreleasefilter.set_input_sampling_rate(sampling_rate)
fastattackreleasefilter.set_input_port(0, powerfilter, 0)
fastattackreleasefilter.set_attack(np.exp(-1 / (sampling_rate * 1e-3)))
fastattackreleasefilter.set_release(np.exp(-1 / (sampling_rate * 50.e-3)))

slowattackreleasefilter = DoubleAttackReleaseFilter(1)
slowattackreleasefilter.set_input_sampling_rate(sampling_rate)
slowattackreleasefilter.set_input_port(0, powerfilter, 0)
slowattackreleasefilter.set_attack(np.exp(-1 / (sampling_rate * 5e-3)))
slowattackreleasefilter.set_release(np.exp(-1 / (sampling_rate * 50.e-3)))

volumefilter = DoubleVolumeFilter(1)
volumefilter.set_input_sampling_rate(sampling_rate)
volumefilter.set_volume(-1)
volumefilter.set_input_port(0, slowattackreleasefilter, 0)
import numpy as np
import matplotlib.pyplot as plt

from ATK.Core import DoubleInPointerFilter, DoubleOutPointerFilter, PipelineGlobalSinkFilter

from ATK.Dynamic import DoubleAttackReleaseFilter, DoubleAttackReleaseHysteresisFilter

processsize = 3000
sampling_rate = 44100

data = np.sin(np.arange(processsize) * np.pi * 40 / sampling_rate).reshape(-1, 1)
data = data ** 2
infilter = DoubleInPointerFilter(data, True)
infilter.set_output_sampling_rate(sampling_rate)

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

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

attackreleasefilter2 = DoubleAttackReleaseHysteresisFilter(1)
attackreleasefilter2.set_input_sampling_rate(sampling_rate)
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)))
processsize = len(data)

data = data.reshape(-1, 1)
infilter = Int16InPointerFilter(data, True)
infilter.set_output_sampling_rate(sampling_rate)

derivativefilter = DoubleDerivativeFilter()
derivativefilter.set_input_sampling_rate(sampling_rate)
derivativefilter.set_input_port(0, infilter, 0)

powerfilter = DoublePowerFilter(1)
powerfilter.set_input_sampling_rate(sampling_rate)
powerfilter.set_input_port(0, derivativefilter, 0)
powerfilter.set_memory(np.exp(-1/(sampling_rate*1e-3)))

fastattackreleasefilter = DoubleAttackReleaseFilter(1)
fastattackreleasefilter.set_input_sampling_rate(sampling_rate)
fastattackreleasefilter.set_input_port(0, powerfilter, 0)
fastattackreleasefilter.set_attack(np.exp(-1/(sampling_rate*1e-3)))
fastattackreleasefilter.set_release(np.exp(-1/(sampling_rate*50.e-3)))

slowattackreleasefilter = DoubleAttackReleaseFilter(1)
slowattackreleasefilter.set_input_sampling_rate(sampling_rate)
slowattackreleasefilter.set_input_port(0, powerfilter, 0)
slowattackreleasefilter.set_attack(np.exp(-1/(sampling_rate*5e-3)))
slowattackreleasefilter.set_release(np.exp(-1/(sampling_rate*50.e-3)))

volumefilter = DoubleVolumeFilter(1)
volumefilter.set_input_sampling_rate(sampling_rate)
volumefilter.set_volume(-1)
volumefilter.set_input_port(0, slowattackreleasefilter, 0)
Пример #9
0
# get from http://www.telefunken-elektroakustik.com/download/brew/

filename = "Break Ca-01.wav"
sampling_rate, data = wavfile.read(filename)
processsize = len(data)

data = data.reshape(-1, 1)
infilter = Int16InPointerFilter(data, True)
infilter.set_output_sampling_rate(sampling_rate)

powerfilter = DoublePowerFilter(1)
powerfilter.set_input_sampling_rate(sampling_rate)
powerfilter.set_input_port(0, infilter, 0)
powerfilter.set_memory(np.exp(-1 / (sampling_rate * .1e-3)))

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

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

applygainfilter = DoubleApplyGainFilter(1)
applygainfilter.set_input_sampling_rate(sampling_rate)
applygainfilter.set_input_port(0, gainfilter, 0)
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
Пример #11
0
infilterl.set_output_sampling_rate(sampling_rate)
infilterr = Int32InPointerFilter(datar, True)
infilterr.set_output_sampling_rate(sampling_rate)

msfilter = FloatMiddleSideFilter()
msfilter.set_input_sampling_rate(sampling_rate)
msfilter.set_input_port(0, infilterl, 0)
msfilter.set_input_port(1, infilterr, 0)

powerfilter = DoublePowerFilter(2)
powerfilter.set_input_sampling_rate(sampling_rate)
powerfilter.set_input_port(0, msfilter, 0)
powerfilter.set_input_port(1, msfilter, 1)
powerfilter.set_memory(np.exp(-1/(sampling_rate*.1e-3)))

attackreleasefilterm = DoubleAttackReleaseFilter(1)
attackreleasefilterm.set_input_sampling_rate(sampling_rate)
attackreleasefilterm.set_input_port(0, powerfilter, 0)
attackreleasefilterm.set_attack(np.exp(-1/(sampling_rate*1e-3)))
attackreleasefilterm.set_release(np.exp(-1/(sampling_rate*100e-3)))

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)