Ejemplo n.º 1
0
def synthesize1(amps, freqs, ts):
    """Synthesize a mixture of complex sinusoids with given amps and freqs.

    amps: amplitudes
    freqs: frequencies in Hz
    ts: times to evaluate the signal

    returns: wave array
    """
    components = [
        thinkdsp.ComplexSinusoid(freq, amp) for amp, freq in zip(amps, freqs)
    ]
    signal = thinkdsp.SumSignal(*components)

    ys = signal.evaluate(ts)
    return ys
Ejemplo n.º 2
0
    def testComplexSinusoid(self):
        signal = thinkdsp.ComplexSinusoid(440, 0.7, 1.1)
        result = signal.evaluate(2.1) * complex(-1.5, -0.5)

        self.assertAlmostEqual(result, -0.164353351475 - 1.09452637056j)