def curve(self, freq, p_freq, q): """This method implements the stastistical distribution used to pick the frequency for each :py:class:`splat.gen.Particle` object. It returns a frequency ``freq`` in linear scale altered around the target frequency ``p_freq`` with the parameter ``q``. The default implementation produces something a little bit like a normal distribution but is not a standard function.""" f_log = _splat.lin2dB(freq) s = _splat.lin2dB(p_freq) f_curve = s - 0.5 * ((2 * s) - (2 * f_log)) * math.exp(-( (s - f_log) * (s - f_log)) / _splat.dB2lin(q)) return _splat.dB2lin(f_curve)
def curve(self, freq, p_freq, q): """This method implements the stastistical distribution used to pick the frequency for each :py:class:`splat.gen.Particle` object. It returns a frequency ``freq`` in linear scale altered around the target frequency ``p_freq`` with the parameter ``q``. The default implementation produces something a little bit like a normal distribution but is not a standard function.""" f_log = _splat.lin2dB(freq) s = _splat.lin2dB(p_freq) f_curve = s - 0.5 * ((2 * s) - (2 * f_log)) * math.exp( -((s - f_log) * (s - f_log)) / _splat.dB2lin(q)) return _splat.dB2lin(f_curve)
def run(self, start, end, freq, share=1.0, levels=None, *args, **kw): """Run the generator using the standard interface, with the extra ``share`` argument which is passed to the internal :py:meth:`splat.gen.ParticlePool.iterate` object.""" if self.start is None: self._start = start self._end = end else: self._start = min(self.start, start) self._end = max(self.end, end) freq = _splat.Signal(self.frag, freq, (self.end - self.start)) n_events = self._pool.count() step = n_events / self.progress_step progress = 0 for i, p in enumerate(self._pool.iterate(start, end, share)): if self.do_show_progress and (i % step) == 0: self.show_progress(progress) progress += self.progress_step if self._eq: g = self._eq.value(p.freq) else: g = 0.0 if self._gain_fuzz: g += random.uniform(-self._gain_fuzz, self._gain_fuzz) if self._relative_gain_fuzz: levels = tuple(g + random.uniform(-self._relative_gain_fuzz, self._relative_gain_fuzz) for g in range(self.frag.channels)) else: levels = tuple(g for i in range(self.frag.channels)) levels = tuple(_splat.dB2lin(g) for g in levels) if self._q: p_freq = self.curve(freq[self.frag.s2n(p.start)][0], p.freq, self._q.value(p.start)) else: p_freq = p.freq self.subgen.run(p.start, p.end, p_freq, levels=levels, *args, **kw)
def freq(self): """Frequency as a linear value in Hz.""" return _splat.dB2lin(self.f_log)
def mix(self, frag, sample, t, g=0.0): """Alternative mixing method implementation with random errors.""" t += random.uniform(*self._te) l = tuple(g + random.uniform(*self._ge) for i in range(frag.channels)) l = tuple(_splat.dB2lin(c) for c in l) frag.mix(sample, t, 0.0, l)