File: fareyleni.csd

package info (click to toggle)
csound-manual 1%3A6.08.0~dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 34,580 kB
  • sloc: xml: 193,471; python: 1,332; makefile: 783
file content (89 lines) | stat: -rw-r--r-- 1,932 bytes parent folder | download | duplicates (13)
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
<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
-odac     ;;;realtime audio out
;-iadc    ;;;uncomment -iadc for RT audio input as well 
; For Non-realtime ouput leave only the line below:
; -o fareyleni.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 32
nchnls = 2
0dbfs  = 1

      ; initialise integer n for Farey Sequence F_8
      gifarn init 8	

      ; calculate length of F_8, it should return 23 for |F_8|
      gires fareyleni gifarn  

      ; convert to negative number for the GEN routine because
      ; the table length won't be a power of 2 
      ; (The length of a Farey Sequence of n > 1 is always an odd number)
      gilen init gires * -1 
      	   	       	               
      ; create F_8 with GENfarey, the negative table number prevents 
      ; unnecessary normalisation (F_8 IS already normalised)
      ; 	         	    n  	   mode: 
      gifarey ftgen 100, 0, gilen, "farey", gifarn, 4
      ; if mode=4 then 1 is added to each element of F_n.
      ; Useful for creating just tuning tables that can be read by the cps2pch opcode.

instr 1
      ; the very last element of F_n is not needed in the case of tuning tables
      ires = gires - 1 
      ; read out and print to file
      kndx init 0 
      if (kndx < ires) then    
      	 kelem tab kndx, gifarey
      	 fprintks "farey8_tuning.txt", "%2.6f\\n", kelem
      	 kndx = kndx+1
      endif
      
endin

instr 2

ip   cps2pch p4, -100
asig poscil .5, ip, 1
aenv linseg 0, 0.1, 1, p3-0.2, 1, 0.1, 0
     outs asig * aenv, asig * aenv

endin
</CsInstruments>
<CsScore>
f1 0 8192 10 1	;sine wave

i1	0     .1

i2	1	.5	8.00
i2	+	.	>
i2	+	.	>
i2	+	.	>
i2	+	.	>
i2	+	.	>
i2	+	.	>
i2	+	.	>
i2	+	.	>
i2	+	.	>
i2	+	.	>
i2	+	.	>
i2	+	.	>
i2	+	.	>
i2	+	.	>
i2	+	.	>
i2	+	.	>
i2	+	.	>
i2	+	.	>
i2	+	.	>
i2	+	.	>
i2	+	.	>
i2	+	1	8.22


e
</CsScore>
</CsoundSynthesizer>