File: lua_scoregen.csd

package info (click to toggle)
csound 1%3A6.18.1%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 63,220 kB
  • sloc: ansic: 192,643; cpp: 14,149; javascript: 9,654; objc: 9,181; python: 3,376; java: 3,337; sh: 1,840; yacc: 1,255; xml: 985; perl: 635; lisp: 411; tcl: 341; lex: 217; makefile: 128
file content (104 lines) | stat: -rw-r--r-- 2,824 bytes parent folder | download | duplicates (3)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<CsoundSynthesizer>
<CsOptions>
-odac -dm3 --sample-accurate
</CsOptions>
<CsInstruments>

sr      = 44100
ksmps   = 100
nchnls  = 2


; Lua code to generate a score in the orchestra header.
lua_exec {{
print (package.path)
package.path = package.path .. ";/storage/emulated/0/silencio/?.lua"
local ffi = require("ffi")
local math = require("math")
local string = require("string")

local silencio = require ("Silencio")
local csoundApi = ffi.load("csoundandroid")
-- Declare the parts of the Csound API that we need.
ffi.cdef[[
    int csoundGetKsmps(void *);
    double csoundGetSr(void *);
    int csoundInputMessage(void *, const char *message);
]]
-- Print that we have acquired the global Csound object.
print('csound:', csound)
-- Prove that the Csound API and object are working.
print('sr:', csoundApi.csoundGetSr(csound))

-- Compute a score using the logistic equation.

local c = .999938749
local y = 0.57
local y1 = 0.58
local interval = 1 / 5
local duration = 4 * interval
local insno = 1
local scoretime = 0.5

for i = 1, 200 do
    scoretime = scoretime + interval
    y1 = c * y * (1 - y) * 4
    y = y1
    local key = math.floor(36 + y * 60)
    local velocity = 80

    -- Format each iteration of the logistic equation as a Csound score event and schedule it.
    
    local message = string.format('i %d %9.4f %9.4f %9.4f %9.4f', insno, scoretime, duration, key, velocity)
    print(message)
    csoundApi.csoundInputMessage(csound, message)
end

}}


gasendL		init		0
gasendR		init		0 

chnset      .5, "slider4"

            instr       1
            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
            ; Simple FM instrument.
            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
khz         =           cpsmidinn(p4)
kamplitude  =           ampdb(p5) * 0.1
ktrackpady  chnget      "slider1"
kcarrier    =           1 + 10 * ktrackpady
ktrackpadx  chnget      "slider2"
kmodulator  =           1 + 10 * ktrackpadx
iattack     =           0.03
irelease    =           0.1
isustain    =           p3
p3          =           iattack + isustain + irelease
            ; Intensity sidebands.
intensity   chnget      "slider3"
kindex      line        intensity * 20, p3, 0.25
isine       ftgenonce   1, 0, 16384, 10, 1
asignal     foscili     kamplitude, khz, kcarrier, kmodulator, kindex, isine
adamping    linseg      0, iattack, 1, isustain, 1, irelease, 0
asignal     =           asignal * adamping
gasendL     =           gasendL + asignal
gasendR     =           gasendR + asignal
            endin

		instr		reverb
print p1, p2, p3
kreverbdelay  chnget      "slider4"
aL,aR		reverbsc	gasendL, gasendR,kreverbdelay, 10000
		outs		aL, aR
		clear		gasendL, gasendR
		endin
            
alwayson "reverb"

</CsInstruments>
<CsScore>
f 0 3600
</CsScore>
</CsoundSynthesizer>