You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I am trying to implement a patch where I set up an array of SVFilters with a white noise input. I have been playing with the resonance parameter and trying to find some kind of curve that keeps the loudness/amplitude of the output consistent as the resonance increases. I noticed that there is a very modest rise in volume up until around 0.8 or 0.9 where it gets steeper and steeper. Perhaps @ideoforms knows some equation that predicts the output amplitude of the filter given a resonance value and white noise input? This gets especially important when I start to stack filters in a cascade, and I haven't yet found a way to keep the volume of the output relatively smooth. Here is my current attempt:
classFilteredNoise(sf.Patch):
def__init__(
self,
filter_type="low_pass", # can be 'low_pass', 'band_pass', 'high_pass', 'notch', 'peak', 'low_shelf', 'high_shelf'cutoff=440,
resonance=0.5,
amplitude=0.5,
panning=0
):
super().__init__()
filter_types= ["low_pass", "band_pass", "high_pass", "notch", "peak", "low_shelf", "high_shelf"]
assertfilter_typeinfilter_types, f"Filter type must be one of {filter_types}"cutoff=self.add_input("cutoff", cutoff)
resonance=self.add_input("resonance", resonance)
amplitude=self.add_input("amplitude", amplitude)
panning=self.add_input("panning", panning)
panning=panning*0.5+0.5resonance=sf.Clip(resonance, 0, 0.999)
noise=sf.WhiteNoise()
# attenuation: as resonance increases, the amplitude of the filter output decreasesatten_threshold=0.5db_at_threshold=-1max_attenuation=-16attenuation_light=sf.ScaleLinLin(resonance, 0, atten_threshold, 0, db_at_threshold)
attenuation_heavy=sf.ScaleLinLin(resonance, atten_threshold, 1, db_at_threshold, max_attenuation)
attenuation_db=sf.SelectInput([attenuation_light, attenuation_heavy], resonance>atten_threshold)
attenuation_coeff=sf.DecibelsToAmplitude(attenuation_db)
filters=sf.SVFilter(noise, filter_type=filter_type, cutoff=cutoff, resonance=resonance)
filters=sf.SVFilter(filters*attenuation_coeff, filter_type=filter_type, cutoff=cutoff, resonance=resonance)
filters=sf.SVFilter(filters*attenuation_coeff, filter_type=filter_type, cutoff=cutoff, resonance=resonance)
filters=sf.SVFilter(filters*attenuation_coeff, filter_type=filter_type, cutoff=cutoff, resonance=resonance)
filters=sf.SVFilter(filters*attenuation_coeff, filter_type=filter_type, cutoff=cutoff, resonance=resonance)
filters=sf.SVFilter(filters*attenuation_coeff, filter_type=filter_type, cutoff=cutoff, resonance=resonance)
panning=UpMixer(panning, filters.num_output_channels).outputmix=Mixer(filters*amplitude, panning, 2)
self.set_output(mix)
Okay, for now, the simple trick of dividing the output by its RMS seems to do the trick. Not sure how theoretically sound this is, but it seems to work quite well:
classFilteredNoise(sf.Patch):
def__init__(
self,
filter_type="low_pass", # can be 'low_pass', 'band_pass', 'high_pass', 'notch', 'peak', 'low_shelf', 'high_shelf'cutoff=440,
resonance=0.5,
amplitude=0.5,
panning=0,
order=3
):
super().__init__()
filter_types= ["low_pass", "band_pass", "high_pass", "notch", "peak", "low_shelf", "high_shelf"]
assertfilter_typeinfilter_types, f"Filter type must be one of {filter_types}"cutoff=self.add_input("cutoff", cutoff)
resonance=self.add_input("resonance", resonance)
amplitude=self.add_input("amplitude", amplitude)
panning=self.add_input("panning", panning)
panning=panning*0.5+0.5resonance=sf.Clip(resonance, 0, 0.999)
self.order=np.clip(order, 1, 10)
noise=sf.WhiteNoise()
# First onefilters=sf.SVFilter(noise, filter_type=filter_type, cutoff=cutoff, resonance=resonance)
# The restforiinrange(self.order-1):
filters=sf.SVFilter(filters, filter_type=filter_type, cutoff=cutoff, resonance=resonance)
panning=UpMixer(panning, filters.num_output_channels).outputmix=Mixer(filters, panning, 2)
mix_rms=sf.RMS(mix)
mix=mix/mix_rmsmix=mix*amplitudeself.set_output(mix)
Hi! I am trying to implement a patch where I set up an array of
SVFilter
s with a white noise input. I have been playing with theresonance
parameter and trying to find some kind of curve that keeps the loudness/amplitude of the output consistent as the resonance increases. I noticed that there is a very modest rise in volume up until around 0.8 or 0.9 where it gets steeper and steeper. Perhaps @ideoforms knows some equation that predicts the output amplitude of the filter given a resonance value and white noise input? This gets especially important when I start to stack filters in a cascade, and I haven't yet found a way to keep the volume of the output relatively smooth. Here is my current attempt:My helper classes:
Example:
Any tips would be much appreciated! :)
The text was updated successfully, but these errors were encountered: