Instruction r (instruction répéter)

r — Débute une section répétée.

Description

Débute une section répétée, qui dure jusqu'à la prochaine instruction s, r ou e.

Syntaxe

r p1 p2

Initialisation

p1 -- Nombre de répétitions de la section demandé.

p2 -- Macro(nom) pour indexer chaque répétition (facultatif).

Exécution

Afin de rendre les sections plus souples qu'une simple édition, la macro nommée en p2 reçoit la valeur 1 à la première boucle dans la section, 2 à la seconde, 3 à la troisième, etc. On peut l'utiliser pour changer la valeur des p-champs, ou l'ignorer.

[Avertissement] Avertissement

A cause de sérieux problèmes d'interaction avec l'expansion de macro, les sections doivent commencer et finir dans le même fichier, à l'extérieur de toute macro.

Exemples

Voici un exemple d'instruction r. Il utilise le fichier r.csd.

Exemple 1052. Exemple d'instruction r.

<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 r.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
  ; The score's p4 parameter has the number of repeats.
  kreps = p4
  ; The score's p5 parameter has our note's frequency.
  kcps = p5
  
  ; Print the number of repeats.
  printks "Repeated %i time(s).\\n", 1, kreps

  ; Generate a nice beep.
  a1 oscil 20000, kcps, 1
  out a1
endin


</CsInstruments>
<CsScore>

; Table #1, a sine wave.
f 1 0 16384 10 1

; We'll repeat this section 6 times. Each time it 
; is repeated, its macro REPS_MACRO is incremented. 
r6 REPS_MACRO

; Play Instrument #1.
; p4 = the r statement's macro, REPS_MACRO.
; p5 = the frequency in cycles per second.
i 1 00.10 00.10 $REPS_MACRO 1760
i 1 00.30 00.10 $REPS_MACRO 880
i 1 00.50 00.10 $REPS_MACRO 440
i 1 00.70 00.10 $REPS_MACRO 220

; Marks the end of the section.
s

e


</CsScore>
</CsoundSynthesizer>


Crédits

Auteur : John ffitch
University of Bath/Codemist Ltd.
Bath, UK
Avril 1998

Nouveau dans la version 3.48 de Csound

Exemple écrit par Kevin Conder