~nasser/8fl

8fl/api-macros.fnl -rw-r--r-- 1.1 KiB
2934f9e8Ramsey Nasser Use negative track numbers for fx columns a month ago
                                                                                
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
(fn <> [...]
  (let [name# (tostring (gensym :cycle))]
    (match (# [...])
      0 nil
      1
      `(do
        (when (not (. _CYCLES ,name#))
          (tset _CYCLES ,name# (cycle ,...)))
        ((. _CYCLES ,name#)))
      _
      `(do
        (when (not (. _CYCLES ,name#))
          (tset _CYCLES ,name# (cycle [,...])))
        ((. _CYCLES ,name#))))))

(fn <&> [...]
  (let [name# (tostring (gensym :cycle))]
    `(do
      (when (not (. _CYCLES ,name#))
        (tset _CYCLES ,name# (cycle (& ,...))))
      ((. _CYCLES ,name#)))))

(fn <?> [...]
  (let [name# (tostring (gensym :cycle))]
    `(do
      (when (not (. _CYCLES ,name#))
        (tset _CYCLES ,name# (choice-of [,...])))
      ((. _CYCLES ,name#)))))

(fn $> [...]
    (match (# [...])
        0 nil
        1 `(onpattern
            (fn [] (do ,...)))
        _ `(onpattern
            (fn [p#]
                (let [args# [,...]]
                    ;; renoise must be in scope for this to work
                    ;; the env.use("renoise") in main.lua/useStandardLibrary
                    ;; accomplishes this
                    (balance-and-render! p# args#))))))

{ : <> : <&> : <?> : $> }