Simulating hard sync in csound

by Ian Sayer

Printer friendly


Hard sync or phase sync has been a popular tool in the synthesis arsenal since the ARP Odessey/2600. It is still used frequently in modern electronic dance music.
Analogue VCO's typically work by charging a capacitor at a rate proportional to the sum of the CV inputs. When the voltage across the capacitor exceeds a threshold, a comparitor generates a pulse, which rapidly discharges the capacitor, and the cycle repeats. Other waveforms are derived from further processing of the basic sawtooth.
In an analogue synth with more than one oscillator, sync is simply (and inexpensively) implemented by allowing the reset pulse of one oscillator (the master) to reset the cycle of another oscillator (the slave). The harmonic content of the slave oscillator varies depending on the ratio of the two frequencies, so long as the slave frequency is higher than the master.

 

Master Oscillator
Slave Oscillator


When trying to duplicate this effect in csound, you might consider using two oscil opcodes. However, the sort of arate inter-operator interaction required is difficult.
The instrument shown below achieves the same effect using a single phasor/table pair. The csound oscil opcode scans a waveform stored in a table at a specified frequency. Using phasor and table allows a little more flexibility. The phasor generates a signal that varies from 0 to 1 at a specified frequency. This signal is used by the table operator to lookup values in a table. Two of the optional table parameters are used in this instance.
 

ixmode = 1 this sets the table index mode to assume that asig is normalised to the range 0-1. The default is 0 where you must scale the index yourself.
iwrap = 1 this lets out of range index values wrap back through the table. The default 0 results in under and over index values repeating the first and last entries in the table.
 

The trick now is to scale the signal level of the phasor, for example, a factor of two means the table is scanned twice for every period of the phasor. This scale factor corresponds to the slave frequency in the analogue counterpart. The instrument includes a lowpass filter for authenticity, it also helps mask any clicks which may be present.
---- .orc
sr = 44100
kr = 882
ksmps = 50
nchnls = 1

;------------------------------------------------------------------
instr 1 ; Hard Sync Sawtooth, Ian Sayer 20 Aug 2002
;------------------------------------------------------------------

; sync sweep start ratio, time, end ratio
aSweep line 8,p3,1

; filter sweep
kFc expon sr/3,p3*.75,sr/12

; use phasor+tablei pair
aphs phasor p4

; use aSweep to scale table index, use table wrap mode (parameter 4 = 1)
async tablei aphs*aSweep,1,1,0,1

; lowpass filter
alpf lpf18 async, kFc, 0, 0

; output result scaled to 14bits (1/2 full scale)
out alpf*(2^14)
endin
----- .sco
; GEN7 line segments for sawtooth
f1 0 4096 7 -1 4092 1 4
i1 0 1 55
i1 1 .5 330
-------

This is a very simple instrument intended to illustrate the technique, feel free to expand by adding amplitude envelope, more complex modulation options etc. Also try other basic waveforms.

Soft Sync is also found on some analogue synthesisers. Two very distinct varieties exist. The old Roland M100 modular variety involved a variable threshold which prevented the sync from happening unless the slave cycle level was greater than that level. The result sounded like hard sync that wasn't working properly. The other variety of soft sync used the master reset pulse to reverse the slope of the slave rather that resetting the cycle. The result is a subtle version of hard sync.

Links

http://www.csounds.com/tootsother/east/Phasor/Phasor.html

Examples of hard sync

Neon Lights, Kraftwerk, Sweeping base note in last section.
Lets Go, The Cars - Main synthesiser hook.
Higher state of consciousness, Josh Wink.