Exemplo n.º 1
0
    def __init__(self,
                 pitch,
                 pitch_per_second=12,
                 decibels=1,
                 decibels_per_second=1,
                 samplerate=utilities.DEFAULT_SAMPLE_RATE):
        self.frequency = utilities.pitch_to_frequency(pitch)
        self.phase = 0
        self.amplitude = utilities.decibels_to_amplitude_ratio(decibels)

        self.pitch_per_second = pitch_per_second
        self.decibels_per_second = decibels_per_second
        self.goal_frequency = self.frequency
        self.goal_amplitude = self.amplitude
        self.samplerate = samplerate
Exemplo n.º 2
0
 def set_pitch(self, pitch):
     '''Set the goal pitch that the sinewave will gradually shift towards.'''
     self.goal_frequency = utilities.pitch_to_frequency(pitch)
Exemplo n.º 3
0
def test_pitch_to_frequency():
    # 0 is middle C
    assert utilities.pitch_to_frequency(0) == utilities.MIDDLE_C_FREQUENCY
    # 9 is middle A (440)
    assert math.isclose(utilities.pitch_to_frequency(9), 440, rel_tol=0.1)