Is there an opcode for an oscillator that allows an a-rate phase signal is an input parameter?
A-rate phase?
hi
andx phasor xcps [, iphs]
and
ares tablei andx, ifn [, ixmode] [, ixoff] [, iwrap]
combo giving a rate control over frequency and phase shift.
or you can use
ares oscilikts xamp, xcps, kfn, async, kphs [, istor]
put it in opcode with ksmps 1
Thanks! I found this info: http://www.csounds.com/manual/html/oscilikts.html
But what do I have to do with async?
async for synchronize with another oscilator , if you dont need it, just init it .
async init 0
I want to build a synth for phase modulation but when I want to modulate the phase in k-rate (instead of a-rate) than I have to generate the modulation signal in k-rate. What oscillator opcode will do that? I’m stuck.
you can simply do like this
kmod = amod.
of just go with tablei. andx parameter can be modulated to get phase modulation.
ares tablei andx+amod, ifn [, ixmode] [, ixoff] [, iwrap]
its better to keep everything a rate if possible.
Thank you
I haven’t got the time to try it out now, but will do so later. Thanks again.
I first tried to build a simple oscillator with phasor and tablei. See:
<Cabbage></Cabbage>
<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>
ksmps = 32
nchnls = 2
0dbfs = 1
instr 1
andx phasor 440
amod = 0
giSin ftgen 0, 0, 2^10, 10, 1
aOut tablei andx + amod, giSin
outs aOut, aOut
endin
</CsInstruments>
<CsScore>
;causes Csound to run for about 7000 years...
f0 z
</CsScore>
</CsoundSynthesizer>
But no sound. What’s wrong?
By default, tablei needs to be passed a valid index between 0 and the number of samples in the table. Phasor only outputs values between 0 and 1. If you add a 1 after giSin it tell the table to use values in the range of 0 to 1 instead. Btw, I don’t think it’s wise to put an ftgen
inside an instrument block. Each time that instrument is started Csound may try to allocate memory for the table.
Thanks! I have changed it to this now:
<Cabbage></Cabbage>
<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>
ksmps = 32
nchnls = 2
0dbfs = 1
giSin ftgen 0, 0, 2^10, 10, 1
instr 1
andx phasor 440
amod = 0
aOut tablei andx + amod, giSin, 1
outs aOut, aOut
endin
</CsInstruments>
<CsScore>
;causes Csound to run for about 7000 years...
f0 z
</CsScore>
</CsoundSynthesizer>
But still no sound.
You need to actually start an instrument if you want to hear the output from it. A guitar won’t make a sound on its own So either add a MIDI keyboard so you can trigger the instrument that way, or add a score statement to start instrument 1.
Yes - this works :
<Cabbage>
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>
ksmps = 32
nchnls = 2
0dbfs = 1
giSin ftgen 0, 0, 2^10, 10, 1, 1
instr 1
andx phasor 400
amod = 0
aOut tablei andx + amod, giSin, 1
outs aOut, aOut
endin
</CsInstruments>
<CsScore>
i 1 0 3
</CsScore>
</CsoundSynthesizer>
Then I guess that this is the phase modulation version of my earlier Primitive Frequency Modulation Synth but I’m not quite sure about it. Also the official definition of the modulation index for phase modulation looks quite weird to me.
<Cabbage>
form caption("Primitive PM-synth") size(800, 500), guiMode("queue"), pluginId("def1")
signaldisplay bounds(590, 30, 170, 140), colour("lime"), displayType("waveform"), signalVariable("aOutput")
signaldisplay bounds(590, 240, 170, 140), colour("lime"), displayType("spectroscope"), signalVariable("aOutput")
keyboard bounds(20, 405, 750, 75)
rslider bounds(18, 30, 80, 80) channel("vol") range(0, 1, 0.5, 1, 0.001) colour(255, 0, 0, 255) text("Volume") textColour(255, 255, 0, 255)
rslider bounds(100, 30, 80, 80) channel("att") range(0.001, 0.25, 0.02, 1, 0.001) colour(255, 0, 0, 255) text("Attack") textColour(255, 245, 0, 255)
rslider bounds(180, 30, 80, 80) channel("dec") range(0.001, 0.25, 0.01, 1, 0.01) colour(255, 0, 0, 255) text("Decay") textColour(255, 245, 0, 255)
rslider bounds(260, 30, 80, 80) channel("sus") range(0, 1, 0.7, 1, 0.001) colour(255, 0, 0, 255) text("Sustain") textColour(255, 245, 0, 255)
rslider bounds(340, 30, 80, 80) channel("rel") range(0, 1, 0.1, 1, 0.001) colour(255, 0, 0, 255) text("Release") textColour(255, 245, 0, 255)
label bounds(20, 135, 400, 15) text("Carrier") colour(255, 255, 255, 225) fontColour(255, 0, 0, 255)
rslider bounds(20, 165, 80, 80) channel("csin") range(0.001, 1, 0.2, 1, 0.001) colour(255, 0, 0, 255) text("Sine") textColour(255, 255, 0, 255)
rslider bounds(100, 165, 80, 80) channel("csaw") range(0.001, 1, 0.2, 1, 0.001) colour(255, 0, 0, 255) text("Saw") textColour(255, 255, 0, 255)
rslider bounds(180, 165, 80, 80) channel("csqu") range(0.001, 1, 0.2, 1, 0.001) colour(255, 0, 0, 255) text("Square") textColour(255, 255, 0, 255)
rslider bounds(260, 165, 80, 80) channel("ctri") range(0.001, 1, 0.2, 1, 0.001) colour(255, 0, 0, 255) text("Triangle") textColour(255, 255, 0, 255)
rslider bounds(340, 165, 80, 80) channel("cimp") range(0.001, 1, 0.2, 1, 0.001) colour(255, 0, 0, 255) text("Impulse") textColour(255, 255, 0, 255)
label bounds(20, 265, 400, 15) text("Modulator") colour(255, 255, 255, 255) fontColour(255, 0, 0, 255)
rslider bounds(20, 295, 80, 80) channel("msin") range(0.001, 1, 0.2, 1, 0.001) colour(255, 0, 0, 255) text("Sine") textColour(255, 255, 0, 255)
rslider bounds(100, 295, 80, 80) channel("msaw") range(0.001, 1, 0.2, 1, 0.001) colour(255, 0, 0, 255) text("Saw") textColour(255, 255, 0, 255)
rslider bounds(180, 295, 80, 80) channel("msqu") range(0.001, 1, 0.2, 1, 0.001) colour(255, 0, 0, 255) text("Square") textColour(255, 255, 0, 255)
rslider bounds(260, 295, 80, 80) channel("mtri") range(0.001, 1, 0.2, 1, 0.001) colour(255, 0, 0, 255) text("Triangle") textColour(255, 255, 0, 255)
rslider bounds(340, 295, 80, 80) channel("mimp") range(0.001, 1, 0.2, 1, 0.001) colour(255, 0, 0, 255) text("Impulse") textColour(255, 255, 0, 255)
rslider bounds(460, 30, 80, 80) channel("modind") range(0, 5, 2.5, 1, 0.001) colour(255, 0, 0, 255) text("Mod. index") textColour(255, 255, 0, 255)
rslider bounds(460, 165, 80, 80) channel("freqrat") range(0, 5, 1, 1, 0.001) colour(255, 0, 0, 255) text("Freq. ratio") textColour(255, 255, 0, 255)
rslider bounds(460, 300, 80, 80) channel("fintun") range(-0.1, 0.1, 0, 1, 0.001) colour(255, 0, 0, 255) text("Fine-tuning") textColour(255, 255, 0, 255)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-m0d -n -+rtmidi=NULL -M0 --midi-key-cps=4 --midi-velocity-amp=5 --displays
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1
giSin ftgen 0, 0, 2^10, 10, 1
giSaw ftgen 0, 0, 2^10, 10, 1, 1/2, 1/3, 1/4, 1/5, 1/6, 1/7, 1/8, 1/9
giSqu ftgen 0, 0, 2^10, 10, 1, 0, 1/3, 0, 1/5, 0, 1/7, 0, 1/9
giTri ftgen 0, 0, 2^10, 10, 1, 0, -1/9, 0, 1/25, 0, -1/49, 0, 1/81
giImp ftgen 0, 0, 2^10, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1
instr 1
kVol chnget "vol"
iAtt chnget "att"
iDec chnget "dec"
iSus chnget "sus"
iRel chnget "rel"
kCSin chnget "csin"
kCSaw chnget "csaw"
kCSqu chnget "csqu"
kCTri chnget "ctri"
kCImp chnget "cimp"
kMSin chnget "msin"
kMSaw chnget "msaw"
kMSqu chnget "msqu"
kMTri chnget "mtri"
kMImp chnget "mimp"
kModind chnget "modind"
kFreqrat chnget "freqrat"
kFintun chnget "fintun"
kRat = kFreqrat + kFintun
aModulatorSin poscil p5, p4*kRat, giSin
aModulatorSaw poscil p5, p4*kRat, giSaw
aModulatorSqu poscil p5, p4*kRat, giSqu
aModulatorTri poscil p5, p4*kRat, giTri
aModulatorImp poscil p5, p4*kRat, giImp
kSumM = kMSin + kMSaw + kMSqu + kMTri + kMImp
aModulator = (kMSin*aModulatorSin + kMSaw*aModulatorSaw + kMSqu*aModulatorSqu + kMTri*aModulatorTri + kMImp*aModulatorImp)/kSumM
andx phasor p4
amod = kModind*aModulator
aCarrierSin tablei andx + amod, giSin, 1
andx phasor p4
amod = kModind*aModulator
aCarrierSaw tablei andx + amod, giSaw, 1
andx phasor p4
amod = kModind*aModulator
aCarrierSqu tablei andx + amod, giSqu, 1
andx phasor p4
amod = kModind*aModulator
aCarrierTri tablei andx + amod, giTri, 1
andx phasor p4
amod = kModind*aModulator
aCarrierImp tablei andx + amod, giImp, 1
kADSR madsr iAtt, iDec, iSus, iRel
kSumC = kCSin + kCSaw + kCSqu + kCTri + kCImp
aOutput = kADSR*kVol*(kCSin*aCarrierSin + kCSaw*aCarrierSaw + kCSqu*aCarrierSqu + kCTri*aCarrierTri + kCImp*aCarrierImp)/kSumC
out aOutput, aOutput
display aOutput, .1, 1
dispfft aOutput, .1, 1024
endin
</CsInstruments>
<CsScore>
;causes Csound to run for about 7000 years...
f0 z
</CsScore>