@devaloop/devalang 0.1.2 โ 0.1.4
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/LICENSE +20 -20
- package/README.md +335 -251
- package/out-tsc/examples/basic-usage.js +17 -17
- package/package.json +1 -1
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Devaloop Labs
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Devaloop Labs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,251 +1,335 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
<img src="https://devalang.com/images/devalang-logo-min.png" alt="Devalang Logo" width="100" />
|
|
3
|
-
</div>
|
|
4
|
-
|
|
5
|
-

|
|
6
|
-

|
|
7
|
-

|
|
8
|
-
|
|
9
|
-

|
|
10
|
-

|
|
11
|
-

|
|
12
|
-
|
|
13
|
-

|
|
14
|
-

|
|
15
|
-

|
|
16
|
-
|
|
17
|
-

|
|
18
|
-

|
|
19
|
-
|
|
20
|
-
# ๐ฆ Devalang โ Write music with code
|
|
21
|
-
|
|
22
|
-
Devalang is a compact domain-specific language (DSL) for music makers
|
|
23
|
-
Compose loops, control samples, synthesize audio, and render your ideas โ all in clean, readable text
|
|
24
|
-
|
|
25
|
-
Whether you're prototyping a beat, building generative music
|
|
26
|
-
|
|
27
|
-
From studio sketches to live sets, Devalang puts musical ideas into motion
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
>
|
|
31
|
-
>
|
|
32
|
-
> **NEW**: [Devalang Playground V2.0 is now available](https://playground.devalang.com) โ Try it in your browser!
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
#
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
#
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
#
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
-
|
|
232
|
-
-
|
|
233
|
-
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="https://devalang.com/images/devalang-logo-min.png" alt="Devalang Logo" width="100" />
|
|
3
|
+
</div>
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
|
|
9
|
+

|
|
10
|
+

|
|
11
|
+

|
|
12
|
+
|
|
13
|
+

|
|
14
|
+

|
|
15
|
+

|
|
16
|
+
|
|
17
|
+

|
|
18
|
+

|
|
19
|
+
|
|
20
|
+
# ๐ฆ Devalang โ Write music with code
|
|
21
|
+
|
|
22
|
+
Devalang is a compact **domain-specific language** (DSL) for **music makers**, **sound designers**, and **creative coders**.
|
|
23
|
+
Compose loops, control samples, synthesize audio, and render your ideas โ all in clean, **readable text**.
|
|
24
|
+
|
|
25
|
+
Whether you're prototyping a beat, building **generative music**, or **performing live**, Devalang gives you rhythmic precision with the elegance of code.
|
|
26
|
+
|
|
27
|
+
**From studio sketches to live sets, Devalang puts musical ideas into motion.**
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
> **๐ v0.1.0+ - Complete Rewriting**
|
|
31
|
+
>
|
|
32
|
+
> **NEW**: [Devalang Playground V2.0 is now available](https://playground.devalang.com) โ Try it in your browser!
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
## ๐ Quick Access
|
|
36
|
+
|
|
37
|
+
### Websites & Resources
|
|
38
|
+
- [๐ Website](https://devalang.com) โ Project homepage
|
|
39
|
+
- [โถ๏ธ Playground](https://playground.devalang.com) โ Try Devalang in your browser
|
|
40
|
+
- [๐ Documentation](https://docs.devalang.com) โ Complete language reference
|
|
41
|
+
|
|
42
|
+
### Important files
|
|
43
|
+
- [๐ Changelog](./docs/CHANGELOG.md) โ Version history
|
|
44
|
+
- [๐ก Examples](./examples/)
|
|
45
|
+
|
|
46
|
+
### Common projects and tools
|
|
47
|
+
- [๐ฆ Devapack](https://github.com/devaloop-labs/devapack) โ Community-driven addons
|
|
48
|
+
- [๐งฉ VSCode Extension](https://marketplace.visualstudio.com/items?itemName=devaloop.devalang-vscode) โ Syntax highlighting & snippets
|
|
49
|
+
|
|
50
|
+
### Downloads
|
|
51
|
+
- [๐ Installers](https://devalang.com/download) โ For Windows, macOS, and Linux
|
|
52
|
+
- [๐ฆ npm](https://www.npmjs.com/package/@devaloop/devalang) โ Install via npm
|
|
53
|
+
- [๐ฆ cargo](https://crates.io/crates/devalang) โ Install via Cargo
|
|
54
|
+
|
|
55
|
+
## โก Quick Start
|
|
56
|
+
|
|
57
|
+
### Try in Your Browser
|
|
58
|
+
|
|
59
|
+
> **[Launch the Playground](https://playground.devalang.com) to try Devalang without installing anything.**
|
|
60
|
+
|
|
61
|
+
### Download the Installers (Recommended)
|
|
62
|
+
|
|
63
|
+
Visit the [Download page](https://devalang.com/download) to get the latest releases for Windows, macOS, and Linux.
|
|
64
|
+
|
|
65
|
+
### Install via npm (Node.js)
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
npm install -g @devaloop/devalang
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Install via Cargo (Rust)
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
cargo install devalang
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Create Your First Project
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# Initialize a new project
|
|
81
|
+
devalang init my-project
|
|
82
|
+
|
|
83
|
+
# Navigate to the project
|
|
84
|
+
cd my-project
|
|
85
|
+
|
|
86
|
+
# Check syntax
|
|
87
|
+
devalang check --entry examples/index.deva
|
|
88
|
+
|
|
89
|
+
# Build audio files
|
|
90
|
+
devalang build --path examples/index.deva --formats wav mid
|
|
91
|
+
|
|
92
|
+
# Play audio (live mode)
|
|
93
|
+
devalang play --live --input examples/index.deva
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## ๐ฆ (optional) Install addons
|
|
97
|
+
|
|
98
|
+
Devalang supports addons to extend functionalities. This allows you to easily add sound banks, effects, or other features.
|
|
99
|
+
|
|
100
|
+
> To create your own addon, please refer to the [Devapack documentation](https://github.com/devaloop-labs/devapack/tree/main/docs).
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# List available addons
|
|
104
|
+
devalang addon list
|
|
105
|
+
|
|
106
|
+
# Install an addon (format: <author>.<addon-name>)
|
|
107
|
+
devalang addon install devaloop.808
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
This will install the `devaloop.808` sound bank in your current working directory inside `.deva` folder.
|
|
111
|
+
|
|
112
|
+
**You can then use it in your Devalang scripts !**
|
|
113
|
+
|
|
114
|
+
## ๐ต Your First Devalang File
|
|
115
|
+
|
|
116
|
+
Create a file `hello.deva` or `index.deva` (if you do not specify `--input` argument, it defaults to `index.deva`).
|
|
117
|
+
|
|
118
|
+
#### Nomenclature for .deva files
|
|
119
|
+
|
|
120
|
+
- Devalang files use the `.deva` extension.
|
|
121
|
+
- Devalang engine is **indentation-sensitive** for blocks, similar to Python.
|
|
122
|
+
- Files are plain text and can be edited with **any text editor** (VSCode recommended).
|
|
123
|
+
- Ensure your text editor supports **UTF-8 encoding**.
|
|
124
|
+
- Devalang is **case-sensitive**, so be consistent with capitalization.
|
|
125
|
+
- Devalang reads files from **top to bottom**, so order matters.
|
|
126
|
+
- Devalang files typically start with global settings (e.g., `bpm`, `bank`), followed by definitions (`synth`, `pattern`, `group`), and finally execution commands (`spawn`, `play`).
|
|
127
|
+
- Devalang files can include comments using `#` or `//` for single-line comments.
|
|
128
|
+
- You can name your files anything, but `index.deva` is a common convention for the main entry file.
|
|
129
|
+
- You can organize your project with subfolders as needed. (use module system like `@import { var } from '<module_path>'` and `@export { var }`).
|
|
130
|
+
|
|
131
|
+
Refer to the [documentation](https://docs.devalang.com) for a complete syntax reference.
|
|
132
|
+
|
|
133
|
+
```deva
|
|
134
|
+
# Set the tempo
|
|
135
|
+
bpm 120
|
|
136
|
+
|
|
137
|
+
# Load a bank of sounds (make sure you have the bank installed)
|
|
138
|
+
bank devaloop.808 as drums
|
|
139
|
+
|
|
140
|
+
# Create a simple kick pattern
|
|
141
|
+
pattern kickPattern with drums.kick = "x--- x--- x--- x---"
|
|
142
|
+
|
|
143
|
+
# Define a synth and a melody
|
|
144
|
+
let mySynth = synth saw
|
|
145
|
+
|
|
146
|
+
# Define a melody using a group to organize notes
|
|
147
|
+
group myMelody:
|
|
148
|
+
|
|
149
|
+
mySynth -> note(C5)
|
|
150
|
+
-> duration(500) # 500ms
|
|
151
|
+
|
|
152
|
+
mySynth -> note(E5)
|
|
153
|
+
-> duration(1/4) # Quarter note
|
|
154
|
+
|
|
155
|
+
mySynth -> note(G5)
|
|
156
|
+
-> duration(1/16) # Sixteenth note
|
|
157
|
+
-> velocity(0.8) # Velocity (0.0 to 1.0) or 0-127
|
|
158
|
+
-> lpf(800) # Lowpass filter at 800Hz
|
|
159
|
+
-> reverb({ size: 0.3 }) # Reverb effect
|
|
160
|
+
|
|
161
|
+
# Play the melody (in parallel)
|
|
162
|
+
spawn myMelody
|
|
163
|
+
|
|
164
|
+
# Play the kick pattern (in parallel too)
|
|
165
|
+
spawn kickPattern
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### (optional) Configure project settings
|
|
169
|
+
|
|
170
|
+
You can create a `devalang.json` (recommended) or `devalang.toml` or even `.devalang` (legacy) file to customize check/build/play settings.
|
|
171
|
+
|
|
172
|
+
This typically evitate to re-type common arguments like `--path`, `--formats`, etc.
|
|
173
|
+
|
|
174
|
+
> Comments are not supported in config files, please use `devalang init` to generate a default config.
|
|
175
|
+
|
|
176
|
+
```jsonc
|
|
177
|
+
{
|
|
178
|
+
"project": {
|
|
179
|
+
"name": "My Awesome Project" // Change this to adjust project name
|
|
180
|
+
},
|
|
181
|
+
"paths": {
|
|
182
|
+
"entry": "audio/helloWorld.deva", // Change this to adjust entry file path
|
|
183
|
+
"output": "output" // Change this to adjust output directory
|
|
184
|
+
},
|
|
185
|
+
"audio": {
|
|
186
|
+
"format": ["wav", "mid"], // Change this to adjust output formats (options: wav, mid, mp3)
|
|
187
|
+
"bit_depth": 16, // Change this to 24 or 32 for higher quality
|
|
188
|
+
"channels": 2, // Change this to 1 for mono output
|
|
189
|
+
"sample_rate": 44100, // Change this to 48000 for higher quality
|
|
190
|
+
"resample_quality": "sinc24", // Change this to adjust resampling quality (options: sinc8, sinc16, sinc24, sinc32)
|
|
191
|
+
"bpm": 120 // Change this to adjust the project tempo (only if not set in code)
|
|
192
|
+
},
|
|
193
|
+
"live": {
|
|
194
|
+
"crossfade_ms": 500 // Change this to adjust crossfade duration when playing live
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Build the audio
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
# Build to WAV, MP3, and MIDI
|
|
204
|
+
devalang build --path hello.deva --formats wav,mp3,mid
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Play the audio
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
# Play the audio file
|
|
211
|
+
devalang play --input hello.deva
|
|
212
|
+
|
|
213
|
+
# Play live (repeats and watch until stopped)
|
|
214
|
+
devalang play --live --input hello.deva
|
|
215
|
+
|
|
216
|
+
# Play live loop with very short crossfade
|
|
217
|
+
# With 50ms, transitions between loops are no more distinguishable
|
|
218
|
+
devalang play --live --crossfade-ms 50 --input hello.deva
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## ๐ Features
|
|
222
|
+
|
|
223
|
+
### ๐ต **Core Language**
|
|
224
|
+
- โ
**Lexer & Parser** โ Complete tokenization and AST generation
|
|
225
|
+
- โ
**Patterns** โ Rhythmic notation with swing, humanize, velocity
|
|
226
|
+
- โ
**Synths** โ Built-in synthesizers with ADSR envelopes
|
|
227
|
+
- โ
**Filters** โ Lowpass, highpass, bandpass audio filtering
|
|
228
|
+
- โ
**Effects** โ Reverb, delay, distortion, drive, chorus
|
|
229
|
+
- โ
**Variables** โ `let`, `const`, `var` with scoping
|
|
230
|
+
- โ
**Groups & Spawn** โ Organize and parallelize execution
|
|
231
|
+
- โ
**Loops & Conditions** โ `for`, `if`, `else` control flow
|
|
232
|
+
- โ
**Triggers** โ Conditional audio triggering
|
|
233
|
+
- โ
**Events** โ Event system with `on` and `emit`
|
|
234
|
+
|
|
235
|
+
### ๐ ๏ธ **CLI Tools**
|
|
236
|
+
- โ
`devalang init` โ Scaffold new projects (3 templates)
|
|
237
|
+
- โ
`devalang build` โ Compile to WAV/MIDI
|
|
238
|
+
- โ
`devalang check` โ Validate syntax
|
|
239
|
+
- โ
`devalang play` โ Audio playback
|
|
240
|
+
- โ
`devalang addon` โ Manage addons (install, list, discover)
|
|
241
|
+
- โ
`devalang login/logout` โ Authentication
|
|
242
|
+
- โ
`devalang telemetry` โ Privacy controls
|
|
243
|
+
|
|
244
|
+
### ๐ **WASM API**
|
|
245
|
+
- โ
`render_audio()` โ Browser audio rendering
|
|
246
|
+
- โ
`render_midi_array()` โ MIDI export
|
|
247
|
+
- โ
`debug_render()` โ Debug information
|
|
248
|
+
- โ
`parse()` โ Parse Devalang code
|
|
249
|
+
- โ
TypeScript types included
|
|
250
|
+
|
|
251
|
+
### ๐ฆ **Output Formats**
|
|
252
|
+
- โ
**WAV** โ 16/24/32-bit audio export
|
|
253
|
+
- โ
**MIDI** โ Standard MIDI file export
|
|
254
|
+
- โ
**MP3** โ Lossy audio export (via LAME)
|
|
255
|
+
|
|
256
|
+
### ๐ฏ **Performance**
|
|
257
|
+
- โก **Fast builds** โ 7-10ms for typical projects
|
|
258
|
+
- โก **Low latency** โ Optimized audio engine
|
|
259
|
+
- โก **Release builds** โ 5-6x faster than debug
|
|
260
|
+
|
|
261
|
+
### ๐ **Learning Resources**
|
|
262
|
+
- โ
**Online Docs** โ Complete language reference
|
|
263
|
+
- โ
**VSCode Extension** โ Syntax highlighting
|
|
264
|
+
|
|
265
|
+
## ๐ก Why Devalang?
|
|
266
|
+
|
|
267
|
+
- ๐น **Prototype audio ideas** without opening a DAW
|
|
268
|
+
- ๐ป **Integrate sound** into code-based workflows
|
|
269
|
+
- ๐๏ธ **Control audio parameters** with readable syntax
|
|
270
|
+
- ๐งช **Build musical logic** with variables and conditions
|
|
271
|
+
- ๐ **Create patterns** with expressive notation
|
|
272
|
+
- ๐จ **Live code** with fast iteration cycles
|
|
273
|
+
- ๐ฆ **Version control** your music with git
|
|
274
|
+
|
|
275
|
+
## ๐ Documentation
|
|
276
|
+
|
|
277
|
+
Visit **[docs.devalang.com](https://docs.devalang.com)** for:
|
|
278
|
+
- Complete syntax reference
|
|
279
|
+
- API documentation
|
|
280
|
+
- WASM integration guide
|
|
281
|
+
- CLI command reference
|
|
282
|
+
- Advanced tutorials
|
|
283
|
+
- Best practices
|
|
284
|
+
|
|
285
|
+
## ๐ง Development
|
|
286
|
+
|
|
287
|
+
### Build from Source
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
# Clone the repository
|
|
291
|
+
git clone https://github.com/devaloop-labs/devalang.git
|
|
292
|
+
cd devalang
|
|
293
|
+
|
|
294
|
+
# NPM (TypeScript) and Cargo (Rust) are required
|
|
295
|
+
npm install
|
|
296
|
+
|
|
297
|
+
# Build CLI (Rust)
|
|
298
|
+
cargo build
|
|
299
|
+
|
|
300
|
+
# Build WASM (Web & Node.js)
|
|
301
|
+
npm run rust:wasm:all
|
|
302
|
+
|
|
303
|
+
# Build TypeScript
|
|
304
|
+
npm run ts:build
|
|
305
|
+
|
|
306
|
+
# Run tests
|
|
307
|
+
cargo test --features cli
|
|
308
|
+
npm test
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
## ๐ค Contributing
|
|
312
|
+
|
|
313
|
+
We welcome contributions! See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.
|
|
314
|
+
|
|
315
|
+
### Ways to Contribute
|
|
316
|
+
|
|
317
|
+
- ๐ **Report bugs** via [GitHub Issues](https://github.com/devaloop-labs/devalang/issues)
|
|
318
|
+
- ๐ก **Suggest features** in discussions
|
|
319
|
+
- ๐ **Improve docs** with pull requests
|
|
320
|
+
- ๐ต **Share examples** of your creations
|
|
321
|
+
- ๐งช **Write tests** for new features
|
|
322
|
+
|
|
323
|
+
## ๐ License
|
|
324
|
+
|
|
325
|
+
MIT License โ See [LICENSE](./LICENSE) for details.
|
|
326
|
+
|
|
327
|
+
Copyright (c) 2025 Devaloop
|
|
328
|
+
|
|
329
|
+
---
|
|
330
|
+
|
|
331
|
+
<div align="center">
|
|
332
|
+
<strong>Made with โค๏ธ by <a href="https://labscend.studio">Labscend Studios</a></strong>
|
|
333
|
+
<br />
|
|
334
|
+
<sub>Star โญ the repo if you like it !</sub>
|
|
335
|
+
</div>
|
|
@@ -44,10 +44,10 @@ async function main() {
|
|
|
44
44
|
console.log('๐ต Devalang TypeScript API Example\n');
|
|
45
45
|
// 1. Parse Devalang code
|
|
46
46
|
console.log('1๏ธโฃ Parsing code...');
|
|
47
|
-
const parseResult = await devalang.parse('example.deva', `
|
|
48
|
-
bpm 120
|
|
49
|
-
let s = synth sine {}
|
|
50
|
-
s -> note(C4, { duration: 500 })
|
|
47
|
+
const parseResult = await devalang.parse('example.deva', `
|
|
48
|
+
bpm 120
|
|
49
|
+
let s = synth sine {}
|
|
50
|
+
s -> note(C4, { duration: 500 })
|
|
51
51
|
`);
|
|
52
52
|
if (parseResult.success) {
|
|
53
53
|
console.log(`โ
Parsed ${parseResult.statements.length} statements\n`);
|
|
@@ -58,13 +58,13 @@ async function main() {
|
|
|
58
58
|
}
|
|
59
59
|
// 2. Render audio
|
|
60
60
|
console.log('2๏ธโฃ Rendering audio...');
|
|
61
|
-
const audioCode = `
|
|
62
|
-
bpm 120
|
|
63
|
-
let mySynth = synth sine {
|
|
64
|
-
attack: 0.01,
|
|
65
|
-
release: 0.3
|
|
66
|
-
}
|
|
67
|
-
mySynth -> note(A4, { duration: 1000, velocity: 80 })
|
|
61
|
+
const audioCode = `
|
|
62
|
+
bpm 120
|
|
63
|
+
let mySynth = synth sine {
|
|
64
|
+
attack: 0.01,
|
|
65
|
+
release: 0.3
|
|
66
|
+
}
|
|
67
|
+
mySynth -> note(A4, { duration: 1000, velocity: 80 })
|
|
68
68
|
`;
|
|
69
69
|
const audioBuffer = await devalang.renderAudio(audioCode, {
|
|
70
70
|
sampleRate: 44100,
|
|
@@ -81,12 +81,12 @@ async function main() {
|
|
|
81
81
|
console.log(` - BPM: ${debugResult.bpm}\n`);
|
|
82
82
|
// 4. Export MIDI
|
|
83
83
|
console.log('4๏ธโฃ Exporting MIDI...');
|
|
84
|
-
const midiCode = `
|
|
85
|
-
bpm 140
|
|
86
|
-
let piano = synth sine {}
|
|
87
|
-
piano -> note(C4, { duration: 500 })
|
|
88
|
-
piano -> note(E4, { duration: 500 })
|
|
89
|
-
piano -> note(G4, { duration: 1000 })
|
|
84
|
+
const midiCode = `
|
|
85
|
+
bpm 140
|
|
86
|
+
let piano = synth sine {}
|
|
87
|
+
piano -> note(C4, { duration: 500 })
|
|
88
|
+
piano -> note(E4, { duration: 500 })
|
|
89
|
+
piano -> note(G4, { duration: 1000 })
|
|
90
90
|
`;
|
|
91
91
|
const midiBytes = await devalang.renderMidi(midiCode, {
|
|
92
92
|
bpm: 140
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devaloop/devalang",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.4",
|
|
5
5
|
"description": "Write music like code. Devalang is a domain-specific language (DSL) for sound designers and music hackers. Compose, automate, and control sound โ in plain text.",
|
|
6
6
|
"main": "out-tsc/index.js",
|
|
7
7
|
"types": "./out-tsc/index.d.ts",
|