Cabbage Logo
Back to Cabbage Site

Osc syncing

I still ask for an explanation of what ifn=-1 of tablei opcode stands for.
I suspect that it implies a sine wave, same as oscil1i opcode. Csound documentation has no clue and I cannot find an online explanation.

I suspect you are correct. Most of the ‘oscil’ opcodes can take a -1 for table number, which defaults to a sine. I guess the table opcodes are the same.

1 Like

Yes, that’s right. The -1 is a relatively recent addition to prevent you from having to build a sine wave function everytime. I think the manual authors forgot to mention this in the tablei entry, it is included in the oscil_ opcode entries.

The wraparound switch is not actually needed in this example, so
a2 tablei aphase2,-1,1,0,1
could simply be:
a2 tablei aphase2,-1,1
If you start modifying the aphase variables, you will probably want wraparound switched on again.

The half-sine envelope is indeed to prevent a harsh, high-frequency buzzing (with aliasing) that results from the instantaneous snap back to phase zero triggered in the second syncphasor. If you feel that the half-sine is softening the hard sound you are after too much, you can try a Tukey envelope and vary the duration of the soft attack-decay. I have attached an example.
hardsyncOscillatorsTukeyWindow.csd (1.8 KB)

1 Like

This is my last message on this thread.
I solved the problems successfully using your help.
I have replaced poscil and vco2 opcodes in my synth with ftgen and tablei hardsyncing with syncphasor in ksmps=32. :smiley:
The CPU load of the VST synth in FLStudio is the same as in Image Line and Native Instrument synths in my collection.

Since my test instrument required syncing of variable Pulse Width waveforms, I had a little problem in generating the the tables inside the instrument, but I solved the problem with the following code:
The use of reinit and rerirurn opcodes was inevitable in order to alter the width of the pulse during performance.

 ksmps = 32
 nchnls = 2
 0dbfs = 1
  
 instr 1
  kfreq1    chnget  "freq1"
  kfreq2    chnget  "freq2"
  kamp      chnget  "amp"
  kPW1      chnget  "PW1"
  kPW2      chnget  "PW2"
  
  kchanged  changed kPW1, kPW2
  
  if kchanged == 1 then
    reinit reset
  endif
  
  reset:
    ipw11 = int(i(kPW1) * 4096)
    ipw10 = 4096 - ipw11 
    ipwtab1 ftgen 11, 0, 4097, 7, 1, ipw11, 1, 0 , -1, ipw10, -1   
    ipw21 = int(i(kPW2) * 4096)
    ipw20 = 4096 - ipw21 
    ipwtab2 ftgen 12, 0, 4097, 7, 1, ipw21, 1, 0 , -1, ipw20, -1       
  rireturn    

  aphase1,asyncout1 syncphasor  kfreq1, a(0)
  aphase2,asyncout2 syncphasor  kfreq2, asyncout1
  
  a1                tablei      aphase1, ipwtab1, 1
  a2                tablei      aphase2, ipwtab2, 1
  ao                ntrpol      a1, a2, .5
  ao                *=          kamp
  
                    outs        aOsc1,aOsc1
 endin