Use Non-Frames Version Previous Page Next Page
Signal Generators: Additive Synthesis/Resynthesis

adsynt


  ar      adsynt    kamp, kcps, iwfn, ifreqfn, iampfn, icnt[, iphs]


Description

Performs additive synthesis with an arbitrary number of partials, not necessarily harmonic.

Initialization

iwfn – table containing a waveform, usually a sine. Table values are not interpolated for performance reasons, so larger tables provide better quality.

ifreqfn – table containing frequency values for each partial. ifreqfn may contain beginning frequency values for each partial, but is usually used for generating parameters at runtime with tablew. Frequencies must be relative to kcps. Size must be at least icnt.

iampfn – table containing amplitude values for each partial. iampfn may contain beginning amplitude values for each partial, but is usually used for generating parameters at runtime with tablew. Amplitudes must be relative to kamp. Size must be at least icnt.

icnt – number of partials to be generated

iphs – initial phase of each oscillator, if iphs = -1, initialization is skipped. If iphs > 1, all phases will be initialized with a random value.

Performance

kamp – amplitude of note

kcps – base frequency of note. Partial frequencies will be relative to kcps.

Frequency and amplitude of each partial is given in the two tables provided. The purpose of this opcode is to have an instrument generate synthesis parameters at k-rate and write them to global parameter tables with the tablew opcode.

Examples

These two instruments perform additive synthesis. The output of each sounds like a Tibetan bowl. The first one is static, as parameters are only generated at init-time. In the second one, parameters are continuously changed.




  gifrqs  ftgen  2, 0, 32, 7, 0, 32, 0              ; generate two emty tables for adsynt

  giamps  ftgen  3, 0, 32, 7, 0, 32, 0              ; for freqency and amp parameters

  

 instr 1                                             ; generates paramaters at init time

  icnt    =          10                             ; generate 10 voices

  index   =          0                              ; init loop index

  

  loop:                                             ; loop only executed at init time

  

  ifreq   pow       index + 1, 1.5                  ; define non-harmonic partials

  iamp    =         1 / (index+1)                   ; define amplitudes

          tableiw   ifreq, index, gifrqs            ; write to tables

          tableiw   iamp, index, giamps             ; used by adsynt

  

  index   =         index + 1

  if (index < icnt) igoto loop                      ; do loop

  

  asig    adsynt    5000, 150, giwave, gifrqs, giamps, icnt

          out       asig

 endin

  

    

 instr 2                                            ; generates paramaters every k-cycle

  icnt    =          10                             ; generate 10 voices

  kindex  =          0                              ; reset loop index

  loop:                                             ; loop executed every k-cycle

  

  kspeed  pow        kindex + 1, 1.6                ; generate lfo for frequencies

  kphas   phasorbnk  kspeed * 0.7, kindex, icnt     ; individual phase for each voice

  klfo    table      kphas, giwave, 1

  kdepth  pow        1.4, kindex                    ; arbitrary parameter twiddling...

  kfreq   pow        kindex + 1, 1.5

  kfreq   =          kfreq + klfo*0.006*kdepth

          tablew     kfreq, kindex, gifrqs          ; write freqs to table for adsynt

  

  kspeed  pow        kindex + 1, 0.8                ; generate lfo for amplitudes

  kphas   phasorbnk  kspeed*0.13, kindex, icnt, 2   ; individual phase for each voice

  klfo    table      kphas, giwave, 1

  kamp    pow        1 / (kindex + 1), 0.4          ; arbitrary parameter twiddling...

  kamp    =          kamp * (0.3+0.35*(klfo+1))

          tablew     kamp, kindex, giamps           ; write amps to table for adsynt

  

  kindex  =          kindex + 1

  if (kindex < icnt) kgoto loop                     ; do loop

  giwave  ftgen  1, 0, 1024, 10, 1                  ; generate a sinewave table

  asig    adsynt     5000, 150, giwave, gifrqs, giamps, icnt

          out        asig

 endin

  

Author

Peter Neubäcker
Munich, Germany
August, 1999
New in Csound version 3.58


Use Non-Frames Version Previous Page Next Page
Signal Generators: Additive Synthesis/Resynthesis