Ejemplo n.º 1
0
    def test_release(self):
        y_slow = adsp.level_detect(self.sig_rel, _fs_, release_ms=20)
        speed_slow = 1 / np.argmax(y_slow < (0.0 + _tolerance_))

        y_fast = adsp.level_detect(self.sig_rel, _fs_, release_ms=5)
        speed_fast = 1 / np.argmax(y_fast < (0.0 + _tolerance_))

        self.assertTrue(
            speed_fast > speed_slow,
            'Fast isn\'t faster than slow!, speed_fast: {}, speed_slow {}'.
            format(speed_fast, speed_slow))
Ejemplo n.º 2
0
    def test_attack(self):
        y_slow = adsp.level_detect(self.sig_att, _fs_, attack_ms=20)
        speed_slow = 1 / np.argmax(y_slow > (1.0 - _tolerance_))

        y_fast = adsp.level_detect(self.sig_att, _fs_, attack_ms=0.5)
        speed_fast = 1 / np.argmax(y_fast > (1.0 - _tolerance_))

        self.assertTrue(
            speed_fast > speed_slow,
            'Fast isn\'t faster than slow!, speed_fast: {}, speed_slow {}'.
            format(speed_fast, speed_slow))
Ejemplo n.º 3
0
    def process_measurement(self, measurement):
        """
        Processes a measurement made using the probe signal
        for this object.
        """
        self.far_response = adsp.normalize(
            signal.convolve(measurement, self.inv_probe))

        amax = np.argmax(self.far_response)
        level = adsp.level_detect(self.far_response, self.fs)
        off = int(self.fs / 10)
        amin = np.argwhere(level[amax - off:amax] < 0.05)[-1][0]
        amax = amax - (off - amin)
        end = amax + np.argwhere(level[amax:] < 10**(-60 / 20))[0][0]

        self.harm_responses = [self.far_response[amax:end]]
        for i in range(1, len(self.harm_times)):
            start = amax - self.harm_times[i]
            end = amax - self.harm_times[i - 1]
            self.harm_responses.append(self.far_response[start:end])
Ejemplo n.º 4
0
 def run_mode(self, mode):
     y = adsp.level_detect(self.sig, _fs_, release_ms=0.1, mode=mode)
     for n, p in enumerate(_points_):
         self.check_point(y, p, _exps_[n], mode)
# the original sound has ended.
#
# The plot below shows the output of the generator with level
# detector architecture, with an attack time of 1 millisecond,
# and a release time of 5 milliseconds.

# %%
N = 5000
fs = 44100
freq = 2000
x = np.sin(2 * np.pi * freq / fs * np.arange(N))
x[:1000] = np.zeros(1000)
x[4000:] = np.zeros(1000)

y = get_sine_half_freq(x, fs, 1200, 6)
y *= adsp.level_detect(x, fs, attack_ms=1, release_ms=5)
y = adsp.normalize(y)

plt.plot(x)
plt.plot(y)
plt.title('Generated Subharmonic with Level Detector')
plt.xlabel('Time [samples]')
plt.legend(['Input', 'Generated'], loc="lower right")

# %% [markdown]
# ### Pre-Filter
#
# Finally, we need just one more modification for a full-on bass
# enhancer effect: a lowpass filter before the generator. In the
# real world, the input signal for our effect won't just be sine
# waves. In order to keep our generator from getting confused