250 likes | 391 Views
Oscillator Algorithm. Oscillator Algorithm. SI. Sampling Increment (determines frequency). PHS. Phase Count (0 ≤ PHS < L). Waveform Table. 0. L-1. Output. Sampling Increment. If SI = 1.0:. SR. exp.: 43 Hz = 44100 / 1024. freqF =. L. To create a specific target frequency:. freqT.
E N D
Oscillator Algorithm SI Sampling Increment (determines frequency) PHS Phase Count (0 ≤ PHS < L) Waveform Table 0 L-1 Output
Sampling Increment If SI = 1.0: SR exp.: 43 Hz = 44100 / 1024 freqF = L To create a specific target frequency: freqT SI = exp.: 10.23 = 440.0 / 43 freqF Or: L * freq. SI = SR
Oscillator Stages L * frequency Initialization: SI = SR PHS = 0 or other initial value PHS = (PHS + SI)%L Sample Rate: IPHS = int(PHS) OUT = WAVE(IPHS) …… etc.
General Stages Initialization: Control rate: Sample Rate: once every n samples SR / second
Program Flow init: control: sample: t
Oscillator Detail SI int fract Waveform Table + 0 PHS int fract 1 = 2 result int fract 3 4 index = (int)PHS 5 N bits n bits ……… 2N = L L-1 (210 = 1024)
N bits n bits n determines the frequency accuracy Df n 0 4 8 12 16 43.066 2.692 0.168 0.0105 0.000657 SR = 44100 L = 1024 How much accuracy is necessary?
L oscillator interpolated 256 512 1024 2048 36 42 48 54 84 96 108 120 dB dB Signal to Noise Depends on L & method Trade-off
Interpolating Oscillator wavetable M M+1 nT int fract output = wavetable(M) + fract*(wavetable(M+1)-wavetable(M))
Envelope Generator Specification LevelScale TimeScale Env.type EnvGen Frequency Mul: Amp Wavetable Osc signal
Envelope Multiplication Osc t * EnvGen t = result t
Env: Changing Amplitude Type: ADSR Attack Decay amp Sustain Release t 0 peakLevel sustainLevel sustainLevel 0 attackTime decayTime sustainTime releaseTime Specification:
Envelope Scaling peak amplitude t duration peak amplitude t duration
Real Instruments Effort ff high t mf med. t p low t
Interpolation by Sample amp(L+1) amp amp(L) n nT L L+1 N n amp =amp(L)+ (amp(L+1)-amp(L)) N + = * / operations count: 1 1 1 1
Interpolation by Successive Addition amp(L+1) amp amp(L) n nT N initialization:amp=amp(L) (amp(L+1)-amp(L)) Damp = N loop:amp=amp + Damp (N times!) + = * / operations count: 1 0 0 0
Interpolation by Successive Multiplication amp(L+1) amp amp(L) n nT N initialization:amp=amp(L) Amp(L+1) Damp = 10 pow( log ( ) - log (Amp(L)) ) N loop:amp=amp * Damp (N times!) + = * / operations count: 0 0 1 0
Problems discontinuities amp nT
Changing Amplitude at low Control Rate Very Audible! sample interpolation frame interpolation nT Discontinuity!
Discontinuities in Samples t Sample hold for 2 sampling instances! Audible Click
Discontinuities in Phase/Frequency f t a t Very Audible
SuperCollider control rate 44100 kr = = 689 Hz 64 block rates? 44100 = 43 Hz 1024 44100 = 86 Hz 512 44100 = 344 Hz 128