Ejemplo n.º 1
0
import numpy as np
from scipy.io import wavfile

from ATK.Core import Int16InPointerFilter, Int16OutPointerFilter
from ATK.Tools import FloatMiddleSideFilter, FloatVolumeFilter

sampling_rate, data = wavfile.read("stereofile.wav")

infilter = Int16InPointerFilter(data, True)
infilter.set_output_sampling_rate(sampling_rate)

print infilter.get_nb_output_ports()
assert infilter.get_nb_output_ports() == 2

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

volumefilter = FloatVolumeFilter(1)
volumefilter.set_input_sampling_rate(sampling_rate)
volumefilter.set_input_port(0, msfilter, 1)
volumefilter.set_volume(.5)

msmergefilter = FloatMiddleSideFilter()
msmergefilter.set_input_sampling_rate(sampling_rate)
msmergefilter.set_input_port(0, msfilter, 0)
msmergefilter.set_input_port(1, volumefilter, 0)
  
volumefilter2 = FloatVolumeFilter(2)
Ejemplo n.º 2
0
sampling_ratel, datal = wavfile.read("KEYS LEFT - DI - LaChappel 992.wav")
sampling_rater, datar = wavfile.read("KEYS RIGHT - DI - LaChappel 992.wav")

assert sampling_ratel == sampling_rater

sampling_rate = sampling_ratel

datal = datal.reshape(-1, 1)
datar = datar.reshape(-1, 1)
infilterl = Int32InPointerFilter(datal, True)
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)))