This repository has been archived by the owner on Jul 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
perfuma.orc
72 lines (55 loc) · 1.53 KB
/
perfuma.orc
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
//trans rights
//Copyright © 2022 Amy Universe
//This work is free. You can redistribute it and/or modify it under the
//terms of the Do What The Fuck You Want To Public License, Version 2,
//as published by Sam Hocevar. See the COPYING file for more details.
;arbitrary number of clocks running at multiples of frequency
;and divided versions of them
;Syntax:
;kOutMul[], kOutDiv[] Perfuma kFrq, kMul[], kDiv[]
;kOutMul[]: multiplied clocks output
;kOutDiv[]: divided clocks output
;kFrq: main frequency
;kMul[]: clock multipliers
;kDiv[]: divider (counter) for each clock
;don't change array length past initialization
opcode Perfuma, k[]k[], kk[]k[]
kFrq, kMul[], kDiv[] xin
iLen = min(lenarray(kMul), lenarray(kDiv))
kOutMul[] init iLen
kOutDiv[] init iLen
kOutMul = 0
kOutDiv = 0
;multiplied clocks' counters count up to kr
kMCnt[] init iLen
ii = 0
while ii < iLen do
kMCnt[ii] init kr
ii += 1
od
ki = 0
while ki < iLen do
kMCnt[ki] = kMCnt[ki] + kMul[ki]*kFrq
if kMCnt[ki] >= kr then
kOutMul[ki] = 1
kMCnt[ki] = kMCnt[ki] - kr
endif
ki += 1
od
;divided frequency of the multiplied clocks (by counting)
kDCnt[] init iLen
ki = 0
while ki < iLen do
if kOutMul[ki] == 1 then
kDCnt[ki] = kDCnt[ki] - 1
endif
if kDCnt[ki] <= 0 then
kOutDiv[ki] = 1
kDCnt[ki] = kDiv[ki]
endif
ki += 1
od
xout kOutMul, kOutDiv
endop
;kOutMul[], kOutDiv1[], kOutDiv2[] Perfuma kFrq, kMul[], kDiv1[], kDiv2[] ?
;kM1[], kM2[], kD1[], kD2[] Perfuma kFrq, km1[], km2[], kd1[], kd2[] ?