midichn

midichn — Retourne le numéro de canal MIDI duquel la note a été activée.

Description

midichn retourne le numéro de canal MIDI (1 à 16) duquel la note a été activée. Dans le cas d'une note venant d'une partition, il retourne 0.

Syntaxe

ichn midichn

Initialisation

ichn -- numéro de canal. Si la note courante provient d'une partition, il prend la valeur zéro.

Exemples

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

Exemple 362. Exemple simple de l'opcode midichn.

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   No messages  MIDI in
-odac           -iadc     -d         -M0  ;;;RT audio I/O with MIDI in
; For Non-realtime ouput leave only the line below:
; -o midichn.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

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

; Instrument #1.
instr 1
  i1 midichn

  print i1
endin


</CsInstruments>
<CsScore>

; Play Instrument #1 for 12 seconds.
i 1 0 12
e


</CsScore>
</CsoundSynthesizer>


Voici un exemple avancé de l'opcode midichn. Il utilise le fichier midichn_advanced.csd.

Ne pas oublier qu'il faut l'option -F flag lorsque l'on utilise un fichier MIDI externe comme « midichn_advanced.mid ».

Exemple 363. Un exemple avancé de l'opcode midichn.

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

sr	=  44100
ksmps	=  10
nchnls	=  1

	massign  1, 1		; all channels use instr 1
	massign  2, 1
	massign  3, 1
	massign  4, 1
	massign  5, 1
	massign  6, 1
	massign  7, 1
	massign  8, 1
	massign  9, 1
	massign 10, 1
	massign 11, 1
	massign 12, 1
	massign 13, 1
	massign 14, 1
	massign 15, 1
	massign 16, 1

gicnt	=  0			; note counter

	instr 1

gicnt	=  gicnt + 1	; update note counter
kcnt	init gicnt	; copy to local variable
ichn	midichn		; get channel number
istime	times		; note-on time

	if (ichn > 0.5) goto l2		; MIDI note
	printks "note %.0f (time = %.2f) was activated from the score\\n", \
		3600, kcnt, istime
	goto l1
l2:
	printks "note %.0f (time = %.2f) was activated from channel %.0f\\n", \
		3600, kcnt, istime, ichn
l1:
	endin


</CsInstruments>
<CsScore>

t 0 60
f 0 6 2 -2 0
i 1 1 0.5
i 1 4 0.5
e


</CsScore>
</CsoundSynthesizer>


Sa sortie contiendra des lignes comme celles-ci :

note 7 (time = 0.00) was activated from channel 4
note 8 (time = 0.00) was activated from channel 2

Voir Aussi

pgmassign

Crédits

Auteur : Istvan Varga
Mai 2002

L'exemple simple a été écrit par Kevin Conder.

Nouveau dans la version 4.20