| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
|
| 4 |
</CsOptions> |
| 5 |
<CsInstruments> |
| 6 |
|
| 7 |
sr=44100 |
| 8 |
ksmps=10 |
| 9 |
nchnls=1 |
| 10 |
|
| 11 |
gifarn init 8 ; initialise integer for Farey Sequence F_8 |
| 12 |
gires fareyleni gifarn ; calculate length of F_8, returns 23 |
| 13 |
; the table length won't be a power of 2 |
| 14 |
; (The length of a Farey Sequence with n > 1 is always odd) |
| 15 |
gilen init gires * -1 |
| 16 |
|
| 17 |
gifarey ftgen 200, 0, gilen, "farey", gifarn, 0 |
| 18 |
|
| 19 |
; initialize destiniation table with 0s |
| 20 |
gifiltered ftgen 0, 0, gilen, 21, 1, 0 |
| 21 |
|
| 22 |
; initialize second destiniation table with 0s |
| 23 |
gifiltered2 ftgen 0, 0, gilen, 21, 1, 0 |
| 24 |
|
| 25 |
; table filtering opcode: dest. source, mode, threshold |
| 26 |
ginumpassed tablefilteri gifiltered, gifarey, 1, 6 |
| 27 |
; the threshold parameter indicates that denominators whose weights are heavier |
| 28 |
; than 6 are not passing through the filter. The weight is calculated using |
| 29 |
; Clarence Barlow's function of indigestibility of a number. According to this function, |
| 30 |
; higher prime numbers contribute to an increased weight of any natural integer they divide. |
| 31 |
; ginumpassed is the number of elements from the source table 'gifarey' |
| 32 |
; that have passed the test and which have been copied to the destination table 'gifiltered' |
| 33 |
|
| 34 |
; apply a different filter: |
| 35 |
ginumpassed2 tablefilteri gifiltered2, gifarey, 2, 5 |
| 36 |
; In mode=2 we again test the digestibility of the denominators of the |
| 37 |
; fractions in the source table. |
| 38 |
; The difference to mode=1 is that we now let pass only vaules from the |
| 39 |
; source that are as heavy as the threshold or greater. |
| 40 |
|
| 41 |
|
| 42 |
instr 4 |
| 43 |
kndx init 0 ; read out elements of now filtered F_8 sequentially and print to file |
| 44 |
if (kndx < ginumpassed) then |
| 45 |
kelem tab kndx, gifiltered |
| 46 |
fprintks "fareyfilter_lp.txt", "%2.6f\\n", kelem |
| 47 |
kndx = kndx+1 |
| 48 |
endif |
| 49 |
endin |
| 50 |
|
| 51 |
instr 5 |
| 52 |
kndx init 0 ; read out elements and print to file |
| 53 |
if (kndx < ginumpassed2) then |
| 54 |
kelem tab kndx, gifiltered2 |
| 55 |
fprintks "fareyfilter_hp.txt", "%2.6f\\n", kelem |
| 56 |
kndx = kndx+1 |
| 57 |
endif |
| 58 |
endin |
| 59 |
|
| 60 |
</CsInstruments> |
| 61 |
<CsScore> |
| 62 |
|
| 63 |
i4 0 1 |
| 64 |
i5 0 1 |
| 65 |
e |
| 66 |
</CsScore> |
| 67 |
</CsoundSynthesizer> |