Skip to content

buzz

Output is a set of harmonically related sine partials.

Syntax

ares = buzz(xamp, xcps, knh, ifn [, iphs])
ares buzz xamp, xcps, knh, ifn [, iphs]

Initialization

ifn -- table number of a stored function containing a sine wave. A large table of at least 8192 points is recommended.

iphs (optional, default=0) -- initial phase of the fundamental frequency, expressed as a fraction of a cycle (0 to 1). A negative value will cause phase initialization to be skipped. The default value is zero

Performance

xamp -- amplitude

xcps -- frequency in cycles per second

The buzz units generate an additive set of harmonically related cosine partials of fundamental frequency xcps, and whose amplitudes are scaled so their summation peak equals xamp. The selection and strength of partials is determined by the following control parameters:

knh -- total number of harmonics requested. New in Csound version 3.57, knh defaults to one. If knh is negative, the absolute value is used.

buzz and gbuzz are useful as complex sound sources in subtractive synthesis. buzz is a special case of the more general gbuzz in which klh = kmul = 1; it thus produces a set of knh equal-strength harmonic partials, beginning with the fundamental. (This is a band-limited pulse train; if the partials extend to the Nyquist, i.e. knh = int (sr / 2 / fundamental freq.), the result is a real pulse train of amplitude xamp.)

Although knh may be varied during performance, its internal value is necessarily integer and may cause “pops” due to discontinuities in the output. buzz can be amplitude- and/or frequency-modulated by either control or audio signals.

N.B. This unit has its analog in GEN11, in which the same set of cosines can be stored in a function table for sampling by an oscillator. Although computationally more efficient, the stored pulse train has a fixed spectral content, not a time-varying one as above.

Examples

Here is an example of the buzz opcode. It uses the file buzz-modern.csd.

Example of the buzz opcode.
<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
-odac  -d   ;;;RT audio out
;-iadc    ;;;uncomment -iadc if RT audio input is needed too
; For Non-realtime ouput leave only the line below:
; -o buzz.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 32
nchnls = 2
0dbfs =  1

instr 1
  cps:k = 110
  fn:i  = 1

  nh:k = line(p4, p3, p5)
  sig:a = buzz(1, cps, nh, fn)
  outs(sig, sig)
endin

</CsInstruments>
<CsScore>

;sine wave.
f 1 0 16384 10 1

i 1 0 3 20 20
i 1 + 3 3  3
i 1 + 3 10 1
e

</CsScore>
</CsoundSynthesizer>

Here is an example of the buzz opcode. It uses the file buzz.csd.

Example of the buzz opcode.
<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
-odac     ;;;RT audio out
;-iadc    ;;;uncomment -iadc if RT audio input is needed too
; For Non-realtime ouput leave only the line below:
; -o buzz.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1

instr 1

kcps = 110
ifn  = 1

knh  line p4, p3, p5
asig buzz 1, kcps, knh, ifn
     outs asig, asig
endin

</CsInstruments>
<CsScore>

;sine wave.
f 1 0 16384 10 1

i 1 0 3 20 20
i 1 + 3 3 3
i 1 + 3 10 1
e

</CsScore>
</CsoundSynthesizer>

A musical example featuring the buzz opcode: BuzzFof_Cucchi-modern.csd by Stefano Cucchi.

Musical example of the buzz opcode.
<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
-odac     ;;;realtime audio out
;-iadc    ;;;uncomment -iadc if realtime audio input is needed too
; For Non-realtime ouput leave only the line below:
;-o BuzzFof_Cucchi.wav -W ;;; for file output any platform


; By Stefano Cucchi - 2022

</CsOptions>
<CsInstruments>

sr = 48000
ksmps = 10 
nchnls = 2
0dbfs  = 1

rev1L@global:a = init(0)
rev1R@global:a = init(0)

instr buzz
  dur:i = p3
  DensInit:i = p4  ; Initial bouncing density
  DensFinal:i = p5 ; Final bouncing density

  fe1:k = expseg(DensInit, dur, DensFinal)

  ftndx:k = linseg(0, dur*0.2, 1, dur*0.2, 0, dur*0.6, 1)
  resfn:i = 2
  ftfn:i = 1
  ftmorf(ftndx, ftfn, resfn)
  env:k = expseg(0.0001, p11, p8, dur-p11-p12, p8, p12, 0.0001)

  sig:a = buzz(env, fe1, sr/(2*fe1), 2)
  freqformant:k = expseg(p6, dur, p7)
  form:a = fofilter(sig, freqformant, 0.007, 0.04)


  filtergain:i = 0.015
  eq:a = pareq(form, freqformant, filtergain, 0.1, 0)

  randompan:k = randi(0.5, 4, p9)
  randompan += 0.5

  aL, aR = pan2(eq*16, randompan)

  outch(1, aL)
  outch(2, aR)

  Delay1:a = delay(aL, 0.2)
  Delay2:a = delay(aR, 0.36)

  outch(1, Delay2*0.01)
  outch(2, Delay1*0.01)

  rev1L += aR * p10
  rev1R += aL * p10
endin


instr fof
  dur:i = p3
  freq1:i = cpspch (p4)
  freq2:i = cpspch (p5)
  freq3:i = cpspch (p6)
  freq4:i = cpspch (p7)
  freq:k = expseg(freq1, dur*p8, freq2, dur*p9, freq3, dur*p10, freq4)

  amp:i = 0.99

  random1:k = randomi(-3, 3, 4)
  random2:k = randomi(-30, 30, 8)
  Jitter1:k = jitter(2, 0.2, 5)
  form1:k = p11 + random1
  oct1:k = 2
  band1:k = p12 + random2
  ris1:k = 0.003
  dur1:k = 0.12
  dec1:k = 0.007
  olaps1:i = 1900
  fna1:i = 15

  random3:k = randomi(-2, 2.2, 3.8)
  random4:k = randomi(-25, 26, 2.6)
  Jitter2:k = jitter(3, 0.2, 3)
  form2:k = p13 + random3
  oct2:k = 2
  band2:k = p14 + random4
  ris2:k = 0.0003
  dur2:k = 0.012
  dec2:k = 0.07
  olaps2:i = 1700
  fna2:i = 16

  fnb:i = 18
  totdur:i = 800

  Fof1:a = fof(amp, freq+Jitter1, form1, oct1, band1, ris1, dur1, dec1, \
               olaps1, fna1, fnb, totdur)
  Fof2:a = fof(amp*0.9, (freq*2.01)+Jitter2, form2, oct2, band2, ris2, \
               dur2, dec2, olaps2, fna2, fnb, totdur)

  Env:k = expseg(0.0001, p15, p16, dur-p15-p17, p16, p17, 0.0001)

  somma:a = (Fof1 + Fof2*0.72) * Env
  somma = dam(somma, 0.7, 1.2, 0.8, 0.001, 0.2)
  somma *= 2.9
  delaytime:a = randomi(0.01, 0.5, 4)
  sommadel:a = vdelay(somma, delaytime, 0.6)

  Pan:i = p18

  outch(1, somma * (1-Pan))
  outch(2, sommadel * Pan)

  rev1L += somma*0.3
  rev1R += sommadel*0.3
endin


instr 100 ; REV

  time1:k = randomi(2.3, 3.6, 6)
  time2:k = randomi(2.2, 3.7, 7)

  arev1L = reverb2(rev1L, time1, 0.1)
  arev1R = reverb2(rev1R, time2, 0.8)

  timedelay1:a = randomi(0.3, 0.4, 5)
  timedelay2:a = randomi(0.3, 0.4, 8)
  arev2L = vdelay(arev1L, timedelay1, 0.6)
  arev2R = vdelay(arev1R, timedelay2, 0.6)

  totL:a = (arev1L*0.12) + (arev2R*0.34)
  totR:a = (arev1R*0.12) + (arev2L*0.34)

  random1:k = randomi(0.25, 0.41, 8)
  random2:k = randomi(0.23, 0.39, 7)

  outch(1, totL*random1)
  outch(2, totR*random2)

  clear(rev1L)
  clear(rev1R) 
endin

</CsInstruments>
<CsScore>

t 0 60 20 46 20 35; TEMPO

; function - "buzz1";
f1 0 2 -2 3 4
f2 0 4097 10 1 /*contents of f2 dont matter */
f3 0 4096 10 1
f4 0 4097 10 1 0 1 0 1 0 1 0 1 1 1

; function - buzz2
f6 0 4096 10 1 0.5 0.9


; functions - fof1
f 15 0 4096 10 1 0 1 0 1 0 1   
f 16 0 4096 10 1 0 1 0 0  1    
; sigmoid wave
f 18 0 1024 19 0.5 0.5 270 0.5 


;REVERB
i 100 0 53;


;                 dens    dens  form   form      vol      pan      REV     rAttack Decay
i "buzz" 0   5    2      120  1200    200       0.1      0.11     0.1       0.2    2
i "buzz" 2   8    1      34   450     12200     0.11     0.6       0.3      0.01   2
i "buzz" 4   6    20     5    500     4600      0.12     0.1       0.5      0.1    2
i "buzz" 8   9    43     680  15500   300      0.092    0.4       0.01      0.1    2


i "buzz" 19  15    4     120   14200   200       0.12    0.15      0.9      0.01   3
i "buzz" 21  13    3.8   35    2000    14200     0.09    0.49      0.3      0.01   3


i "buzz" 35  2    611    2  4000    4012      0.013     0.9       0.81      0.1   3
i "buzz" 35  2    40     43   1000   112       0.02      0.1       0.1      0.1   3

i "buzz" 39 2     20     27   3000    300      0.4       0.4       0.3      0.4   3
i "buzz" 39 2      4     72   79      5112     0.14      0.1       0.3      0.8   3

i "buzz" 42  6    11     49   50      1112      0.1      0.3       0.1      2.5   2
i "buzz" 42  9     2     812  100     4112     0.12      0.7       0.45     3.7  4


;                  Pitch1   Pitch2  Pitch3   Pitch4 -  portamenti(somma = 1)-Form1  Band1  Form2  Band2  Att    VOl  Rel   Pan
i "fof" 0     13   4.01    6.01    4.01     3.05       0.15   0.35  0.50     500   200     890    59    7.31   0.21  4.3  0.2
i "fof" 0     14   4.09    3.08    5.03     4.11       0.35   0.50  0.25     600   200     700    59    6.31   0.21  5.3  0.99


i "fof" 50   10    5.09    6.08    7.08     4.08      0.40   0.20  0.40      6230  720      2700   85   4.01   0.02 3.03  0.01
i "fof" 50.05 10   5.09    6.08    7.08     4.08      0.40   0.20  0.40      4230  420      1700   15   4.01   0.03 4.03  0.67

i "fof" 51    10   5.09    6.03    7.02     4.11      0.40   0.20  0.40      2300   720     5700   859  4.01   0.01 3.03  0.78
i "fof" 51.03 10   5.09    6.03    7.02     4.11      0.40   0.20  0.40      2300   720     5700   859  4.6    0.01 3.03  0.23

e 2

</CsScore>
</CsoundSynthesizer>

A musical example featuring the buzz opcode: BuzzFof_Cucchi.csd by Stefano Cucchi.

Musical example of the buzz opcode.
<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
-odac     ;;;realtime audio out
;-iadc    ;;;uncomment -iadc if realtime audio input is needed too
; For Non-realtime ouput leave only the line below:
;-o BuzzFof_Cucchi.wav -W ;;; for file output any platform


; By Stefano Cucchi - 2022

</CsOptions>
<CsInstruments>

sr = 48000
ksmps = 10 
nchnls = 2
0dbfs  = 1


garev1L init 0
garev1R init 0


instr buzz

 iDensInit = p4  ; Initial bouncing density
 iDensFinal = p5 ; Final bouncing density

 kfe1  expseg iDensInit, p3, iDensFinal

 kftndx linseg 0, p3*0.2, 1, p3*0.2, 0, p3*0.6, 1
 iresfn = 2
 iftfn = 1
 ftmorf kftndx, iftfn, iresfn
 kenv expseg 0.0001, p11, p8, p3-p11-p12, p8, p12, 0.0001

 asig buzz kenv, kfe1, sr/(2*kfe1), 2
 kfreqformant expseg p6, p3, p7
 aform fofilter asig, kfreqformant, 0.007, 0.04


 ifiltergain = 0.015
 aeq pareq aform, kfreqformant, ifiltergain, 0.1, 0

 krandompan randi 0.5, 4, p9
 krandompan = krandompan+0.5

 aL, aR pan2 aeq*16, krandompan

 outch 1, aL 
 outch 2, aR 

 adelay1 delay aL, 0.2
 adelay2 delay aR, 0.36

 outch 1, adelay2*0.01
 outch 2, adelay1*0.01


 garev1L = garev1L + aR * p10
 garev1R = garev1R + aL * p10

 endin


instr fof

 ifreq1 = cpspch (p4)
 ifreq2 = cpspch (p5)
 ifreq3 = cpspch (p6)
 ifreq4 = cpspch (p7)
 kfreq expseg ifreq1, p3*p8, ifreq2, p3*p9, ifreq3, p3*p10, ifreq4

 iAmp = 0.99

 krandom1 randomi -3, 3, 4
 krandom2 randomi -30, 30, 8
 kjitter1 jitter 2, 0.2, 5
 kform1 = p11 + krandom1
 koct1 = 2
 kband1 = p12 + krandom2
 kris1 = 0.003
 kdur1 = 0.12
 kdec1 = 0.007
 iolaps1 = 1900
 ifna1 = 15

 krandom3 randomi -2, 2.2, 3.8
 krandom4 randomi -25, 26, 2.6
 kjitter2 jitter 3, 0.2, 3

 kform2 = p13 + krandom3
 koct2 = 2
 kband2 = p14 + krandom4
 kris2 = 0.0003
 kdur2 = 0.012
 kdec2 = 0.07
 iolaps2 = 1700
 ifna2 = 16

 ifnb = 18
 itotdur = 800

 afof1 fof iAmp, kfreq+kjitter1, kform1, koct1, kband1, kris1, kdur1, kdec1, iolaps1, ifna1, ifnb, itotdur
 afof2 fof iAmp*0.9, (kfreq*2.01)+kjitter2, kform2, koct2, kband2, kris2, kdur2, kdec2, iolaps2, ifna2, ifnb, itotdur

 kEnv expseg 0.0001, p15, p16, p3-p15-p17, p16, p17, 0.0001

 asomma = (afof1 + afof2*0.72) * kEnv
 asomma dam asomma, 0.7, 1.2, 0.8, 0.001, 0.2
 asomma = asomma*2.9
 adelaytime randomi 0.01, 0.5, 4
 asommadel vdelay asomma, adelaytime, 0.6

 ipan = p18

 outch 1, asomma * (1-p18)
 outch 2, asommadel * p18

 garev1L = garev1L + asomma*0.3
 garev1R = garev1R + asommadel*0.3

 endin


instr 100 ; REV

 ktime1 randomi  2.3, 3.6, 6
 ktime2 randomi  2.2, 3.7, 7

 arev1L reverb2 garev1L, ktime1, 0.1
 arev1R reverb2 garev1R, ktime2, 0.8

 atimedelay1 randomi 0.3, 0.4, 5
 atimedelay2 randomi 0.3, 0.4, 8
 arev2L vdelay arev1L, atimedelay1, 0.6
 arev2R vdelay arev1R, atimedelay2, 0.6

 atotL = (arev1L*0.12) + (arev2R*0.34)
 atotR = (arev1R*0.12) + (arev2L*0.34)

 krandom1 randomi 0.25, 0.41, 8
 krandom2 randomi 0.23, 0.39, 7

 outch 1, atotL*krandom1
 outch 2, atotR*krandom2

 clear garev1L
 clear garev1R 

 endin



</CsInstruments>
<CsScore>


t 0 60 20 46 20 35; TEMPO

; function - "buzz1";
f1 0 2 -2 3 4
f2 0 4097 10 1 /*contents of f2 dont matter */
f3 0 4096 10 1
f4 0 4097 10 1 0 1 0 1 0 1 0 1 1 1

; function - buzz2
f6 0 4096 10 1 0.5 0.9


; functions - fof1
f 15 0 4096 10 1 0 1 0 1 0 1   
f 16 0 4096 10 1 0 1 0 0  1    
; sigmoid wave
f 18 0 1024 19 0.5 0.5 270 0.5 


;REVERB
i 100 0 53;


;                 dens    dens  form   form      vol      pan      REV     rAttack Decay
i "buzz" 0   5    2      120  1200    200       0.1      0.11     0.1       0.2    2
i "buzz" 2   8    1      34   450     12200     0.11     0.6       0.3      0.01   2
i "buzz" 4   6    20     5    500     4600      0.12     0.1       0.5      0.1    2
i "buzz" 8   9    43     680  15500   300      0.092    0.4       0.01      0.1    2


i "buzz" 19  15    4     120   14200   200       0.12    0.15      0.9      0.01   3
i "buzz" 21  13    3.8   35    2000    14200     0.09    0.49      0.3      0.01   3


i "buzz" 35  2    611    2  4000    4012      0.013     0.9       0.81      0.1   3
i "buzz" 35  2    40     43   1000   112       0.02      0.1       0.1      0.1   3

i "buzz" 39 2     20     27   3000    300      0.4       0.4       0.3      0.4   3
i "buzz" 39 2      4     72   79      5112     0.14      0.1       0.3      0.8   3

i "buzz" 42  6    11     49   50      1112      0.1      0.3       0.1      2.5   2
i "buzz" 42  9     2     812  100     4112     0.12      0.7       0.45     3.7  4


;                  Pitch1   Pitch2  Pitch3   Pitch4 -  portamenti(somma = 1)-Form1  Band1  Form2  Band2  Att    VOl  Rel   Pan
i "fof" 0     13   4.01    6.01    4.01     3.05       0.15   0.35  0.50     500   200     890    59    7.31   0.21  4.3  0.2
i "fof" 0     14   4.09    3.08    5.03     4.11       0.35   0.50  0.25     600   200     700    59    6.31   0.21  5.3  0.99


i "fof" 50   10    5.09    6.08    7.08     4.08      0.40   0.20  0.40      6230  720      2700   85   4.01   0.02 3.03  0.01
i "fof" 50.05 10   5.09    6.08    7.08     4.08      0.40   0.20  0.40      4230  420      1700   15   4.01   0.03 4.03  0.67

i "fof" 51    10   5.09    6.03    7.02     4.11      0.40   0.20  0.40      2300   720     5700   859  4.01   0.01 3.03  0.78
i "fof" 51.03 10   5.09    6.03    7.02     4.11      0.40   0.20  0.40      2300   720     5700   859  4.6    0.01 3.03  0.23

e 2



</CsScore>
</CsoundSynthesizer>

See Also

Dynamic Spectrum Oscillators

Credits

September 2003. Thanks to Kanata Motohashi for correcting the mentions of the kmul parameter.