Csound Csound-dev Csound-tekno Search About

[Csnd] Changing a waveform table while playing it?

Date2020-09-06 20:32
FromForrest Cahoon
Subject[Csnd] Changing a waveform table while playing it?
Greetings, Csounders!

I have been experimenting with linear waveforms, as illustrated by this simple sample csd:

<CsoundSynthesizer>
<CsInstruments>

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

giPoint = 0
giTriWave ftgen 0, 0, 8192, 7, 1, giPoint, -1, (8192 - giPoint), 1

instr 1

iAmpl = ampdbfs(p4)
iFreq = p5
aOut poscil iAmpl, iFreq, giTriWave
outs aOut, aOut

endin

</CsInstruments>
<CsScore>
i1 0 4 -1 300
</CsScore>
</CsoundSynthesizer>

Here I use GEN07 to create a waveform whose shape is controlled by giPoint. When giPoint is 0, it's a sawtooth, and when it's 4192, it's a triangle wave.

What I'd like to be able to do is change the value of giPoint while the sound is playing. I know that can't be done with the csd I have here, because the table is set at i-time before the instrument plays.

I see in the docs that some of the table-related opcodes talk about changing tables at k-rate, but I couldn't really figure it out.

Is what I want to do possible? Should I be taking a different approach besides using tables?
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2020-09-06 20:56
Fromjoachim heintz
SubjectRe: [Csnd] Changing a waveform table while playing it?
something like this would be one solution:




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

giPoint = 0
giTriWave ftgen 0, 0, 8192, 7, 1, giPoint, -1, (8192 - giPoint), 1

instr 1
iAmpl = ampdbfs(p4)
iFreq = p5
aOut poscil iAmpl, iFreq, giTriWave
outs aOut, aOut
endin

instr 2
iPoint = 4000
iTriWave ftgen 0, 0, 8192, 7, 1, iPoint, -1, (8192 - iPoint), 1
tableicopy giTriWave, iTriWave
endin



i 1 0 4 -1 300
i 2 2 0



you can call instr 2 as often as you like, also from inside instr 1, 
with schedulek, schedwhen or similar opcodes.

best -
	joachim


On 06/09/2020 21:32, Forrest Cahoon wrote:
> Greetings, Csounders!
> 
> I have been experimenting with linear waveforms, as illustrated by this 
> simple sample csd:
> 
> 
> 
> 
> sr = 48000
> ksmps = 32
> nchnls = 2
> 0dbfs = 1
> 
> giPoint = 0
> giTriWave ftgen 0, 0, 8192, 7, 1, giPoint, -1, (8192 - giPoint), 1
> 
> instr 1
> 
> iAmpl = ampdbfs(p4)
> iFreq = p5
> aOut poscil iAmpl, iFreq, giTriWave
> outs aOut, aOut
> 
> endin
> 
> 
> 
> i1 0 4 -1 300
> 
> 
> 
> Here I use GEN07 to create a waveform whose shape is controlled by 
> giPoint. When giPoint is 0, it's a sawtooth, and when it's 4192, it's a 
> triangle wave.
> 
> What I'd like to be able to do is change the value of giPoint while the 
> sound is playing. I know that can't be done with the csd I have here, 
> because the table is set at i-time before the instrument plays.
> 
> I see in the docs that some of the table-related opcodes talk about 
> changing tables at k-rate, but I couldn't really figure it out.
> 
> Is what I want to do possible? Should I be taking a different approach 
> besides using tables?
> Csound mailing list Csound@listserv.heanet.ie 
>  
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to 
> https://github.com/csound/csound/issues Discussions of bugs and features 
> can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2020-09-06 22:02
From"Jeanette C."
SubjectRe: [Csnd] Changing a waveform table while playing it?
Sep 6 2020, Forrest Cahoon has written:
...
> Here I use GEN07 to create a waveform whose shape is controlled by giPoint.
> When giPoint is 0, it's a sawtooth, and when it's 4192, it's a triangle
> wave.
...
Depending on how much you want to experiment with waveforms, other basic
sound generators spring to mind. The squinewave allows a lot of morphing
between sine, square, saw and triangle. Also one of the vco2 waveforms
morph between saw and triangle. Also you might consider loopseg for a
more general purpose shifting of waveforms there are variants of loopseg
with exponential segments. They have k-rate time/value pairs. The
loopseg family only outputs k-rate signals, but with ksmps set to one
and the a() or interp() opcodes you can convert these back to audio
without any loss of samplerate precision.

If you can imagine/calculate the outcome with waveterrain opcodes are
very powerful! And they were enriched by a few more opcodees in Csound
6.15 by DocB. They allow for a lot of geometric manipulation of
waveforms, though it might be a little difficult to see - without some
thought - what these waveforms will be exactly. Or maybe it's me not
having a good 2d imagination or the mathematics. :)

Best wishes,

Jeanette

-- 
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

I'm so curious, what do you think of me <3
(Britney Spears)

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here