xyscale

xyscale — Interpolation linéaire 2D.

Description

Opcode du greffon emugens.

Interpolation linéaire 2D entre quatre points à (0,0), (1,0), (0,1) et (1,1)

Syntaxe

kout xyscale kx, ky, k00, k10, k01, k11

Exécution

kx, ky -- Coordonnées pour évaluer l'interpolation. Valeurs entre 0 et 1, où :

k00 -- valeur du point de coordonnées (x=0, y=0)

k10 -- valeur du point de coordonnées (x=1, y=0)

k01 -- valeur du point de coordonnées (x=0, y=1)

k11 -- valeur du point de coordonnées (x=1, y=1)


      (0,1)      (1,1)

      
      (0,0)      (1,0)
         
              
    

Etant données quatre valeurs placées aux sommets d'un carré, la valeur interpolée au point (x, y) est trouvée, où x et y sont compris entre 0 et 1.

Examples

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

Exemple 1156. Exemple de l'opcode xyscale.

<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
; Audio out   Audio in    No messages
-odac           -iadc     -d     ;;;RT audio I/O
</CsOptions>
<CsInstruments>

ksmps=128
nchnls=2

giwidth = 400
giheight = 300
FLpanel "FLmouse", giwidth, giheight, 10, 10
FLpanelEnd

FLrun

0dbfs = 1

instr 1
  ; We define four chords for bottom-left, bottom-right, top-left and top-right
  ; Use the mouse to interpolate between them
  ibl[] fillarray ntom:i("4C"), ntom:i("4Eb"), ntom:i("4G")
  itl[] fillarray ntom:i("4E"), ntom:i("4G#"), ntom:i("4B")
  ibr[] fillarray ntom:i("4G"), ntom:i("4A"), ntom:i("4B")
  itr[] fillarray ntom:i("4Eb"), ntom:i("4Eb+"), ntom:i("4F")
 
  kmousex, kmousey, kb1, kb2, kb3    FLmouse 2
  kx = limit(kmousex/giwidth, 0, 1)
  ky = 1 - limit(kmousey/giheight, 0, 1)

  printf "x: %f   y: %f \n", changed(kx, ky), kx, ky

  iamp = 0.1
  a0 oscili iamp, mtof(xyscale(kx, ky, ibl[0], itl[0], ibr[0], itr[0]))
  a1 oscili iamp, mtof(xyscale(kx, ky, ibl[1], itl[1], ibr[1], itr[1]))
  a2 oscili iamp, mtof(xyscale(kx, ky, ibl[2], itl[2], ibr[2], itr[2]))
  aout = sum(a0, a1, a2)
  outs aout, aout  
endin

</CsInstruments>
<CsScore>
i 1 0 120

</CsScore>
</CsoundSynthesizer>


Voir aussi

scale, ntrpol, linlin

Crédits

Par : Eduardo Moguillansky 2017