def Process4Samples(self, vector): ''' Same as above but vectorized for a 4 samples tuple ''' # Vector = (x_{n}, x_{n + 1}, x_{n + 2}, x_{n + 3}) # previous = (x_{n - 1}, x_{n}, x_{n + 1}, x_{n + 2}) # last = (x_{n - 2}, x_{n - 1}, x_{n}, x_{n + 1}) previous = filters_common.RotateOnRight(vector, self._history[1]) last = filters_common.RotateOnRight(previous, self._history[0]) current = filters_common.MulConst(vector, self._gain) previous = filters_common.MulConst(previous, self._coeffs[1]) last = filters_common.MulConst(last, self._coeffs[0]) tmp_sum = numpy.add(current, previous) tmp_sum = numpy.add(tmp_sum, last) oldest_out = tmp_sum[0] \ + self._history[2] * self._coeffs[2] \ + self._history[3] * self._coeffs[3] old_out = tmp_sum[1] \ + self._history[3] * self._coeffs[2] \ + oldest_out * self._coeffs[3] new_out = tmp_sum[2] \ + oldest_out * self._coeffs[2] \ + old_out * self._coeffs[3] newest_out = tmp_sum[3] \ + old_out * self._coeffs[2] \ + new_out * self._coeffs[3] out = (oldest_out, old_out, new_out, newest_out) self._history = filters_common.TakeEachRightHalf(vector, out) return out
def Process4Samples(self, vector): """ Actual process function """ out = [0.0, 0.0, 0.0, 0.0] direct_v = filters_common.MulConst(vector, 0.18 + 0.25 * self._resonance) last = self._last for idx, sample in enumerate(direct_v): actual_input = sample - self._resonance * last current_side_factor = min(max(self._last_side_factor, -1.0), 1.0) self._last_side_factor = actual_input * actual_input self._last_side_factor *= 0.062 self._last_side_factor += current_side_factor * 0.993 current_side_factor = 1.0 - current_side_factor + current_side_factor * current_side_factor / 2.0 actual_input *= current_side_factor # Todo: find a more elegant way to do that tmp_filtered = actual_input for lowpass in self._filters[0:2]: tmp_filtered = lowpass.ProcessSample(tmp_filtered) # Saturation tmp_filtered = self._Saturation(tmp_filtered) for lowpass in self._filters[2:4]: tmp_filtered = lowpass.ProcessSample(tmp_filtered) out[idx] = tmp_filtered last = tmp_filtered self._last = last return out
def Process4Samples(self, vector): ''' Actual process function - vectorized version ''' direct_v = filters_common.MulConst(vector, self._coeff / 2.0) out = [0.0, 0.0, 0.0, 0.0] last = self._last for idx, direct in enumerate(direct_v): out[idx] = direct + last last = out[idx] * (1.0 - self._coeff) + direct self._last = last # actual_coeff = [1.0, 1.0 - self._coeff, 1.0 - self._coeff, 1.0 - self._coeff] # out = direct_v + filters_common.RotateOnRight(direct_v, self._last) # oldest_out = direct_v[0] \ # + self._last # old_out = direct_v[1] \ # + oldest_out * (1.0 - self._coeff) + direct_v[0] # new_out = direct_v[2] \ # + old_out * (1.0 - self._coeff) + direct_v[1] # newest_out = direct_v[3] \ # + new_out * (1.0 - self._coeff) + direct_v[2] # out = (oldest_out, old_out, new_out, newest_out) # self._last = newest_out * (1.0 - self._coeff) + direct_v[3] return out
def Process4Samples(self, vector): direct_v = filters_common.MulConst(vector, self._pole_coeff / 2.0) out = [0.0, 0.0, 0.0, 0.0] last = self._last zero_coeff = self._zero_coeff for idx, direct in enumerate(direct_v): out[idx] = direct + last last = out[idx] * (1.0 - self._pole_coeff) + zero_coeff * direct self._last = last return out
def Process4Samples(self, vector): ''' Actual process function ''' return super(MoogLowAliasNonLinearBaseLowpass, self).Process4Samples( filters_common.MulConst(vector, 2.0))
def Process4Samples(self, vector): return super(MoogBaseLowpass, self).Process4Samples( filters_common.MulConst(vector, 2.0 / 1.3))