active

active — Retourne le nombre d'instances actives d'un instrument.

Description

Retourne le nombre d'instances actives d'un instrument.

Syntaxe

ir active insnum
kres active kinsnum

Initialisation

insnum -- numéro de l'instrument concerné

Exécution

kinsnum -- numéro de l'instrument concerné

active retourne le nombre d'instances actives de l'instrument numéro insnum/kinsnum. A partir de Csound 4.17 la sortie est mise à jour au taux-k (si l'argument d'entrée est de taux-k), pour permettre un comptage dynamique des instances d'instrument.

Exemples

Voici un exemple de l'opcode active. Il utilise le fichier active.csd.

Exemple 31. Exemple simple de l'opcode active.

Voir les sections Audio en Temps Réel et Options de la Ligne de Commande pour plus d'information sur l'utilisation des options de la ligne de commande.

<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
; Audio out   Audio in
-odac           -iadc    ;;;RT audio I/O
; For Non-realtime ouput leave only the line below:
; -o active.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

; Initialize the global variables.
sr = 44100
kr = 4410
ksmps = 10
nchnls = 1

; Instrument #1 - a noisy waveform.
instr 1
  ; Generate a really noisy waveform.
  anoisy rand 44100
  ; Turn down its amplitude.
  aoutput gain anoisy, 2500
  ; Send it to the output.
  out aoutput
endin

; Instrument #2 - counts active instruments.
instr 2
  ; Count the active instances of Instrument #1.
  icount active 1
  ; Print the number of active instances.
  print icount
endin


</CsInstruments>
<CsScore>

; Start the first instance of Instrument #1 at 0:00 seconds.
i 1 0.0 3.0

; Start the second instance of Instrument #1 at 0:015 seconds.
i 1 1.5 1.5

; Play Instrument #2 at 0:01 seconds, when we have only 
; one active instance of Instrument #1.
i 2 1.0 0.1

; Play Instrument #2 at 0:02 seconds, when we have 
; two active instances of Instrument #1.
i 2 2.0 0.1
e


</CsScore>
</CsoundSynthesizer>


Sa sortie contiendra des lignes comme :

instr 2:  icount = 1.000
instr 2:  icount = 2.000

Voici un exemple plus avancé de l'opcode active. Il affiche le résultat de l'opcode active au taux-k. Il utilise le fichier active_k.csd.

Exemple 32. Exemple de l'opcode active au taux-k.

<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
; Audio out   Audio in
-odac           -iadc    ;;;RT audio I/O
; For Non-realtime ouput leave only the line below:
; -o active_k.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

; Initialize the global variables.
sr = 44100
kr = 4410
ksmps = 10
nchnls = 1

; Instrument #1 - a noisy waveform.
instr 1
  ; Generate a really noisy waveform.
  anoisy rand 44100
  ; Turn down its amplitude.
  aoutput gain anoisy, 2500
  ; Send it to the output.
  out aoutput
endin

; Instrument #2 - counts active instruments at k-rate.
instr 2
  ; Count the active instances of Instrument #1.
  kcount active 1
  ; Print the number of active instances.
  printk2 kcount
endin


</CsInstruments>
<CsScore>

; Start the first instance of Instrument #1 at 0:00 seconds.
i 1 0.0 3.0

; Start the second instance of Instrument #1 at 0:015 seconds.
i 1 1.5 1.5

; Play Instrument #2 at 0:01 seconds, when we have only 
; one active instance of Instrument #1.
i 2 1.0 0.1

; Play Instrument #2 at 0:02 seconds, when we have 
; two active instances of Instrument #1.
i 2 2.0 0.1
e


</CsScore>
</CsoundSynthesizer>


Sa sortie contiendra des lignes comme :

 i2     1.00000
 i2     2.00000

Voici un autre exemple de l'opcode active, qui utilise le nombre d'instances pour calculer le gain. Il utilise le fichier active_scale.csd.

Exemple 33. Exemple de l'opcode active au taux-k.

<CsoundSynthesizer>
<CsOptions>

</CsOptions>
<CsInstruments>

sr= 44100
ksmps = 64
0dbfs = 1

;by Victor Lazzarini 2008

instr 1
kscal active  1
kamp port   1/kscal, 0.01
asig  oscili  kamp, p4, 1
kenv linseg 0, 0.1,1,p3-0.2,1,0.1, 0

        out asig*kenv
endin

</CsInstruments>
<CsScore>
f1 0 16384 10 1

i1 0 10 440
i1 1 3  220
i1 2 5  350
i1 4 3  700
</CsScore>
</CsoundSynthesizer>


Crédits

Auteur : John ffitch
University of Bath/Codemist Ltd.
Bath, UK
Juillet 1999

Exemples écrits par Kevin Conder.

Nouveau dans la version 3.57 de Csound