Csound Csound-dev Csound-tekno Search About

[Csnd] print values if subinstr is active

Date2024-05-19 11:31
FromStefan Thomas
Subject[Csnd] print values if subinstr is active
Dear community,
In the following example, I would like to print the value of iamp, but only if the subinstrument is activated (when a midi key is pressed).
How could I achieve this?
<CsoundSynthesizer>
<CsOptions>
-o dac -Ma
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1

instr 1 ;master instrument
inumparts =         p4 ;number of partials
ibasfreq          cpsmidi
ibaseamp       ampmidi 1
ipart     =         1 ;count variable for loop
;loop for inumparts over the ipart variable
;and trigger inumpartss instanes of the subinstrument
loop:
ifreq     =         ibasfreq * ipart
iamp      =         ibaseamp/ipart/inumparts
          event_i   "i", 10, 0, p3, ifreq, iamp
          loop_le   ipart, 1, inumparts, loop
endin

instr 10 ;subinstrument for playing one partial
ifreq     =         p4 ;frequency of this partial
iamp      =         p5 ;amplitude of this partial
aenv      transeg   0, .01, 0, iamp, p3-0.1, -10, 0
apart     poscil    aenv, ifreq
          outs      apart, apart
endin

</CsInstruments>
<CsScore>
;         number of partials
i 1 0 3   10
i 1 3 3   20
i 1 6 3   2
</CsScore>
</CsoundSynthesizer>
;Example by joachim heintz
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

Date2024-05-19 11:56
Fromjoachim heintz
SubjectRe: [Csnd] print values if subinstr is active
hi stefan -
i don't understand this condition: "only if the subinstrument is 
activated (when a midi key is pressed)".
do you trigger via midi keyboard, or via score, or both?
best -
	joachim


On 19/05/2024 12:31, Stefan Thomas wrote:
> Dear community,
> In the following example, I would like to print the value of iamp, but 
> only if the subinstrument is activated (when a midi key is pressed).
> How could I achieve this?
> 
> 
> -o dac -Ma
> 
> 
> sr = 44100
> ksmps = 32
> nchnls = 2
> 0dbfs = 1
> 
> instr 1 ;master instrument
> inumparts =         p4 ;number of partials
> ibasfreq          cpsmidi
> ibaseamp       ampmidi 1
> ipart     =         1 ;count variable for loop
> ;loop for inumparts over the ipart variable
> ;and trigger inumpartss instanes of the subinstrument
> loop:
> ifreq     =         ibasfreq * ipart
> iamp      =         ibaseamp/ipart/inumparts
>            event_i   "i", 10, 0, p3, ifreq, iamp
>            loop_le   ipart, 1, inumparts, loop
> endin
> 
> instr 10 ;subinstrument for playing one partial
> ifreq     =         p4 ;frequency of this partial
> iamp      =         p5 ;amplitude of this partial
> aenv      transeg   0, .01, 0, iamp, p3-0.1, -10, 0
> apart     poscil    aenv, ifreq
>            outs      apart, apart
> endin
> 
> 
> 
> ;         number of partials
> i 1 0 3   10
> i 1 3 3   20
> i 1 6 3   2
> 
> 
> ;Example by joachim heintz
> 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

Date2024-05-19 18:26
FromStefan Thomas
SubjectRe: [Csnd] print values if subinstr is active
I trigger via midi keyboard instr 1 which triggers instr 10

joachim heintz <jh@joachimheintz.de> schrieb am So., 19. Mai 2024, 12:57:
hi stefan -
i don't understand this condition: "only if the subinstrument is
activated (when a midi key is pressed)".
do you trigger via midi keyboard, or via score, or both?
best -
        joachim


On 19/05/2024 12:31, Stefan Thomas wrote:
> Dear community,
> In the following example, I would like to print the value of iamp, but
> only if the subinstrument is activated (when a midi key is pressed).
> How could I achieve this?
> <CsoundSynthesizer>
> <CsOptions>
> -o dac -Ma
> </CsOptions>
> <CsInstruments>
> sr = 44100
> ksmps = 32
> nchnls = 2
> 0dbfs = 1
>
> instr 1 ;master instrument
> inumparts =         p4 ;number of partials
> ibasfreq          cpsmidi
> ibaseamp       ampmidi 1
> ipart     =         1 ;count variable for loop
> ;loop for inumparts over the ipart variable
> ;and trigger inumpartss instanes of the subinstrument
> loop:
> ifreq     =         ibasfreq * ipart
> iamp      =         ibaseamp/ipart/inumparts
>            event_i   "i", 10, 0, p3, ifreq, iamp
>            loop_le   ipart, 1, inumparts, loop
> endin
>
> instr 10 ;subinstrument for playing one partial
> ifreq     =         p4 ;frequency of this partial
> iamp      =         p5 ;amplitude of this partial
> aenv      transeg   0, .01, 0, iamp, p3-0.1, -10, 0
> apart     poscil    aenv, ifreq
>            outs      apart, apart
> endin
>
> </CsInstruments>
> <CsScore>
> ;         number of partials
> i 1 0 3   10
> i 1 3 3   20
> i 1 6 3   2
> </CsScore>
> </CsoundSynthesizer>
> ;Example by joachim heintz
> Csound mailing list Csound@listserv.heanet.ie
> <mailto:Csound@listserv.heanet.ie>
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND> Send bugs reports to
> https://github.com/csound/csound/issues
> <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

Date2024-05-19 18:51
Fromjoachim heintz
SubjectRe: [Csnd] print values if subinstr is active
but then, what is the question?
why not simply print(iamp)?

On 19/05/2024 19:26, Stefan Thomas wrote:
> I trigger via midi keyboard instr 1 which triggers instr 10
> 
> joachim heintz > 
> schrieb am So., 19. Mai 2024, 12:57:
> 
>     hi stefan -
>     i don't understand this condition: "only if the subinstrument is
>     activated (when a midi key is pressed)".
>     do you trigger via midi keyboard, or via score, or both?
>     best -
>              joachim
> 
> 
>     On 19/05/2024 12:31, Stefan Thomas wrote:
>      > Dear community,
>      > In the following example, I would like to print the value of
>     iamp, but
>      > only if the subinstrument is activated (when a midi key is pressed).
>      > How could I achieve this?
>      > 
>      > 
>      > -o dac -Ma
>      > 
>      > 
>      > sr = 44100
>      > ksmps = 32
>      > nchnls = 2
>      > 0dbfs = 1
>      >
>      > instr 1 ;master instrument
>      > inumparts =         p4 ;number of partials
>      > ibasfreq          cpsmidi
>      > ibaseamp       ampmidi 1
>      > ipart     =         1 ;count variable for loop
>      > ;loop for inumparts over the ipart variable
>      > ;and trigger inumpartss instanes of the subinstrument
>      > loop:
>      > ifreq     =         ibasfreq * ipart
>      > iamp      =         ibaseamp/ipart/inumparts
>      >            event_i   "i", 10, 0, p3, ifreq, iamp
>      >            loop_le   ipart, 1, inumparts, loop
>      > endin
>      >
>      > instr 10 ;subinstrument for playing one partial
>      > ifreq     =         p4 ;frequency of this partial
>      > iamp      =         p5 ;amplitude of this partial
>      > aenv      transeg   0, .01, 0, iamp, p3-0.1, -10, 0
>      > apart     poscil    aenv, ifreq
>      >            outs      apart, apart
>      > endin
>      >
>      > 
>      > 
>      > ;         number of partials
>      > i 1 0 3   10
>      > i 1 3 3   20
>      > i 1 6 3   2
>      > 
>      > 
>      > ;Example by joachim heintz
>      > 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

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

Date2024-05-19 19:26
FromStefan Thomas
SubjectRe: [Csnd] print values if subinstr is active
Sorry, I made a couple of mistakes in the code, I was too hasty again.
With this below quoted code I get, before pressing the first midikey the following messages:
instr 10:  iamp = 0.000
instr 10:  iamp = 0.000
instr 10:  iamp = 0.000
instr 10:  iamp = 0.000
instr 10:  iamp = 0.000
instr 10:  iamp = 0.000
instr 10:  iamp = 0.000
instr 10:  iamp = 0.000
instr 10:  iamp = 0.000
instr 10:  iamp = 0.000

<CsoundSynthesizer>
<CsOptions>
-o dac -Ma -m0d
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1
alwayson 1
instr 1 ;master instrument
inumparts =         10 ;number of partials
ibasfreq          cpsmidi
ibaseamp       ampmidi 1
ipart     =         1 ;count variable for loop
;loop for inumparts over the ipart variable
;and trigger inumpartss instanes of the subinstrument
loop:
ifreq     =         ibasfreq * ipart
iamp      =         ibaseamp/ipart/inumparts
          event_i   "i", 10, 0, p3, ifreq, iamp
          loop_le   ipart, 1, inumparts, loop
endin
;         number of partials

instr 10 ;subinstrument for playing one partial
ifreq     =         p4 ;frequency of this partial
iamp      =         p5 ;amplitude of this partial
print(iamp)
aenv      transeg   0, .01, 0, iamp, p3-0.1, -10, 0
apart     poscil    aenv, ifreq
          outs      apart, apart
endin

</CsInstruments>
<CsScore>
</CsScore>
</CsoundSynthesizer>
;Example by joachim heintz

Am So., 19. Mai 2024 um 19:51 Uhr schrieb joachim heintz <jh@joachimheintz.de>:
but then, what is the question?
why not simply print(iamp)?

On 19/05/2024 19:26, Stefan Thomas wrote:
> I trigger via midi keyboard instr 1 which triggers instr 10
>
> joachim heintz <jh@joachimheintz.de <mailto:jh@joachimheintz.de>>
> schrieb am So., 19. Mai 2024, 12:57:
>
>     hi stefan -
>     i don't understand this condition: "only if the subinstrument is
>     activated (when a midi key is pressed)".
>     do you trigger via midi keyboard, or via score, or both?
>     best -
>              joachim
>
>
>     On 19/05/2024 12:31, Stefan Thomas wrote:
>      > Dear community,
>      > In the following example, I would like to print the value of
>     iamp, but
>      > only if the subinstrument is activated (when a midi key is pressed).
>      > How could I achieve this?
>      > <CsoundSynthesizer>
>      > <CsOptions>
>      > -o dac -Ma
>      > </CsOptions>
>      > <CsInstruments>
>      > sr = 44100
>      > ksmps = 32
>      > nchnls = 2
>      > 0dbfs = 1
>      >
>      > instr 1 ;master instrument
>      > inumparts =         p4 ;number of partials
>      > ibasfreq          cpsmidi
>      > ibaseamp       ampmidi 1
>      > ipart     =         1 ;count variable for loop
>      > ;loop for inumparts over the ipart variable
>      > ;and trigger inumpartss instanes of the subinstrument
>      > loop:
>      > ifreq     =         ibasfreq * ipart
>      > iamp      =         ibaseamp/ipart/inumparts
>      >            event_i   "i", 10, 0, p3, ifreq, iamp
>      >            loop_le   ipart, 1, inumparts, loop
>      > endin
>      >
>      > instr 10 ;subinstrument for playing one partial
>      > ifreq     =         p4 ;frequency of this partial
>      > iamp      =         p5 ;amplitude of this partial
>      > aenv      transeg   0, .01, 0, iamp, p3-0.1, -10, 0
>      > apart     poscil    aenv, ifreq
>      >            outs      apart, apart
>      > endin
>      >
>      > </CsInstruments>
>      > <CsScore>
>      > ;         number of partials
>      > i 1 0 3   10
>      > i 1 3 3   20
>      > i 1 6 3   2
>      > </CsScore>
>      > </CsoundSynthesizer>
>      > ;Example by joachim heintz
>      > Csound mailing list Csound@listserv.heanet.ie
>     <mailto:Csound@listserv.heanet.ie>
>      > <mailto:Csound@listserv.heanet.ie
>     <mailto:Csound@listserv.heanet.ie>>
>      > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>     <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND>
>      > <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>     <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND>> Send bugs reports to
>      > https://github.com/csound/csound/issues
>     <https://github.com/csound/csound/issues>
>      > <https://github.com/csound/csound/issues
>     <https://github.com/csound/csound/issues>> Discussions of bugs and
>      > features can be posted here
>
>     Csound mailing list
>     Csound@listserv.heanet.ie <mailto:Csound@listserv.heanet.ie>
>     https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>     <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND>
>     Send bugs reports to
>     https://github.com/csound/csound/issues
>     <https://github.com/csound/csound/issues>
>     Discussions of bugs and features can be posted here
>
> Csound mailing list Csound@listserv.heanet.ie
> <mailto:Csound@listserv.heanet.ie>
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND> Send bugs reports to
> https://github.com/csound/csound/issues
> <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

Date2024-05-19 19:56
FromDave Seidel
SubjectRe: [Csnd] print values if subinstr is active
Unless I'm reading this wrong, it looks like you are running instr 1 from the score, and instr 1 is invoking instr 10 in a loop. which will happen regardless of MIDI input.

On Sun, May 19, 2024 at 2:26 PM Stefan Thomas <kontrapunktstefan@gmail.com> wrote:
Sorry, I made a couple of mistakes in the code, I was too hasty again.
With this below quoted code I get, before pressing the first midikey the following messages:
instr 10:  iamp = 0.000
instr 10:  iamp = 0.000
instr 10:  iamp = 0.000
instr 10:  iamp = 0.000
instr 10:  iamp = 0.000
instr 10:  iamp = 0.000
instr 10:  iamp = 0.000
instr 10:  iamp = 0.000
instr 10:  iamp = 0.000
instr 10:  iamp = 0.000

<CsoundSynthesizer>
<CsOptions>
-o dac -Ma -m0d
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1
alwayson 1
instr 1 ;master instrument
inumparts =         10 ;number of partials
ibasfreq          cpsmidi
ibaseamp       ampmidi 1
ipart     =         1 ;count variable for loop
;loop for inumparts over the ipart variable
;and trigger inumpartss instanes of the subinstrument
loop:
ifreq     =         ibasfreq * ipart
iamp      =         ibaseamp/ipart/inumparts
          event_i   "i", 10, 0, p3, ifreq, iamp
          loop_le   ipart, 1, inumparts, loop
endin
;         number of partials

instr 10 ;subinstrument for playing one partial
ifreq     =         p4 ;frequency of this partial
iamp      =         p5 ;amplitude of this partial
print(iamp)
aenv      transeg   0, .01, 0, iamp, p3-0.1, -10, 0
apart     poscil    aenv, ifreq
          outs      apart, apart
endin

</CsInstruments>
<CsScore>
</CsScore>
</CsoundSynthesizer>
;Example by joachim heintz

Am So., 19. Mai 2024 um 19:51 Uhr schrieb joachim heintz <jh@joachimheintz.de>:
but then, what is the question?
why not simply print(iamp)?

On 19/05/2024 19:26, Stefan Thomas wrote:
> I trigger via midi keyboard instr 1 which triggers instr 10
>
> joachim heintz <jh@joachimheintz.de <mailto:jh@joachimheintz.de>>
> schrieb am So., 19. Mai 2024, 12:57:
>
>     hi stefan -
>     i don't understand this condition: "only if the subinstrument is
>     activated (when a midi key is pressed)".
>     do you trigger via midi keyboard, or via score, or both?
>     best -
>              joachim
>
>
>     On 19/05/2024 12:31, Stefan Thomas wrote:
>      > Dear community,
>      > In the following example, I would like to print the value of
>     iamp, but
>      > only if the subinstrument is activated (when a midi key is pressed).
>      > How could I achieve this?
>      > <CsoundSynthesizer>
>      > <CsOptions>
>      > -o dac -Ma
>      > </CsOptions>
>      > <CsInstruments>
>      > sr = 44100
>      > ksmps = 32
>      > nchnls = 2
>      > 0dbfs = 1
>      >
>      > instr 1 ;master instrument
>      > inumparts =         p4 ;number of partials
>      > ibasfreq          cpsmidi
>      > ibaseamp       ampmidi 1
>      > ipart     =         1 ;count variable for loop
>      > ;loop for inumparts over the ipart variable
>      > ;and trigger inumpartss instanes of the subinstrument
>      > loop:
>      > ifreq     =         ibasfreq * ipart
>      > iamp      =         ibaseamp/ipart/inumparts
>      >            event_i   "i", 10, 0, p3, ifreq, iamp
>      >            loop_le   ipart, 1, inumparts, loop
>      > endin
>      >
>      > instr 10 ;subinstrument for playing one partial
>      > ifreq     =         p4 ;frequency of this partial
>      > iamp      =         p5 ;amplitude of this partial
>      > aenv      transeg   0, .01, 0, iamp, p3-0.1, -10, 0
>      > apart     poscil    aenv, ifreq
>      >            outs      apart, apart
>      > endin
>      >
>      > </CsInstruments>
>      > <CsScore>
>      > ;         number of partials
>      > i 1 0 3   10
>      > i 1 3 3   20
>      > i 1 6 3   2
>      > </CsScore>
>      > </CsoundSynthesizer>
>      > ;Example by joachim heintz
>      > Csound mailing list Csound@listserv.heanet.ie
>     <mailto:Csound@listserv.heanet.ie>
>      > <mailto:Csound@listserv.heanet.ie
>     <mailto:Csound@listserv.heanet.ie>>
>      > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>     <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND>
>      > <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>     <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND>> Send bugs reports to
>      > https://github.com/csound/csound/issues
>     <https://github.com/csound/csound/issues>
>      > <https://github.com/csound/csound/issues
>     <https://github.com/csound/csound/issues>> Discussions of bugs and
>      > features can be posted here
>
>     Csound mailing list
>     Csound@listserv.heanet.ie <mailto:Csound@listserv.heanet.ie>
>     https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>     <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND>
>     Send bugs reports to
>     https://github.com/csound/csound/issues
>     <https://github.com/csound/csound/issues>
>     Discussions of bugs and features can be posted here
>
> Csound mailing list Csound@listserv.heanet.ie
> <mailto:Csound@listserv.heanet.ie>
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND> Send bugs reports to
> https://github.com/csound/csound/issues
> <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
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

Date2024-05-19 19:59
Fromjoachim heintz
SubjectRe: [Csnd] print values if subinstr is active
but why do you write "alwayson 1"?
what you want to do is to trrigger your instr 1 via midi keyboard.
this happens, as you say. (otherwise it would be a problem of the midi 
settings.)
so no need for a score, and no need for any alwayson.
here are more descriptions: 
https://flossmanual.csound.com/midi/triggering-instrument-instances


On 19/05/2024 20:26, Stefan Thomas wrote:
> Sorry, I made a couple of mistakes in the code, I was too hasty again.
> With this below quoted code I get, before pressing the first midikey the 
> following messages:
> instr 10:  iamp = 0.000
> instr 10:  iamp = 0.000
> instr 10:  iamp = 0.000
> instr 10:  iamp = 0.000
> instr 10:  iamp = 0.000
> instr 10:  iamp = 0.000
> instr 10:  iamp = 0.000
> instr 10:  iamp = 0.000
> instr 10:  iamp = 0.000
> instr 10:  iamp = 0.000
> 
> 
> 
> -o dac -Ma -m0d
> 
> 
> sr = 44100
> ksmps = 32
> nchnls = 2
> 0dbfs = 1
> alwayson 1
> instr 1 ;master instrument
> inumparts =         10 ;number of partials
> ibasfreq          cpsmidi
> ibaseamp       ampmidi 1
> ipart     =         1 ;count variable for loop
> ;loop for inumparts over the ipart variable
> ;and trigger inumpartss instanes of the subinstrument
> loop:
> ifreq     =         ibasfreq * ipart
> iamp      =         ibaseamp/ipart/inumparts
>            event_i   "i", 10, 0, p3, ifreq, iamp
>            loop_le   ipart, 1, inumparts, loop
> endin
> ;         number of partials
> 
> instr 10 ;subinstrument for playing one partial
> ifreq     =         p4 ;frequency of this partial
> iamp      =         p5 ;amplitude of this partial
> print(iamp)
> aenv      transeg   0, .01, 0, iamp, p3-0.1, -10, 0
> apart     poscil    aenv, ifreq
>            outs      apart, apart
> endin
> 
> 
> 
> 
> 
> ;Example by joachim heintz
> 
> Am So., 19. Mai 2024 um 19:51 Uhr schrieb joachim heintz 
> >:
> 
>     but then, what is the question?
>     why not simply print(iamp)?
> 
>     On 19/05/2024 19:26, Stefan Thomas wrote:
>      > I trigger via midi keyboard instr 1 which triggers instr 10
>      >
>      > joachim heintz 
>     >>
>      > schrieb am So., 19. Mai 2024, 12:57:
>      >
>      >     hi stefan -
>      >     i don't understand this condition: "only if the subinstrument is
>      >     activated (when a midi key is pressed)".
>      >     do you trigger via midi keyboard, or via score, or both?
>      >     best -
>      >              joachim
>      >
>      >
>      >     On 19/05/2024 12:31, Stefan Thomas wrote:
>      >      > Dear community,
>      >      > In the following example, I would like to print the value of
>      >     iamp, but
>      >      > only if the subinstrument is activated (when a midi key is
>     pressed).
>      >      > How could I achieve this?
>      >      > 
>      >      > 
>      >      > -o dac -Ma
>      >      > 
>      >      > 
>      >      > sr = 44100
>      >      > ksmps = 32
>      >      > nchnls = 2
>      >      > 0dbfs = 1
>      >      >
>      >      > instr 1 ;master instrument
>      >      > inumparts =         p4 ;number of partials
>      >      > ibasfreq          cpsmidi
>      >      > ibaseamp       ampmidi 1
>      >      > ipart     =         1 ;count variable for loop
>      >      > ;loop for inumparts over the ipart variable
>      >      > ;and trigger inumpartss instanes of the subinstrument
>      >      > loop:
>      >      > ifreq     =         ibasfreq * ipart
>      >      > iamp      =         ibaseamp/ipart/inumparts
>      >      >            event_i   "i", 10, 0, p3, ifreq, iamp
>      >      >            loop_le   ipart, 1, inumparts, loop
>      >      > endin
>      >      >
>      >      > instr 10 ;subinstrument for playing one partial
>      >      > ifreq     =         p4 ;frequency of this partial
>      >      > iamp      =         p5 ;amplitude of this partial
>      >      > aenv      transeg   0, .01, 0, iamp, p3-0.1, -10, 0
>      >      > apart     poscil    aenv, ifreq
>      >      >            outs      apart, apart
>      >      > endin
>      >      >
>      >      > 
>      >      > 
>      >      > ;         number of partials
>      >      > i 1 0 3   10
>      >      > i 1 3 3   20
>      >      > i 1 6 3   2
>      >      > 
>      >      > 
>      >      > ;Example by joachim heintz
>      >      > 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
> 
>     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

Date2024-05-19 20:47
FromStefan Thomas
SubjectRe: [Csnd] print values if subinstr is active
okay, that's the way. I will try it. Thanks!

Am So., 19. Mai 2024 um 20:59 Uhr schrieb joachim heintz <jh@joachimheintz.de>:
but why do you write "alwayson 1"?
what you want to do is to trrigger your instr 1 via midi keyboard.
this happens, as you say. (otherwise it would be a problem of the midi
settings.)
so no need for a score, and no need for any alwayson.
here are more descriptions:
https://flossmanual.csound.com/midi/triggering-instrument-instances


On 19/05/2024 20:26, Stefan Thomas wrote:
> Sorry, I made a couple of mistakes in the code, I was too hasty again.
> With this below quoted code I get, before pressing the first midikey the
> following messages:
> instr 10:  iamp = 0.000
> instr 10:  iamp = 0.000
> instr 10:  iamp = 0.000
> instr 10:  iamp = 0.000
> instr 10:  iamp = 0.000
> instr 10:  iamp = 0.000
> instr 10:  iamp = 0.000
> instr 10:  iamp = 0.000
> instr 10:  iamp = 0.000
> instr 10:  iamp = 0.000
>
> <CsoundSynthesizer>
> <CsOptions>
> -o dac -Ma -m0d
> </CsOptions>
> <CsInstruments>
> sr = 44100
> ksmps = 32
> nchnls = 2
> 0dbfs = 1
> alwayson 1
> instr 1 ;master instrument
> inumparts =         10 ;number of partials
> ibasfreq          cpsmidi
> ibaseamp       ampmidi 1
> ipart     =         1 ;count variable for loop
> ;loop for inumparts over the ipart variable
> ;and trigger inumpartss instanes of the subinstrument
> loop:
> ifreq     =         ibasfreq * ipart
> iamp      =         ibaseamp/ipart/inumparts
>            event_i   "i", 10, 0, p3, ifreq, iamp
>            loop_le   ipart, 1, inumparts, loop
> endin
> ;         number of partials
>
> instr 10 ;subinstrument for playing one partial
> ifreq     =         p4 ;frequency of this partial
> iamp      =         p5 ;amplitude of this partial
> print(iamp)
> aenv      transeg   0, .01, 0, iamp, p3-0.1, -10, 0
> apart     poscil    aenv, ifreq
>            outs      apart, apart
> endin
>
> </CsInstruments>
> <CsScore>
> </CsScore>
> </CsoundSynthesizer>
> ;Example by joachim heintz
>
> Am So., 19. Mai 2024 um 19:51 Uhr schrieb joachim heintz
> <jh@joachimheintz.de <mailto:jh@joachimheintz.de>>:
>
>     but then, what is the question?
>     why not simply print(iamp)?
>
>     On 19/05/2024 19:26, Stefan Thomas wrote:
>      > I trigger via midi keyboard instr 1 which triggers instr 10
>      >
>      > joachim heintz <jh@joachimheintz.de <mailto:jh@joachimheintz.de>
>     <mailto:jh@joachimheintz.de <mailto:jh@joachimheintz.de>>>
>      > schrieb am So., 19. Mai 2024, 12:57:
>      >
>      >     hi stefan -
>      >     i don't understand this condition: "only if the subinstrument is
>      >     activated (when a midi key is pressed)".
>      >     do you trigger via midi keyboard, or via score, or both?
>      >     best -
>      >              joachim
>      >
>      >
>      >     On 19/05/2024 12:31, Stefan Thomas wrote:
>      >      > Dear community,
>      >      > In the following example, I would like to print the value of
>      >     iamp, but
>      >      > only if the subinstrument is activated (when a midi key is
>     pressed).
>      >      > How could I achieve this?
>      >      > <CsoundSynthesizer>
>      >      > <CsOptions>
>      >      > -o dac -Ma
>      >      > </CsOptions>
>      >      > <CsInstruments>
>      >      > sr = 44100
>      >      > ksmps = 32
>      >      > nchnls = 2
>      >      > 0dbfs = 1
>      >      >
>      >      > instr 1 ;master instrument
>      >      > inumparts =         p4 ;number of partials
>      >      > ibasfreq          cpsmidi
>      >      > ibaseamp       ampmidi 1
>      >      > ipart     =         1 ;count variable for loop
>      >      > ;loop for inumparts over the ipart variable
>      >      > ;and trigger inumpartss instanes of the subinstrument
>      >      > loop:
>      >      > ifreq     =         ibasfreq * ipart
>      >      > iamp      =         ibaseamp/ipart/inumparts
>      >      >            event_i   "i", 10, 0, p3, ifreq, iamp
>      >      >            loop_le   ipart, 1, inumparts, loop
>      >      > endin
>      >      >
>      >      > instr 10 ;subinstrument for playing one partial
>      >      > ifreq     =         p4 ;frequency of this partial
>      >      > iamp      =         p5 ;amplitude of this partial
>      >      > aenv      transeg   0, .01, 0, iamp, p3-0.1, -10, 0
>      >      > apart     poscil    aenv, ifreq
>      >      >            outs      apart, apart
>      >      > endin
>      >      >
>      >      > </CsInstruments>
>      >      > <CsScore>
>      >      > ;         number of partials
>      >      > i 1 0 3   10
>      >      > i 1 3 3   20
>      >      > i 1 6 3   2
>      >      > </CsScore>
>      >      > </CsoundSynthesizer>
>      >      > ;Example by joachim heintz
>      >      > Csound mailing list Csound@listserv.heanet.ie
>     <mailto:Csound@listserv.heanet.ie>
>      >     <mailto:Csound@listserv.heanet.ie
>     <mailto:Csound@listserv.heanet.ie>>
>      >      > <mailto:Csound@listserv.heanet.ie
>     <mailto:Csound@listserv.heanet.ie>
>      >     <mailto:Csound@listserv.heanet.ie
>     <mailto:Csound@listserv.heanet.ie>>>
>      >      > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>     <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND>
>      >     <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>     <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND>>
>      >      > <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>     <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND>
>      >     <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>     <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND>>> Send bugs reports to
>      >      > https://github.com/csound/csound/issues
>     <https://github.com/csound/csound/issues>
>      >     <https://github.com/csound/csound/issues
>     <https://github.com/csound/csound/issues>>
>      >      > <https://github.com/csound/csound/issues
>     <https://github.com/csound/csound/issues>
>      >     <https://github.com/csound/csound/issues
>     <https://github.com/csound/csound/issues>>> Discussions of bugs and
>      >      > features can be posted here
>      >
>      >     Csound mailing list
>      > Csound@listserv.heanet.ie <mailto:Csound@listserv.heanet.ie>
>     <mailto:Csound@listserv.heanet.ie <mailto:Csound@listserv.heanet.ie>>
>      > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>     <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND>
>      >     <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>     <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND>>
>      >     Send bugs reports to
>      > https://github.com/csound/csound/issues
>     <https://github.com/csound/csound/issues>
>      >     <https://github.com/csound/csound/issues
>     <https://github.com/csound/csound/issues>>
>      >     Discussions of bugs and features can be posted here
>      >
>      > Csound mailing list Csound@listserv.heanet.ie
>     <mailto:Csound@listserv.heanet.ie>
>      > <mailto:Csound@listserv.heanet.ie
>     <mailto:Csound@listserv.heanet.ie>>
>      > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>     <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND>
>      > <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>     <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND>> Send bugs reports to
>      > https://github.com/csound/csound/issues
>     <https://github.com/csound/csound/issues>
>      > <https://github.com/csound/csound/issues
>     <https://github.com/csound/csound/issues>> Discussions of bugs and
>      > features can be posted here
>
>     Csound mailing list
>     Csound@listserv.heanet.ie <mailto:Csound@listserv.heanet.ie>
>     https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>     <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND>
>     Send bugs reports to
>     https://github.com/csound/csound/issues
>     <https://github.com/csound/csound/issues>
>     Discussions of bugs and features can be posted here
>
> Csound mailing list Csound@listserv.heanet.ie
> <mailto:Csound@listserv.heanet.ie>
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND> Send bugs reports to
> https://github.com/csound/csound/issues
> <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