Csound Csound-dev Csound-tekno Search About

Interaction Between mxadsr and maxalloc

Date2016-06-25 23:23
FromEmmett Palaima
SubjectInteraction Between mxadsr and maxalloc
I'm trying to implement an envelope in my synthesis app, using mxadsr. In the same app I also use maxalloc to limit the number of voices in my synthesizer to prevent it from crashing from receiving to many notes at once. 

This leads to the problem that since mxadsr adds a release phase to the instrument, an instance in the release phase will still count for maxalloc, meaning the user can't start a new note until all the release phases are over. 

Does anyone have any advice for getting around this, either in the interface design or programmatically? 

My app is written in objective C using Csound for iOS. Notes are currently triggered through Steven Yi's keyboard from the Csound for iOS examples. I use a turnoff instrument to end the notes when a keyup action happens. Here is my csd:

<CsoundSynthesizer>

<CsOptions>

</CsOptions>

<CsInstruments>


sr = 44100

ksmps = 128

nchnls = 2

0dbfs = 1.0


giSine ftgen 3, 0, 16384, 10, 1

giSquare ftgen 1, 0, 16384, 10, 1, 0 , .33, 0, .2 , 0, .14, 0 , .11, 0, .09 ;odd harmonics

giSaw ftgen 2, 0, 16384, 10, 1, 0.5, 0.3, 0.25, 0.2, 0.167, 0.14, 0.125, .111


maxalloc 2, 4


turnon 1000

turnon 999


instr 1000 ;global controls

ktune1 chnget "osc1tune"

ktune2 chnget "osc2tune"

koscmix chnget "oscbalance"

kcutoff chnget "cutoff"

kreson chnget "resonance"

klfoamp chnget "lfoamp"

klforate chnget "lforate"

kfenvlev chnget "filterenvlevel"


gkactp port kactive, .01

gktune1p port ktune1, .01

gktune2p port ktune2, .01

gkoscmix port koscmix, .01

gkcutoff port kcutoff, .01

gkreson port kreson, .01

gklfoamp port klfoamp, .01

gklforate port klforate, .01

gkfenvlev port kfenvlev, .01


endin


instr 999


gklfo lfo gklfoamp, gklforate


endin


instr 1 ;turnoff instrument used in conjunction with keyUp


turnoff2 p4, 4, 1

turnoff


endin


instr 2 ;subtractive synth


kcps init 0

kkeytrak init 0


kactive active 2

kactp port kactive, .01


kfiltenv mxadsr p7, p8, p9, p10


kcps1 = (440.0*exp(log(2.0)*((p4+gktune1p)-69.0)/12.0)) ;translates midi to pitch

kcps2 = (440.0*exp(log(2.0)*((p4+gktune2p)-69.0)/12.0))

kkeytrack = (12*log2(gkcutoff/440)) ;sets up midi value for filter cutoff

klocalcut = (440.0*exp(log(2.0)*((p4+kkeytrack+gklfo+(kfiltenv*gkfenvlev))-69.0)/12.0)) ;uses midi value with input note to create keyboard tracking


apopenv mxadsr .03, 0, 1, .03



aosc1 oscil3 1/(gkactp+1)*apopenv*(1-gkoscmix), kcps1, p5

aosc2 oscil3 1/(gkactp+1)*apopenv*gkoscmix, kcps2, p6


afilter moogladder aosc1+aosc2, klocalcut, gkreson


;aosc vco .25-(.1*kactive), kcps, 2, .5, giSine


outs afilter, afilter

endin


</CsInstruments>

<CsScore>


</CsScore>

</CsoundSynthesizer>



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

Date2016-06-26 00:06
FromOeyvind Brandtsegg
SubjectRe: Interaction Between mxadsr and maxalloc
mmm, just a half-baked idea, but:
You could use the "active" opcode to read the number of active instances,
then bypass additional instances (after your allowed number of
instances) with something like
kactive active p1
if kactive > iN then
turnoff
endif
This would duplicate what you already have with maxalloc, then you
could modify it to allow for extra instances if any instance is in the
release stage.
Checking if an instance is in the release stage can be done by:
xtratim ireleasetime
krelease release

Actually I'm not sure (don't remember) if active will report an
instrument active during the release stage, if it does not, then the
release flag modification is not necessary.

best
Oeyvind

2016-06-26 0:23 GMT+02:00 Emmett Palaima :
> I'm trying to implement an envelope in my synthesis app, using mxadsr. In
> the same app I also use maxalloc to limit the number of voices in my
> synthesizer to prevent it from crashing from receiving to many notes at
> once.
>
> This leads to the problem that since mxadsr adds a release phase to the
> instrument, an instance in the release phase will still count for maxalloc,
> meaning the user can't start a new note until all the release phases are
> over.
>
> Does anyone have any advice for getting around this, either in the interface
> design or programmatically?
>
> My app is written in objective C using Csound for iOS. Notes are currently
> triggered through Steven Yi's keyboard from the Csound for iOS examples. I
> use a turnoff instrument to end the notes when a keyup action happens. Here
> is my csd:
>
> 
>
> 
>
> 
>
> 
>
>
> sr = 44100
>
> ksmps = 128
>
> nchnls = 2
>
> 0dbfs = 1.0
>
>
> giSine ftgen 3, 0, 16384, 10, 1
>
> giSquare ftgen 1, 0, 16384, 10, 1, 0 , .33, 0, .2 , 0, .14, 0 , .11, 0, .09
> ;odd harmonics
>
> giSaw ftgen 2, 0, 16384, 10, 1, 0.5, 0.3, 0.25, 0.2, 0.167, 0.14, 0.125,
> .111
>
>
> maxalloc 2, 4
>
>
> turnon 1000
>
> turnon 999
>
>
> instr 1000 ;global controls
>
> ktune1 chnget "osc1tune"
>
> ktune2 chnget "osc2tune"
>
> koscmix chnget "oscbalance"
>
> kcutoff chnget "cutoff"
>
> kreson chnget "resonance"
>
> klfoamp chnget "lfoamp"
>
> klforate chnget "lforate"
>
> kfenvlev chnget "filterenvlevel"
>
>
> gkactp port kactive, .01
>
> gktune1p port ktune1, .01
>
> gktune2p port ktune2, .01
>
> gkoscmix port koscmix, .01
>
> gkcutoff port kcutoff, .01
>
> gkreson port kreson, .01
>
> gklfoamp port klfoamp, .01
>
> gklforate port klforate, .01
>
> gkfenvlev port kfenvlev, .01
>
>
> endin
>
>
> instr 999
>
>
> gklfo lfo gklfoamp, gklforate
>
>
> endin
>
>
> instr 1 ;turnoff instrument used in conjunction with keyUp
>
>
> turnoff2 p4, 4, 1
>
> turnoff
>
>
> endin
>
>
> instr 2 ;subtractive synth
>
>
> kcps init 0
>
> kkeytrak init 0
>
>
> kactive active 2
>
> kactp port kactive, .01
>
>
> kfiltenv mxadsr p7, p8, p9, p10
>
>
> kcps1 = (440.0*exp(log(2.0)*((p4+gktune1p)-69.0)/12.0)) ;translates midi to
> pitch
>
> kcps2 = (440.0*exp(log(2.0)*((p4+gktune2p)-69.0)/12.0))
>
> kkeytrack = (12*log2(gkcutoff/440)) ;sets up midi value for filter cutoff
>
> klocalcut =
> (440.0*exp(log(2.0)*((p4+kkeytrack+gklfo+(kfiltenv*gkfenvlev))-69.0)/12.0))
> ;uses midi value with input note to create keyboard tracking
>
>
> apopenv mxadsr .03, 0, 1, .03
>
>
>
> aosc1 oscil3 1/(gkactp+1)*apopenv*(1-gkoscmix), kcps1, p5
>
> aosc2 oscil3 1/(gkactp+1)*apopenv*gkoscmix, kcps2, p6
>
>
> afilter moogladder aosc1+aosc2, klocalcut, gkreson
>
>
> ;aosc vco .25-(.1*kactive), kcps, 2, .5, giSine
>
>
> outs afilter, afilter
>
> endin
>
>
> 
>
> 
>
>
> 
>
> 
>
>
>
> 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


Date2016-06-26 10:53
FromIain McCurdy
SubjectRe: Interaction Between mxadsr and maxalloc
Actually you can now choose whether active includes notes in their release stage or not using its third arg.
http://csound.github.io/docs/manual/active.html

Iain

> Date: Sun, 26 Jun 2016 01:06:31 +0200
> From: oyvind.brandtsegg@NTNU.NO
> Subject: Re: [Csnd] Interaction Between mxadsr and maxalloc
> To: CSOUND@LISTSERV.HEANET.IE
>
> mmm, just a half-baked idea, but:
> You could use the "active" opcode to read the number of active instances,
> then bypass additional instances (after your allowed number of
> instances) with something like
> kactive active p1
> if kactive > iN then
> turnoff
> endif
> This would duplicate what you already have with maxalloc, then you
> could modify it to allow for extra instances if any instance is in the
> release stage.
> Checking if an instance is in the release stage can be done by:
> xtratim ireleasetime
> krelease release
>
> Actually I'm not sure (don't remember) if active will report an
> instrument active during the release stage, if it does not, then the
> release flag modification is not necessary.
>
> best
> Oeyvind
>
> 2016-06-26 0:23 GMT+02:00 Emmett Palaima <epalaima@berklee.edu>:
> > I'm trying to implement an envelope in my synthesis app, using mxadsr. In
> > the same app I also use maxalloc to limit the number of voices in my
> > synthesizer to prevent it from crashing from receiving to many notes at
> > once.
> >
> > This leads to the problem that since mxadsr adds a release phase to the
> > instrument, an instance in the release phase will still count for maxalloc,
> > meaning the user can't start a new note until all the release phases are
> > over.
> >
> > Does anyone have any advice for getting around this, either in the interface
> > design or programmatically?
> >
> > My app is written in objective C using Csound for iOS. Notes are currently
> > triggered through Steven Yi's keyboard from the Csound for iOS examples. I
> > use a turnoff instrument to end the notes when a keyup action happens. Here
> > is my csd:
> >
> > <CsoundSynthesizer>
> >
> > <CsOptions>
> >
> > </CsOptions>
> >
> > <CsInstruments>
> >
> >
> > sr = 44100
> >
> > ksmps = 128
> >
> > nchnls = 2
> >
> > 0dbfs = 1.0
> >
> >
> > giSine ftgen 3, 0, 16384, 10, 1
> >
> > giSquare ftgen 1, 0, 16384, 10, 1, 0 , .33, 0, .2 , 0, .14, 0 , .11, 0, .09
> > ;odd harmonics
> >
> > giSaw ftgen 2, 0, 16384, 10, 1, 0.5, 0.3, 0.25, 0.2, 0.167, 0.14, 0.125,
> > .111
> >
> >
> > maxalloc 2, 4
> >
> >
> > turnon 1000
> >
> > turnon 999
> >
> >
> > instr 1000 ;global controls
> >
> > ktune1 chnget "osc1tune"
> >
> > ktune2 chnget "osc2tune"
> >
> > koscmix chnget "oscbalance"
> >
> > kcutoff chnget "cutoff"
> >
> > kreson chnget "resonance"
> >
> > klfoamp chnget "lfoamp"
> >
> > klforate chnget "lforate"
> >
> > kfenvlev chnget "filterenvlevel"
> >
> >
> > gkactp port kactive, .01
> >
> > gktune1p port ktune1, .01
> >
> > gktune2p port ktune2, .01
> >
> > gkoscmix port koscmix, .01
> >
> > gkcutoff port kcutoff, .01
> >
> > gkreson port kreson, .01
> >
> > gklfoamp port klfoamp, .01
> >
> > gklforate port klforate, .01
> >
> > gkfenvlev port kfenvlev, .01
> >
> >
> > endin
> >
> >
> > instr 999
> >
> >
> > gklfo lfo gklfoamp, gklforate
> >
> >
> > endin
> >
> >
> > instr 1 ;turnoff instrument used in conjunction with keyUp
> >
> >
> > turnoff2 p4, 4, 1
> >
> > turnoff
> >
> >
> > endin
> >
> >
> > instr 2 ;subtractive synth
> >
> >
> > kcps init 0
> >
> > kkeytrak init 0
> >
> >
> > kactive active 2
> >
> > kactp port kactive, .01
> >
> >
> > kfiltenv mxadsr p7, p8, p9, p10
> >
> >
> > kcps1 = (440.0*exp(log(2.0)*((p4+gktune1p)-69.0)/12.0)) ;translates midi to
> > pitch
> >
> > kcps2 = (440.0*exp(log(2.0)*((p4+gktune2p)-69.0)/12.0))
> >
> > kkeytrack = (12*log2(gkcutoff/440)) ;sets up midi value for filter cutoff
> >
> > klocalcut =
> > (440.0*exp(log(2.0)*((p4+kkeytrack+gklfo+(kfiltenv*gkfenvlev))-69.0)/12.0))
> > ;uses midi value with input note to create keyboard tracking
> >
> >
> > apopenv mxadsr .03, 0, 1, .03
> >
> >
> >
> > aosc1 oscil3 1/(gkactp+1)*apopenv*(1-gkoscmix), kcps1, p5
> >
> > aosc2 oscil3 1/(gkactp+1)*apopenv*gkoscmix, kcps2, p6
> >
> >
> > afilter moogladder aosc1+aosc2, klocalcut, gkreson
> >
> >
> > ;aosc vco .25-(.1*kactive), kcps, 2, .5, giSine
> >
> >
> > outs afilter, afilter
> >
> > endin
> >
> >
> > </CsInstruments>
> >
> > <CsScore>
> >
> >
> > </CsScore>
> >
> > </CsoundSynthesizer>
> >
> >
> >
> > 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
>
>
>
> --
>
> Oeyvind Brandtsegg
> Professor of Music Technology
> NTNU
> 7491 Trondheim
> Norway
> Cell: +47 92 203 205
>
> http://www.partikkelaudio.com/
> http://soundcloud.com/brandtsegg
> http://flyndresang.no/
> http://soundcloud.com/t-emp
>
> 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

Date2016-06-26 19:06
FromEmmett Palaima
SubjectRe: Interaction Between mxadsr and maxalloc
Thats good to know. Is that new feature in Csound 6.07?

On Sun, Jun 26, 2016 at 4:53 AM, Iain McCurdy <i_mccurdy@hotmail.com> wrote:
Actually you can now choose whether active includes notes in their release stage or not using its third arg.
http://csound.github.io/docs/manual/active.html

Iain

> Date: Sun, 26 Jun 2016 01:06:31 +0200
> From: oyvind.brandtsegg@NTNU.NO
> Subject: Re: [Csnd] Interaction Between mxadsr and maxalloc
> To: CSOUND@LISTSERV.HEANET.IE

>
> mmm, just a half-baked idea, but:
> You could use the "active" opcode to read the number of active instances,
> then bypass additional instances (after your allowed number of
> instances) with something like
> kactive active p1
> if kactive > iN then
> turnoff
> endif
> This would duplicate what you already have with maxalloc, then you
> could modify it to allow for extra instances if any instance is in the
> release stage.
> Checking if an instance is in the release stage can be done by:
> xtratim ireleasetime
> krelease release
>
> Actually I'm not sure (don't remember) if active will report an
> instrument active during the release stage, if it does not, then the
> release flag modification is not necessary.
>
> best
> Oeyvind
>
> 2016-06-26 0:23 GMT+02:00 Emmett Palaima <epalaima@berklee.edu>:
> > I'm trying to implement an envelope in my synthesis app, using mxadsr. In
> > the same app I also use maxalloc to limit the number of voices in my
> > synthesizer to prevent it from crashing from receiving to many notes at
> > once.
> >
> > This leads to the problem that since mxadsr adds a release phase to the
> > instrument, an instance in the release phase will still count for maxalloc,
> > meaning the user can't start a new note until all the release phases are
> > over.
> >
> > Does anyone have any advice for getting around this, either in the interface
> > design or programmatically?
> >
> > My app is written in objective C using Csound for iOS. Notes are currently
> > triggered through Steven Yi's keyboard from the Csound for iOS examples. I
> > use a turnoff instrument to end the notes when a keyup action happens. Here
> > is my csd:
> >
> > <CsoundSynthesizer>
> >
> > <CsOptions>
> >
> > </CsOptions>
> >
> > <CsInstruments>
> >
> >
> > sr = 44100
> >
> > ksmps = 128
> >
> > nchnls = 2
> >
> > 0dbfs = 1.0
> >
> >
> > giSine ftgen 3, 0, 16384, 10, 1
> >
> > giSquare ftgen 1, 0, 16384, 10, 1, 0 , .33, 0, .2 , 0, .14, 0 , .11, 0, .09
> > ;odd harmonics
> >
> > giSaw ftgen 2, 0, 16384, 10, 1, 0.5, 0.3, 0.25, 0.2, 0.167, 0.14, 0.125,
> > .111
> >
> >
> > maxalloc 2, 4
> >
> >
> > turnon 1000
> >
> > turnon 999
> >
> >
> > instr 1000 ;global controls
> >
> > ktune1 chnget "osc1tune"
> >
> > ktune2 chnget "osc2tune"
> >
> > koscmix chnget "oscbalance"
> >
> > kcutoff chnget "cutoff"
> >
> > kreson chnget "resonance"
> >
> > klfoamp chnget "lfoamp"
> >
> > klforate chnget "lforate"
> >
> > kfenvlev chnget "filterenvlevel"
> >
> >
> > gkactp port kactive, .01
> >
> > gktune1p port ktune1, .01
> >
> > gktune2p port ktune2, .01
> >
> > gkoscmix port koscmix, .01
> >
> > gkcutoff port kcutoff, .01
> >
> > gkreson port kreson, .01
> >
> > gklfoamp port klfoamp, .01
> >
> > gklforate port klforate, .01
> >
> > gkfenvlev port kfenvlev, .01
> >
> >
> > endin
> >
> >
> > instr 999
> >
> >
> > gklfo lfo gklfoamp, gklforate
> >
> >
> > endin
> >
> >
> > instr 1 ;turnoff instrument used in conjunction with keyUp
> >
> >
> > turnoff2 p4, 4, 1
> >
> > turnoff
> >
> >
> > endin
> >
> >
> > instr 2 ;subtractive synth
> >
> >
> > kcps init 0
> >
> > kkeytrak init 0
> >
> >
> > kactive active 2
> >
> > kactp port kactive, .01
> >
> >
> > kfiltenv mxadsr p7, p8, p9, p10
> >
> >
> > kcps1 = (440.0*exp(log(2.0)*((p4+gktune1p)-69.0)/12.0)) ;translates midi to
> > pitch
> >
> > kcps2 = (440.0*exp(log(2.0)*((p4+gktune2p)-69.0)/12.0))
> >
> > kkeytrack = (12*log2(gkcutoff/440)) ;sets up midi value for filter cutoff
> >
> > klocalcut =
> > (440.0*exp(log(2.0)*((p4+kkeytrack+gklfo+(kfiltenv*gkfenvlev))-69.0)/12.0))
> > ;uses midi value with input note to create keyboard tracking
> >
> >
> > apopenv mxadsr .03, 0, 1, .03
> >
> >
> >
> > aosc1 oscil3 1/(gkactp+1)*apopenv*(1-gkoscmix), kcps1, p5
> >
> > aosc2 oscil3 1/(gkactp+1)*apopenv*gkoscmix, kcps2, p6
> >
> >
> > afilter moogladder aosc1+aosc2, klocalcut, gkreson
> >
> >
> > ;aosc vco .25-(.1*kactive), kcps, 2, .5, giSine
> >
> >
> > outs afilter, afilter
> >
> > endin
> >
> >
> > </CsInstruments>
> >
> > <CsScore>
> >
> >
> > </CsScore>
> >
> > </CsoundSynthesizer>
> >
> >
> >
> > 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
>
>
>
> --
>
> Oeyvind Brandtsegg
> Professor of Music Technology
> NTNU
> 7491 Trondheim
> Norway
> Cell: +47 92 203 205
>
> http://www.partikkelaudio.com/
> http://soundcloud.com/brandtsegg
> http://flyndresang.no/
> http://soundcloud.com/t-emp
>
> 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