Csound Csound-dev Csound-tekno Search About

Active Opcode Output Changing Before Instrument is Done

Date2016-06-20 01:55
FromEmmett Palaima
SubjectActive Opcode Output Changing Before Instrument is Done
Hi, I am currently working on an app an app that models an additive synthesizer, and in order to enable polyphony while simultaneously avoiding clipping I was using the active opcode to scale the amplitude of my oscillator. This works great except for that active seems to be registering a change in the number of active instruments before the instrument fully shuts off. 

This means I get a Warning, Division by 0 error every time the last instance of my instrument is turned off. I tried reworking the way I was scaling the output to avoid this, but this causes the output of the instrument to be scaled up just as it is turning off, leading to a more pronounced click. 

I will probably solve the issue with the port opcode, but that seems like kind of a work around, so I was wondering if anyone else could suggest a better solution. Here is the instrument I was using. 

instr 2 


kactive active 2


kcps init (440.0*exp(log(2.0)*((p4)-69.0)/12.0)) ;translates midi to pitch


aosc oscil3 1/(kactive+1), kcps, 2 ;this is the version that creates clicks

;aosc oscil3 .5/kactive, kcps, 2  ;this is the version that gives division by zero warning


outs aosc, aosc

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-20 08:32
FromIain McCurdy
SubjectRe: Active Opcode Output Changing Before Instrument is Done
Could you attach the full instrument and provide details of version and platform? When I test the code you provided, it works for me as you desire without a div. by zero error.
Iain


Date: Sun, 19 Jun 2016 19:55:55 -0500
From: epalaima@BERKLEE.EDU
Subject: [Csnd] Active Opcode Output Changing Before Instrument is Done
To: CSOUND@LISTSERV.HEANET.IE

Hi, I am currently working on an app an app that models an additive synthesizer, and in order to enable polyphony while simultaneously avoiding clipping I was using the active opcode to scale the amplitude of my oscillator. This works great except for that active seems to be registering a change in the number of active instruments before the instrument fully shuts off. 

This means I get a Warning, Division by 0 error every time the last instance of my instrument is turned off. I tried reworking the way I was scaling the output to avoid this, but this causes the output of the instrument to be scaled up just as it is turning off, leading to a more pronounced click. 

I will probably solve the issue with the port opcode, but that seems like kind of a work around, so I was wondering if anyone else could suggest a better solution. Here is the instrument I was using. 

instr 2 


kactive active 2


kcps init (440.0*exp(log(2.0)*((p4)-69.0)/12.0)) ;translates midi to pitch


aosc oscil3 1/(kactive+1), kcps, 2 ;this is the version that creates clicks

;aosc oscil3 .5/kactive, kcps, 2  ;this is the version that gives division by zero warning


outs aosc, aosc

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-21 05:39
FromEmmett Palaima
SubjectRe: Active Opcode Output Changing Before Instrument is Done

Here is the turnoff instrument as well. Both are controlled by the score events triggered by Steven Yi's keyboard from the Csound for iOS examples. 


keyDown triggers: i2.%d 0 -2 %d, %d

keyUp triggers: i1 0 .1 2.%d


%d represents the midi note number of the key in both cases.


instr 1 ;turnoff instrument used in conjunction with keyUp


turnoff2 p4, 4, 1

turnoff


endin


instr 2 


kactive active 2


kcps init (440.0*exp(log(2.0)*((p4)-69.0)/12.0)) ;translates midi to pitch


aosc oscil3 1/(kactive+1), kcps, 2 ;this is the version that creates clicks

;aosc oscil3 .5/kactive, kcps, 2  ;this is the version that gives division by zero warning


outs aosc, aosc

endin


On Mon, Jun 20, 2016 at 2:32 AM, Iain McCurdy <i_mccurdy@hotmail.com> wrote:
Could you attach the full instrument and provide details of version and platform? When I test the code you provided, it works for me as you desire without a div. by zero error.
Iain


Date: Sun, 19 Jun 2016 19:55:55 -0500
From: epalaima@BERKLEE.EDU
Subject: [Csnd] Active Opcode Output Changing Before Instrument is Done
To: CSOUND@LISTSERV.HEANET.IE


Hi, I am currently working on an app an app that models an additive synthesizer, and in order to enable polyphony while simultaneously avoiding clipping I was using the active opcode to scale the amplitude of my oscillator. This works great except for that active seems to be registering a change in the number of active instruments before the instrument fully shuts off. 

This means I get a Warning, Division by 0 error every time the last instance of my instrument is turned off. I tried reworking the way I was scaling the output to avoid this, but this causes the output of the instrument to be scaled up just as it is turning off, leading to a more pronounced click. 

I will probably solve the issue with the port opcode, but that seems like kind of a work around, so I was wondering if anyone else could suggest a better solution. Here is the instrument I was using. 

instr 2 


kactive active 2


kcps init (440.0*exp(log(2.0)*((p4)-69.0)/12.0)) ;translates midi to pitch


aosc oscil3 1/(kactive+1), kcps, 2 ;this is the version that creates clicks

;aosc oscil3 .5/kactive, kcps, 2  ;this is the version that gives division by zero warning


outs aosc, aosc

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
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

Date2016-06-21 05:40
FromEmmett Palaima
SubjectRe: Active Opcode Output Changing Before Instrument is Done
My bad, small typo:

keyDown triggers: i2.%d 0 -2 %d

On Mon, Jun 20, 2016 at 11:39 PM, Emmett Palaima <epalaima@berklee.edu> wrote:

Here is the turnoff instrument as well. Both are controlled by the score events triggered by Steven Yi's keyboard from the Csound for iOS examples. 


keyDown triggers: i2.%d 0 -2 %d, %d

keyUp triggers: i1 0 .1 2.%d


%d represents the midi note number of the key in both cases.


instr 1 ;turnoff instrument used in conjunction with keyUp


turnoff2 p4, 4, 1

turnoff


endin


instr 2 


kactive active 2


kcps init (440.0*exp(log(2.0)*((p4)-69.0)/12.0)) ;translates midi to pitch


aosc oscil3 1/(kactive+1), kcps, 2 ;this is the version that creates clicks

;aosc oscil3 .5/kactive, kcps, 2  ;this is the version that gives division by zero warning


outs aosc, aosc

endin


On Mon, Jun 20, 2016 at 2:32 AM, Iain McCurdy <i_mccurdy@hotmail.com> wrote:
Could you attach the full instrument and provide details of version and platform? When I test the code you provided, it works for me as you desire without a div. by zero error.
Iain


Date: Sun, 19 Jun 2016 19:55:55 -0500
From: epalaima@BERKLEE.EDU
Subject: [Csnd] Active Opcode Output Changing Before Instrument is Done
To: CSOUND@LISTSERV.HEANET.IE


Hi, I am currently working on an app an app that models an additive synthesizer, and in order to enable polyphony while simultaneously avoiding clipping I was using the active opcode to scale the amplitude of my oscillator. This works great except for that active seems to be registering a change in the number of active instruments before the instrument fully shuts off. 

This means I get a Warning, Division by 0 error every time the last instance of my instrument is turned off. I tried reworking the way I was scaling the output to avoid this, but this causes the output of the instrument to be scaled up just as it is turning off, leading to a more pronounced click. 

I will probably solve the issue with the port opcode, but that seems like kind of a work around, so I was wondering if anyone else could suggest a better solution. Here is the instrument I was using. 

instr 2 


kactive active 2


kcps init (440.0*exp(log(2.0)*((p4)-69.0)/12.0)) ;translates midi to pitch


aosc oscil3 1/(kactive+1), kcps, 2 ;this is the version that creates clicks

;aosc oscil3 .5/kactive, kcps, 2  ;this is the version that gives division by zero warning


outs aosc, aosc

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
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