@devaloop/devalang 0.0.1-alpha.10 → 0.0.1-alpha.11

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.
Files changed (51) hide show
  1. package/.devalang +9 -4
  2. package/Cargo.toml +54 -49
  3. package/README.md +59 -142
  4. package/docs/CHANGELOG.md +42 -1
  5. package/docs/ROADMAP.md +1 -1
  6. package/docs/TODO.md +1 -1
  7. package/examples/bank.deva +9 -0
  8. package/examples/duration.deva +9 -0
  9. package/examples/index.deva +0 -2
  10. package/out-tsc/bin/devalang.exe +0 -0
  11. package/package.json +1 -1
  12. package/project-version.json +3 -3
  13. package/rust/cli/bank.rs +455 -0
  14. package/rust/cli/build.rs +1 -1
  15. package/rust/cli/check.rs +1 -1
  16. package/rust/cli/driver.rs +280 -0
  17. package/rust/cli/install.rs +17 -0
  18. package/rust/cli/mod.rs +5 -200
  19. package/rust/cli/play.rs +1 -1
  20. package/rust/cli/update.rs +4 -0
  21. package/rust/common/cdn.rs +11 -0
  22. package/rust/common/mod.rs +1 -0
  23. package/rust/config/driver.rs +76 -0
  24. package/rust/config/loader.rs +98 -1
  25. package/rust/config/mod.rs +1 -15
  26. package/rust/core/audio/engine.rs +31 -3
  27. package/rust/core/audio/interpreter/arrow_call.rs +17 -4
  28. package/rust/core/audio/interpreter/trigger.rs +34 -1
  29. package/rust/core/audio/loader/trigger.rs +12 -0
  30. package/rust/core/lexer/handler/driver.rs +12 -1
  31. package/rust/core/lexer/handler/mod.rs +1 -0
  32. package/rust/core/lexer/handler/slash.rs +21 -0
  33. package/rust/core/lexer/token.rs +1 -0
  34. package/rust/core/parser/driver.rs +8 -0
  35. package/rust/core/parser/handler/arrow_call.rs +29 -4
  36. package/rust/core/parser/handler/dot.rs +103 -37
  37. package/rust/core/preprocessor/loader.rs +93 -14
  38. package/rust/core/preprocessor/resolver/driver.rs +5 -0
  39. package/rust/core/shared/bank.rs +21 -0
  40. package/rust/core/shared/duration.rs +1 -0
  41. package/rust/core/shared/mod.rs +2 -1
  42. package/rust/core/shared/value.rs +1 -0
  43. package/rust/installer/bank.rs +55 -0
  44. package/rust/installer/mod.rs +1 -0
  45. package/rust/lib.rs +1 -0
  46. package/rust/main.rs +62 -5
  47. package/rust/utils/installer.rs +56 -0
  48. package/rust/utils/mod.rs +2 -1
  49. package/docs/COMMANDS.md +0 -85
  50. package/docs/CONFIG.md +0 -30
  51. package/docs/SYNTAX.md +0 -230
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
- ```