Csound Csound-dev Csound-tekno Search About

[Csnd] more efficient lush synth pad?

Date2019-03-13 01:34
FromEd Cashin
Subject[Csnd] more efficient lush synth pad?
Hi!

In csound I am happy to find I can make a synth pad sound that I imagined.


However!  To avoid overwhelming my laptop, I have to turn ksmps way up (1024) or turn JACK buffering way up.

I suspect I'm maybe missing some opportunities to use tables in order to make things easier computationally.  I would really appreciate hearing any suggestions on how to make the code below leaner while maintaining the lush and dynamic sound.

saws-pad.csd by Ed Cashin 2019, based on
PolyphonyControl.csd
Written by Iain McCurdy 2008, Rewritten 2012 (originally entitled 'MonoOverlaps.csd').

<CsoundSynthesizer>

<CsOptions>
;UNCOMMENT THE FOLLOWING LINE OF CODE IF YOU DO NOT HAVE A MIDI KEYBOARD CONNECTED
; -odac -dm0 -M0 -+rtmidi=virtual
;-odac -3 -+rtaudio=jack -+rtmidi=alsa -M hw:5,0 -dm0
-odac -3 -+rtaudio=jack -+rtmidi=alsa -M hw:5,0 -dm0 -B 4096
</CsOptions>

<CsInstruments>

sr     =     88200 
ksmps     =     1024
nchnls     =     2
0dbfs    =    1

FLcolor    255, 255, 255, 100, 200, 200
        FLpanel    "Polyphony Control", 500, 250, 0, 0

;                                                      ON | OFF | TYPE | WIDTH | HEIGHT | X | Y | OPCODE | INS | STARTTIM | IDUR
gkExit,ihExit    FLbutton    "Exit Example",        1,   0,    21,    120,     25,  375, 200,    0,    999,      0,    0.001

;VALUE DISPLAY BOXES                WIDTH | HEIGHT | X |  Y
idatt            FLvalue    " ",         60,       20,    5,   25
iddec            FLvalue    " ",         60,       20,    5,   75
idsus            FLvalue    " ",         60,       20,    5,  125
idrel            FLvalue    " ",         60,       20,    5,  175

;                                        MIN  | MAX | EXP | TYPE |  DISP  | WIDTH | HEIGHT | X | Y
gkatt, ihatt        FLslider     "Attack Time",        0.01,  12,   -1,    23,   idatt,    490,    25,     5,   0
gkdec, ihdec        FLslider     "Decay Time",        0.01,   8,   -1,    23,   iddec,    490,    25,     5,  50
gksus, ihsus        FLslider     "Sustain Level",    0,      1,    0,    23,   idsus,    490,    25,     5, 100    ;SUSTAIN LEVEL CANNOT BE ZERO FOR mxadsr OPCODE
gkrel, ihrel        FLslider     "Release Time",        0.01,  12,   -1,    23,   idrel,    490,    25,     5, 150

;COUNTERS                            MIN | MAX | STEP1 | STEP2 | TYPE | WIDTH | HEIGHT  | X | Y | OPCODE
gkPolyLimit, ihPolyLimit     FLcount  "Polyphony Limit",     1,    127,     1,      1,      2,   120,      25,    5, 200,   -1

            FLsetVal_i    0.27,     ihatt
            FLsetVal_i    4,     ihdec
            FLsetVal_i    0.42,     ihsus
            FLsetVal_i    1.77,     ihrel
            FLsetVal_i    6,     ihPolyLimit

        FLpanel_end    ;END OF PANEL CONTENTS

        FLrun        ;RUN THE WIDGET THREAD!

;NUMBER OF ACTIVE NOTES
;(NOTES IN RELEASE STAGE REGARDED AS INACTIVE)
gkactive init 0

; output audio
gaL init 0
gaR init 0

instr    1    ; NOTE TRIGGERING INSTRUMENT
    gkactive init i(gkactive) + 1    ;INCREMENT NOTE COUNTER
   
    if gkactive > i(gkPolyLimit) then
      turnoff
    endif

    krel release            ;IF NOTE HELD = 0, IF NOTE RELEASED = 1
    ktrig trigger krel,0.5,0    ;WHEN RELEASE FLAG CROSSES 0.5 UPWARDS, I.E. NOTE HAS BEEN RELEASED...   
    if ktrig==1 then       
     gkactive = gkactive - 1    ;...DECREMENT ACTIVE NOTES COUNTER
    endif

    icps    cpsmidi            ;READ CYCLES PER SECOND VALUES FROM MIDI KEYBOARD INPUT
    iamp    ampmidi    1
    ;                ATT      |  DEC    |  SUS    |   REL
    aenv     madsr     i(gkatt),  i(gkdec), i(gksus),  i(gkrel)    ;MIDI SENSING ADSR ENVELOPE WITH LINEAR SEGMENTS
    kfatt = gkatt
    kfsus ntrpol gksus, iamp, 0.8
    kfco     madsr     i(kfatt),  i(gkdec), i(kfsus),  i(gkrel)    ;MIDI SENSING ADSR ENVELOPE WITH LINEAR SEGMENTS
    ;OUTPUT OPCODE   AMP      CPS FUNCTION_TABLE
    asig    vco2    0.3*iamp, icps, 0                ;AUDIO OSCILLATOR
    ispread init 0.25 ; Hz
    ichaos init 0.6
    asaw1 vco2 iamp / 4, icps - ispread, 0
    asaw2 vco2 iamp / 4, icps + ispread, 0
    klfo1 lfo 0.4, 0.05, 0
    klfo2 lfo 0.3, 0.15, 0
    anoise1 noise ichaos, 0
    anoise2 noise ichaos, 0
    asaw3 vco (iamp / 4) * anoise1, icps + klfo1, 0
    asaw4 vco (iamp / 4) * anoise2, icps + klfo2, 0
    asub vco2 iamp / 2, icps / 2, 12
    kfoldmod1 lfo 3, 0.3
    kfoldmod2 lfo 4, 0.2
    asub1 fold asub, 9.5 + kfoldmod1
    asub2 fold asub, 10.5 + kfoldmod2
     aL = asig + asub1 + asaw1 + asaw3
    aR = asig + asub2 + asaw2 + asaw4
    kfiltmod1 lfo 500, 0.2
    kfiltmod2 lfo 400, 0.1
    kfco = 1
    aL moogladder aL, (7000 + kfiltmod1) * kfco, 0.3, 1
    aR moogladder aR, (7000 + kfiltmod2) * kfco, 0.3, 1
    gaL clip gaL + (aL * aenv), 0, 0.7
    gaR clip gaR + (aL * aenv), 0, 0.7
endin

instr 99
      arL, arR reverbsc gaL, gaR, 0.85, 12000, sr, 0.5, 1
      aoutL ntrpol gaL, arL, 0.6
      aoutR ntrpol gaR, arR, 0.6
      outs aoutL, aoutR
      gaL = 0
      gaR = 0
endin

instr    999    ;QUIT
    exitnow        ;EXIT CSOUND IMMEDIATELY
endin

</CsInstruments>

<CsScore>
f 1 0 32768 10 1
f10 0 65536 10 1 0 0 0 0 0 0 0 0 .05
i 99 0 3600  ; reverb
</CsScore>

</CsoundSynthesizer>


--
  Ed Cashin <ecashin@noserose.net>
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

Date2019-03-13 10:00
From"Jeanette C."
SubjectRe: [Csnd] more efficient lush synth pad?
Mar 13 2019, Ed Cashin has written:
...
> I suspect I'm maybe missing some opportunities to use tables in order to
> make things easier computationally.  I would really appreciate hearing any
> suggestions on how to make the code below leaner while maintaining the lush
> and dynamic sound.
...
Hi Ed,
I'll not work on your code directly. But here are some ideas:
there is the "padsynth" GEN routine to create chorusing/beating sounds.
It's the technique developed by Nasca Octavian Paul for ZynAddSubFX
(Yoshimi).

You could also try for a chorus, either using the flanger effect or
modulating one or more delay lines with LFOs.

Not sure how much this would do: but the randh noise has a frequency
parameter, so you can turn it down. Something like this might help in
variations:
knoise randh kmodamp, kmodfreq
kmodnoise port knoise, islewtime

Other than that I *THINK* that vco2 is quite efficient generating a
sawtooth.

You could try using a sine wave with oscil for your "subharmonic". It
might not change the sound drastically and could decrease CPU usage a
bit.

Best wishes,

Jeanette

-- 
  * Website: http://juliencoder.de - for summer is a state of sound
  * SoundCloud: https://soundcloud.com/jeanette_c
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * GitHub: https://github.com/jeanette-c
  * Twitter: https://twitter.com/jeanette_c_s

Don't worry, you're gonna be alright,
But Cinderella's got to go <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

Date2019-03-13 15:13
Fromthorin kerr
SubjectRe: [Csnd] more efficient lush synth pad?
Attachmentspadoscil.csd  
Hi Ed,

I've found lush pad sounds using a combination of vco2init, vco2ft, and oscbnk. oscbnk lets you have control over the number of oscillators, so, you have some control over efficiency (albeit trading it for 'lushness').

I've attached an example, having a go at the sound you were happy with. See what you think.

Thorin




On Wed, 13 Mar. 2019, 11:34 am Ed Cashin, <ecashin@noserose.net> wrote:
Hi!

In csound I am happy to find I can make a synth pad sound that I imagined.


However!  To avoid overwhelming my laptop, I have to turn ksmps way up (1024) or turn JACK buffering way up.

I suspect I'm maybe missing some opportunities to use tables in order to make things easier computationally.  I would really appreciate hearing any suggestions on how to make the code below leaner while maintaining the lush and dynamic sound.

saws-pad.csd by Ed Cashin 2019, based on
PolyphonyControl.csd
Written by Iain McCurdy 2008, Rewritten 2012 (originally entitled 'MonoOverlaps.csd').

<CsoundSynthesizer>

<CsOptions>
;UNCOMMENT THE FOLLOWING LINE OF CODE IF YOU DO NOT HAVE A MIDI KEYBOARD CONNECTED
; -odac -dm0 -M0 -+rtmidi=virtual
;-odac -3 -+rtaudio=jack -+rtmidi=alsa -M hw:5,0 -dm0
-odac -3 -+rtaudio=jack -+rtmidi=alsa -M hw:5,0 -dm0 -B 4096
</CsOptions>

<CsInstruments>

sr     =     88200 
ksmps     =     1024
nchnls     =     2
0dbfs    =    1

FLcolor    255, 255, 255, 100, 200, 200
        FLpanel    "Polyphony Control", 500, 250, 0, 0

;                                                      ON | OFF | TYPE | WIDTH | HEIGHT | X | Y | OPCODE | INS | STARTTIM | IDUR
gkExit,ihExit    FLbutton    "Exit Example",        1,   0,    21,    120,     25,  375, 200,    0,    999,      0,    0.001

;VALUE DISPLAY BOXES                WIDTH | HEIGHT | X |  Y
idatt            FLvalue    " ",         60,       20,    5,   25
iddec            FLvalue    " ",         60,       20,    5,   75
idsus            FLvalue    " ",         60,       20,    5,  125
idrel            FLvalue    " ",         60,       20,    5,  175

;                                        MIN  | MAX | EXP | TYPE |  DISP  | WIDTH | HEIGHT | X | Y
gkatt, ihatt        FLslider     "Attack Time",        0.01,  12,   -1,    23,   idatt,    490,    25,     5,   0
gkdec, ihdec        FLslider     "Decay Time",        0.01,   8,   -1,    23,   iddec,    490,    25,     5,  50
gksus, ihsus        FLslider     "Sustain Level",    0,      1,    0,    23,   idsus,    490,    25,     5, 100    ;SUSTAIN LEVEL CANNOT BE ZERO FOR mxadsr OPCODE
gkrel, ihrel        FLslider     "Release Time",        0.01,  12,   -1,    23,   idrel,    490,    25,     5, 150

;COUNTERS                            MIN | MAX | STEP1 | STEP2 | TYPE | WIDTH | HEIGHT  | X | Y | OPCODE
gkPolyLimit, ihPolyLimit     FLcount  "Polyphony Limit",     1,    127,     1,      1,      2,   120,      25,    5, 200,   -1

            FLsetVal_i    0.27,     ihatt
            FLsetVal_i    4,     ihdec
            FLsetVal_i    0.42,     ihsus
            FLsetVal_i    1.77,     ihrel
            FLsetVal_i    6,     ihPolyLimit

        FLpanel_end    ;END OF PANEL CONTENTS

        FLrun        ;RUN THE WIDGET THREAD!

;NUMBER OF ACTIVE NOTES
;(NOTES IN RELEASE STAGE REGARDED AS INACTIVE)
gkactive init 0

; output audio
gaL init 0
gaR init 0

instr    1    ; NOTE TRIGGERING INSTRUMENT
    gkactive init i(gkactive) + 1    ;INCREMENT NOTE COUNTER
   
    if gkactive > i(gkPolyLimit) then
      turnoff
    endif

    krel release            ;IF NOTE HELD = 0, IF NOTE RELEASED = 1
    ktrig trigger krel,0.5,0    ;WHEN RELEASE FLAG CROSSES 0.5 UPWARDS, I.E. NOTE HAS BEEN RELEASED...   
    if ktrig==1 then       
     gkactive = gkactive - 1    ;...DECREMENT ACTIVE NOTES COUNTER
    endif

    icps    cpsmidi            ;READ CYCLES PER SECOND VALUES FROM MIDI KEYBOARD INPUT
    iamp    ampmidi    1
    ;                ATT      |  DEC    |  SUS    |   REL
    aenv     madsr     i(gkatt),  i(gkdec), i(gksus),  i(gkrel)    ;MIDI SENSING ADSR ENVELOPE WITH LINEAR SEGMENTS
    kfatt = gkatt
    kfsus ntrpol gksus, iamp, 0.8
    kfco     madsr     i(kfatt),  i(gkdec), i(kfsus),  i(gkrel)    ;MIDI SENSING ADSR ENVELOPE WITH LINEAR SEGMENTS
    ;OUTPUT OPCODE   AMP      CPS FUNCTION_TABLE
    asig    vco2    0.3*iamp, icps, 0                ;AUDIO OSCILLATOR
    ispread init 0.25 ; Hz
    ichaos init 0.6
    asaw1 vco2 iamp / 4, icps - ispread, 0
    asaw2 vco2 iamp / 4, icps + ispread, 0
    klfo1 lfo 0.4, 0.05, 0
    klfo2 lfo 0.3, 0.15, 0
    anoise1 noise ichaos, 0
    anoise2 noise ichaos, 0
    asaw3 vco (iamp / 4) * anoise1, icps + klfo1, 0
    asaw4 vco (iamp / 4) * anoise2, icps + klfo2, 0
    asub vco2 iamp / 2, icps / 2, 12
    kfoldmod1 lfo 3, 0.3
    kfoldmod2 lfo 4, 0.2
    asub1 fold asub, 9.5 + kfoldmod1
    asub2 fold asub, 10.5 + kfoldmod2
     aL = asig + asub1 + asaw1 + asaw3
    aR = asig + asub2 + asaw2 + asaw4
    kfiltmod1 lfo 500, 0.2
    kfiltmod2 lfo 400, 0.1
    kfco = 1
    aL moogladder aL, (7000 + kfiltmod1) * kfco, 0.3, 1
    aR moogladder aR, (7000 + kfiltmod2) * kfco, 0.3, 1
    gaL clip gaL + (aL * aenv), 0, 0.7
    gaR clip gaR + (aL * aenv), 0, 0.7
endin

instr 99
      arL, arR reverbsc gaL, gaR, 0.85, 12000, sr, 0.5, 1
      aoutL ntrpol gaL, arL, 0.6
      aoutR ntrpol gaR, arR, 0.6
      outs aoutL, aoutR
      gaL = 0
      gaR = 0
endin

instr    999    ;QUIT
    exitnow        ;EXIT CSOUND IMMEDIATELY
endin

</CsInstruments>

<CsScore>
f 1 0 32768 10 1
f10 0 65536 10 1 0 0 0 0 0 0 0 0 .05
i 99 0 3600  ; reverb
</CsScore>

</CsoundSynthesizer>


--
  Ed Cashin <ecashin@noserose.net>
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

Date2019-03-13 16:06
FromEd Cashin
SubjectRe: [Csnd] more efficient lush synth pad?
Hi, Jeanette.  Thanks very much for the suggestions!  I'll respond to selected quotes below.

On Wed, Mar 13, 2019 at 6:00 AM Jeanette C. <julien@mail.upb.de> wrote:
... 
there is the "padsynth" GEN routine to create chorusing/beating sounds.
It's the technique developed by Nasca Octavian Paul for ZynAddSubFX
(Yoshimi).

Thanks.  I tried that opcode quite some time ago but should revisit it.
 
You could also try for a chorus, either using the flanger effect or
modulating one or more delay lines with LFOs.

That kind of modulation is different from the ones I have now, but I did add the ensembleChorus UDO by Bhob Rainey at one point. It's a useful tweak, but it adds to the computational complexity, as it cannot be used instead of the rest of the instrument.
 
Not sure how much this would do: but the randh noise has a frequency
parameter, so you can turn it down. Something like this might help in
variations:
knoise randh kmodamp, kmodfreq
kmodnoise port knoise, islewtime

That's a great idea and something I will try!  Thanks.
 
You could try using a sine wave with oscil for your "subharmonic". It
might not change the sound drastically and could decrease CPU usage a
bit.

I preferred the current sound with the folds on the triangle, but maybe that's a compromise to consider.

--
  Ed Cashin <ecashin@noserose.net>
--
  Ed Cashin <ecashin@noserose.net>
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

Date2019-03-13 16:08
FromEd Cashin
SubjectRe: [Csnd] more efficient lush synth pad?
Hi, Thorin! Those are super suggestions, and I appreciate the example. I’m not sure why it gives me a lot of dac buffer underruns at first, but before it ends I do hear a promising and similar pad sound.

I’ll definitely follow up on this approach. Thanks very much.

On Wed, Mar 13, 2019 at 11:14 AM thorin kerr <thorin.kerr@gmail.com> wrote:
Hi Ed,

I've found lush pad sounds using a combination of vco2init, vco2ft, and oscbnk. oscbnk lets you have control over the number of oscillators, so, you have some control over efficiency (albeit trading it for 'lushness').

I've attached an example, having a go at the sound you were happy with. See what you think.

Thorin




On Wed, 13 Mar. 2019, 11:34 am Ed Cashin, <ecashin@noserose.net> wrote:
Hi!

In csound I am happy to find I can make a synth pad sound that I imagined.


However!  To avoid overwhelming my laptop, I have to turn ksmps way up (1024) or turn JACK buffering way up.

I suspect I'm maybe missing some opportunities to use tables in order to make things easier computationally.  I would really appreciate hearing any suggestions on how to make the code below leaner while maintaining the lush and dynamic sound.

saws-pad.csd by Ed Cashin 2019, based on
PolyphonyControl.csd
Written by Iain McCurdy 2008, Rewritten 2012 (originally entitled 'MonoOverlaps.csd').

<CsoundSynthesizer>

<CsOptions>
;UNCOMMENT THE FOLLOWING LINE OF CODE IF YOU DO NOT HAVE A MIDI KEYBOARD CONNECTED
; -odac -dm0 -M0 -+rtmidi=virtual
;-odac -3 -+rtaudio=jack -+rtmidi=alsa -M hw:5,0 -dm0
-odac -3 -+rtaudio=jack -+rtmidi=alsa -M hw:5,0 -dm0 -B 4096
</CsOptions>

<CsInstruments>

sr     =     88200 
ksmps     =     1024
nchnls     =     2
0dbfs    =    1

FLcolor    255, 255, 255, 100, 200, 200
        FLpanel    "Polyphony Control", 500, 250, 0, 0

;                                                      ON | OFF | TYPE | WIDTH | HEIGHT | X | Y | OPCODE | INS | STARTTIM | IDUR
gkExit,ihExit    FLbutton    "Exit Example",        1,   0,    21,    120,     25,  375, 200,    0,    999,      0,    0.001

;VALUE DISPLAY BOXES                WIDTH | HEIGHT | X |  Y
idatt            FLvalue    " ",         60,       20,    5,   25
iddec            FLvalue    " ",         60,       20,    5,   75
idsus            FLvalue    " ",         60,       20,    5,  125
idrel            FLvalue    " ",         60,       20,    5,  175

;                                        MIN  | MAX | EXP | TYPE |  DISP  | WIDTH | HEIGHT | X | Y
gkatt, ihatt        FLslider     "Attack Time",        0.01,  12,   -1,    23,   idatt,    490,    25,     5,   0
gkdec, ihdec        FLslider     "Decay Time",        0.01,   8,   -1,    23,   iddec,    490,    25,     5,  50
gksus, ihsus        FLslider     "Sustain Level",    0,      1,    0,    23,   idsus,    490,    25,     5, 100    ;SUSTAIN LEVEL CANNOT BE ZERO FOR mxadsr OPCODE
gkrel, ihrel        FLslider     "Release Time",        0.01,  12,   -1,    23,   idrel,    490,    25,     5, 150

;COUNTERS                            MIN | MAX | STEP1 | STEP2 | TYPE | WIDTH | HEIGHT  | X | Y | OPCODE
gkPolyLimit, ihPolyLimit     FLcount  "Polyphony Limit",     1,    127,     1,      1,      2,   120,      25,    5, 200,   -1

            FLsetVal_i    0.27,     ihatt
            FLsetVal_i    4,     ihdec
            FLsetVal_i    0.42,     ihsus
            FLsetVal_i    1.77,     ihrel
            FLsetVal_i    6,     ihPolyLimit

        FLpanel_end    ;END OF PANEL CONTENTS

        FLrun        ;RUN THE WIDGET THREAD!

;NUMBER OF ACTIVE NOTES
;(NOTES IN RELEASE STAGE REGARDED AS INACTIVE)
gkactive init 0

; output audio
gaL init 0
gaR init 0

instr    1    ; NOTE TRIGGERING INSTRUMENT
    gkactive init i(gkactive) + 1    ;INCREMENT NOTE COUNTER
   
    if gkactive > i(gkPolyLimit) then
      turnoff
    endif

    krel release            ;IF NOTE HELD = 0, IF NOTE RELEASED = 1
    ktrig trigger krel,0.5,0    ;WHEN RELEASE FLAG CROSSES 0.5 UPWARDS, I.E. NOTE HAS BEEN RELEASED...   
    if ktrig==1 then       
     gkactive = gkactive - 1    ;...DECREMENT ACTIVE NOTES COUNTER
    endif

    icps    cpsmidi            ;READ CYCLES PER SECOND VALUES FROM MIDI KEYBOARD INPUT
    iamp    ampmidi    1
    ;                ATT      |  DEC    |  SUS    |   REL
    aenv     madsr     i(gkatt),  i(gkdec), i(gksus),  i(gkrel)    ;MIDI SENSING ADSR ENVELOPE WITH LINEAR SEGMENTS
    kfatt = gkatt
    kfsus ntrpol gksus, iamp, 0.8
    kfco     madsr     i(kfatt),  i(gkdec), i(kfsus),  i(gkrel)    ;MIDI SENSING ADSR ENVELOPE WITH LINEAR SEGMENTS
    ;OUTPUT OPCODE   AMP      CPS FUNCTION_TABLE
    asig    vco2    0.3*iamp, icps, 0                ;AUDIO OSCILLATOR
    ispread init 0.25 ; Hz
    ichaos init 0.6
    asaw1 vco2 iamp / 4, icps - ispread, 0
    asaw2 vco2 iamp / 4, icps + ispread, 0
    klfo1 lfo 0.4, 0.05, 0
    klfo2 lfo 0.3, 0.15, 0
    anoise1 noise ichaos, 0
    anoise2 noise ichaos, 0
    asaw3 vco (iamp / 4) * anoise1, icps + klfo1, 0
    asaw4 vco (iamp / 4) * anoise2, icps + klfo2, 0
    asub vco2 iamp / 2, icps / 2, 12
    kfoldmod1 lfo 3, 0.3
    kfoldmod2 lfo 4, 0.2
    asub1 fold asub, 9.5 + kfoldmod1
    asub2 fold asub, 10.5 + kfoldmod2
     aL = asig + asub1 + asaw1 + asaw3
    aR = asig + asub2 + asaw2 + asaw4
    kfiltmod1 lfo 500, 0.2
    kfiltmod2 lfo 400, 0.1
    kfco = 1
    aL moogladder aL, (7000 + kfiltmod1) * kfco, 0.3, 1
    aR moogladder aR, (7000 + kfiltmod2) * kfco, 0.3, 1
    gaL clip gaL + (aL * aenv), 0, 0.7
    gaR clip gaR + (aL * aenv), 0, 0.7
endin

instr 99
      arL, arR reverbsc gaL, gaR, 0.85, 12000, sr, 0.5, 1
      aoutL ntrpol gaL, arL, 0.6
      aoutR ntrpol gaR, arR, 0.6
      outs aoutL, aoutR
      gaL = 0
      gaR = 0
endin

instr    999    ;QUIT
    exitnow        ;EXIT CSOUND IMMEDIATELY
endin

</CsInstruments>

<CsScore>
f 1 0 32768 10 1
f10 0 65536 10 1 0 0 0 0 0 0 0 0 .05
i 99 0 3600  ; reverb
</CsScore>

</CsoundSynthesizer>


--
  Ed Cashin <ecashin@noserose.net>
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
--
  Ed Cashin <ecashin@noserose.net>
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

Date2019-03-13 21:56
Fromthorin kerr
SubjectRe: [Csnd] more efficient lush synth pad?
Hmm, there are a lot of tables initialised by vco2init at the beginning.

Just speculating, but do you have extra flags like --realtime or --num-threads in play?

Thorin




On Thu, 14 Mar. 2019, 2:08 am Ed Cashin, <ecashin@noserose.net> wrote:
Hi, Thorin! Those are super suggestions, and I appreciate the example. I’m not sure why it gives me a lot of dac buffer underruns at first, but before it ends I do hear a promising and similar pad sound.

I’ll definitely follow up on this approach. Thanks very much.

On Wed, Mar 13, 2019 at 11:14 AM thorin kerr <thorin.kerr@gmail.com> wrote:
Hi Ed,

I've found lush pad sounds using a combination of vco2init, vco2ft, and oscbnk. oscbnk lets you have control over the number of oscillators, so, you have some control over efficiency (albeit trading it for 'lushness').

I've attached an example, having a go at the sound you were happy with. See what you think.

Thorin




On Wed, 13 Mar. 2019, 11:34 am Ed Cashin, <ecashin@noserose.net> wrote:
Hi!

In csound I am happy to find I can make a synth pad sound that I imagined.


However!  To avoid overwhelming my laptop, I have to turn ksmps way up (1024) or turn JACK buffering way up.

I suspect I'm maybe missing some opportunities to use tables in order to make things easier computationally.  I would really appreciate hearing any suggestions on how to make the code below leaner while maintaining the lush and dynamic sound.

saws-pad.csd by Ed Cashin 2019, based on
PolyphonyControl.csd
Written by Iain McCurdy 2008, Rewritten 2012 (originally entitled 'MonoOverlaps.csd').

<CsoundSynthesizer>

<CsOptions>
;UNCOMMENT THE FOLLOWING LINE OF CODE IF YOU DO NOT HAVE A MIDI KEYBOARD CONNECTED
; -odac -dm0 -M0 -+rtmidi=virtual
;-odac -3 -+rtaudio=jack -+rtmidi=alsa -M hw:5,0 -dm0
-odac -3 -+rtaudio=jack -+rtmidi=alsa -M hw:5,0 -dm0 -B 4096
</CsOptions>

<CsInstruments>

sr     =     88200 
ksmps     =     1024
nchnls     =     2
0dbfs    =    1

FLcolor    255, 255, 255, 100, 200, 200
        FLpanel    "Polyphony Control", 500, 250, 0, 0

;                                                      ON | OFF | TYPE | WIDTH | HEIGHT | X | Y | OPCODE | INS | STARTTIM | IDUR
gkExit,ihExit    FLbutton    "Exit Example",        1,   0,    21,    120,     25,  375, 200,    0,    999,      0,    0.001

;VALUE DISPLAY BOXES                WIDTH | HEIGHT | X |  Y
idatt            FLvalue    " ",         60,       20,    5,   25
iddec            FLvalue    " ",         60,       20,    5,   75
idsus            FLvalue    " ",         60,       20,    5,  125
idrel            FLvalue    " ",         60,       20,    5,  175

;                                        MIN  | MAX | EXP | TYPE |  DISP  | WIDTH | HEIGHT | X | Y
gkatt, ihatt        FLslider     "Attack Time",        0.01,  12,   -1,    23,   idatt,    490,    25,     5,   0
gkdec, ihdec        FLslider     "Decay Time",        0.01,   8,   -1,    23,   iddec,    490,    25,     5,  50
gksus, ihsus        FLslider     "Sustain Level",    0,      1,    0,    23,   idsus,    490,    25,     5, 100    ;SUSTAIN LEVEL CANNOT BE ZERO FOR mxadsr OPCODE
gkrel, ihrel        FLslider     "Release Time",        0.01,  12,   -1,    23,   idrel,    490,    25,     5, 150

;COUNTERS                            MIN | MAX | STEP1 | STEP2 | TYPE | WIDTH | HEIGHT  | X | Y | OPCODE
gkPolyLimit, ihPolyLimit     FLcount  "Polyphony Limit",     1,    127,     1,      1,      2,   120,      25,    5, 200,   -1

            FLsetVal_i    0.27,     ihatt
            FLsetVal_i    4,     ihdec
            FLsetVal_i    0.42,     ihsus
            FLsetVal_i    1.77,     ihrel
            FLsetVal_i    6,     ihPolyLimit

        FLpanel_end    ;END OF PANEL CONTENTS

        FLrun        ;RUN THE WIDGET THREAD!

;NUMBER OF ACTIVE NOTES
;(NOTES IN RELEASE STAGE REGARDED AS INACTIVE)
gkactive init 0

; output audio
gaL init 0
gaR init 0

instr    1    ; NOTE TRIGGERING INSTRUMENT
    gkactive init i(gkactive) + 1    ;INCREMENT NOTE COUNTER
   
    if gkactive > i(gkPolyLimit) then
      turnoff
    endif

    krel release            ;IF NOTE HELD = 0, IF NOTE RELEASED = 1
    ktrig trigger krel,0.5,0    ;WHEN RELEASE FLAG CROSSES 0.5 UPWARDS, I.E. NOTE HAS BEEN RELEASED...   
    if ktrig==1 then       
     gkactive = gkactive - 1    ;...DECREMENT ACTIVE NOTES COUNTER
    endif

    icps    cpsmidi            ;READ CYCLES PER SECOND VALUES FROM MIDI KEYBOARD INPUT
    iamp    ampmidi    1
    ;                ATT      |  DEC    |  SUS    |   REL
    aenv     madsr     i(gkatt),  i(gkdec), i(gksus),  i(gkrel)    ;MIDI SENSING ADSR ENVELOPE WITH LINEAR SEGMENTS
    kfatt = gkatt
    kfsus ntrpol gksus, iamp, 0.8
    kfco     madsr     i(kfatt),  i(gkdec), i(kfsus),  i(gkrel)    ;MIDI SENSING ADSR ENVELOPE WITH LINEAR SEGMENTS
    ;OUTPUT OPCODE   AMP      CPS FUNCTION_TABLE
    asig    vco2    0.3*iamp, icps, 0                ;AUDIO OSCILLATOR
    ispread init 0.25 ; Hz
    ichaos init 0.6
    asaw1 vco2 iamp / 4, icps - ispread, 0
    asaw2 vco2 iamp / 4, icps + ispread, 0
    klfo1 lfo 0.4, 0.05, 0
    klfo2 lfo 0.3, 0.15, 0
    anoise1 noise ichaos, 0
    anoise2 noise ichaos, 0
    asaw3 vco (iamp / 4) * anoise1, icps + klfo1, 0
    asaw4 vco (iamp / 4) * anoise2, icps + klfo2, 0
    asub vco2 iamp / 2, icps / 2, 12
    kfoldmod1 lfo 3, 0.3
    kfoldmod2 lfo 4, 0.2
    asub1 fold asub, 9.5 + kfoldmod1
    asub2 fold asub, 10.5 + kfoldmod2
     aL = asig + asub1 + asaw1 + asaw3
    aR = asig + asub2 + asaw2 + asaw4
    kfiltmod1 lfo 500, 0.2
    kfiltmod2 lfo 400, 0.1
    kfco = 1
    aL moogladder aL, (7000 + kfiltmod1) * kfco, 0.3, 1
    aR moogladder aR, (7000 + kfiltmod2) * kfco, 0.3, 1
    gaL clip gaL + (aL * aenv), 0, 0.7
    gaR clip gaR + (aL * aenv), 0, 0.7
endin

instr 99
      arL, arR reverbsc gaL, gaR, 0.85, 12000, sr, 0.5, 1
      aoutL ntrpol gaL, arL, 0.6
      aoutR ntrpol gaR, arR, 0.6
      outs aoutL, aoutR
      gaL = 0
      gaR = 0
endin

instr    999    ;QUIT
    exitnow        ;EXIT CSOUND IMMEDIATELY
endin

</CsInstruments>

<CsScore>
f 1 0 32768 10 1
f10 0 65536 10 1 0 0 0 0 0 0 0 0 .05
i 99 0 3600  ; reverb
</CsScore>

</CsoundSynthesizer>


--
  Ed Cashin <ecashin@noserose.net>
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
--
  Ed Cashin <ecashin@noserose.net>
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

On Thu, 14 Mar. 2019, 2:08 am Ed Cashin, <ecashin@noserose.net> wrote:
Hi, Thorin! Those are super suggestions, and I appreciate the example. I’m not sure why it gives me a lot of dac buffer underruns at first, but before it ends I do hear a promising and similar pad sound.

I’ll definitely follow up on this approach. Thanks very much.

On Wed, Mar 13, 2019 at 11:14 AM thorin kerr <thorin.kerr@gmail.com> wrote:
Hi Ed,

I've found lush pad sounds using a combination of vco2init, vco2ft, and oscbnk. oscbnk lets you have control over the number of oscillators, so, you have some control over efficiency (albeit trading it for 'lushness').

I've attached an example, having a go at the sound you were happy with. See what you think.

Thorin




On Wed, 13 Mar. 2019, 11:34 am Ed Cashin, <ecashin@noserose.net> wrote:
Hi!

In csound I am happy to find I can make a synth pad sound that I imagined.


However!  To avoid overwhelming my laptop, I have to turn ksmps way up (1024) or turn JACK buffering way up.

I suspect I'm maybe missing some opportunities to use tables in order to make things easier computationally.  I would really appreciate hearing any suggestions on how to make the code below leaner while maintaining the lush and dynamic sound.

saws-pad.csd by Ed Cashin 2019, based on
PolyphonyControl.csd
Written by Iain McCurdy 2008, Rewritten 2012 (originally entitled 'MonoOverlaps.csd').

<CsoundSynthesizer>

<CsOptions>
;UNCOMMENT THE FOLLOWING LINE OF CODE IF YOU DO NOT HAVE A MIDI KEYBOARD CONNECTED
; -odac -dm0 -M0 -+rtmidi=virtual
;-odac -3 -+rtaudio=jack -+rtmidi=alsa -M hw:5,0 -dm0
-odac -3 -+rtaudio=jack -+rtmidi=alsa -M hw:5,0 -dm0 -B 4096
</CsOptions>

<CsInstruments>

sr     =     88200 
ksmps     =     1024
nchnls     =     2
0dbfs    =    1

FLcolor    255, 255, 255, 100, 200, 200
        FLpanel    "Polyphony Control", 500, 250, 0, 0

;                                                      ON | OFF | TYPE | WIDTH | HEIGHT | X | Y | OPCODE | INS | STARTTIM | IDUR
gkExit,ihExit    FLbutton    "Exit Example",        1,   0,    21,    120,     25,  375, 200,    0,    999,      0,    0.001

;VALUE DISPLAY BOXES                WIDTH | HEIGHT | X |  Y
idatt            FLvalue    " ",         60,       20,    5,   25
iddec            FLvalue    " ",         60,       20,    5,   75
idsus            FLvalue    " ",         60,       20,    5,  125
idrel            FLvalue    " ",         60,       20,    5,  175

;                                        MIN  | MAX | EXP | TYPE |  DISP  | WIDTH | HEIGHT | X | Y
gkatt, ihatt        FLslider     "Attack Time",        0.01,  12,   -1,    23,   idatt,    490,    25,     5,   0
gkdec, ihdec        FLslider     "Decay Time",        0.01,   8,   -1,    23,   iddec,    490,    25,     5,  50
gksus, ihsus        FLslider     "Sustain Level",    0,      1,    0,    23,   idsus,    490,    25,     5, 100    ;SUSTAIN LEVEL CANNOT BE ZERO FOR mxadsr OPCODE
gkrel, ihrel        FLslider     "Release Time",        0.01,  12,   -1,    23,   idrel,    490,    25,     5, 150

;COUNTERS                            MIN | MAX | STEP1 | STEP2 | TYPE | WIDTH | HEIGHT  | X | Y | OPCODE
gkPolyLimit, ihPolyLimit     FLcount  "Polyphony Limit",     1,    127,     1,      1,      2,   120,      25,    5, 200,   -1

            FLsetVal_i    0.27,     ihatt
            FLsetVal_i    4,     ihdec
            FLsetVal_i    0.42,     ihsus
            FLsetVal_i    1.77,     ihrel
            FLsetVal_i    6,     ihPolyLimit

        FLpanel_end    ;END OF PANEL CONTENTS

        FLrun        ;RUN THE WIDGET THREAD!

;NUMBER OF ACTIVE NOTES
;(NOTES IN RELEASE STAGE REGARDED AS INACTIVE)
gkactive init 0

; output audio
gaL init 0
gaR init 0

instr    1    ; NOTE TRIGGERING INSTRUMENT
    gkactive init i(gkactive) + 1    ;INCREMENT NOTE COUNTER
   
    if gkactive > i(gkPolyLimit) then
      turnoff
    endif

    krel release            ;IF NOTE HELD = 0, IF NOTE RELEASED = 1
    ktrig trigger krel,0.5,0    ;WHEN RELEASE FLAG CROSSES 0.5 UPWARDS, I.E. NOTE HAS BEEN RELEASED...   
    if ktrig==1 then       
     gkactive = gkactive - 1    ;...DECREMENT ACTIVE NOTES COUNTER
    endif

    icps    cpsmidi            ;READ CYCLES PER SECOND VALUES FROM MIDI KEYBOARD INPUT
    iamp    ampmidi    1
    ;                ATT      |  DEC    |  SUS    |   REL
    aenv     madsr     i(gkatt),  i(gkdec), i(gksus),  i(gkrel)    ;MIDI SENSING ADSR ENVELOPE WITH LINEAR SEGMENTS
    kfatt = gkatt
    kfsus ntrpol gksus, iamp, 0.8
    kfco     madsr     i(kfatt),  i(gkdec), i(kfsus),  i(gkrel)    ;MIDI SENSING ADSR ENVELOPE WITH LINEAR SEGMENTS
    ;OUTPUT OPCODE   AMP      CPS FUNCTION_TABLE
    asig    vco2    0.3*iamp, icps, 0                ;AUDIO OSCILLATOR
    ispread init 0.25 ; Hz
    ichaos init 0.6
    asaw1 vco2 iamp / 4, icps - ispread, 0
    asaw2 vco2 iamp / 4, icps + ispread, 0
    klfo1 lfo 0.4, 0.05, 0
    klfo2 lfo 0.3, 0.15, 0
    anoise1 noise ichaos, 0
    anoise2 noise ichaos, 0
    asaw3 vco (iamp / 4) * anoise1, icps + klfo1, 0
    asaw4 vco (iamp / 4) * anoise2, icps + klfo2, 0
    asub vco2 iamp / 2, icps / 2, 12
    kfoldmod1 lfo 3, 0.3
    kfoldmod2 lfo 4, 0.2
    asub1 fold asub, 9.5 + kfoldmod1
    asub2 fold asub, 10.5 + kfoldmod2
     aL = asig + asub1 + asaw1 + asaw3
    aR = asig + asub2 + asaw2 + asaw4
    kfiltmod1 lfo 500, 0.2
    kfiltmod2 lfo 400, 0.1
    kfco = 1
    aL moogladder aL, (7000 + kfiltmod1) * kfco, 0.3, 1
    aR moogladder aR, (7000 + kfiltmod2) * kfco, 0.3, 1
    gaL clip gaL + (aL * aenv), 0, 0.7
    gaR clip gaR + (aL * aenv), 0, 0.7
endin

instr 99
      arL, arR reverbsc gaL, gaR, 0.85, 12000, sr, 0.5, 1
      aoutL ntrpol gaL, arL, 0.6
      aoutR ntrpol gaR, arR, 0.6
      outs aoutL, aoutR
      gaL = 0
      gaR = 0
endin

instr    999    ;QUIT
    exitnow        ;EXIT CSOUND IMMEDIATELY
endin

</CsInstruments>

<CsScore>
f 1 0 32768 10 1
f10 0 65536 10 1 0 0 0 0 0 0 0 0 .05
i 99 0 3600  ; reverb
</CsScore>

</CsoundSynthesizer>


--
  Ed Cashin <ecashin@noserose.net>
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
--
  Ed Cashin <ecashin@noserose.net>
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

Date2019-03-13 22:58
FromBernt Isak Wærstad
SubjectRe: [Csnd] more efficient lush synth pad?
I think moogladder is quite expensive, so perhaps try to not have an instance on each voice and move it to the global instrument instead? Or try with something like lpf18 instead


On Wed, 13 Mar 2019 at 22:56, thorin kerr <thorin.kerr@gmail.com> wrote:
Hmm, there are a lot of tables initialised by vco2init at the beginning.

Just speculating, but do you have extra flags like --realtime or --num-threads in play?

Thorin




On Thu, 14 Mar. 2019, 2:08 am Ed Cashin, <ecashin@noserose.net> wrote:
Hi, Thorin! Those are super suggestions, and I appreciate the example. I’m not sure why it gives me a lot of dac buffer underruns at first, but before it ends I do hear a promising and similar pad sound.

I’ll definitely follow up on this approach. Thanks very much.

On Wed, Mar 13, 2019 at 11:14 AM thorin kerr <thorin.kerr@gmail.com> wrote:
Hi Ed,

I've found lush pad sounds using a combination of vco2init, vco2ft, and oscbnk. oscbnk lets you have control over the number of oscillators, so, you have some control over efficiency (albeit trading it for 'lushness').

I've attached an example, having a go at the sound you were happy with. See what you think.

Thorin




On Wed, 13 Mar. 2019, 11:34 am Ed Cashin, <ecashin@noserose.net> wrote:
Hi!

In csound I am happy to find I can make a synth pad sound that I imagined.


However!  To avoid overwhelming my laptop, I have to turn ksmps way up (1024) or turn JACK buffering way up.

I suspect I'm maybe missing some opportunities to use tables in order to make things easier computationally.  I would really appreciate hearing any suggestions on how to make the code below leaner while maintaining the lush and dynamic sound.

saws-pad.csd by Ed Cashin 2019, based on
PolyphonyControl.csd
Written by Iain McCurdy 2008, Rewritten 2012 (originally entitled 'MonoOverlaps.csd').

<CsoundSynthesizer>

<CsOptions>
;UNCOMMENT THE FOLLOWING LINE OF CODE IF YOU DO NOT HAVE A MIDI KEYBOARD CONNECTED
; -odac -dm0 -M0 -+rtmidi=virtual
;-odac -3 -+rtaudio=jack -+rtmidi=alsa -M hw:5,0 -dm0
-odac -3 -+rtaudio=jack -+rtmidi=alsa -M hw:5,0 -dm0 -B 4096
</CsOptions>

<CsInstruments>

sr     =     88200 
ksmps     =     1024
nchnls     =     2
0dbfs    =    1

FLcolor    255, 255, 255, 100, 200, 200
        FLpanel    "Polyphony Control", 500, 250, 0, 0

;                                                      ON | OFF | TYPE | WIDTH | HEIGHT | X | Y | OPCODE | INS | STARTTIM | IDUR
gkExit,ihExit    FLbutton    "Exit Example",        1,   0,    21,    120,     25,  375, 200,    0,    999,      0,    0.001

;VALUE DISPLAY BOXES                WIDTH | HEIGHT | X |  Y
idatt            FLvalue    " ",         60,       20,    5,   25
iddec            FLvalue    " ",         60,       20,    5,   75
idsus            FLvalue    " ",         60,       20,    5,  125
idrel            FLvalue    " ",         60,       20,    5,  175

;                                        MIN  | MAX | EXP | TYPE |  DISP  | WIDTH | HEIGHT | X | Y
gkatt, ihatt        FLslider     "Attack Time",        0.01,  12,   -1,    23,   idatt,    490,    25,     5,   0
gkdec, ihdec        FLslider     "Decay Time",        0.01,   8,   -1,    23,   iddec,    490,    25,     5,  50
gksus, ihsus        FLslider     "Sustain Level",    0,      1,    0,    23,   idsus,    490,    25,     5, 100    ;SUSTAIN LEVEL CANNOT BE ZERO FOR mxadsr OPCODE
gkrel, ihrel        FLslider     "Release Time",        0.01,  12,   -1,    23,   idrel,    490,    25,     5, 150

;COUNTERS                            MIN | MAX | STEP1 | STEP2 | TYPE | WIDTH | HEIGHT  | X | Y | OPCODE
gkPolyLimit, ihPolyLimit     FLcount  "Polyphony Limit",     1,    127,     1,      1,      2,   120,      25,    5, 200,   -1

            FLsetVal_i    0.27,     ihatt
            FLsetVal_i    4,     ihdec
            FLsetVal_i    0.42,     ihsus
            FLsetVal_i    1.77,     ihrel
            FLsetVal_i    6,     ihPolyLimit

        FLpanel_end    ;END OF PANEL CONTENTS

        FLrun        ;RUN THE WIDGET THREAD!

;NUMBER OF ACTIVE NOTES
;(NOTES IN RELEASE STAGE REGARDED AS INACTIVE)
gkactive init 0

; output audio
gaL init 0
gaR init 0

instr    1    ; NOTE TRIGGERING INSTRUMENT
    gkactive init i(gkactive) + 1    ;INCREMENT NOTE COUNTER
   
    if gkactive > i(gkPolyLimit) then
      turnoff
    endif

    krel release            ;IF NOTE HELD = 0, IF NOTE RELEASED = 1
    ktrig trigger krel,0.5,0    ;WHEN RELEASE FLAG CROSSES 0.5 UPWARDS, I.E. NOTE HAS BEEN RELEASED...   
    if ktrig==1 then       
     gkactive = gkactive - 1    ;...DECREMENT ACTIVE NOTES COUNTER
    endif

    icps    cpsmidi            ;READ CYCLES PER SECOND VALUES FROM MIDI KEYBOARD INPUT
    iamp    ampmidi    1
    ;                ATT      |  DEC    |  SUS    |   REL
    aenv     madsr     i(gkatt),  i(gkdec), i(gksus),  i(gkrel)    ;MIDI SENSING ADSR ENVELOPE WITH LINEAR SEGMENTS
    kfatt = gkatt
    kfsus ntrpol gksus, iamp, 0.8
    kfco     madsr     i(kfatt),  i(gkdec), i(kfsus),  i(gkrel)    ;MIDI SENSING ADSR ENVELOPE WITH LINEAR SEGMENTS
    ;OUTPUT OPCODE   AMP      CPS FUNCTION_TABLE
    asig    vco2    0.3*iamp, icps, 0                ;AUDIO OSCILLATOR
    ispread init 0.25 ; Hz
    ichaos init 0.6
    asaw1 vco2 iamp / 4, icps - ispread, 0
    asaw2 vco2 iamp / 4, icps + ispread, 0
    klfo1 lfo 0.4, 0.05, 0
    klfo2 lfo 0.3, 0.15, 0
    anoise1 noise ichaos, 0
    anoise2 noise ichaos, 0
    asaw3 vco (iamp / 4) * anoise1, icps + klfo1, 0
    asaw4 vco (iamp / 4) * anoise2, icps + klfo2, 0
    asub vco2 iamp / 2, icps / 2, 12
    kfoldmod1 lfo 3, 0.3
    kfoldmod2 lfo 4, 0.2
    asub1 fold asub, 9.5 + kfoldmod1
    asub2 fold asub, 10.5 + kfoldmod2
     aL = asig + asub1 + asaw1 + asaw3
    aR = asig + asub2 + asaw2 + asaw4
    kfiltmod1 lfo 500, 0.2
    kfiltmod2 lfo 400, 0.1
    kfco = 1
    aL moogladder aL, (7000 + kfiltmod1) * kfco, 0.3, 1
    aR moogladder aR, (7000 + kfiltmod2) * kfco, 0.3, 1
    gaL clip gaL + (aL * aenv), 0, 0.7
    gaR clip gaR + (aL * aenv), 0, 0.7
endin

instr 99
      arL, arR reverbsc gaL, gaR, 0.85, 12000, sr, 0.5, 1
      aoutL ntrpol gaL, arL, 0.6
      aoutR ntrpol gaR, arR, 0.6
      outs aoutL, aoutR
      gaL = 0
      gaR = 0
endin

instr    999    ;QUIT
    exitnow        ;EXIT CSOUND IMMEDIATELY
endin

</CsInstruments>

<CsScore>
f 1 0 32768 10 1
f10 0 65536 10 1 0 0 0 0 0 0 0 0 .05
i 99 0 3600  ; reverb
</CsScore>

</CsoundSynthesizer>


--
  Ed Cashin <ecashin@noserose.net>
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
--
  Ed Cashin <ecashin@noserose.net>
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

On Thu, 14 Mar. 2019, 2:08 am Ed Cashin, <ecashin@noserose.net> wrote:
Hi, Thorin! Those are super suggestions, and I appreciate the example. I’m not sure why it gives me a lot of dac buffer underruns at first, but before it ends I do hear a promising and similar pad sound.

I’ll definitely follow up on this approach. Thanks very much.

On Wed, Mar 13, 2019 at 11:14 AM thorin kerr <thorin.kerr@gmail.com> wrote:
Hi Ed,

I've found lush pad sounds using a combination of vco2init, vco2ft, and oscbnk. oscbnk lets you have control over the number of oscillators, so, you have some control over efficiency (albeit trading it for 'lushness').

I've attached an example, having a go at the sound you were happy with. See what you think.

Thorin




On Wed, 13 Mar. 2019, 11:34 am Ed Cashin, <ecashin@noserose.net> wrote:
Hi!

In csound I am happy to find I can make a synth pad sound that I imagined.


However!  To avoid overwhelming my laptop, I have to turn ksmps way up (1024) or turn JACK buffering way up.

I suspect I'm maybe missing some opportunities to use tables in order to make things easier computationally.  I would really appreciate hearing any suggestions on how to make the code below leaner while maintaining the lush and dynamic sound.

saws-pad.csd by Ed Cashin 2019, based on
PolyphonyControl.csd
Written by Iain McCurdy 2008, Rewritten 2012 (originally entitled 'MonoOverlaps.csd').

<CsoundSynthesizer>

<CsOptions>
;UNCOMMENT THE FOLLOWING LINE OF CODE IF YOU DO NOT HAVE A MIDI KEYBOARD CONNECTED
; -odac -dm0 -M0 -+rtmidi=virtual
;-odac -3 -+rtaudio=jack -+rtmidi=alsa -M hw:5,0 -dm0
-odac -3 -+rtaudio=jack -+rtmidi=alsa -M hw:5,0 -dm0 -B 4096
</CsOptions>

<CsInstruments>

sr     =     88200 
ksmps     =     1024
nchnls     =     2
0dbfs    =    1

FLcolor    255, 255, 255, 100, 200, 200
        FLpanel    "Polyphony Control", 500, 250, 0, 0

;                                                      ON | OFF | TYPE | WIDTH | HEIGHT | X | Y | OPCODE | INS | STARTTIM | IDUR
gkExit,ihExit    FLbutton    "Exit Example",        1,   0,    21,    120,     25,  375, 200,    0,    999,      0,    0.001

;VALUE DISPLAY BOXES                WIDTH | HEIGHT | X |  Y
idatt            FLvalue    " ",         60,       20,    5,   25
iddec            FLvalue    " ",         60,       20,    5,   75
idsus            FLvalue    " ",         60,       20,    5,  125
idrel            FLvalue    " ",         60,       20,    5,  175

;                                        MIN  | MAX | EXP | TYPE |  DISP  | WIDTH | HEIGHT | X | Y
gkatt, ihatt        FLslider     "Attack Time",        0.01,  12,   -1,    23,   idatt,    490,    25,     5,   0
gkdec, ihdec        FLslider     "Decay Time",        0.01,   8,   -1,    23,   iddec,    490,    25,     5,  50
gksus, ihsus        FLslider     "Sustain Level",    0,      1,    0,    23,   idsus,    490,    25,     5, 100    ;SUSTAIN LEVEL CANNOT BE ZERO FOR mxadsr OPCODE
gkrel, ihrel        FLslider     "Release Time",        0.01,  12,   -1,    23,   idrel,    490,    25,     5, 150

;COUNTERS                            MIN | MAX | STEP1 | STEP2 | TYPE | WIDTH | HEIGHT  | X | Y | OPCODE
gkPolyLimit, ihPolyLimit     FLcount  "Polyphony Limit",     1,    127,     1,      1,      2,   120,      25,    5, 200,   -1

            FLsetVal_i    0.27,     ihatt
            FLsetVal_i    4,     ihdec
            FLsetVal_i    0.42,     ihsus
            FLsetVal_i    1.77,     ihrel
            FLsetVal_i    6,     ihPolyLimit

        FLpanel_end    ;END OF PANEL CONTENTS

        FLrun        ;RUN THE WIDGET THREAD!

;NUMBER OF ACTIVE NOTES
;(NOTES IN RELEASE STAGE REGARDED AS INACTIVE)
gkactive init 0

; output audio
gaL init 0
gaR init 0

instr    1    ; NOTE TRIGGERING INSTRUMENT
    gkactive init i(gkactive) + 1    ;INCREMENT NOTE COUNTER
   
    if gkactive > i(gkPolyLimit) then
      turnoff
    endif

    krel release            ;IF NOTE HELD = 0, IF NOTE RELEASED = 1
    ktrig trigger krel,0.5,0    ;WHEN RELEASE FLAG CROSSES 0.5 UPWARDS, I.E. NOTE HAS BEEN RELEASED...   
    if ktrig==1 then       
     gkactive = gkactive - 1    ;...DECREMENT ACTIVE NOTES COUNTER
    endif

    icps    cpsmidi            ;READ CYCLES PER SECOND VALUES FROM MIDI KEYBOARD INPUT
    iamp    ampmidi    1
    ;                ATT      |  DEC    |  SUS    |   REL
    aenv     madsr     i(gkatt),  i(gkdec), i(gksus),  i(gkrel)    ;MIDI SENSING ADSR ENVELOPE WITH LINEAR SEGMENTS
    kfatt = gkatt
    kfsus ntrpol gksus, iamp, 0.8
    kfco     madsr     i(kfatt),  i(gkdec), i(kfsus),  i(gkrel)    ;MIDI SENSING ADSR ENVELOPE WITH LINEAR SEGMENTS
    ;OUTPUT OPCODE   AMP      CPS FUNCTION_TABLE
    asig    vco2    0.3*iamp, icps, 0                ;AUDIO OSCILLATOR
    ispread init 0.25 ; Hz
    ichaos init 0.6
    asaw1 vco2 iamp / 4, icps - ispread, 0
    asaw2 vco2 iamp / 4, icps + ispread, 0
    klfo1 lfo 0.4, 0.05, 0
    klfo2 lfo 0.3, 0.15, 0
    anoise1 noise ichaos, 0
    anoise2 noise ichaos, 0
    asaw3 vco (iamp / 4) * anoise1, icps + klfo1, 0
    asaw4 vco (iamp / 4) * anoise2, icps + klfo2, 0
    asub vco2 iamp / 2, icps / 2, 12
    kfoldmod1 lfo 3, 0.3
    kfoldmod2 lfo 4, 0.2
    asub1 fold asub, 9.5 + kfoldmod1
    asub2 fold asub, 10.5 + kfoldmod2
     aL = asig + asub1 + asaw1 + asaw3
    aR = asig + asub2 + asaw2 + asaw4
    kfiltmod1 lfo 500, 0.2
    kfiltmod2 lfo 400, 0.1
    kfco = 1
    aL moogladder aL, (7000 + kfiltmod1) * kfco, 0.3, 1
    aR moogladder aR, (7000 + kfiltmod2) * kfco, 0.3, 1
    gaL clip gaL + (aL * aenv), 0, 0.7
    gaR clip gaR + (aL * aenv), 0, 0.7
endin

instr 99
      arL, arR reverbsc gaL, gaR, 0.85, 12000, sr, 0.5, 1
      aoutL ntrpol gaL, arL, 0.6
      aoutR ntrpol gaR, arR, 0.6
      outs aoutL, aoutR
      gaL = 0
      gaR = 0
endin

instr    999    ;QUIT
    exitnow        ;EXIT CSOUND IMMEDIATELY
endin

</CsInstruments>

<CsScore>
f 1 0 32768 10 1
f10 0 65536 10 1 0 0 0 0 0 0 0 0 .05
i 99 0 3600  ; reverb
</CsScore>

</CsoundSynthesizer>


--
  Ed Cashin <ecashin@noserose.net>
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
--
  Ed Cashin <ecashin@noserose.net>
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


--
Mvh.

Bernt Isak Wærstad


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

Date2019-03-14 00:17
FromEd Cashin
SubjectRe: [Csnd] more efficient lush synth pad?
I had changed the sample rate to 44100, but the buffer problems stop if I add 10 to the start times and change back to 44100.

On Wed, Mar 13, 2019 at 5:56 PM thorin kerr <thorin.kerr@gmail.com> wrote:
Hmm, there are a lot of tables initialised by vco2init at the beginning.

Just speculating, but do you have extra flags like --realtime or --num-threads in play?

Thorin




On Thu, 14 Mar. 2019, 2:08 am Ed Cashin, <ecashin@noserose.net> wrote:
Hi, Thorin! Those are super suggestions, and I appreciate the example. I’m not sure why it gives me a lot of dac buffer underruns at first, but before it ends I do hear a promising and similar pad sound.

I’ll definitely follow up on this approach. Thanks very much.

On Wed, Mar 13, 2019 at 11:14 AM thorin kerr <thorin.kerr@gmail.com> wrote:
Hi Ed,

I've found lush pad sounds using a combination of vco2init, vco2ft, and oscbnk. oscbnk lets you have control over the number of oscillators, so, you have some control over efficiency (albeit trading it for 'lushness').

I've attached an example, having a go at the sound you were happy with. See what you think.

Thorin




On Wed, 13 Mar. 2019, 11:34 am Ed Cashin, <ecashin@noserose.net> wrote:
Hi!

In csound I am happy to find I can make a synth pad sound that I imagined.


However!  To avoid overwhelming my laptop, I have to turn ksmps way up (1024) or turn JACK buffering way up.

I suspect I'm maybe missing some opportunities to use tables in order to make things easier computationally.  I would really appreciate hearing any suggestions on how to make the code below leaner while maintaining the lush and dynamic sound.

saws-pad.csd by Ed Cashin 2019, based on
PolyphonyControl.csd
Written by Iain McCurdy 2008, Rewritten 2012 (originally entitled 'MonoOverlaps.csd').

<CsoundSynthesizer>

<CsOptions>
;UNCOMMENT THE FOLLOWING LINE OF CODE IF YOU DO NOT HAVE A MIDI KEYBOARD CONNECTED
; -odac -dm0 -M0 -+rtmidi=virtual
;-odac -3 -+rtaudio=jack -+rtmidi=alsa -M hw:5,0 -dm0
-odac -3 -+rtaudio=jack -+rtmidi=alsa -M hw:5,0 -dm0 -B 4096
</CsOptions>

<CsInstruments>

sr     =     88200 
ksmps     =     1024
nchnls     =     2
0dbfs    =    1

FLcolor    255, 255, 255, 100, 200, 200
        FLpanel    "Polyphony Control", 500, 250, 0, 0

;                                                      ON | OFF | TYPE | WIDTH | HEIGHT | X | Y | OPCODE | INS | STARTTIM | IDUR
gkExit,ihExit    FLbutton    "Exit Example",        1,   0,    21,    120,     25,  375, 200,    0,    999,      0,    0.001

;VALUE DISPLAY BOXES                WIDTH | HEIGHT | X |  Y
idatt            FLvalue    " ",         60,       20,    5,   25
iddec            FLvalue    " ",         60,       20,    5,   75
idsus            FLvalue    " ",         60,       20,    5,  125
idrel            FLvalue    " ",         60,       20,    5,  175

;                                        MIN  | MAX | EXP | TYPE |  DISP  | WIDTH | HEIGHT | X | Y
gkatt, ihatt        FLslider     "Attack Time",        0.01,  12,   -1,    23,   idatt,    490,    25,     5,   0
gkdec, ihdec        FLslider     "Decay Time",        0.01,   8,   -1,    23,   iddec,    490,    25,     5,  50
gksus, ihsus        FLslider     "Sustain Level",    0,      1,    0,    23,   idsus,    490,    25,     5, 100    ;SUSTAIN LEVEL CANNOT BE ZERO FOR mxadsr OPCODE
gkrel, ihrel        FLslider     "Release Time",        0.01,  12,   -1,    23,   idrel,    490,    25,     5, 150

;COUNTERS                            MIN | MAX | STEP1 | STEP2 | TYPE | WIDTH | HEIGHT  | X | Y | OPCODE
gkPolyLimit, ihPolyLimit     FLcount  "Polyphony Limit",     1,    127,     1,      1,      2,   120,      25,    5, 200,   -1

            FLsetVal_i    0.27,     ihatt
            FLsetVal_i    4,     ihdec
            FLsetVal_i    0.42,     ihsus
            FLsetVal_i    1.77,     ihrel
            FLsetVal_i    6,     ihPolyLimit

        FLpanel_end    ;END OF PANEL CONTENTS

        FLrun        ;RUN THE WIDGET THREAD!

;NUMBER OF ACTIVE NOTES
;(NOTES IN RELEASE STAGE REGARDED AS INACTIVE)
gkactive init 0

; output audio
gaL init 0
gaR init 0

instr    1    ; NOTE TRIGGERING INSTRUMENT
    gkactive init i(gkactive) + 1    ;INCREMENT NOTE COUNTER
   
    if gkactive > i(gkPolyLimit) then
      turnoff
    endif

    krel release            ;IF NOTE HELD = 0, IF NOTE RELEASED = 1
    ktrig trigger krel,0.5,0    ;WHEN RELEASE FLAG CROSSES 0.5 UPWARDS, I.E. NOTE HAS BEEN RELEASED...   
    if ktrig==1 then       
     gkactive = gkactive - 1    ;...DECREMENT ACTIVE NOTES COUNTER
    endif

    icps    cpsmidi            ;READ CYCLES PER SECOND VALUES FROM MIDI KEYBOARD INPUT
    iamp    ampmidi    1
    ;                ATT      |  DEC    |  SUS    |   REL
    aenv     madsr     i(gkatt),  i(gkdec), i(gksus),  i(gkrel)    ;MIDI SENSING ADSR ENVELOPE WITH LINEAR SEGMENTS
    kfatt = gkatt
    kfsus ntrpol gksus, iamp, 0.8
    kfco     madsr     i(kfatt),  i(gkdec), i(kfsus),  i(gkrel)    ;MIDI SENSING ADSR ENVELOPE WITH LINEAR SEGMENTS
    ;OUTPUT OPCODE   AMP      CPS FUNCTION_TABLE
    asig    vco2    0.3*iamp, icps, 0                ;AUDIO OSCILLATOR
    ispread init 0.25 ; Hz
    ichaos init 0.6
    asaw1 vco2 iamp / 4, icps - ispread, 0
    asaw2 vco2 iamp / 4, icps + ispread, 0
    klfo1 lfo 0.4, 0.05, 0
    klfo2 lfo 0.3, 0.15, 0
    anoise1 noise ichaos, 0
    anoise2 noise ichaos, 0
    asaw3 vco (iamp / 4) * anoise1, icps + klfo1, 0
    asaw4 vco (iamp / 4) * anoise2, icps + klfo2, 0
    asub vco2 iamp / 2, icps / 2, 12
    kfoldmod1 lfo 3, 0.3
    kfoldmod2 lfo 4, 0.2
    asub1 fold asub, 9.5 + kfoldmod1
    asub2 fold asub, 10.5 + kfoldmod2
     aL = asig + asub1 + asaw1 + asaw3
    aR = asig + asub2 + asaw2 + asaw4
    kfiltmod1 lfo 500, 0.2
    kfiltmod2 lfo 400, 0.1
    kfco = 1
    aL moogladder aL, (7000 + kfiltmod1) * kfco, 0.3, 1
    aR moogladder aR, (7000 + kfiltmod2) * kfco, 0.3, 1
    gaL clip gaL + (aL * aenv), 0, 0.7
    gaR clip gaR + (aL * aenv), 0, 0.7
endin

instr 99
      arL, arR reverbsc gaL, gaR, 0.85, 12000, sr, 0.5, 1
      aoutL ntrpol gaL, arL, 0.6
      aoutR ntrpol gaR, arR, 0.6
      outs aoutL, aoutR
      gaL = 0
      gaR = 0
endin

instr    999    ;QUIT
    exitnow        ;EXIT CSOUND IMMEDIATELY
endin

</CsInstruments>

<CsScore>
f 1 0 32768 10 1
f10 0 65536 10 1 0 0 0 0 0 0 0 0 .05
i 99 0 3600  ; reverb
</CsScore>

</CsoundSynthesizer>


--
  Ed Cashin <ecashin@noserose.net>
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
--
  Ed Cashin <ecashin@noserose.net>
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

On Thu, 14 Mar. 2019, 2:08 am Ed Cashin, <ecashin@noserose.net> wrote:
Hi, Thorin! Those are super suggestions, and I appreciate the example. I’m not sure why it gives me a lot of dac buffer underruns at first, but before it ends I do hear a promising and similar pad sound.

I’ll definitely follow up on this approach. Thanks very much.

On Wed, Mar 13, 2019 at 11:14 AM thorin kerr <thorin.kerr@gmail.com> wrote:
Hi Ed,

I've found lush pad sounds using a combination of vco2init, vco2ft, and oscbnk. oscbnk lets you have control over the number of oscillators, so, you have some control over efficiency (albeit trading it for 'lushness').

I've attached an example, having a go at the sound you were happy with. See what you think.

Thorin




On Wed, 13 Mar. 2019, 11:34 am Ed Cashin, <ecashin@noserose.net> wrote:
Hi!

In csound I am happy to find I can make a synth pad sound that I imagined.


However!  To avoid overwhelming my laptop, I have to turn ksmps way up (1024) or turn JACK buffering way up.

I suspect I'm maybe missing some opportunities to use tables in order to make things easier computationally.  I would really appreciate hearing any suggestions on how to make the code below leaner while maintaining the lush and dynamic sound.

saws-pad.csd by Ed Cashin 2019, based on
PolyphonyControl.csd
Written by Iain McCurdy 2008, Rewritten 2012 (originally entitled 'MonoOverlaps.csd').

<CsoundSynthesizer>

<CsOptions>
;UNCOMMENT THE FOLLOWING LINE OF CODE IF YOU DO NOT HAVE A MIDI KEYBOARD CONNECTED
; -odac -dm0 -M0 -+rtmidi=virtual
;-odac -3 -+rtaudio=jack -+rtmidi=alsa -M hw:5,0 -dm0
-odac -3 -+rtaudio=jack -+rtmidi=alsa -M hw:5,0 -dm0 -B 4096
</CsOptions>

<CsInstruments>

sr     =     88200 
ksmps     =     1024
nchnls     =     2
0dbfs    =    1

FLcolor    255, 255, 255, 100, 200, 200
        FLpanel    "Polyphony Control", 500, 250, 0, 0

;                                                      ON | OFF | TYPE | WIDTH | HEIGHT | X | Y | OPCODE | INS | STARTTIM | IDUR
gkExit,ihExit    FLbutton    "Exit Example",        1,   0,    21,    120,     25,  375, 200,    0,    999,      0,    0.001

;VALUE DISPLAY BOXES                WIDTH | HEIGHT | X |  Y
idatt            FLvalue    " ",         60,       20,    5,   25
iddec            FLvalue    " ",         60,       20,    5,   75
idsus            FLvalue    " ",         60,       20,    5,  125
idrel            FLvalue    " ",         60,       20,    5,  175

;                                        MIN  | MAX | EXP | TYPE |  DISP  | WIDTH | HEIGHT | X | Y
gkatt, ihatt        FLslider     "Attack Time",        0.01,  12,   -1,    23,   idatt,    490,    25,     5,   0
gkdec, ihdec        FLslider     "Decay Time",        0.01,   8,   -1,    23,   iddec,    490,    25,     5,  50
gksus, ihsus        FLslider     "Sustain Level",    0,      1,    0,    23,   idsus,    490,    25,     5, 100    ;SUSTAIN LEVEL CANNOT BE ZERO FOR mxadsr OPCODE
gkrel, ihrel        FLslider     "Release Time",        0.01,  12,   -1,    23,   idrel,    490,    25,     5, 150

;COUNTERS                            MIN | MAX | STEP1 | STEP2 | TYPE | WIDTH | HEIGHT  | X | Y | OPCODE
gkPolyLimit, ihPolyLimit     FLcount  "Polyphony Limit",     1,    127,     1,      1,      2,   120,      25,    5, 200,   -1

            FLsetVal_i    0.27,     ihatt
            FLsetVal_i    4,     ihdec
            FLsetVal_i    0.42,     ihsus
            FLsetVal_i    1.77,     ihrel
            FLsetVal_i    6,     ihPolyLimit

        FLpanel_end    ;END OF PANEL CONTENTS

        FLrun        ;RUN THE WIDGET THREAD!

;NUMBER OF ACTIVE NOTES
;(NOTES IN RELEASE STAGE REGARDED AS INACTIVE)
gkactive init 0

; output audio
gaL init 0
gaR init 0

instr    1    ; NOTE TRIGGERING INSTRUMENT
    gkactive init i(gkactive) + 1    ;INCREMENT NOTE COUNTER
   
    if gkactive > i(gkPolyLimit) then
      turnoff
    endif

    krel release            ;IF NOTE HELD = 0, IF NOTE RELEASED = 1
    ktrig trigger krel,0.5,0    ;WHEN RELEASE FLAG CROSSES 0.5 UPWARDS, I.E. NOTE HAS BEEN RELEASED...   
    if ktrig==1 then       
     gkactive = gkactive - 1    ;...DECREMENT ACTIVE NOTES COUNTER
    endif

    icps    cpsmidi            ;READ CYCLES PER SECOND VALUES FROM MIDI KEYBOARD INPUT
    iamp    ampmidi    1
    ;                ATT      |  DEC    |  SUS    |   REL
    aenv     madsr     i(gkatt),  i(gkdec), i(gksus),  i(gkrel)    ;MIDI SENSING ADSR ENVELOPE WITH LINEAR SEGMENTS
    kfatt = gkatt
    kfsus ntrpol gksus, iamp, 0.8
    kfco     madsr     i(kfatt),  i(gkdec), i(kfsus),  i(gkrel)    ;MIDI SENSING ADSR ENVELOPE WITH LINEAR SEGMENTS
    ;OUTPUT OPCODE   AMP      CPS FUNCTION_TABLE
    asig    vco2    0.3*iamp, icps, 0                ;AUDIO OSCILLATOR
    ispread init 0.25 ; Hz
    ichaos init 0.6
    asaw1 vco2 iamp / 4, icps - ispread, 0
    asaw2 vco2 iamp / 4, icps + ispread, 0
    klfo1 lfo 0.4, 0.05, 0
    klfo2 lfo 0.3, 0.15, 0
    anoise1 noise ichaos, 0
    anoise2 noise ichaos, 0
    asaw3 vco (iamp / 4) * anoise1, icps + klfo1, 0
    asaw4 vco (iamp / 4) * anoise2, icps + klfo2, 0
    asub vco2 iamp / 2, icps / 2, 12
    kfoldmod1 lfo 3, 0.3
    kfoldmod2 lfo 4, 0.2
    asub1 fold asub, 9.5 + kfoldmod1
    asub2 fold asub, 10.5 + kfoldmod2
     aL = asig + asub1 + asaw1 + asaw3
    aR = asig + asub2 + asaw2 + asaw4
    kfiltmod1 lfo 500, 0.2
    kfiltmod2 lfo 400, 0.1
    kfco = 1
    aL moogladder aL, (7000 + kfiltmod1) * kfco, 0.3, 1
    aR moogladder aR, (7000 + kfiltmod2) * kfco, 0.3, 1
    gaL clip gaL + (aL * aenv), 0, 0.7
    gaR clip gaR + (aL * aenv), 0, 0.7
endin

instr 99
      arL, arR reverbsc gaL, gaR, 0.85, 12000, sr, 0.5, 1
      aoutL ntrpol gaL, arL, 0.6
      aoutR ntrpol gaR, arR, 0.6
      outs aoutL, aoutR
      gaL = 0
      gaR = 0
endin

instr    999    ;QUIT
    exitnow        ;EXIT CSOUND IMMEDIATELY
endin

</CsInstruments>

<CsScore>
f 1 0 32768 10 1
f10 0 65536 10 1 0 0 0 0 0 0 0 0 .05
i 99 0 3600  ; reverb
</CsScore>

</CsoundSynthesizer>


--
  Ed Cashin <ecashin@noserose.net>
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
--
  Ed Cashin <ecashin@noserose.net>
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


--
  Ed Cashin <ecashin@noserose.net>
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

Date2019-03-14 00:18
FromEd Cashin
SubjectRe: [Csnd] more efficient lush synth pad?
I'll try a different filter, yes.  (I do want to keep each note filtered independently if possible, though.)

On Wed, Mar 13, 2019 at 6:58 PM Bernt Isak Wærstad <berntisak@gmail.com> wrote:
I think moogladder is quite expensive, so perhaps try to not have an instance on each voice and move it to the global instrument instead? Or try with something like lpf18 instead


On Wed, 13 Mar 2019 at 22:56, thorin kerr <thorin.kerr@gmail.com> wrote:
Hmm, there are a lot of tables initialised by vco2init at the beginning.

Just speculating, but do you have extra flags like --realtime or --num-threads in play?

Thorin




On Thu, 14 Mar. 2019, 2:08 am Ed Cashin, <ecashin@noserose.net> wrote:
Hi, Thorin! Those are super suggestions, and I appreciate the example. I’m not sure why it gives me a lot of dac buffer underruns at first, but before it ends I do hear a promising and similar pad sound.

I’ll definitely follow up on this approach. Thanks very much.

On Wed, Mar 13, 2019 at 11:14 AM thorin kerr <thorin.kerr@gmail.com> wrote:
Hi Ed,

I've found lush pad sounds using a combination of vco2init, vco2ft, and oscbnk. oscbnk lets you have control over the number of oscillators, so, you have some control over efficiency (albeit trading it for 'lushness').

I've attached an example, having a go at the sound you were happy with. See what you think.

Thorin




On Wed, 13 Mar. 2019, 11:34 am Ed Cashin, <ecashin@noserose.net> wrote:
Hi!

In csound I am happy to find I can make a synth pad sound that I imagined.


However!  To avoid overwhelming my laptop, I have to turn ksmps way up (1024) or turn JACK buffering way up.

I suspect I'm maybe missing some opportunities to use tables in order to make things easier computationally.  I would really appreciate hearing any suggestions on how to make the code below leaner while maintaining the lush and dynamic sound.

saws-pad.csd by Ed Cashin 2019, based on
PolyphonyControl.csd
Written by Iain McCurdy 2008, Rewritten 2012 (originally entitled 'MonoOverlaps.csd').

<CsoundSynthesizer>

<CsOptions>
;UNCOMMENT THE FOLLOWING LINE OF CODE IF YOU DO NOT HAVE A MIDI KEYBOARD CONNECTED
; -odac -dm0 -M0 -+rtmidi=virtual
;-odac -3 -+rtaudio=jack -+rtmidi=alsa -M hw:5,0 -dm0
-odac -3 -+rtaudio=jack -+rtmidi=alsa -M hw:5,0 -dm0 -B 4096
</CsOptions>

<CsInstruments>

sr     =     88200 
ksmps     =     1024
nchnls     =     2
0dbfs    =    1

FLcolor    255, 255, 255, 100, 200, 200
        FLpanel    "Polyphony Control", 500, 250, 0, 0

;                                                      ON | OFF | TYPE | WIDTH | HEIGHT | X | Y | OPCODE | INS | STARTTIM | IDUR
gkExit,ihExit    FLbutton    "Exit Example",        1,   0,    21,    120,     25,  375, 200,    0,    999,      0,    0.001

;VALUE DISPLAY BOXES                WIDTH | HEIGHT | X |  Y
idatt            FLvalue    " ",         60,       20,    5,   25
iddec            FLvalue    " ",         60,       20,    5,   75
idsus            FLvalue    " ",         60,       20,    5,  125
idrel            FLvalue    " ",         60,       20,    5,  175

;                                        MIN  | MAX | EXP | TYPE |  DISP  | WIDTH | HEIGHT | X | Y
gkatt, ihatt        FLslider     "Attack Time",        0.01,  12,   -1,    23,   idatt,    490,    25,     5,   0
gkdec, ihdec        FLslider     "Decay Time",        0.01,   8,   -1,    23,   iddec,    490,    25,     5,  50
gksus, ihsus        FLslider     "Sustain Level",    0,      1,    0,    23,   idsus,    490,    25,     5, 100    ;SUSTAIN LEVEL CANNOT BE ZERO FOR mxadsr OPCODE
gkrel, ihrel        FLslider     "Release Time",        0.01,  12,   -1,    23,   idrel,    490,    25,     5, 150

;COUNTERS                            MIN | MAX | STEP1 | STEP2 | TYPE | WIDTH | HEIGHT  | X | Y | OPCODE
gkPolyLimit, ihPolyLimit     FLcount  "Polyphony Limit",     1,    127,     1,      1,      2,   120,      25,    5, 200,   -1

            FLsetVal_i    0.27,     ihatt
            FLsetVal_i    4,     ihdec
            FLsetVal_i    0.42,     ihsus
            FLsetVal_i    1.77,     ihrel
            FLsetVal_i    6,     ihPolyLimit

        FLpanel_end    ;END OF PANEL CONTENTS

        FLrun        ;RUN THE WIDGET THREAD!

;NUMBER OF ACTIVE NOTES
;(NOTES IN RELEASE STAGE REGARDED AS INACTIVE)
gkactive init 0

; output audio
gaL init 0
gaR init 0

instr    1    ; NOTE TRIGGERING INSTRUMENT
    gkactive init i(gkactive) + 1    ;INCREMENT NOTE COUNTER
   
    if gkactive > i(gkPolyLimit) then
      turnoff
    endif

    krel release            ;IF NOTE HELD = 0, IF NOTE RELEASED = 1
    ktrig trigger krel,0.5,0    ;WHEN RELEASE FLAG CROSSES 0.5 UPWARDS, I.E. NOTE HAS BEEN RELEASED...   
    if ktrig==1 then       
     gkactive = gkactive - 1    ;...DECREMENT ACTIVE NOTES COUNTER
    endif

    icps    cpsmidi            ;READ CYCLES PER SECOND VALUES FROM MIDI KEYBOARD INPUT
    iamp    ampmidi    1
    ;                ATT      |  DEC    |  SUS    |   REL
    aenv     madsr     i(gkatt),  i(gkdec), i(gksus),  i(gkrel)    ;MIDI SENSING ADSR ENVELOPE WITH LINEAR SEGMENTS
    kfatt = gkatt
    kfsus ntrpol gksus, iamp, 0.8
    kfco     madsr     i(kfatt),  i(gkdec), i(kfsus),  i(gkrel)    ;MIDI SENSING ADSR ENVELOPE WITH LINEAR SEGMENTS
    ;OUTPUT OPCODE   AMP      CPS FUNCTION_TABLE
    asig    vco2    0.3*iamp, icps, 0                ;AUDIO OSCILLATOR
    ispread init 0.25 ; Hz
    ichaos init 0.6
    asaw1 vco2 iamp / 4, icps - ispread, 0
    asaw2 vco2 iamp / 4, icps + ispread, 0
    klfo1 lfo 0.4, 0.05, 0
    klfo2 lfo 0.3, 0.15, 0
    anoise1 noise ichaos, 0
    anoise2 noise ichaos, 0
    asaw3 vco (iamp / 4) * anoise1, icps + klfo1, 0
    asaw4 vco (iamp / 4) * anoise2, icps + klfo2, 0
    asub vco2 iamp / 2, icps / 2, 12
    kfoldmod1 lfo 3, 0.3
    kfoldmod2 lfo 4, 0.2
    asub1 fold asub, 9.5 + kfoldmod1
    asub2 fold asub, 10.5 + kfoldmod2
     aL = asig + asub1 + asaw1 + asaw3
    aR = asig + asub2 + asaw2 + asaw4
    kfiltmod1 lfo 500, 0.2
    kfiltmod2 lfo 400, 0.1
    kfco = 1
    aL moogladder aL, (7000 + kfiltmod1) * kfco, 0.3, 1
    aR moogladder aR, (7000 + kfiltmod2) * kfco, 0.3, 1
    gaL clip gaL + (aL * aenv), 0, 0.7
    gaR clip gaR + (aL * aenv), 0, 0.7
endin

instr 99
      arL, arR reverbsc gaL, gaR, 0.85, 12000, sr, 0.5, 1
      aoutL ntrpol gaL, arL, 0.6
      aoutR ntrpol gaR, arR, 0.6
      outs aoutL, aoutR
      gaL = 0
      gaR = 0
endin

instr    999    ;QUIT
    exitnow        ;EXIT CSOUND IMMEDIATELY
endin

</CsInstruments>

<CsScore>
f 1 0 32768 10 1
f10 0 65536 10 1 0 0 0 0 0 0 0 0 .05
i 99 0 3600  ; reverb
</CsScore>

</CsoundSynthesizer>


--
  Ed Cashin <ecashin@noserose.net>
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
--
  Ed Cashin <ecashin@noserose.net>
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

On Thu, 14 Mar. 2019, 2:08 am Ed Cashin, <ecashin@noserose.net> wrote:
Hi, Thorin! Those are super suggestions, and I appreciate the example. I’m not sure why it gives me a lot of dac buffer underruns at first, but before it ends I do hear a promising and similar pad sound.

I’ll definitely follow up on this approach. Thanks very much.

On Wed, Mar 13, 2019 at 11:14 AM thorin kerr <thorin.kerr@gmail.com> wrote:
Hi Ed,

I've found lush pad sounds using a combination of vco2init, vco2ft, and oscbnk. oscbnk lets you have control over the number of oscillators, so, you have some control over efficiency (albeit trading it for 'lushness').

I've attached an example, having a go at the sound you were happy with. See what you think.

Thorin




On Wed, 13 Mar. 2019, 11:34 am Ed Cashin, <ecashin@noserose.net> wrote:
Hi!

In csound I am happy to find I can make a synth pad sound that I imagined.


However!  To avoid overwhelming my laptop, I have to turn ksmps way up (1024) or turn JACK buffering way up.

I suspect I'm maybe missing some opportunities to use tables in order to make things easier computationally.  I would really appreciate hearing any suggestions on how to make the code below leaner while maintaining the lush and dynamic sound.

saws-pad.csd by Ed Cashin 2019, based on
PolyphonyControl.csd
Written by Iain McCurdy 2008, Rewritten 2012 (originally entitled 'MonoOverlaps.csd').

<CsoundSynthesizer>

<CsOptions>
;UNCOMMENT THE FOLLOWING LINE OF CODE IF YOU DO NOT HAVE A MIDI KEYBOARD CONNECTED
; -odac -dm0 -M0 -+rtmidi=virtual
;-odac -3 -+rtaudio=jack -+rtmidi=alsa -M hw:5,0 -dm0
-odac -3 -+rtaudio=jack -+rtmidi=alsa -M hw:5,0 -dm0 -B 4096
</CsOptions>

<CsInstruments>

sr     =     88200 
ksmps     =     1024
nchnls     =     2
0dbfs    =    1

FLcolor    255, 255, 255, 100, 200, 200
        FLpanel    "Polyphony Control", 500, 250, 0, 0

;                                                      ON | OFF | TYPE | WIDTH | HEIGHT | X | Y | OPCODE | INS | STARTTIM | IDUR
gkExit,ihExit    FLbutton    "Exit Example",        1,   0,    21,    120,     25,  375, 200,    0,    999,      0,    0.001

;VALUE DISPLAY BOXES                WIDTH | HEIGHT | X |  Y
idatt            FLvalue    " ",         60,       20,    5,   25
iddec            FLvalue    " ",         60,       20,    5,   75
idsus            FLvalue    " ",         60,       20,    5,  125
idrel            FLvalue    " ",         60,       20,    5,  175

;                                        MIN  | MAX | EXP | TYPE |  DISP  | WIDTH | HEIGHT | X | Y
gkatt, ihatt        FLslider     "Attack Time",        0.01,  12,   -1,    23,   idatt,    490,    25,     5,   0
gkdec, ihdec        FLslider     "Decay Time",        0.01,   8,   -1,    23,   iddec,    490,    25,     5,  50
gksus, ihsus        FLslider     "Sustain Level",    0,      1,    0,    23,   idsus,    490,    25,     5, 100    ;SUSTAIN LEVEL CANNOT BE ZERO FOR mxadsr OPCODE
gkrel, ihrel        FLslider     "Release Time",        0.01,  12,   -1,    23,   idrel,    490,    25,     5, 150

;COUNTERS                            MIN | MAX | STEP1 | STEP2 | TYPE | WIDTH | HEIGHT  | X | Y | OPCODE
gkPolyLimit, ihPolyLimit     FLcount  "Polyphony Limit",     1,    127,     1,      1,      2,   120,      25,    5, 200,   -1

            FLsetVal_i    0.27,     ihatt
            FLsetVal_i    4,     ihdec
            FLsetVal_i    0.42,     ihsus
            FLsetVal_i    1.77,     ihrel
            FLsetVal_i    6,     ihPolyLimit

        FLpanel_end    ;END OF PANEL CONTENTS

        FLrun        ;RUN THE WIDGET THREAD!

;NUMBER OF ACTIVE NOTES
;(NOTES IN RELEASE STAGE REGARDED AS INACTIVE)
gkactive init 0

; output audio
gaL init 0
gaR init 0

instr    1    ; NOTE TRIGGERING INSTRUMENT
    gkactive init i(gkactive) + 1    ;INCREMENT NOTE COUNTER
   
    if gkactive > i(gkPolyLimit) then
      turnoff
    endif

    krel release            ;IF NOTE HELD = 0, IF NOTE RELEASED = 1
    ktrig trigger krel,0.5,0    ;WHEN RELEASE FLAG CROSSES 0.5 UPWARDS, I.E. NOTE HAS BEEN RELEASED...   
    if ktrig==1 then       
     gkactive = gkactive - 1    ;...DECREMENT ACTIVE NOTES COUNTER
    endif

    icps    cpsmidi            ;READ CYCLES PER SECOND VALUES FROM MIDI KEYBOARD INPUT
    iamp    ampmidi    1
    ;                ATT      |  DEC    |  SUS    |   REL
    aenv     madsr     i(gkatt),  i(gkdec), i(gksus),  i(gkrel)    ;MIDI SENSING ADSR ENVELOPE WITH LINEAR SEGMENTS
    kfatt = gkatt
    kfsus ntrpol gksus, iamp, 0.8
    kfco     madsr     i(kfatt),  i(gkdec), i(kfsus),  i(gkrel)    ;MIDI SENSING ADSR ENVELOPE WITH LINEAR SEGMENTS
    ;OUTPUT OPCODE   AMP      CPS FUNCTION_TABLE
    asig    vco2    0.3*iamp, icps, 0                ;AUDIO OSCILLATOR
    ispread init 0.25 ; Hz
    ichaos init 0.6
    asaw1 vco2 iamp / 4, icps - ispread, 0
    asaw2 vco2 iamp / 4, icps + ispread, 0
    klfo1 lfo 0.4, 0.05, 0
    klfo2 lfo 0.3, 0.15, 0
    anoise1 noise ichaos, 0
    anoise2 noise ichaos, 0
    asaw3 vco (iamp / 4) * anoise1, icps + klfo1, 0
    asaw4 vco (iamp / 4) * anoise2, icps + klfo2, 0
    asub vco2 iamp / 2, icps / 2, 12
    kfoldmod1 lfo 3, 0.3
    kfoldmod2 lfo 4, 0.2
    asub1 fold asub, 9.5 + kfoldmod1
    asub2 fold asub, 10.5 + kfoldmod2
     aL = asig + asub1 + asaw1 + asaw3
    aR = asig + asub2 + asaw2 + asaw4
    kfiltmod1 lfo 500, 0.2
    kfiltmod2 lfo 400, 0.1
    kfco = 1
    aL moogladder aL, (7000 + kfiltmod1) * kfco, 0.3, 1
    aR moogladder aR, (7000 + kfiltmod2) * kfco, 0.3, 1
    gaL clip gaL + (aL * aenv), 0, 0.7
    gaR clip gaR + (aL * aenv), 0, 0.7
endin

instr 99
      arL, arR reverbsc gaL, gaR, 0.85, 12000, sr, 0.5, 1
      aoutL ntrpol gaL, arL, 0.6
      aoutR ntrpol gaR, arR, 0.6
      outs aoutL, aoutR
      gaL = 0
      gaR = 0
endin

instr    999    ;QUIT
    exitnow        ;EXIT CSOUND IMMEDIATELY
endin

</CsInstruments>

<CsScore>
f 1 0 32768 10 1
f10 0 65536 10 1 0 0 0 0 0 0 0 0 .05
i 99 0 3600  ; reverb
</CsScore>

</CsoundSynthesizer>


--
  Ed Cashin <ecashin@noserose.net>
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
--
  Ed Cashin <ecashin@noserose.net>
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


--
Mvh.

Bernt Isak Wærstad


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


--
  Ed Cashin <ecashin@noserose.net>
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

Date2019-03-15 11:45
From"Dr. Richard Boulanger"
SubjectRe: [Csnd] more efficient lush synth pad?
Ed,

Really nice instrument - thanks for sharing.

-dB

_____________________________________________
Dr. Richard Boulanger
Professor of Electronic Production and Design
Professional Writing and Music Technology Division
Berklee College of Music
______________________________________________
OFFICE: 1126 Boylston St., Suite 201 (EPD), Suite 208 (Boulanger)
______________________________________________


On Tue, Mar 12, 2019 at 9:35 PM Ed Cashin <ecashin@noserose.net> wrote:
Hi!

In csound I am happy to find I can make a synth pad sound that I imagined.


However!  To avoid overwhelming my laptop, I have to turn ksmps way up (1024) or turn JACK buffering way up.

I suspect I'm maybe missing some opportunities to use tables in order to make things easier computationally.  I would really appreciate hearing any suggestions on how to make the code below leaner while maintaining the lush and dynamic sound.

saws-pad.csd by Ed Cashin 2019, based on
PolyphonyControl.csd
Written by Iain McCurdy 2008, Rewritten 2012 (originally entitled 'MonoOverlaps.csd').

<CsoundSynthesizer>

<CsOptions>
;UNCOMMENT THE FOLLOWING LINE OF CODE IF YOU DO NOT HAVE A MIDI KEYBOARD CONNECTED
; -odac -dm0 -M0 -+rtmidi=virtual
;-odac -3 -+rtaudio=jack -+rtmidi=alsa -M hw:5,0 -dm0
-odac -3 -+rtaudio=jack -+rtmidi=alsa -M hw:5,0 -dm0 -B 4096
</CsOptions>

<CsInstruments>

sr     =     88200 
ksmps     =     1024
nchnls     =     2
0dbfs    =    1

FLcolor    255, 255, 255, 100, 200, 200
        FLpanel    "Polyphony Control", 500, 250, 0, 0

;                                                      ON | OFF | TYPE | WIDTH | HEIGHT | X | Y | OPCODE | INS | STARTTIM | IDUR
gkExit,ihExit    FLbutton    "Exit Example",        1,   0,    21,    120,     25,  375, 200,    0,    999,      0,    0.001

;VALUE DISPLAY BOXES                WIDTH | HEIGHT | X |  Y
idatt            FLvalue    " ",         60,       20,    5,   25
iddec            FLvalue    " ",         60,       20,    5,   75
idsus            FLvalue    " ",         60,       20,    5,  125
idrel            FLvalue    " ",         60,       20,    5,  175

;                                        MIN  | MAX | EXP | TYPE |  DISP  | WIDTH | HEIGHT | X | Y
gkatt, ihatt        FLslider     "Attack Time",        0.01,  12,   -1,    23,   idatt,    490,    25,     5,   0
gkdec, ihdec        FLslider     "Decay Time",        0.01,   8,   -1,    23,   iddec,    490,    25,     5,  50
gksus, ihsus        FLslider     "Sustain Level",    0,      1,    0,    23,   idsus,    490,    25,     5, 100    ;SUSTAIN LEVEL CANNOT BE ZERO FOR mxadsr OPCODE
gkrel, ihrel        FLslider     "Release Time",        0.01,  12,   -1,    23,   idrel,    490,    25,     5, 150

;COUNTERS                            MIN | MAX | STEP1 | STEP2 | TYPE | WIDTH | HEIGHT  | X | Y | OPCODE
gkPolyLimit, ihPolyLimit     FLcount  "Polyphony Limit",     1,    127,     1,      1,      2,   120,      25,    5, 200,   -1

            FLsetVal_i    0.27,     ihatt
            FLsetVal_i    4,     ihdec
            FLsetVal_i    0.42,     ihsus
            FLsetVal_i    1.77,     ihrel
            FLsetVal_i    6,     ihPolyLimit

        FLpanel_end    ;END OF PANEL CONTENTS

        FLrun        ;RUN THE WIDGET THREAD!

;NUMBER OF ACTIVE NOTES
;(NOTES IN RELEASE STAGE REGARDED AS INACTIVE)
gkactive init 0

; output audio
gaL init 0
gaR init 0

instr    1    ; NOTE TRIGGERING INSTRUMENT
    gkactive init i(gkactive) + 1    ;INCREMENT NOTE COUNTER
   
    if gkactive > i(gkPolyLimit) then
      turnoff
    endif

    krel release            ;IF NOTE HELD = 0, IF NOTE RELEASED = 1
    ktrig trigger krel,0.5,0    ;WHEN RELEASE FLAG CROSSES 0.5 UPWARDS, I.E. NOTE HAS BEEN RELEASED...   
    if ktrig==1 then       
     gkactive = gkactive - 1    ;...DECREMENT ACTIVE NOTES COUNTER
    endif

    icps    cpsmidi            ;READ CYCLES PER SECOND VALUES FROM MIDI KEYBOARD INPUT
    iamp    ampmidi    1
    ;                ATT      |  DEC    |  SUS    |   REL
    aenv     madsr     i(gkatt),  i(gkdec), i(gksus),  i(gkrel)    ;MIDI SENSING ADSR ENVELOPE WITH LINEAR SEGMENTS
    kfatt = gkatt
    kfsus ntrpol gksus, iamp, 0.8
    kfco     madsr     i(kfatt),  i(gkdec), i(kfsus),  i(gkrel)    ;MIDI SENSING ADSR ENVELOPE WITH LINEAR SEGMENTS
    ;OUTPUT OPCODE   AMP      CPS FUNCTION_TABLE
    asig    vco2    0.3*iamp, icps, 0                ;AUDIO OSCILLATOR
    ispread init 0.25 ; Hz
    ichaos init 0.6
    asaw1 vco2 iamp / 4, icps - ispread, 0
    asaw2 vco2 iamp / 4, icps + ispread, 0
    klfo1 lfo 0.4, 0.05, 0
    klfo2 lfo 0.3, 0.15, 0
    anoise1 noise ichaos, 0
    anoise2 noise ichaos, 0
    asaw3 vco (iamp / 4) * anoise1, icps + klfo1, 0
    asaw4 vco (iamp / 4) * anoise2, icps + klfo2, 0
    asub vco2 iamp / 2, icps / 2, 12
    kfoldmod1 lfo 3, 0.3
    kfoldmod2 lfo 4, 0.2
    asub1 fold asub, 9.5 + kfoldmod1
    asub2 fold asub, 10.5 + kfoldmod2
     aL = asig + asub1 + asaw1 + asaw3
    aR = asig + asub2 + asaw2 + asaw4
    kfiltmod1 lfo 500, 0.2
    kfiltmod2 lfo 400, 0.1
    kfco = 1
    aL moogladder aL, (7000 + kfiltmod1) * kfco, 0.3, 1
    aR moogladder aR, (7000 + kfiltmod2) * kfco, 0.3, 1
    gaL clip gaL + (aL * aenv), 0, 0.7
    gaR clip gaR + (aL * aenv), 0, 0.7
endin

instr 99
      arL, arR reverbsc gaL, gaR, 0.85, 12000, sr, 0.5, 1
      aoutL ntrpol gaL, arL, 0.6
      aoutR ntrpol gaR, arR, 0.6
      outs aoutL, aoutR
      gaL = 0
      gaR = 0
endin

instr    999    ;QUIT
    exitnow        ;EXIT CSOUND IMMEDIATELY
endin

</CsInstruments>

<CsScore>
f 1 0 32768 10 1
f10 0 65536 10 1 0 0 0 0 0 0 0 0 .05
i 99 0 3600  ; reverb
</CsScore>

</CsoundSynthesizer>


--
  Ed Cashin <ecashin@noserose.net>
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

Date2019-03-15 11:46
From"Dr. Richard Boulanger"
SubjectRe: [Csnd] more efficient lush synth pad?
Thorin,

A nice alternative OscilPad instrument.  Thanks for sharing!

-dB
_____________________________________________
Dr. Richard Boulanger
Professor of Electronic Production and Design
Professional Writing and Music Technology Division
Berklee College of Music
______________________________________________
OFFICE: 1126 Boylston St., Suite 201 (EPD), Suite 208 (Boulanger)
______________________________________________


On Wed, Mar 13, 2019 at 11:13 AM thorin kerr <thorin.kerr@gmail.com> wrote:
Hi Ed,

I've found lush pad sounds using a combination of vco2init, vco2ft, and oscbnk. oscbnk lets you have control over the number of oscillators, so, you have some control over efficiency (albeit trading it for 'lushness').

I've attached an example, having a go at the sound you were happy with. See what you think.

Thorin




On Wed, 13 Mar. 2019, 11:34 am Ed Cashin, <ecashin@noserose.net> wrote:
Hi!

In csound I am happy to find I can make a synth pad sound that I imagined.


However!  To avoid overwhelming my laptop, I have to turn ksmps way up (1024) or turn JACK buffering way up.

I suspect I'm maybe missing some opportunities to use tables in order to make things easier computationally.  I would really appreciate hearing any suggestions on how to make the code below leaner while maintaining the lush and dynamic sound.

saws-pad.csd by Ed Cashin 2019, based on
PolyphonyControl.csd
Written by Iain McCurdy 2008, Rewritten 2012 (originally entitled 'MonoOverlaps.csd').

<CsoundSynthesizer>

<CsOptions>
;UNCOMMENT THE FOLLOWING LINE OF CODE IF YOU DO NOT HAVE A MIDI KEYBOARD CONNECTED
; -odac -dm0 -M0 -+rtmidi=virtual
;-odac -3 -+rtaudio=jack -+rtmidi=alsa -M hw:5,0 -dm0
-odac -3 -+rtaudio=jack -+rtmidi=alsa -M hw:5,0 -dm0 -B 4096
</CsOptions>

<CsInstruments>

sr     =     88200 
ksmps     =     1024
nchnls     =     2
0dbfs    =    1

FLcolor    255, 255, 255, 100, 200, 200
        FLpanel    "Polyphony Control", 500, 250, 0, 0

;                                                      ON | OFF | TYPE | WIDTH | HEIGHT | X | Y | OPCODE | INS | STARTTIM | IDUR
gkExit,ihExit    FLbutton    "Exit Example",        1,   0,    21,    120,     25,  375, 200,    0,    999,      0,    0.001

;VALUE DISPLAY BOXES                WIDTH | HEIGHT | X |  Y
idatt            FLvalue    " ",         60,       20,    5,   25
iddec            FLvalue    " ",         60,       20,    5,   75
idsus            FLvalue    " ",         60,       20,    5,  125
idrel            FLvalue    " ",         60,       20,    5,  175

;                                        MIN  | MAX | EXP | TYPE |  DISP  | WIDTH | HEIGHT | X | Y
gkatt, ihatt        FLslider     "Attack Time",        0.01,  12,   -1,    23,   idatt,    490,    25,     5,   0
gkdec, ihdec        FLslider     "Decay Time",        0.01,   8,   -1,    23,   iddec,    490,    25,     5,  50
gksus, ihsus        FLslider     "Sustain Level",    0,      1,    0,    23,   idsus,    490,    25,     5, 100    ;SUSTAIN LEVEL CANNOT BE ZERO FOR mxadsr OPCODE
gkrel, ihrel        FLslider     "Release Time",        0.01,  12,   -1,    23,   idrel,    490,    25,     5, 150

;COUNTERS                            MIN | MAX | STEP1 | STEP2 | TYPE | WIDTH | HEIGHT  | X | Y | OPCODE
gkPolyLimit, ihPolyLimit     FLcount  "Polyphony Limit",     1,    127,     1,      1,      2,   120,      25,    5, 200,   -1

            FLsetVal_i    0.27,     ihatt
            FLsetVal_i    4,     ihdec
            FLsetVal_i    0.42,     ihsus
            FLsetVal_i    1.77,     ihrel
            FLsetVal_i    6,     ihPolyLimit

        FLpanel_end    ;END OF PANEL CONTENTS

        FLrun        ;RUN THE WIDGET THREAD!

;NUMBER OF ACTIVE NOTES
;(NOTES IN RELEASE STAGE REGARDED AS INACTIVE)
gkactive init 0

; output audio
gaL init 0
gaR init 0

instr    1    ; NOTE TRIGGERING INSTRUMENT
    gkactive init i(gkactive) + 1    ;INCREMENT NOTE COUNTER
   
    if gkactive > i(gkPolyLimit) then
      turnoff
    endif

    krel release            ;IF NOTE HELD = 0, IF NOTE RELEASED = 1
    ktrig trigger krel,0.5,0    ;WHEN RELEASE FLAG CROSSES 0.5 UPWARDS, I.E. NOTE HAS BEEN RELEASED...   
    if ktrig==1 then       
     gkactive = gkactive - 1    ;...DECREMENT ACTIVE NOTES COUNTER
    endif

    icps    cpsmidi            ;READ CYCLES PER SECOND VALUES FROM MIDI KEYBOARD INPUT
    iamp    ampmidi    1
    ;                ATT      |  DEC    |  SUS    |   REL
    aenv     madsr     i(gkatt),  i(gkdec), i(gksus),  i(gkrel)    ;MIDI SENSING ADSR ENVELOPE WITH LINEAR SEGMENTS
    kfatt = gkatt
    kfsus ntrpol gksus, iamp, 0.8
    kfco     madsr     i(kfatt),  i(gkdec), i(kfsus),  i(gkrel)    ;MIDI SENSING ADSR ENVELOPE WITH LINEAR SEGMENTS
    ;OUTPUT OPCODE   AMP      CPS FUNCTION_TABLE
    asig    vco2    0.3*iamp, icps, 0                ;AUDIO OSCILLATOR
    ispread init 0.25 ; Hz
    ichaos init 0.6
    asaw1 vco2 iamp / 4, icps - ispread, 0
    asaw2 vco2 iamp / 4, icps + ispread, 0
    klfo1 lfo 0.4, 0.05, 0
    klfo2 lfo 0.3, 0.15, 0
    anoise1 noise ichaos, 0
    anoise2 noise ichaos, 0
    asaw3 vco (iamp / 4) * anoise1, icps + klfo1, 0
    asaw4 vco (iamp / 4) * anoise2, icps + klfo2, 0
    asub vco2 iamp / 2, icps / 2, 12
    kfoldmod1 lfo 3, 0.3
    kfoldmod2 lfo 4, 0.2
    asub1 fold asub, 9.5 + kfoldmod1
    asub2 fold asub, 10.5 + kfoldmod2
     aL = asig + asub1 + asaw1 + asaw3
    aR = asig + asub2 + asaw2 + asaw4
    kfiltmod1 lfo 500, 0.2
    kfiltmod2 lfo 400, 0.1
    kfco = 1
    aL moogladder aL, (7000 + kfiltmod1) * kfco, 0.3, 1
    aR moogladder aR, (7000 + kfiltmod2) * kfco, 0.3, 1
    gaL clip gaL + (aL * aenv), 0, 0.7
    gaR clip gaR + (aL * aenv), 0, 0.7
endin

instr 99
      arL, arR reverbsc gaL, gaR, 0.85, 12000, sr, 0.5, 1
      aoutL ntrpol gaL, arL, 0.6
      aoutR ntrpol gaR, arR, 0.6
      outs aoutL, aoutR
      gaL = 0
      gaR = 0
endin

instr    999    ;QUIT
    exitnow        ;EXIT CSOUND IMMEDIATELY
endin

</CsInstruments>

<CsScore>
f 1 0 32768 10 1
f10 0 65536 10 1 0 0 0 0 0 0 0 0 .05
i 99 0 3600  ; reverb
</CsScore>

</CsoundSynthesizer>


--
  Ed Cashin <ecashin@noserose.net>
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
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