Cabbage Logo
Back to Cabbage Site

Fine tune / oct control

fine tune / oct control; is there a specific way that i would add both of those in such a way that they wouldnt conflict? or would i just have a combo box that says what octave i want?

aOut vco2 p5, p4*chnget:k(“osc1fine”)*chnget:k(“osc1oct”)

Thanks @AveAcsent for reposting! So you want both coarse and fine tuning with two different sliders?

If “osc1oct” ranges from 1 to 2, it will takes care of the octave tuning from that perspective. I guess your fine tuning depends on how fine you want it? And what is the maximum range you wish to fine tune? If you wish to fine tune by a semitone, you could do something like, so long as the fine tune slider is set to range of 0 to 1?

 <Cabbage>
form caption("Untitled") size(400, 300), colour(58, 110, 182), pluginid("def1")
keyboard bounds(8, 158, 381, 95)
rslider bounds(8, 12, 60, 60) range(0, 1, 0, 1, 0.001), channel("fineTune")
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 -m0d --midi-key-cps=4 --midi-velocity-amp=5
</CsOptions>
<CsInstruments>
; Initialize the global variables. 
ksmps = 32
nchnls = 2
0dbfs = 1

;instrument will be triggered by keyboard widget
instr 1
kEnv madsr .1, .2, .6, .4
iSemitone = (2^(1/12)*p4)-p4
aOut vco2 p5, p4+iSemitone*chnget:k("fineTune")
outs aOut*kEnv, aOut*kEnv
endin

</CsInstruments>
<CsScore>
;causes Csound to run for about 7000 years...
f0 z
</CsScore>
</CsoundSynthesizer>

yeah, kind of. I want to have a slider control the finetune by + or - 1 semitone, and a combo box controlling the octave.
i have the widgets, i just cant get it to function like i want it tofinettune problemo

That last code I posted should help you then. It will let you fine tune by a semitone. If you want more than change the power to which the base is raised by. 1/2 will give you a semitone. 2/12, two semitones, etc.

I think you can also use octave here…

Psuedo code:
kcps = p4*octave(chnget(“octave”))

Wow, that seems like opcode bloat if ever I saw it :roll_eyes: I see there is also one for semitones. I would much rather see my students try to work these ratios out using simple math than reaching straight for an opcode.

So then, since i want + and -2 octaves, would i have a combo box choosing from a collection of assorted values? (ie 0.25, 0.5, 1, 2, and 4) and then multiply p4+iSemitone*chnget:k(“fineTune”) by thye output?

That should work. I think it should be p4 times octave ratio + semitone times fine tune :wink:

And another opcode for cents too… There’s definitely value in knowing how to do it manually, but at the same time I feel using the opcode for it makes for much clearer reading code.

Currently, I’m using it like this:
kTuneOctaves chnget “octaves”
kTuneSemitones chnget “semitones”
kTuneCents chnget “cents”
kTuneCombo = cent(kTuneCents+(kTuneSemitones100)+(kTuneOctaves1200))

These means everything is done with a very straightforward +/- knob for each control… octave scales -3/+3, semitones -12/+12, and cents -100/+100, each with a stepsize of one (so no +1.5 on octave or anything like that).

But sure, to each their own. I’ll try not to be too bad of an influence on your students in the future :slight_smile:

Ha, I don’t think you could be a bad influence Kevin! It just pains me to see students avoiding math at all costs!