Csound Csound-dev Csound-tekno Search About

[Csnd] can't print global i-variable

Date2012-08-05 11:42
FromStefan Thomas
Subject[Csnd] can't print global i-variable
Dear community,
in order to prevent samples out of range I want to print the value of the global amplitude in a midi-triggered csd-file.
The problem: the file uses additive-synthesis and the amplitude for the individual partials comes out off a ftable.
Unfortunately I didn't succeed with my attempt. Only at the very beginning I get the message:
instr 102:  giAmp = 0.000
(before I've touched any key).
Here is my simplified code, hope it's not too long:
;;;;;;;;;;;;;;;;;;;;;;;;;; SNIPPET ;;;;;;;;;
<CsoundSynthesizer>
<CsOptions>
-odevaudio -Ma
</CsOptions>
; ==============================================
<CsInstruments>

sr    =    48000
ksmps     =     1000
nchnls    =    2
0dbfs    =    1
giAmp    init     0
gisine         ftgen 0,0,2^10, 10, 1
giAmpCurve    ftgen    0,0,128,-16,1,128,2,0 ; curve for Amplitude of the partials
giratiotab    ftgen 0,0,-6,-2,1,2,3,4,5,6        ; ratios of the partials
instr 1   
imaxdur    =    1
imaxamp ampmidi 0.1

icps cpsmidi
iatt = 0.1
ipartnumber        = 1
inumparts        = 6
isubinstr    = 101+icps/sr
;;;;;;;;;;;;;;;;;;;;;;;;   LOOP STARTS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
loop:
;;;;;;;;;;;;;;;;;;;;;;;;;; frequencies ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
iratio        table        ipartnumber-1, giratiotab
ipartfreq    =        iratio * icps
;;;;;;;;;;;;;;;;;;;;;;;;; amplitudes ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ipartamp    table    (ipartnumber-1)/(inumparts-1),giAmpCurve,1
    ipartamp    =    ipartamp*imaxamp
;;;;;;;;;;;;;;;;;;;;;;;;;; duration ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ipartdur        =        imaxdur/ipartnumber
;;;;;;;;;;;;;;;;;;;;;;;;; attack ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ipartatt    = iatt/ipartnumber
;;;;;;;;;;;;;;;;;;;;;;;; send it to subinstrument ;;;;;;;;;
        event_i    "i", isubinstr, 0, ipartdur, ipartfreq, ipartamp, ipartatt
        loop_le    ipartnumber, 1, inumparts, loop 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; END OF LOOP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

endin
instr 101
ipartdur    = p3
ipartfreq    = p4
ipartamp    = p5
giAmp         = ipartamp+giAmp
ipartatt    = p6
asig        poscil        ipartamp, ipartfreq, gisine
;;; envelope
     adec    linseg    0,ipartatt,0,ipartdur-ipartatt,-98
     aenv   =   ampdb(adec)
;;; output
    aout = aenv*asig
outs aout, aout
endin

instr 102 ; reads the accumulated Amplitudes of the partials and prints it
print giAmp
endin
</CsInstruments>
; ==============================================
<CsScore>
f     0 10
i1     0 10
i102    0 10


</CsScore>
</CsoundSynthesizer>




Date2012-08-05 11:57
Frompeiman khosravi
SubjectRe: [Csnd] can't print global i-variable
Hi Stefan,

I suppose the giAmp is changing on a note-to-note basis and you want to print these changes?

You need to convert it to krate in this case and use printk2 instead:

(instr 101)
giAmp         = ipartamp+giAmp
gkamp init giAmp


(instr 102)
printk2 gkamp

Best,
Peiman 

On 5 August 2012 11:42, Stefan Thomas <kontrapunktstefan@gmail.com> wrote:
Dear community,
in order to prevent samples out of range I want to print the value of the global amplitude in a midi-triggered csd-file.
The problem: the file uses additive-synthesis and the amplitude for the individual partials comes out off a ftable.
Unfortunately I didn't succeed with my attempt. Only at the very beginning I get the message:
instr 102:  giAmp = 0.000
(before I've touched any key).
Here is my simplified code, hope it's not too long:
;;;;;;;;;;;;;;;;;;;;;;;;;; SNIPPET ;;;;;;;;;
<CsoundSynthesizer>
<CsOptions>
-odevaudio -Ma
</CsOptions>
; ==============================================
<CsInstruments>

sr    =    48000
ksmps     =     1000
nchnls    =    2
0dbfs    =    1
giAmp    init     0
gisine         ftgen 0,0,2^10, 10, 1
giAmpCurve    ftgen    0,0,128,-16,1,128,2,0 ; curve for Amplitude of the partials
giratiotab    ftgen 0,0,-6,-2,1,2,3,4,5,6        ; ratios of the partials
instr 1   
imaxdur    =    1
imaxamp ampmidi 0.1

icps cpsmidi
iatt = 0.1
ipartnumber        = 1
inumparts        = 6
isubinstr    = 101+icps/sr
;;;;;;;;;;;;;;;;;;;;;;;;   LOOP STARTS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
loop:
;;;;;;;;;;;;;;;;;;;;;;;;;; frequencies ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
iratio        table        ipartnumber-1, giratiotab
ipartfreq    =        iratio * icps
;;;;;;;;;;;;;;;;;;;;;;;;; amplitudes ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ipartamp    table    (ipartnumber-1)/(inumparts-1),giAmpCurve,1
    ipartamp    =    ipartamp*imaxamp
;;;;;;;;;;;;;;;;;;;;;;;;;; duration ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ipartdur        =        imaxdur/ipartnumber
;;;;;;;;;;;;;;;;;;;;;;;;; attack ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ipartatt    = iatt/ipartnumber
;;;;;;;;;;;;;;;;;;;;;;;; send it to subinstrument ;;;;;;;;;
        event_i    "i", isubinstr, 0, ipartdur, ipartfreq, ipartamp, ipartatt
        loop_le    ipartnumber, 1, inumparts, loop 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; END OF LOOP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

endin
instr 101
ipartdur    = p3
ipartfreq    = p4
ipartamp    = p5
giAmp         = ipartamp+giAmp
ipartatt    = p6
asig        poscil        ipartamp, ipartfreq, gisine
;;; envelope
     adec    linseg    0,ipartatt,0,ipartdur-ipartatt,-98
     aenv   =   ampdb(adec)
;;; output
    aout = aenv*asig
outs aout, aout
endin

instr 102 ; reads the accumulated Amplitudes of the partials and prints it
print giAmp
endin
</CsInstruments>
; ==============================================
<CsScore>
f     0 10
i1     0 10
i102    0 10


</CsScore>
</CsoundSynthesizer>





Date2012-08-05 13:52
FromStefan Thomas
SubjectRe: [Csnd] can't print global i-variable
Dear peiman,
thanks for Your explanations.
Yes, giAmp changes on a note-to-note basis and I thought, that this variable can change when pressing a key.
I've adopted Your proposals and it works now as desired!

2012/8/5 peiman khosravi <peimankhosravi@gmail.com>
Hi Stefan,

I suppose the giAmp is changing on a note-to-note basis and you want to print these changes?

You need to convert it to krate in this case and use printk2 instead:

(instr 101)
giAmp         = ipartamp+giAmp
gkamp init giAmp


(instr 102)
printk2 gkamp

Best,
Peiman 

On 5 August 2012 11:42, Stefan Thomas <kontrapunktstefan@gmail.com> wrote:
Dear community,
in order to prevent samples out of range I want to print the value of the global amplitude in a midi-triggered csd-file.
The problem: the file uses additive-synthesis and the amplitude for the individual partials comes out off a ftable.
Unfortunately I didn't succeed with my attempt. Only at the very beginning I get the message:
instr 102:  giAmp = 0.000
(before I've touched any key).
Here is my simplified code, hope it's not too long:
;;;;;;;;;;;;;;;;;;;;;;;;;; SNIPPET ;;;;;;;;;
<CsoundSynthesizer>
<CsOptions>
-odevaudio -Ma
</CsOptions>
; ==============================================
<CsInstruments>

sr    =    48000
ksmps     =     1000
nchnls    =    2
0dbfs    =    1
giAmp    init     0
gisine         ftgen 0,0,2^10, 10, 1
giAmpCurve    ftgen    0,0,128,-16,1,128,2,0 ; curve for Amplitude of the partials
giratiotab    ftgen 0,0,-6,-2,1,2,3,4,5,6        ; ratios of the partials
instr 1   
imaxdur    =    1
imaxamp ampmidi 0.1

icps cpsmidi
iatt = 0.1
ipartnumber        = 1
inumparts        = 6
isubinstr    = 101+icps/sr
;;;;;;;;;;;;;;;;;;;;;;;;   LOOP STARTS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
loop:
;;;;;;;;;;;;;;;;;;;;;;;;;; frequencies ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
iratio        table        ipartnumber-1, giratiotab
ipartfreq    =        iratio * icps
;;;;;;;;;;;;;;;;;;;;;;;;; amplitudes ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ipartamp    table    (ipartnumber-1)/(inumparts-1),giAmpCurve,1
    ipartamp    =    ipartamp*imaxamp
;;;;;;;;;;;;;;;;;;;;;;;;;; duration ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ipartdur        =        imaxdur/ipartnumber
;;;;;;;;;;;;;;;;;;;;;;;;; attack ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ipartatt    = iatt/ipartnumber
;;;;;;;;;;;;;;;;;;;;;;;; send it to subinstrument ;;;;;;;;;
        event_i    "i", isubinstr, 0, ipartdur, ipartfreq, ipartamp, ipartatt
        loop_le    ipartnumber, 1, inumparts, loop 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; END OF LOOP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

endin
instr 101
ipartdur    = p3
ipartfreq    = p4
ipartamp    = p5
giAmp         = ipartamp+giAmp
ipartatt    = p6
asig        poscil        ipartamp, ipartfreq, gisine
;;; envelope
     adec    linseg    0,ipartatt,0,ipartdur-ipartatt,-98
     aenv   =   ampdb(adec)
;;; output
    aout = aenv*asig
outs aout, aout
endin

instr 102 ; reads the accumulated Amplitudes of the partials and prints it
print giAmp
endin
</CsInstruments>
; ==============================================
<CsScore>
f     0 10
i1     0 10
i102    0 10


</CsScore>
</CsoundSynthesizer>






Date2012-08-05 13:59
FromStefan Thomas
SubjectRe: [Csnd] can't print global i-variable
Sorry, I would like to ask one more question.
I get the following terminal's output:
 i102     0.37523
I would like to change it to:
gkamp 0.37523
How can I achieve it?

2012/8/5 peiman khosravi <peimankhosravi@gmail.com>
Hi Stefan,

I suppose the giAmp is changing on a note-to-note basis and you want to print these changes?

You need to convert it to krate in this case and use printk2 instead:

(instr 101)
giAmp         = ipartamp+giAmp
gkamp init giAmp


(instr 102)
printk2 gkamp

Best,
Peiman 

On 5 August 2012 11:42, Stefan Thomas <kontrapunktstefan@gmail.com> wrote:
Dear community,
in order to prevent samples out of range I want to print the value of the global amplitude in a midi-triggered csd-file.
The problem: the file uses additive-synthesis and the amplitude for the individual partials comes out off a ftable.
Unfortunately I didn't succeed with my attempt. Only at the very beginning I get the message:
instr 102:  giAmp = 0.000
(before I've touched any key).
Here is my simplified code, hope it's not too long:
;;;;;;;;;;;;;;;;;;;;;;;;;; SNIPPET ;;;;;;;;;
<CsoundSynthesizer>
<CsOptions>
-odevaudio -Ma
</CsOptions>
; ==============================================
<CsInstruments>

sr    =    48000
ksmps     =     1000
nchnls    =    2
0dbfs    =    1
giAmp    init     0
gisine         ftgen 0,0,2^10, 10, 1
giAmpCurve    ftgen    0,0,128,-16,1,128,2,0 ; curve for Amplitude of the partials
giratiotab    ftgen 0,0,-6,-2,1,2,3,4,5,6        ; ratios of the partials
instr 1   
imaxdur    =    1
imaxamp ampmidi 0.1

icps cpsmidi
iatt = 0.1
ipartnumber        = 1
inumparts        = 6
isubinstr    = 101+icps/sr
;;;;;;;;;;;;;;;;;;;;;;;;   LOOP STARTS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
loop:
;;;;;;;;;;;;;;;;;;;;;;;;;; frequencies ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
iratio        table        ipartnumber-1, giratiotab
ipartfreq    =        iratio * icps
;;;;;;;;;;;;;;;;;;;;;;;;; amplitudes ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ipartamp    table    (ipartnumber-1)/(inumparts-1),giAmpCurve,1
    ipartamp    =    ipartamp*imaxamp
;;;;;;;;;;;;;;;;;;;;;;;;;; duration ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ipartdur        =        imaxdur/ipartnumber
;;;;;;;;;;;;;;;;;;;;;;;;; attack ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ipartatt    = iatt/ipartnumber
;;;;;;;;;;;;;;;;;;;;;;;; send it to subinstrument ;;;;;;;;;
        event_i    "i", isubinstr, 0, ipartdur, ipartfreq, ipartamp, ipartatt
        loop_le    ipartnumber, 1, inumparts, loop 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; END OF LOOP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

endin
instr 101
ipartdur    = p3
ipartfreq    = p4
ipartamp    = p5
giAmp         = ipartamp+giAmp
ipartatt    = p6
asig        poscil        ipartamp, ipartfreq, gisine
;;; envelope
     adec    linseg    0,ipartatt,0,ipartdur-ipartatt,-98
     aenv   =   ampdb(adec)
;;; output
    aout = aenv*asig
outs aout, aout
endin

instr 102 ; reads the accumulated Amplitudes of the partials and prints it
print giAmp
endin
</CsInstruments>
; ==============================================
<CsScore>
f     0 10
i1     0 10
i102    0 10


</CsScore>
</CsoundSynthesizer>






Date2012-08-05 14:11
Frompeiman khosravi
SubjectRe: [Csnd] can't print global i-variable
Hello,

You can use printks instead. Something like this:

printks "giamp = %f\n", 0, gkamp

"%f" means take the value of gkamp and print it as a float. "\n" is a newline, otherwise everything is printed on the same line.

Best,
P

On 5 August 2012 13:59, Stefan Thomas <kontrapunktstefan@gmail.com> wrote:
Sorry, I would like to ask one more question.
I get the following terminal's output:
 i102     0.37523
I would like to change it to:
gkamp 0.37523
How can I achieve it?


2012/8/5 peiman khosravi <peimankhosravi@gmail.com>
Hi Stefan,

I suppose the giAmp is changing on a note-to-note basis and you want to print these changes?

You need to convert it to krate in this case and use printk2 instead:

(instr 101)
giAmp         = ipartamp+giAmp
gkamp init giAmp


(instr 102)
printk2 gkamp

Best,
Peiman 

On 5 August 2012 11:42, Stefan Thomas <kontrapunktstefan@gmail.com> wrote:
Dear community,
in order to prevent samples out of range I want to print the value of the global amplitude in a midi-triggered csd-file.
The problem: the file uses additive-synthesis and the amplitude for the individual partials comes out off a ftable.
Unfortunately I didn't succeed with my attempt. Only at the very beginning I get the message:
instr 102:  giAmp = 0.000
(before I've touched any key).
Here is my simplified code, hope it's not too long:
;;;;;;;;;;;;;;;;;;;;;;;;;; SNIPPET ;;;;;;;;;
<CsoundSynthesizer>
<CsOptions>
-odevaudio -Ma
</CsOptions>
; ==============================================
<CsInstruments>

sr    =    48000
ksmps     =     1000
nchnls    =    2
0dbfs    =    1
giAmp    init     0
gisine         ftgen 0,0,2^10, 10, 1
giAmpCurve    ftgen    0,0,128,-16,1,128,2,0 ; curve for Amplitude of the partials
giratiotab    ftgen 0,0,-6,-2,1,2,3,4,5,6        ; ratios of the partials
instr 1   
imaxdur    =    1
imaxamp ampmidi 0.1

icps cpsmidi
iatt = 0.1
ipartnumber        = 1
inumparts        = 6
isubinstr    = 101+icps/sr
;;;;;;;;;;;;;;;;;;;;;;;;   LOOP STARTS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
loop:
;;;;;;;;;;;;;;;;;;;;;;;;;; frequencies ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
iratio        table        ipartnumber-1, giratiotab
ipartfreq    =        iratio * icps
;;;;;;;;;;;;;;;;;;;;;;;;; amplitudes ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ipartamp    table    (ipartnumber-1)/(inumparts-1),giAmpCurve,1
    ipartamp    =    ipartamp*imaxamp
;;;;;;;;;;;;;;;;;;;;;;;;;; duration ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ipartdur        =        imaxdur/ipartnumber
;;;;;;;;;;;;;;;;;;;;;;;;; attack ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ipartatt    = iatt/ipartnumber
;;;;;;;;;;;;;;;;;;;;;;;; send it to subinstrument ;;;;;;;;;
        event_i    "i", isubinstr, 0, ipartdur, ipartfreq, ipartamp, ipartatt
        loop_le    ipartnumber, 1, inumparts, loop 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; END OF LOOP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

endin
instr 101
ipartdur    = p3
ipartfreq    = p4
ipartamp    = p5
giAmp         = ipartamp+giAmp
ipartatt    = p6
asig        poscil        ipartamp, ipartfreq, gisine
;;; envelope
     adec    linseg    0,ipartatt,0,ipartdur-ipartatt,-98
     aenv   =   ampdb(adec)
;;; output
    aout = aenv*asig
outs aout, aout
endin

instr 102 ; reads the accumulated Amplitudes of the partials and prints it
print giAmp
endin
</CsInstruments>
; ==============================================
<CsScore>
f     0 10
i1     0 10
i102    0 10


</CsScore>
</CsoundSynthesizer>







Date2012-08-05 14:30
FromStefan Thomas
SubjectRe: [Csnd] can't print global i-variable
Thanks, that's it!

2012/8/5 peiman khosravi <peimankhosravi@gmail.com>
Hello,

You can use printks instead. Something like this:

printks "giamp = %f\n", 0, gkamp

"%f" means take the value of gkamp and print it as a float. "\n" is a newline, otherwise everything is printed on the same line.

Best,
P


On 5 August 2012 13:59, Stefan Thomas <kontrapunktstefan@gmail.com> wrote:
Sorry, I would like to ask one more question.
I get the following terminal's output:
 i102     0.37523
I would like to change it to:
gkamp 0.37523
How can I achieve it?


2012/8/5 peiman khosravi <peimankhosravi@gmail.com>
Hi Stefan,

I suppose the giAmp is changing on a note-to-note basis and you want to print these changes?

You need to convert it to krate in this case and use printk2 instead:

(instr 101)
giAmp         = ipartamp+giAmp
gkamp init giAmp


(instr 102)
printk2 gkamp

Best,
Peiman 

On 5 August 2012 11:42, Stefan Thomas <kontrapunktstefan@gmail.com> wrote:
Dear community,
in order to prevent samples out of range I want to print the value of the global amplitude in a midi-triggered csd-file.
The problem: the file uses additive-synthesis and the amplitude for the individual partials comes out off a ftable.
Unfortunately I didn't succeed with my attempt. Only at the very beginning I get the message:
instr 102:  giAmp = 0.000
(before I've touched any key).
Here is my simplified code, hope it's not too long:
;;;;;;;;;;;;;;;;;;;;;;;;;; SNIPPET ;;;;;;;;;
<CsoundSynthesizer>
<CsOptions>
-odevaudio -Ma
</CsOptions>
; ==============================================
<CsInstruments>

sr    =    48000
ksmps     =     1000
nchnls    =    2
0dbfs    =    1
giAmp    init     0
gisine         ftgen 0,0,2^10, 10, 1
giAmpCurve    ftgen    0,0,128,-16,1,128,2,0 ; curve for Amplitude of the partials
giratiotab    ftgen 0,0,-6,-2,1,2,3,4,5,6        ; ratios of the partials
instr 1   
imaxdur    =    1
imaxamp ampmidi 0.1

icps cpsmidi
iatt = 0.1
ipartnumber        = 1
inumparts        = 6
isubinstr    = 101+icps/sr
;;;;;;;;;;;;;;;;;;;;;;;;   LOOP STARTS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
loop:
;;;;;;;;;;;;;;;;;;;;;;;;;; frequencies ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
iratio        table        ipartnumber-1, giratiotab
ipartfreq    =        iratio * icps
;;;;;;;;;;;;;;;;;;;;;;;;; amplitudes ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ipartamp    table    (ipartnumber-1)/(inumparts-1),giAmpCurve,1
    ipartamp    =    ipartamp*imaxamp
;;;;;;;;;;;;;;;;;;;;;;;;;; duration ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ipartdur        =        imaxdur/ipartnumber
;;;;;;;;;;;;;;;;;;;;;;;;; attack ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ipartatt    = iatt/ipartnumber
;;;;;;;;;;;;;;;;;;;;;;;; send it to subinstrument ;;;;;;;;;
        event_i    "i", isubinstr, 0, ipartdur, ipartfreq, ipartamp, ipartatt
        loop_le    ipartnumber, 1, inumparts, loop 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; END OF LOOP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

endin
instr 101
ipartdur    = p3
ipartfreq    = p4
ipartamp    = p5
giAmp         = ipartamp+giAmp
ipartatt    = p6
asig        poscil        ipartamp, ipartfreq, gisine
;;; envelope
     adec    linseg    0,ipartatt,0,ipartdur-ipartatt,-98
     aenv   =   ampdb(adec)
;;; output
    aout = aenv*asig
outs aout, aout
endin

instr 102 ; reads the accumulated Amplitudes of the partials and prints it
print giAmp
endin
</CsInstruments>
; ==============================================
<CsScore>
f     0 10
i1     0 10
i102    0 10


</CsScore>
</CsoundSynthesizer>