tb

tb0, tb1, tb2, tb3, tb4, tb5, tb6, tb7, tb8, tb9, tb10, tb11, tb12, tb13, tb14, tb15, tb0_init, tb1_init, tb2_init, tb3_init, tb4_init, tb5_init, tb6_init, tb7_init, tb8_init, tb9_init, tb10_init, tb11_init, tb12_init, tb13_init, tb14_init, tb15_init — Accès en lecture à une table depuis une expression.

Description

Permet de lire des tables de manière fonctionnelle, à utiliser dans des expressions. Actuellement, Csound ne supporte que les fonctions avec un seul argument en entrée. Cependant, pour accéder aux éléments d'une table, on doit fournir deux nombres : le numéro de la table et l'indice de l'élément. Donc, afin de pouvoir accéder à un élément d'une table par une fonction, il faut une étape de préparation.

Syntaxe

tb0_init ifn
tb1_init ifn
tb2_init ifn
tb3_init ifn
tb4_init ifn
tb5_init ifn
tb6_init ifn
tb7_init ifn
tb8_init ifn
tb9_init ifn
tb10_init ifn
tb11_init ifn
tb12_init ifn
tb13_init ifn
tb14_init ifn
tb15_init ifn
iout = tb0(iIndex)
kout = tb0(kIndex)
iout = tb1(iIndex)
kout = tb1(kIndex)
iout = tb2(iIndex)
kout = tb2(kIndex)
iout = tb3(iIndex)
kout = tb3(kIndex)
iout = tb4(iIndex)
kout = tb4(kIndex)
iout = tb5(iIndex)
kout = tb5(kIndex)
iout = tb6(iIndex)
kout = tb6(kIndex)
iout = tb7(iIndex)
kout = tb7(kIndex)
iout = tb8(iIndex)
kout = tb8(kIndex)
iout = tb9(iIndex)
kout = tb9(kIndex)
iout = tb10(iIndex)
kout = tb10(kIndex)
iout = tb11(iIndex)
kout = tb11(kIndex)
iout = tb12(iIndex)
kout = tb12(kIndex)
iout = tb13(iIndex)
kout = tb13(kIndex)
iout = tb14(iIndex)
kout = tb14(kIndex)
iout = tb15(iIndex)
kout = tb15(kIndex)

Exécution

Il y a 16 opcodes différents dont le nom est associé à un nombre compris entre 0 et 15. Il faut associer une table spécifique avec chaque opcode (ainsi le nombre maximum de tables accessibles de manière fonctionnelle est 16). Avant de pouvoir accéder à une table, celle-ci doit être associée avec l'un des 16 opcodes au moyen d'un opcode choisi parmi tb0_init, ..., tb15_init. Par exemple,

      tb0_init  1

associe la table 1 avec la fonction tb0( ), si bien que chaque élément de la table 1 peut être atteint (de manière fonctionnelle) par :

      kvar = tb0(k_some_index_of_table1) * k_some_other_var

      ivar = tb0(i_some_index_of_table1) + i_some_other_var

etc...

En utilisant ces opcodes, on peut réduire considérablement le nombre de lignes d'un orchestre, ce qui améliore sa lisibilité.

Crédits

Ecrit par Gabriel Maldonado.