Sunday, November 13, 2016

30. SawOsc as phasor

We can use SawOsc to produce the wave in tutorial 1.


The gain of SawOsc is reduced by a factor of 2 (gain is 0.5) and initial phase changed so it goes up for the entire period.


The gain of SawOsc goes from -1 to +1, during a period. Changing the gain we go from -.5 to .5. If we add a step of 0.5, we get the desired wave.



# chuck30.py - SawOsc as phasor

SawOsc saw
Step step

# sawtooth oscillator + step of 0.5 connected to dac
dac = step
dac = saw 

# phasor frequency of 100 Hz, step of 0.5
saw.freq = 100
step.next = 0.5

# correct phase and gain
saw.phase = 0.75
saw.gain = 0.5

# Play for 20 ms = 0.02 second (2 periods of 100-Hz)
time(20::ms)

This is the wave, after running python createWav.py chuck30, on command line:


No comments:

Post a Comment