@devaloop/devalang 0.0.1-alpha.16-hotfix.1 → 0.0.1-alpha.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cargo/config.toml +2 -0
- package/.devalang +6 -10
- package/.github/workflows/ci.yml +19 -8
- package/Cargo.toml +18 -2
- package/README.md +80 -33
- package/docs/CHANGELOG.md +56 -0
- package/docs/ROADMAP.md +6 -3
- package/examples/index.deva +52 -35
- package/out-tsc/bin/index.d.ts +2 -0
- package/out-tsc/core/functions/index.d.ts +37 -0
- package/out-tsc/core/functions/index.js +76 -0
- package/out-tsc/core/index.d.ts +6 -0
- package/out-tsc/core/index.js +22 -0
- package/out-tsc/core/types/index.d.ts +4 -0
- package/out-tsc/core/types/index.js +20 -0
- package/out-tsc/core/types/plugin.d.ts +18 -0
- package/out-tsc/core/types/plugin.js +2 -0
- package/out-tsc/core/types/result.d.ts +27 -0
- package/out-tsc/core/types/result.js +2 -0
- package/out-tsc/core/types/statement.d.ts +106 -0
- package/out-tsc/core/types/statement.js +2 -0
- package/out-tsc/core/types/value.d.ts +43 -0
- package/out-tsc/core/types/value.js +2 -0
- package/out-tsc/index.d.ts +7 -0
- package/out-tsc/index.js +41 -2
- package/out-tsc/pkg/devalang_core.d.ts +7 -0
- package/out-tsc/pkg/devalang_core_bg.wasm.d.ts +33 -0
- package/out-tsc/scripts/copy-wasm-dts.d.ts +1 -0
- package/out-tsc/scripts/copy-wasm-dts.js +73 -0
- package/out-tsc/scripts/postinstall.d.ts +1 -0
- package/out-tsc/scripts/postinstall.js +33 -23
- package/out-tsc/scripts/version/bump.d.ts +1 -0
- package/out-tsc/scripts/version/fetch.d.ts +1 -0
- package/out-tsc/scripts/version/index.d.ts +1 -0
- package/out-tsc/scripts/version/sync.d.ts +1 -0
- package/package.json +16 -4
- package/project-version.json +3 -3
- package/rust/cli/bank/api.rs +122 -0
- package/rust/cli/bank/commands.rs +275 -0
- package/rust/cli/bank/mod.rs +29 -0
- package/rust/cli/build/commands.rs +97 -0
- package/rust/cli/build/mod.rs +2 -0
- package/rust/cli/build/process.rs +146 -0
- package/rust/cli/{check.rs → check/mod.rs} +18 -31
- package/rust/cli/discover/commands.rs +253 -0
- package/rust/cli/discover/config.rs +111 -0
- package/rust/cli/discover/fs.rs +19 -0
- package/rust/cli/discover/install.rs +103 -0
- package/rust/cli/discover/metadata.rs +48 -0
- package/rust/cli/discover/mod.rs +5 -0
- package/rust/cli/{init.rs → init/commands.rs} +88 -87
- package/rust/cli/init/mod.rs +1 -0
- package/rust/{installer → cli/install}/addon.rs +5 -9
- package/rust/cli/install/bank.rs +53 -0
- package/rust/cli/{install.rs → install/commands.rs} +9 -9
- package/rust/{installer → cli/install}/mod.rs +2 -3
- package/rust/cli/install/plugin.rs +61 -0
- package/rust/cli/{login.rs → login/commands.rs} +8 -11
- package/rust/cli/login/mod.rs +1 -0
- package/rust/cli/mod.rs +2 -3
- package/rust/cli/{driver.rs → parser.rs} +19 -2
- package/rust/cli/play/commands.rs +324 -0
- package/rust/cli/play/io.rs +17 -0
- package/rust/cli/play/mod.rs +5 -0
- package/rust/cli/play/process.rs +150 -0
- package/rust/cli/play/realtime.rs +91 -0
- package/rust/cli/play/utils.rs +23 -0
- package/rust/cli/telemetry/commands.rs +22 -0
- package/rust/cli/telemetry/event_creator.rs +80 -0
- package/rust/cli/telemetry/mod.rs +3 -0
- package/rust/cli/telemetry/send.rs +51 -0
- package/rust/cli/{template.rs → template/commands.rs} +1 -1
- package/rust/cli/template/mod.rs +1 -0
- package/rust/cli/{update.rs → update/commands.rs} +6 -6
- package/rust/cli/update/mod.rs +1 -0
- package/rust/config/driver.rs +57 -72
- package/rust/config/mod.rs +1 -2
- package/rust/config/ops.rs +26 -0
- package/rust/config/settings.rs +60 -50
- package/rust/core/audio/engine/helpers.rs +146 -0
- package/rust/core/audio/engine/mod.rs +7 -0
- package/rust/core/audio/engine/sample.rs +298 -0
- package/rust/core/audio/engine/synth.rs +310 -0
- package/rust/core/audio/evaluator.rs +15 -12
- package/rust/core/audio/interpreter/arrow_call.rs +99 -24
- package/rust/core/audio/interpreter/call.rs +81 -60
- package/rust/core/audio/interpreter/condition.rs +3 -2
- package/rust/core/audio/interpreter/driver.rs +206 -151
- package/rust/core/audio/interpreter/let_.rs +1 -1
- package/rust/core/audio/interpreter/load.rs +2 -1
- package/rust/core/audio/interpreter/loop_.rs +7 -6
- package/rust/core/audio/interpreter/sleep.rs +2 -1
- package/rust/core/audio/interpreter/spawn.rs +45 -57
- package/rust/core/audio/interpreter/tempo.rs +31 -10
- package/rust/core/audio/interpreter/trigger.rs +2 -2
- package/rust/core/audio/loader/trigger.rs +4 -7
- package/rust/core/audio/player.rs +6 -0
- package/rust/core/audio/renderer.rs +5 -7
- package/rust/core/audio/special/env.rs +3 -1
- package/rust/core/audio/special/math.rs +4 -4
- package/rust/core/audio/special/modulator.rs +2 -2
- package/rust/core/builder/mod.rs +9 -3
- package/rust/core/debugger/lexer.rs +1 -1
- package/rust/core/debugger/mod.rs +6 -0
- package/rust/core/debugger/module.rs +4 -4
- package/rust/core/debugger/preprocessor.rs +1 -1
- package/rust/core/debugger/store.rs +2 -2
- package/rust/core/error/mod.rs +189 -0
- package/rust/core/lexer/handler/arrow.rs +1 -1
- package/rust/core/lexer/handler/at.rs +1 -1
- package/rust/core/lexer/handler/brace.rs +2 -2
- package/rust/core/lexer/handler/colon.rs +1 -1
- package/rust/core/lexer/handler/comment.rs +1 -1
- package/rust/core/lexer/handler/dot.rs +1 -1
- package/rust/core/lexer/handler/driver.rs +1 -1
- package/rust/core/lexer/handler/identifier.rs +1 -1
- package/rust/core/lexer/handler/mod.rs +1 -2
- package/rust/core/lexer/handler/number.rs +1 -1
- package/rust/core/lexer/handler/operator.rs +1 -1
- package/rust/core/lexer/handler/parenthesis.rs +2 -2
- package/rust/core/lexer/handler/slash.rs +1 -1
- package/rust/core/lexer/handler/string.rs +1 -1
- package/rust/core/lexer/mod.rs +22 -12
- package/rust/core/lexer/token.rs +90 -97
- package/rust/core/mod.rs +0 -1
- package/rust/core/parser/driver.rs +66 -13
- package/rust/core/parser/handler/arrow_call.rs +28 -8
- package/rust/core/parser/handler/at.rs +55 -21
- package/rust/core/parser/handler/bank.rs +14 -4
- package/rust/core/parser/handler/condition.rs +6 -3
- package/rust/core/parser/handler/dot.rs +2 -1
- package/rust/core/parser/handler/identifier/automate.rs +13 -16
- package/rust/core/parser/handler/identifier/call.rs +4 -4
- package/rust/core/parser/handler/identifier/emit.rs +9 -5
- package/rust/core/parser/handler/identifier/function.rs +20 -7
- package/rust/core/parser/handler/identifier/group.rs +11 -7
- package/rust/core/parser/handler/identifier/let_.rs +24 -9
- package/rust/core/parser/handler/identifier/mod.rs +6 -5
- package/rust/core/parser/handler/identifier/on.rs +16 -7
- package/rust/core/parser/handler/identifier/print.rs +6 -9
- package/rust/core/parser/handler/identifier/sleep.rs +12 -5
- package/rust/core/parser/handler/identifier/spawn.rs +4 -4
- package/rust/core/parser/handler/identifier/synth.rs +79 -9
- package/rust/core/parser/handler/loop_.rs +39 -14
- package/rust/core/parser/handler/tempo.rs +9 -5
- package/rust/core/parser/mod.rs +0 -1
- package/rust/core/parser/statement.rs +6 -137
- package/rust/core/plugin/loader.rs +41 -27
- package/rust/core/plugin/runner.rs +68 -17
- package/rust/core/preprocessor/loader.rs +155 -33
- package/rust/core/preprocessor/processor.rs +2 -2
- package/rust/core/preprocessor/resolver/bank.rs +6 -8
- package/rust/core/preprocessor/resolver/call.rs +20 -24
- package/rust/core/preprocessor/resolver/condition.rs +6 -8
- package/rust/core/preprocessor/resolver/driver.rs +14 -16
- package/rust/core/preprocessor/resolver/function.rs +6 -6
- package/rust/core/preprocessor/resolver/group.rs +6 -8
- package/rust/core/preprocessor/resolver/loop_.rs +8 -10
- package/rust/core/preprocessor/resolver/spawn.rs +19 -23
- package/rust/core/preprocessor/resolver/synth.rs +6 -8
- package/rust/core/preprocessor/resolver/tempo.rs +6 -8
- package/rust/core/preprocessor/resolver/trigger.rs +22 -19
- package/rust/core/preprocessor/resolver/value.rs +99 -4
- package/rust/core/store/export.rs +28 -28
- package/rust/core/store/function.rs +6 -0
- package/rust/core/store/global.rs +7 -1
- package/rust/core/store/import.rs +28 -28
- package/rust/core/store/variable.rs +1 -1
- package/rust/core/utils/mod.rs +0 -1
- package/rust/lib.rs +102 -9
- package/rust/main.rs +156 -45
- package/rust/types/Cargo.toml +8 -0
- package/rust/types/src/addons.rs +55 -0
- package/rust/types/src/ast.rs +198 -0
- package/rust/types/src/config.rs +74 -0
- package/rust/types/src/lib.rs +12 -0
- package/rust/types/src/telemetry.rs +85 -0
- package/rust/utils/Cargo.toml +23 -0
- package/rust/utils/{error.rs → src/error.rs} +186 -200
- package/rust/utils/src/file.rs +94 -0
- package/rust/utils/src/first_usage.rs +97 -0
- package/rust/utils/{mod.rs → src/lib.rs} +1 -1
- package/rust/utils/{logger.rs → src/logger.rs} +17 -12
- package/rust/utils/src/path.rs +88 -0
- package/rust/utils/src/signature.rs +41 -0
- package/rust/utils/{spinner.rs → src/spinner.rs} +3 -5
- package/rust/utils/src/version.rs +27 -0
- package/rust/utils/{watcher.rs → src/watcher.rs} +13 -1
- package/rust/web/api.rs +5 -0
- package/rust/web/cdn.rs +34 -0
- package/templates/minimal/README.md +98 -54
- package/templates/welcome/README.md +98 -54
- package/templates/welcome/src/index.deva +56 -8
- package/templates/welcome/src/variables.deva +2 -4
- package/tests/rust/TODO.md +0 -0
- package/tests/typescript/index.spec.ts +136 -0
- package/tests/typescript/playhead.spec.ts +36 -0
- package/tests/typescript/render_e2e.spec.ts +77 -0
- package/tsconfig.json +1 -1
- package/typescript/core/functions/index.ts +83 -0
- package/typescript/core/index.ts +6 -0
- package/typescript/core/types/index.ts +4 -0
- package/typescript/core/types/plugin.ts +19 -0
- package/typescript/core/types/result.ts +29 -0
- package/typescript/core/types/statement.ts +47 -0
- package/typescript/core/types/value.ts +29 -0
- package/typescript/index.ts +7 -2
- package/typescript/pkg/devalang_core.d.ts +4 -0
- package/typescript/scripts/copy-wasm-dts.ts +41 -0
- package/typescript/scripts/postinstall.ts +45 -32
- package/rust/cli/bank.rs +0 -462
- package/rust/cli/build.rs +0 -252
- package/rust/cli/generator.rs +0 -1
- package/rust/cli/play.rs +0 -1123
- package/rust/cli/telemetry.rs +0 -19
- package/rust/common/api.rs +0 -5
- package/rust/common/cdn.rs +0 -5
- package/rust/config/loader.rs +0 -165
- package/rust/config/stats.rs +0 -257
- package/rust/core/audio/engine.rs +0 -696
- package/rust/core/shared/bank.rs +0 -21
- package/rust/core/shared/duration.rs +0 -9
- package/rust/core/shared/mod.rs +0 -3
- package/rust/core/shared/value.rs +0 -35
- package/rust/core/utils/validation.rs +0 -35
- package/rust/installer/bank.rs +0 -62
- package/rust/installer/plugin.rs +0 -54
- package/rust/installer/utils.rs +0 -56
- package/rust/utils/file.rs +0 -38
- package/rust/utils/first_usage.rs +0 -76
- package/rust/utils/signature.rs +0 -19
- package/rust/utils/telemetry.rs +0 -292
- package/rust/utils/version.rs +0 -15
- /package/rust/{common → web}/mod.rs +0 -0
- /package/rust/{common → web}/sso.rs +0 -0
|
@@ -9,12 +9,15 @@
|
|
|
9
9
|

|
|
10
10
|

|
|
11
11
|

|
|
12
|
-
|
|
12
|
+
|
|
13
|
+

|
|
14
|
+

|
|
15
|
+

|
|
13
16
|
|
|
14
17
|

|
|
15
18
|

|
|
16
19
|
|
|
17
|
-
|
|
20
|
+

|
|
18
21
|
|
|
19
22
|
# 🦊 Devalang (CORE) — Compose music with code
|
|
20
23
|
|
|
@@ -25,12 +28,13 @@ Whether you're building a track, shaping textures, or performing live, Devalang
|
|
|
25
28
|
|
|
26
29
|
From studio sketches to live sets, Devalang gives you rhythmic control — with the elegance of code.
|
|
27
30
|
|
|
28
|
-
>
|
|
31
|
+
> **🚧 Notice 🚧**
|
|
32
|
+
>
|
|
33
|
+
> Includes synthesis, playback, and rendering features, but is still in early development, and breaking changes may occur.
|
|
29
34
|
>
|
|
30
|
-
>
|
|
35
|
+
> **NEW**: [Devaforge is now available for creating addons](https://github.com/devaloop-labs/devaforge).
|
|
31
36
|
>
|
|
32
|
-
>
|
|
33
|
-
> Linux and macOS binaries will be added in future releases via cross-platform builds.
|
|
37
|
+
> **NEW**: Now available for Windows, Linux, and macOS.
|
|
34
38
|
|
|
35
39
|
## 📚 Quick Access
|
|
36
40
|
|
|
@@ -41,81 +45,113 @@ From studio sketches to live sets, Devalang gives you rhythmic control — with
|
|
|
41
45
|
- [📜 Changelog](./docs/CHANGELOG.md)
|
|
42
46
|
- [💡 Examples](./examples/)
|
|
43
47
|
- [🌐 Project Website](https://devalang.com)
|
|
44
|
-
- [📦
|
|
48
|
+
- [📦 Devaforge on npm](https://www.npmjs.com/package/@devaloop/devaforge)
|
|
49
|
+
- [📦 Devalang on npm](https://www.npmjs.com/package/@devaloop/devalang)
|
|
45
50
|
|
|
46
51
|
## ⏱️ Try it now !
|
|
47
52
|
|
|
48
53
|
### Try Devalang in your browser
|
|
49
54
|
|
|
50
|
-
> Have a look at the
|
|
55
|
+
> [Have a look at the Playground to try Devalang directly in your browser](https://playground.devalang.com)
|
|
51
56
|
|
|
52
|
-
### Try Devalang
|
|
57
|
+
### Try Devalang in your terminal
|
|
58
|
+
|
|
59
|
+
#### With Node.js
|
|
53
60
|
|
|
54
61
|
```bash
|
|
55
|
-
|
|
56
|
-
|
|
62
|
+
npm install -g @devaloop/devalang@latest
|
|
63
|
+
```
|
|
57
64
|
|
|
58
|
-
|
|
65
|
+
#### With Rust
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
cargo install devalang
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
#### Initialize a new project (current directory)
|
|
72
|
+
|
|
73
|
+
```bash
|
|
59
74
|
devalang init --name my-project --template minimal
|
|
60
|
-
cd my-project
|
|
61
75
|
```
|
|
62
76
|
|
|
77
|
+
#### Write your first script
|
|
78
|
+
|
|
63
79
|
Create a new Devalang file `src/index.deva` in the project directory:
|
|
64
80
|
|
|
65
81
|
```deva
|
|
66
82
|
# src/index.deva
|
|
67
83
|
|
|
68
|
-
|
|
69
|
-
|
|
84
|
+
# BPM definition
|
|
85
|
+
bpm 125
|
|
86
|
+
|
|
87
|
+
# Bank picking (make sure you installed it)
|
|
88
|
+
bank devaloop.808 as my808Bank
|
|
89
|
+
|
|
90
|
+
group myGroup:
|
|
91
|
+
# Rhythmic (each beat playing a kick)
|
|
92
|
+
on beat:
|
|
93
|
+
.my808Bank.kick 1/4
|
|
94
|
+
|
|
95
|
+
# Synth definition with ADSR
|
|
96
|
+
let myLead = synth sine {
|
|
70
97
|
attack: 0,
|
|
71
98
|
decay: 100,
|
|
72
99
|
sustain: 100,
|
|
73
100
|
release: 100
|
|
74
101
|
}
|
|
75
102
|
|
|
76
|
-
# Global automation
|
|
77
|
-
automate
|
|
103
|
+
# Global automation
|
|
104
|
+
automate myLead:
|
|
78
105
|
param volume {
|
|
79
106
|
0% = 0.0
|
|
80
|
-
100% =
|
|
81
|
-
}
|
|
82
|
-
param pan {
|
|
83
|
-
0% = -1.0
|
|
84
|
-
100% = 1.0
|
|
107
|
+
100% = 0.5
|
|
85
108
|
}
|
|
86
109
|
param pitch {
|
|
87
110
|
0% = -12.0
|
|
88
111
|
100% = 12.0
|
|
89
112
|
}
|
|
90
113
|
|
|
91
|
-
|
|
114
|
+
# Notes in a loop with condition
|
|
115
|
+
for i in [1, 2, 3]:
|
|
116
|
+
if i == 3:
|
|
117
|
+
myLead -> note(C5, { duration: 200 })
|
|
118
|
+
print "Playing note C5 for " + i
|
|
119
|
+
|
|
120
|
+
# Pause runtime for 500ms
|
|
121
|
+
sleep 500
|
|
122
|
+
|
|
123
|
+
# Note with automation
|
|
124
|
+
myLead -> note(C4, {
|
|
92
125
|
duration: 400,
|
|
93
126
|
velocity: 0.8,
|
|
94
|
-
automate: {
|
|
127
|
+
automate: {
|
|
128
|
+
pan: {
|
|
129
|
+
0%: -1.0,
|
|
130
|
+
100%: 0.0
|
|
131
|
+
}
|
|
132
|
+
}
|
|
95
133
|
})
|
|
96
134
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
135
|
+
# Notes with params
|
|
136
|
+
myLead -> note(E4, { duration: 400 })
|
|
137
|
+
myLead -> note(G4, { duration: 600, glide: true, target_freq: 659.25 })
|
|
138
|
+
myLead -> note(B3, { duration: 400, slide: true, target_amp: 0.3 })
|
|
100
139
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
# Play the lead
|
|
105
|
-
|
|
106
|
-
call main
|
|
140
|
+
# Calling the group to play it
|
|
141
|
+
call myGroup
|
|
107
142
|
```
|
|
108
143
|
|
|
109
144
|
### And the best part ? You can play it directly from the command line:
|
|
110
145
|
|
|
146
|
+
#### Play the script once
|
|
147
|
+
|
|
111
148
|
```bash
|
|
112
|
-
# Play the Devalang file
|
|
113
149
|
devalang play
|
|
150
|
+
```
|
|
114
151
|
|
|
115
|
-
|
|
116
|
-
devalang play --watch
|
|
152
|
+
#### **LIVE mode** (repeat the playback + watch mode)
|
|
117
153
|
|
|
118
|
-
|
|
154
|
+
```bash
|
|
119
155
|
devalang play --repeat
|
|
120
156
|
```
|
|
121
157
|
|
|
@@ -125,40 +161,48 @@ devalang play --repeat
|
|
|
125
161
|
|
|
126
162
|
## ❓ Why Devalang ?
|
|
127
163
|
|
|
128
|
-
- 🎹 Prototype audio ideas without opening a DAW, even VSCode
|
|
164
|
+
- 🎹 Prototype audio ideas without opening a DAW, even VSCode with our Playground
|
|
129
165
|
- 💻 Integrate sound into code-based workflows
|
|
130
166
|
- 🎛️ Control audio parameters through readable syntax
|
|
131
167
|
- 🧪 Build musical logic with variables and conditions
|
|
132
168
|
- 🔄 Create complex patterns with ease
|
|
169
|
+
- 🎚️ Automate everything
|
|
133
170
|
|
|
134
171
|
## 🚀 Features
|
|
135
172
|
|
|
136
|
-
-
|
|
137
|
-
-
|
|
138
|
-
-
|
|
139
|
-
-
|
|
140
|
-
-
|
|
141
|
-
-
|
|
142
|
-
-
|
|
143
|
-
-
|
|
144
|
-
-
|
|
173
|
+
- ⚡ **Fast Build & Hot Reload** — optimized build process for quicker iteration.
|
|
174
|
+
- 🎵 **Audio Engine & Real-time runner** — low-latency playback, render-to-file, and a realtime runner used by `devalang play` for live feedback.
|
|
175
|
+
- ▶️ **Live mode (watch + repeat)** — edit and hear changes instantly with `devalang play --repeat` and watch mode.
|
|
176
|
+
- 🧩 **Language primitives** — synths, notes, ADSR, maps, arrays, loops, conditionals and functions for expressive musical logic.
|
|
177
|
+
- 🎛️ **Per-note automation & modulators** — `automate` maps, `$mod.*`, `$easing.*` and `$math.*` helpers for envelopes and LFOs.
|
|
178
|
+
- 🧩 **Module system & structured AST** — import/export variables, stable AST output for debugging and tooling.
|
|
179
|
+
- 🧰 **Plugins & Addons (WASM-ready)** — install plugins/banks, `@use` directive, and WASM plugin integration so plugins can render or process audio at runtime.
|
|
180
|
+
- 📦 **Addon manager & Devaforge** — CLI commands to discover/install banks, plugins and templates; `devaforge` helps create addons.
|
|
181
|
+
- ⚙️ **CLI tooling** — `build`, `check`, `play`, `install`, `init`, `discover`, `telemetry` and more with consistent flags (`--watch`, `--debug`, `--compress`).
|
|
182
|
+
- 📂 **Project templates & examples** — quick-start templates and many example projects in `examples/`.
|
|
183
|
+
- 🧑💻 **TypeScript API & WASM distribution** — Node-friendly package with TypeScript bindings and a WASM build for browser/Node usage.
|
|
184
|
+
- 🧰 **Editor & formatting support** — VSCode extension and Prettier plugin to edit Devalang with syntax and formatting support.
|
|
185
|
+
- 🎵 **Custom samples & banks** — drop samples into `.deva` and reference them from code; banks of sounds for fast composition.
|
|
186
|
+
- 🔄 **Looping, grouping & scheduling** — precise beat-tied scheduling primitives for complex rhythmic patterns.
|
|
145
187
|
|
|
146
188
|
## 📄 Documentation
|
|
147
189
|
|
|
148
|
-
### Please refer to the
|
|
190
|
+
### [Please refer to the online documentation](https://docs.devalang.com) for detailed information on syntax, features, and usage examples
|
|
149
191
|
|
|
150
|
-
##
|
|
192
|
+
## 📰 What's new
|
|
151
193
|
|
|
152
|
-
-
|
|
153
|
-
-
|
|
194
|
+
- **Devaforge**: Introduced a new system for creating and managing addons, including a CLI for addon generation.
|
|
195
|
+
- **Documentation updates**: Improved documentation for clarity and completeness.
|
|
196
|
+
- **Discovering addons**: Introduced a new command to detect addons.
|
|
197
|
+
- **Public TypeScript API**: Added a public TypeScript API for easier integration.
|
|
198
|
+
- **Improved error messages**: Enhanced error messages for better debugging.
|
|
199
|
+
- **Bug fixes**: Various bug fixes and stability improvements.
|
|
154
200
|
|
|
155
201
|
## 🧪 Roadmap Highlights
|
|
156
202
|
|
|
157
203
|
For more info, see [docs/ROADMAP.md](./docs/ROADMAP.md)
|
|
158
204
|
|
|
159
|
-
- ⏳
|
|
160
|
-
- ⏳ Cross-platform support (Linux, macOS)
|
|
161
|
-
- ⏳ More built-in instruments (e.g. snare, hi-hat, etc.)
|
|
205
|
+
- ⏳ Smart modules
|
|
162
206
|
|
|
163
207
|
## 🛡️ License
|
|
164
208
|
|
|
@@ -1,13 +1,61 @@
|
|
|
1
|
-
# 🦊 Welcome to Devalang
|
|
2
|
-
#
|
|
3
|
-
# Let's start with a simple example that plays a sample in a loop.
|
|
1
|
+
# 🦊 Welcome to Devalang
|
|
2
|
+
# Happy live-coding !
|
|
4
3
|
|
|
5
|
-
@import { bpmVar
|
|
6
|
-
@load "../samples/kick-808.wav" as
|
|
4
|
+
@import { bpmVar } from './variables.deva'
|
|
5
|
+
@load "../samples/kick-808.wav" as myKick
|
|
7
6
|
|
|
7
|
+
# BPM definition
|
|
8
8
|
bpm bpmVar
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
group myGroup:
|
|
11
|
+
# Rhythmic (each beat playing a kick)
|
|
12
|
+
on beat:
|
|
13
|
+
.myKick 1/4
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
# Synth definition with ADSR
|
|
16
|
+
let myLead = synth sine {
|
|
17
|
+
attack: 0,
|
|
18
|
+
decay: 100,
|
|
19
|
+
sustain: 100,
|
|
20
|
+
release: 100
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
# Global automation
|
|
24
|
+
automate myLead:
|
|
25
|
+
param volume {
|
|
26
|
+
0% = 0.0
|
|
27
|
+
100% = 0.5
|
|
28
|
+
}
|
|
29
|
+
param pitch {
|
|
30
|
+
0% = -12.0
|
|
31
|
+
100% = 12.0
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
# Notes in a loop with condition
|
|
35
|
+
for i in [1, 2, 3]:
|
|
36
|
+
if i == 3:
|
|
37
|
+
myLead -> note(C5, { duration: 200 })
|
|
38
|
+
print "Playing note C5 for " + i
|
|
39
|
+
|
|
40
|
+
# Pause runtime for 500ms
|
|
41
|
+
sleep 500
|
|
42
|
+
|
|
43
|
+
# Note with automation
|
|
44
|
+
myLead -> note(C4, {
|
|
45
|
+
duration: 400,
|
|
46
|
+
velocity: 0.8,
|
|
47
|
+
automate: {
|
|
48
|
+
pan: {
|
|
49
|
+
0%: -1.0,
|
|
50
|
+
100%: 0.0
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
# Notes with params
|
|
56
|
+
myLead -> note(E4, { duration: 400 })
|
|
57
|
+
myLead -> note(G4, { duration: 600, glide: true, target_freq: 659.25 })
|
|
58
|
+
myLead -> note(B3, { duration: 400, slide: true, target_amp: 0.3 })
|
|
59
|
+
|
|
60
|
+
# Calling the group to play it
|
|
61
|
+
call myGroup
|
|
File without changes
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import * as fs from "fs";
|
|
3
|
+
import * as os from "os";
|
|
4
|
+
import * as path from "path";
|
|
5
|
+
|
|
6
|
+
// CommonJS bundle import (TypeScript-friendly)
|
|
7
|
+
const core: any = require("../../out-tsc");
|
|
8
|
+
|
|
9
|
+
describe("devalang typescript index", () => {
|
|
10
|
+
let origCwd: string;
|
|
11
|
+
let tmpDir: string | null = null;
|
|
12
|
+
|
|
13
|
+
before(function () {
|
|
14
|
+
// Prepare a temporary project root so wasm code that looks up project files
|
|
15
|
+
// and `.devalang` config can succeed during E2E runs.
|
|
16
|
+
origCwd = process.cwd();
|
|
17
|
+
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "devalang-e2e-"));
|
|
18
|
+
// Create minimal .devalang config file so get_project_root finds it
|
|
19
|
+
fs.writeFileSync(
|
|
20
|
+
path.join(tmpDir, ".devalang"),
|
|
21
|
+
'name = "devalang-test"\n'
|
|
22
|
+
);
|
|
23
|
+
// Ensure .deva exists (optional banks/plugins)
|
|
24
|
+
fs.mkdirSync(path.join(tmpDir, ".deva"), { recursive: true });
|
|
25
|
+
process.chdir(tmpDir);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
after(function () {
|
|
29
|
+
// restore cwd and attempt cleanup
|
|
30
|
+
if (tmpDir) {
|
|
31
|
+
try {
|
|
32
|
+
process.chdir(origCwd);
|
|
33
|
+
// best-effort cleanup
|
|
34
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
35
|
+
} catch (e) {
|
|
36
|
+
// ignore
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
it("should expose render_audio and return a Float32Array when wasm is available", function () {
|
|
41
|
+
// Prefer wasm binding if available
|
|
42
|
+
const wasmFn = core.pkg && core.pkg.render_audio;
|
|
43
|
+
|
|
44
|
+
const sampleProgram = `# simple program for tests
|
|
45
|
+
bpm 120
|
|
46
|
+
|
|
47
|
+
group myLead:
|
|
48
|
+
let mySynth = synth sine
|
|
49
|
+
mySynth -> note(C4, { duration: 400 })
|
|
50
|
+
mySynth -> note(G4, { duration: 400 })
|
|
51
|
+
call myLead
|
|
52
|
+
`;
|
|
53
|
+
|
|
54
|
+
if (typeof wasmFn === "function") {
|
|
55
|
+
try {
|
|
56
|
+
// Get parsed AST first for debugging
|
|
57
|
+
if (core.pkg && typeof core.pkg.parse === "function") {
|
|
58
|
+
try {
|
|
59
|
+
const parsed = core.pkg.parse("playground.deva", sampleProgram);
|
|
60
|
+
// parsed may be an object { ok, ast, errors } or a string
|
|
61
|
+
const astStr =
|
|
62
|
+
parsed && parsed.ast
|
|
63
|
+
? parsed.ast
|
|
64
|
+
: typeof parsed === "string"
|
|
65
|
+
? parsed
|
|
66
|
+
: JSON.stringify(parsed);
|
|
67
|
+
expect(astStr).to.match(/note|synth/i);
|
|
68
|
+
} catch (e) {
|
|
69
|
+
console.warn(
|
|
70
|
+
"[TEST DEBUG] parse() failed or returned non-standard result:",
|
|
71
|
+
e
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const result = wasmFn(sampleProgram);
|
|
77
|
+
expect(result.constructor && result.constructor.name).to.match(
|
|
78
|
+
/Float32Array|Float64Array|ArrayBuffer|Uint8Array/
|
|
79
|
+
);
|
|
80
|
+
} catch (err: any) {
|
|
81
|
+
// If the wasm panicked because the audio buffer is empty, skip the test in this env.
|
|
82
|
+
const msg =
|
|
83
|
+
typeof err === "string"
|
|
84
|
+
? err
|
|
85
|
+
: err && err.message
|
|
86
|
+
? err.message
|
|
87
|
+
: String(err);
|
|
88
|
+
if (msg.includes("Audio buffer is empty")) {
|
|
89
|
+
// skip this test on environments where generating audio isn't supported
|
|
90
|
+
// eslint-disable-next-line no-invalid-this
|
|
91
|
+
this.skip();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
throw err;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// If wasm binding isn't available, ensure a runtime placeholder exists but don't call it
|
|
101
|
+
const runtimeFn = core.render_audio;
|
|
102
|
+
expect(runtimeFn).to.be.a("function");
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it("should find statements for entry module", function () {
|
|
106
|
+
const parseFn = core.pkg && core.pkg.parse;
|
|
107
|
+
if (typeof parseFn !== "function") {
|
|
108
|
+
// nothing to test if parse binding missing
|
|
109
|
+
// eslint-disable-next-line no-invalid-this
|
|
110
|
+
this.skip();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
try {
|
|
114
|
+
const res = parseFn("playground.deva", "bpm 120");
|
|
115
|
+
expect(res).to.be.an("object");
|
|
116
|
+
// prefer explicit shape when available
|
|
117
|
+
if (Object.prototype.hasOwnProperty.call(res, "ok")) {
|
|
118
|
+
expect(res.ok).to.equal(true);
|
|
119
|
+
} else {
|
|
120
|
+
expect(res).to.have.property("ast");
|
|
121
|
+
}
|
|
122
|
+
} catch (err: any) {
|
|
123
|
+
const msg = err && err.message ? err.message : String(err);
|
|
124
|
+
if (
|
|
125
|
+
msg.includes("Module loading error") ||
|
|
126
|
+
msg.includes("Project root not found")
|
|
127
|
+
) {
|
|
128
|
+
// environment not prepared for module loading, skip
|
|
129
|
+
// eslint-disable-next-line no-invalid-this
|
|
130
|
+
this.skip();
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
throw err;
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
|
|
3
|
+
const core: any = require("../../out-tsc");
|
|
4
|
+
|
|
5
|
+
describe("playhead callback", () => {
|
|
6
|
+
it("should call registered callback during run", () => {
|
|
7
|
+
const register = core.pkg && core.pkg.register_playhead_callback;
|
|
8
|
+
const unregister = core.pkg && core.pkg.unregister_playhead_callback;
|
|
9
|
+
if (typeof register !== "function") {
|
|
10
|
+
// skip when wasm not available
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let called = false;
|
|
15
|
+
const cb = (ev: any) => {
|
|
16
|
+
called = true;
|
|
17
|
+
expect(ev).to.have.property("time");
|
|
18
|
+
expect(ev).to.have.property("line");
|
|
19
|
+
expect(ev).to.have.property("column");
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
register(cb);
|
|
23
|
+
|
|
24
|
+
// run a simple program to trigger events
|
|
25
|
+
const program = `bpm 120\n\n.myTrigger 1/4\n`;
|
|
26
|
+
// render_audio will schedule triggers and should invoke the callback during execution
|
|
27
|
+
const render = core.pkg && core.pkg.render_audio;
|
|
28
|
+
if (typeof render === "function") {
|
|
29
|
+
render(program);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
unregister && unregister();
|
|
33
|
+
|
|
34
|
+
expect(called).to.be.true;
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import * as fs from "fs";
|
|
3
|
+
import * as os from "os";
|
|
4
|
+
import * as path from "path";
|
|
5
|
+
|
|
6
|
+
const core: any = require("../../out-tsc");
|
|
7
|
+
|
|
8
|
+
describe("devalang debug_render and render_audio E2E", () => {
|
|
9
|
+
let origCwd: string;
|
|
10
|
+
let tmpDir: string | null = null;
|
|
11
|
+
|
|
12
|
+
before(function () {
|
|
13
|
+
origCwd = process.cwd();
|
|
14
|
+
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "devalang-e2e-"));
|
|
15
|
+
fs.writeFileSync(
|
|
16
|
+
path.join(tmpDir, ".devalang"),
|
|
17
|
+
'name = "devalang-test"\n'
|
|
18
|
+
);
|
|
19
|
+
fs.mkdirSync(path.join(tmpDir, ".deva"), { recursive: true });
|
|
20
|
+
process.chdir(tmpDir as string);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
after(function () {
|
|
24
|
+
if (tmpDir) {
|
|
25
|
+
try {
|
|
26
|
+
process.chdir(origCwd);
|
|
27
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
28
|
+
} catch (e) {
|
|
29
|
+
// ignore
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("debug_render should return diagnostics including note_count and global_vars", function () {
|
|
35
|
+
const dbg = core.pkg && core.pkg.debug_render;
|
|
36
|
+
if (typeof dbg !== "function") {
|
|
37
|
+
// skip if wasm binding missing
|
|
38
|
+
// eslint-disable-next-line no-invalid-this
|
|
39
|
+
this.skip();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const sampleProgram = `# sample program\nbpm 120\n\ngroup myLead:\n let mySynth = synth sine\n mySynth -> note(C4, { duration: 400 })\n mySynth -> note(G4, { duration: 400 })\ncall myLead\n`;
|
|
43
|
+
|
|
44
|
+
const out = dbg(sampleProgram);
|
|
45
|
+
expect(out).to.be.an("object");
|
|
46
|
+
expect(out).to.have.property("samples_len");
|
|
47
|
+
expect(out).to.have.property("any_nonzero");
|
|
48
|
+
expect(out).to.have.property("note_count");
|
|
49
|
+
expect(out).to.have.property("global_vars");
|
|
50
|
+
|
|
51
|
+
// Basic assertions: at least one non-zero sample or note_count > 0
|
|
52
|
+
expect(out.note_count).to.be.at.least(0);
|
|
53
|
+
expect(out.global_vars).to.include("myLead");
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("render_audio should return a Float32Array and not be completely silent", function () {
|
|
57
|
+
const render = (core.pkg && core.pkg.render_audio) || core.render_audio;
|
|
58
|
+
if (typeof render !== "function") {
|
|
59
|
+
// eslint-disable-next-line no-invalid-this
|
|
60
|
+
this.skip();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const sampleProgram = `# sample program\nbpm 120\n\ngroup myLead:\n let mySynth = synth sine\n mySynth -> note(C4, { duration: 400 })\n mySynth -> note(G4, { duration: 400 })\ncall myLead\n`;
|
|
64
|
+
|
|
65
|
+
const arr = render(sampleProgram);
|
|
66
|
+
// If wasm returns JS typed array wrapper, check constructor name
|
|
67
|
+
expect(arr.constructor && arr.constructor.name).to.match(
|
|
68
|
+
/Float32Array|Float64Array|ArrayBuffer|Uint8Array/
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
// Convert to plain array if needed
|
|
72
|
+
const samples: number[] = Array.from(arr as any);
|
|
73
|
+
// Expect either note_count > 0 indirectly via nonzero samples
|
|
74
|
+
const anyNonZero = samples.some((s) => s !== 0);
|
|
75
|
+
expect(anyNonZero).to.be.true;
|
|
76
|
+
});
|
|
77
|
+
});
|
package/tsconfig.json
CHANGED
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
|
53
53
|
|
|
54
54
|
/* Emit */
|
|
55
|
-
|
|
55
|
+
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
|
56
56
|
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
57
57
|
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
58
58
|
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { ParseResult } from "../types/result";
|
|
2
|
+
import { DebugResult } from "../types/result";
|
|
3
|
+
|
|
4
|
+
let wasmPkg: any = undefined;
|
|
5
|
+
try {
|
|
6
|
+
// prefer runtime pkg generated by wasm-pack when available
|
|
7
|
+
// require at runtime so the package can be used even if wasm hasn't been built
|
|
8
|
+
// (this keeps tests and consumers robust).
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
10
|
+
wasmPkg = require("../../pkg/devalang_core");
|
|
11
|
+
} catch (_e) {
|
|
12
|
+
wasmPkg = undefined;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Parses the user code.
|
|
17
|
+
* @param entry_path The entry path for the code.
|
|
18
|
+
* @param source The source code to parse.
|
|
19
|
+
* @returns ParseResult | any
|
|
20
|
+
*/
|
|
21
|
+
export function parse(entry_path: string, source: string): ParseResult | any {
|
|
22
|
+
if (wasmPkg && typeof wasmPkg.parse === "function") {
|
|
23
|
+
return wasmPkg.parse(entry_path, source);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
throw new Error(
|
|
27
|
+
"WASM binding 'parse' not available. Build the wasm package or use the JS runtime."
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Renders the debug information for the user code.
|
|
33
|
+
* @param user_code The user-provided code to render debug information for.
|
|
34
|
+
* @returns DebugResult | any
|
|
35
|
+
*/
|
|
36
|
+
export function debug_render(user_code: string): DebugResult | any {
|
|
37
|
+
if (wasmPkg && typeof wasmPkg.debug_render === "function") {
|
|
38
|
+
return wasmPkg.debug_render(user_code);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
throw new Error(
|
|
42
|
+
"WASM binding 'debug_render' not available. Build the wasm package or use the JS runtime."
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Renders audio from the user code.
|
|
48
|
+
* @param user_code The user-provided code to render audio from.
|
|
49
|
+
* @returns Float32Array
|
|
50
|
+
*/
|
|
51
|
+
export function render_audio(user_code: string): Float32Array {
|
|
52
|
+
if (wasmPkg && typeof wasmPkg.render_audio === "function") {
|
|
53
|
+
return wasmPkg.render_audio(user_code);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Fallback: indicate missing wasm with an empty buffer rather than breaking consumers.
|
|
57
|
+
return new Float32Array(0);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Register a JS callback to receive playhead events { time, line, column } during playback.
|
|
62
|
+
* The callback will be called with a single object argument.
|
|
63
|
+
* @param cb The callback function to register.
|
|
64
|
+
* @returns void
|
|
65
|
+
*/
|
|
66
|
+
export function register_playhead_callback(cb: (ev: { time: number; line: number; column: number }) => void) {
|
|
67
|
+
if (wasmPkg && typeof wasmPkg.register_playhead_callback === "function") {
|
|
68
|
+
return wasmPkg.register_playhead_callback(cb);
|
|
69
|
+
}
|
|
70
|
+
// no-op fallback
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Unregisters the JS callback for playhead events.
|
|
76
|
+
* @returns void
|
|
77
|
+
*/
|
|
78
|
+
export function unregister_playhead_callback() {
|
|
79
|
+
if (wasmPkg && typeof wasmPkg.unregister_playhead_callback === "function") {
|
|
80
|
+
return wasmPkg.unregister_playhead_callback();
|
|
81
|
+
}
|
|
82
|
+
return;
|
|
83
|
+
}
|