Tuesday, July 11, 2017

ex1D07. Markov Basics

# ex1D07.py
# Markov Basics

from moduleCsound import *

tags(1)

header(ksmps=32)

# score written with python loop rather using r

# --- globals

add("seed 0")

# --- instrument

add(r"""
instr 1
iLine[]     array      .2, .5, .3
iVal        random     0, 1
iAccum      =          iLine[0]
iIndex      =          0
 until iAccum >= iVal do
iIndex      +=         1
iAccum      +=         iLine[iIndex]
 enduntil
            printf_i   "Random number = %.3f, next element = %c!\n", 1, iVal, iIndex+97
endin
""")

tags(2)

# --- score

for i in range(10):
    add("i 1 0 0")

tags(3)

writeRun(__file__)

No comments:

Post a Comment

ex3A05. Audio Vector