@devaloop/devalang 0.0.1-alpha.10 → 0.0.1-alpha.12
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/.devalang +6 -1
- package/Cargo.toml +6 -2
- package/README.md +59 -142
- package/docs/CHANGELOG.md +60 -1
- package/docs/ROADMAP.md +1 -1
- package/docs/TODO.md +1 -1
- package/examples/bank.deva +9 -0
- package/examples/duration.deva +9 -0
- package/examples/index.deva +6 -6
- package/out-tsc/bin/devalang.exe +0 -0
- package/package.json +2 -1
- package/project-version.json +3 -3
- package/rust/cli/bank.rs +455 -0
- package/rust/cli/build.rs +1 -1
- package/rust/cli/check.rs +1 -1
- package/rust/cli/driver.rs +280 -0
- package/rust/cli/install.rs +17 -0
- package/rust/cli/mod.rs +5 -200
- package/rust/cli/play.rs +1 -1
- package/rust/cli/update.rs +4 -0
- package/rust/common/cdn.rs +11 -0
- package/rust/common/mod.rs +1 -0
- package/rust/config/driver.rs +76 -0
- package/rust/config/loader.rs +98 -1
- package/rust/config/mod.rs +1 -15
- package/rust/core/audio/engine.rs +151 -10
- package/rust/core/audio/interpreter/arrow_call.rs +17 -4
- package/rust/core/audio/interpreter/trigger.rs +56 -2
- package/rust/core/audio/loader/trigger.rs +12 -0
- package/rust/core/lexer/handler/driver.rs +12 -1
- package/rust/core/lexer/handler/mod.rs +1 -0
- package/rust/core/lexer/handler/slash.rs +21 -0
- package/rust/core/lexer/token.rs +1 -0
- package/rust/core/parser/driver.rs +36 -2
- package/rust/core/parser/handler/arrow_call.rs +29 -4
- package/rust/core/parser/handler/dot.rs +102 -37
- package/rust/core/preprocessor/loader.rs +93 -14
- package/rust/core/preprocessor/resolver/driver.rs +5 -0
- package/rust/core/shared/bank.rs +21 -0
- package/rust/core/shared/duration.rs +1 -0
- package/rust/core/shared/mod.rs +2 -1
- package/rust/core/shared/value.rs +1 -0
- package/rust/installer/bank.rs +55 -0
- package/rust/installer/mod.rs +2 -0
- package/rust/installer/utils.rs +56 -0
- package/rust/main.rs +62 -5
- package/docs/COMMANDS.md +0 -85
- package/docs/CONFIG.md +0 -30
- package/docs/SYNTAX.md +0 -230
package/docs/COMMANDS.md
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
<img src="https://firebasestorage.googleapis.com/v0/b/devaloop-labs.firebasestorage.app/o/devalang-teal-logo.svg?alt=media&token=d2a5705a-1eba-4b49-88e6-895a761fb7f7" alt="Devalang Logo">
|
|
3
|
-
</div>
|
|
4
|
-
|
|
5
|
-
# Devalang Commands Guide
|
|
6
|
-
|
|
7
|
-
## Initialization
|
|
8
|
-
|
|
9
|
-
Initialize a new Devalang project (current folder)
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
devalang init
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
Initialize a new Devalang project (new folder)
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
devalang init --name <project-name> --template <template-name>
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
Available arguments:
|
|
22
|
-
|
|
23
|
-
- `--name`: The name of the project (cannot be empty)
|
|
24
|
-
- `--template`: The template to use for the project (default to `welcome`)
|
|
25
|
-
|
|
26
|
-
## Checking
|
|
27
|
-
|
|
28
|
-
Checking syntax of .deva file(s)
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
devalang check --entry ./examples --output ./output --watch
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
Available arguments :
|
|
35
|
-
|
|
36
|
-
- `--no-config`: Whether to ignore the configuration file (default to `false`)
|
|
37
|
-
- `--entry`: The input folder (default to `./src`)
|
|
38
|
-
- `--output`: The output folder (default to `./output`)
|
|
39
|
-
- `--watch`: Whether to watch for changes and re-analyze (default to `false`)
|
|
40
|
-
|
|
41
|
-
## Building
|
|
42
|
-
|
|
43
|
-
Building AST of .deva file(s)
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
devalang build --entry ./examples --output ./output --watch
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
Available arguments :
|
|
50
|
-
|
|
51
|
-
- `--no-config`: Whether to ignore the configuration file (default to `false`)
|
|
52
|
-
- `--entry`: The input folder (default to `./src`)
|
|
53
|
-
- `--output`: The output folder (default to `./output`)
|
|
54
|
-
- `--watch`: Whether to watch for changes and rebuild (default to `false`)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
## Playing
|
|
58
|
-
|
|
59
|
-
Playing .deva file(s) without audio playback (once)
|
|
60
|
-
|
|
61
|
-
```bash
|
|
62
|
-
devalang play --entry ./examples --output ./output
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
Playing .deva file(s) with audio playback (once by file change)
|
|
66
|
-
|
|
67
|
-
```bash
|
|
68
|
-
devalang play --entry ./examples --output ./output --watch
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
Playing .deva file(s) with audio playback (infinite loop)
|
|
72
|
-
|
|
73
|
-
```bash
|
|
74
|
-
devalang play --entry ./examples --output ./output --repeat
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
Note : You cannot use `--watch` and `--repeat` options together. Use `--repeat` instead.
|
|
78
|
-
|
|
79
|
-
Available arguments :
|
|
80
|
-
|
|
81
|
-
- `--no-config`: Whether to ignore the configuration file (default to `false`)
|
|
82
|
-
- `--entry`: The input folder (default to `./src`)
|
|
83
|
-
- `--output`: The output folder (default to `./output`)
|
|
84
|
-
- `--watch`: Whether to watch for changes and rebuild + play (default to `false`)
|
|
85
|
-
- `--repeat`: Whether to repeat the playback of the audio file (default to `false`)
|
package/docs/CONFIG.md
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
<img src="https://firebasestorage.googleapis.com/v0/b/devaloop-labs.firebasestorage.app/o/devalang-teal-logo.svg?alt=media&token=d2a5705a-1eba-4b49-88e6-895a761fb7f7" alt="Devalang Logo">
|
|
3
|
-
</div>
|
|
4
|
-
|
|
5
|
-
# Devalang Configuration File
|
|
6
|
-
|
|
7
|
-
Use a configuration file if you don't want to pass command-line arguments every time you run a command. The configuration file allows you to set default values for various settings, making it easier to manage your Devalang project.
|
|
8
|
-
|
|
9
|
-
## Ignoring the Configuration File
|
|
10
|
-
|
|
11
|
-
If you prefer not to use a configuration file, you can ignore it by passing the `--no-config` flag when running Devalang commands. This will bypass any settings defined in the configuration file and use only the command-line arguments you provide.
|
|
12
|
-
|
|
13
|
-
## Structure of the Configuration File
|
|
14
|
-
|
|
15
|
-
The configuration file is a TOML (Tom's Obvious, Minimal Language) file that contains key-value pairs to define various settings for your Devalang project. Below is a sample configuration file:
|
|
16
|
-
|
|
17
|
-
```toml
|
|
18
|
-
[defaults]
|
|
19
|
-
entry = "./src"
|
|
20
|
-
output = "./output"
|
|
21
|
-
watch = false
|
|
22
|
-
repeat = true
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
### Available Settings
|
|
26
|
-
|
|
27
|
-
- `entry`: (String) The entry point for your Devalang project (default to `./src`)
|
|
28
|
-
- `output`: (String) The output directory for generated files (default to `./output`)
|
|
29
|
-
- `watch`: (Boolean) Whether to watch for changes in files and automatically rebuild or check them (default to `false`)
|
|
30
|
-
- `repeat`: (Boolean) Whether to repeat the playback of audio files (default to `false`)
|
package/docs/SYNTAX.md
DELETED
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
<img src="https://firebasestorage.googleapis.com/v0/b/devaloop-labs.firebasestorage.app/o/devalang-teal-logo.svg?alt=media&token=d2a5705a-1eba-4b49-88e6-895a761fb7f7" alt="Devalang Logo">
|
|
3
|
-
</div>
|
|
4
|
-
|
|
5
|
-
# Devalang Syntax Guide
|
|
6
|
-
|
|
7
|
-
Devalang supports a simple and intuitive syntax for composing music and sound design. Below is a guide to the basic syntax elements, types, and usage examples.
|
|
8
|
-
|
|
9
|
-
The engine is designed to be easy to read and write, allowing you to focus on your music rather than the code.
|
|
10
|
-
|
|
11
|
-
The engine uses indentation to define blocks, similar to Python. Each block must be indented consistently.
|
|
12
|
-
|
|
13
|
-
➡️ For full examples, check the `examples/` folder of the repository.
|
|
14
|
-
|
|
15
|
-
## Types
|
|
16
|
-
|
|
17
|
-
<details>
|
|
18
|
-
<summary>Show available types</summary>
|
|
19
|
-
|
|
20
|
-
### Duration
|
|
21
|
-
|
|
22
|
-
Duration is defined using a number. It represents the length of a sound in milliseconds.
|
|
23
|
-
|
|
24
|
-
```deva
|
|
25
|
-
let duration = 1000
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
Will play a sound for 1000 milliseconds (1 second).
|
|
29
|
-
|
|
30
|
-
NOTE: Other time units like seconds or beats are not supported yet, but will be in the future.
|
|
31
|
-
|
|
32
|
-
### String
|
|
33
|
-
|
|
34
|
-
Strings are defined using double quotes.
|
|
35
|
-
|
|
36
|
-
```deva
|
|
37
|
-
let string = "myValue"
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
### Number
|
|
41
|
-
|
|
42
|
-
Numbers can be integers or floating-point values. They do not require quotes.
|
|
43
|
-
|
|
44
|
-
```deva
|
|
45
|
-
let number = 99
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### Boolean
|
|
49
|
-
|
|
50
|
-
Booleans can be either `true` or `false` without quotes.
|
|
51
|
-
|
|
52
|
-
```deva
|
|
53
|
-
let boolean = false
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### Map
|
|
57
|
-
|
|
58
|
-
Maps are key-value pairs defined using curly braces. Keys are strings, and values can be of any type (string, number, boolean, map, or array).
|
|
59
|
-
|
|
60
|
-
```deva
|
|
61
|
-
let map = { myKey: 99 }
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
### Array
|
|
65
|
-
|
|
66
|
-
Arrays are ordered lists of values defined using square brackets. Values can be of any type (string, number, boolean, map, or array).
|
|
67
|
-
|
|
68
|
-
```deva
|
|
69
|
-
let array = [3, 4]
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
</details>
|
|
73
|
-
|
|
74
|
-
## Syntax usage
|
|
75
|
-
|
|
76
|
-
### Beats Per Minute
|
|
77
|
-
|
|
78
|
-
BPM is used to set the global tempo of the music.
|
|
79
|
-
|
|
80
|
-
```deva
|
|
81
|
-
bpm 125
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### Sound Bank
|
|
85
|
-
|
|
86
|
-
Bank is used to select a sound bank for the audio engine.
|
|
87
|
-
|
|
88
|
-
```deva
|
|
89
|
-
bank 808
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### Importing / Exporting Modules
|
|
93
|
-
|
|
94
|
-
Modules can be imported and exported to share variables between different files.
|
|
95
|
-
|
|
96
|
-
> ⚠️ The import/export system is still experimental and may change in the future.
|
|
97
|
-
>
|
|
98
|
-
> You must explicitly declare imports and exports in each file — Devalang does not automatically detect or resolve them.
|
|
99
|
-
|
|
100
|
-
Exporting variables from a module :
|
|
101
|
-
|
|
102
|
-
```deva
|
|
103
|
-
# exported.deva
|
|
104
|
-
|
|
105
|
-
let exportedIterator = 10
|
|
106
|
-
let exportedParams = { drive: 50, decay: 30 }
|
|
107
|
-
|
|
108
|
-
@export { exportedIterator, exportedParams }
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
Importing and using the exported variables in another module :
|
|
112
|
-
|
|
113
|
-
```deva
|
|
114
|
-
# index.deva
|
|
115
|
-
|
|
116
|
-
@import { exportedIterator, exportedParams } "./exported.deva"
|
|
117
|
-
|
|
118
|
-
loop exportedIterator:
|
|
119
|
-
.kick auto exportedParams
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
### Loading Samples
|
|
123
|
-
|
|
124
|
-
You can load your own samples and use them in your music.
|
|
125
|
-
|
|
126
|
-
Load usage : `@load <path> as <name>`
|
|
127
|
-
|
|
128
|
-
Trigger usage : `.<name> <duration> <params>`
|
|
129
|
-
|
|
130
|
-
```deva
|
|
131
|
-
@load "./path/to/instrument.mp3" as mySample
|
|
132
|
-
|
|
133
|
-
.mySample auto {reverb: 50, drive: 25}
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
### Variables
|
|
137
|
-
|
|
138
|
-
Variables are defined using the `let` keyword, followed by the variable name and its value. The value can be of any type (string, number, boolean, map, or array).
|
|
139
|
-
|
|
140
|
-
```deva
|
|
141
|
-
let number = 0
|
|
142
|
-
let boolean = true
|
|
143
|
-
let string = "string"
|
|
144
|
-
let map = { myKey: 200 }
|
|
145
|
-
let array = [0, 1, 2]
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
### Loops
|
|
149
|
-
|
|
150
|
-
Loops are defined using the `loop` keyword, followed by the number of iterations. The body of the loop is indented.
|
|
151
|
-
|
|
152
|
-
```deva
|
|
153
|
-
loop 10:
|
|
154
|
-
# ...
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
### Groups
|
|
158
|
-
|
|
159
|
-
Groups are defined using the `group` keyword, followed by the group name. The body of the group is indented.
|
|
160
|
-
|
|
161
|
-
Groups allow you to organize your code into reusable blocks. They can be called or spawned later in the code.
|
|
162
|
-
|
|
163
|
-
```deva
|
|
164
|
-
group myGroup:
|
|
165
|
-
# ...
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
### Conditions
|
|
169
|
-
|
|
170
|
-
Conditions are defined using the `if` keyword, followed by a condition. The body of the condition is indented.
|
|
171
|
-
|
|
172
|
-
```deva
|
|
173
|
-
if myCondition:
|
|
174
|
-
# ...
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
You can also use `else` and `else if` for alternative branches:
|
|
178
|
-
|
|
179
|
-
```deva
|
|
180
|
-
if myCondition:
|
|
181
|
-
# ...
|
|
182
|
-
else if anotherCondition:
|
|
183
|
-
# ...
|
|
184
|
-
else:
|
|
185
|
-
# ...
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
### Calling Groups (Sequential Execution)
|
|
189
|
-
|
|
190
|
-
Groups can be called using the `call` keyword, which executes only the group in sequence.
|
|
191
|
-
|
|
192
|
-
> ⚠️ `call` only works on `group` declarations. It does not apply to other statements.
|
|
193
|
-
|
|
194
|
-
This executes the entire group in the current execution thread, following a sequential order.
|
|
195
|
-
|
|
196
|
-
```deva
|
|
197
|
-
call myGroup
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
### Spawning Groups (Parallel Execution)
|
|
201
|
-
|
|
202
|
-
Groups can be spawned using the `spawn` keyword, which executes only the group in parallel.
|
|
203
|
-
|
|
204
|
-
> ⚠️ spawn also only works on group declarations. It does not make the group’s content parallel unless it explicitly uses spawn inside.
|
|
205
|
-
|
|
206
|
-
This runs the entire group in a separate execution thread, allowing it to play alongside other actions.
|
|
207
|
-
|
|
208
|
-
```deva
|
|
209
|
-
spawn myGroup
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
### Synthesizers
|
|
213
|
-
|
|
214
|
-
Synthesizers are defined using the `synth` keyword, followed by the synthesizer type. You can create a synthesizer instance and use it to play notes.
|
|
215
|
-
|
|
216
|
-
```deva
|
|
217
|
-
let mySynth = synth sine
|
|
218
|
-
|
|
219
|
-
mySynth -> note(C4, { duration: 400 })
|
|
220
|
-
mySynth -> note(G4, { duration: 400 })
|
|
221
|
-
mySynth -> note(E4, { duration: 600 })
|
|
222
|
-
mySynth -> note(A4, { duration: 400 })
|
|
223
|
-
mySynth -> note(F4, { duration: 800 })
|
|
224
|
-
mySynth -> note(D4, { duration: 400 })
|
|
225
|
-
mySynth -> note(B3, { duration: 600 })
|
|
226
|
-
|
|
227
|
-
# You can use call or spawn to execute the synthesizer actions in sequence or parallel.
|
|
228
|
-
|
|
229
|
-
call mySynth
|
|
230
|
-
```
|