File: pycall2.orc

package info (click to toggle)
csound-plugins 1.0.2~dfsg1-5
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,960 kB
  • sloc: cpp: 16,586; ansic: 7,522; python: 458; sh: 94; makefile: 25
file content (35 lines) | stat: -rw-r--r-- 638 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
sr=44100
kr=4410
ksmps=10
nchnls=1

giSinusoid      ftgen   0,      0, 8192, 10,    1

pyinit

pyruni {{
import random

class GetNumberFromPool:
    def __init__(self, e=1.2, a=1.0, f=0.1, N=100):
        self.pool = [(a + i*f) ** e for i in range(N)]

    def __call__(self, n, p):
        if random.random() < p:
            i = int(random.random() * len(self.pool))
            self.pool[i] = n

        return random.choice(self.pool)

get_number_from_pool = GetNumberFromPool()
}}

instr 1

        k1      oscil   1, 3, giSinusoid

        k2      pycall1 "get_number_from_pool", k1 + 2, p4

                printk  0.01, k2

endin