@devaloop/devalang 0.0.1-beta.3 → 0.1.1
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/README.md +182 -152
- package/out-tsc/api.d.ts +180 -0
- package/out-tsc/api.d.ts.map +1 -0
- package/out-tsc/api.js +286 -0
- package/out-tsc/api.js.map +1 -0
- package/out-tsc/bin/index.d.ts +12 -0
- package/out-tsc/bin/index.d.ts.map +1 -0
- package/out-tsc/bin/index.js +20 -54
- package/out-tsc/bin/index.js.map +1 -0
- package/out-tsc/examples/basic-usage.d.ts +8 -0
- package/out-tsc/examples/basic-usage.d.ts.map +1 -0
- package/out-tsc/examples/basic-usage.js +113 -0
- package/out-tsc/examples/basic-usage.js.map +1 -0
- package/out-tsc/index.d.ts +19 -5
- package/out-tsc/index.d.ts.map +1 -0
- package/out-tsc/index.js +24 -6
- package/out-tsc/index.js.map +1 -0
- package/out-tsc/scripts/copy-wasm-dts.d.ts +7 -0
- package/out-tsc/scripts/copy-wasm-dts.d.ts.map +1 -0
- package/out-tsc/scripts/copy-wasm-dts.js +36 -32
- package/out-tsc/scripts/copy-wasm-dts.js.map +1 -0
- package/out-tsc/scripts/postinstall.d.ts +1 -0
- package/out-tsc/scripts/postinstall.d.ts.map +1 -0
- package/out-tsc/scripts/postinstall.js +4 -1
- package/out-tsc/scripts/postinstall.js.map +1 -0
- package/out-tsc/scripts/version/bump.d.ts +5 -1
- package/out-tsc/scripts/version/bump.d.ts.map +1 -0
- package/out-tsc/scripts/version/bump.js +114 -44
- package/out-tsc/scripts/version/bump.js.map +1 -0
- package/out-tsc/scripts/version/fetch.d.ts +12 -1
- package/out-tsc/scripts/version/fetch.d.ts.map +1 -0
- package/out-tsc/scripts/version/fetch.js +68 -24
- package/out-tsc/scripts/version/fetch.js.map +1 -0
- package/out-tsc/scripts/version/index.d.ts +6 -0
- package/out-tsc/scripts/version/index.d.ts.map +1 -0
- package/out-tsc/scripts/version/index.js +44 -22
- package/out-tsc/scripts/version/index.js.map +1 -0
- package/out-tsc/scripts/version/sync.d.ts +5 -1
- package/out-tsc/scripts/version/sync.d.ts.map +1 -0
- package/out-tsc/scripts/version/sync.js +78 -29
- package/out-tsc/scripts/version/sync.js.map +1 -0
- package/out-tsc/types.d.ts +68 -0
- package/out-tsc/types.d.ts.map +1 -0
- package/out-tsc/{core/types/value.js → types.js} +4 -0
- package/out-tsc/types.js.map +1 -0
- package/out-tsc/wasm.d.ts +8 -0
- package/out-tsc/wasm.d.ts.map +1 -0
- package/out-tsc/{core/index.js → wasm.js} +9 -6
- package/out-tsc/wasm.js.map +1 -0
- package/package.json +42 -42
- package/.cargo/config.toml +0 -2
- package/.devalang +0 -9
- package/.github/workflows/ci.yml +0 -103
- package/Cargo.toml +0 -84
- package/docs/CHANGELOG.md +0 -622
- package/docs/CONTRIBUTING.md +0 -101
- package/docs/ROADMAP.md +0 -38
- package/docs/TODO.md +0 -71
- package/examples/automation.deva +0 -42
- package/examples/bank.deva +0 -7
- package/examples/bus.deva +0 -10
- package/examples/chain.deva +0 -19
- package/examples/condition.deva +0 -20
- package/examples/duration.deva +0 -9
- package/examples/effect.deva +0 -2
- package/examples/events.deva +0 -12
- package/examples/filter.deva +0 -11
- package/examples/function.deva +0 -15
- package/examples/group.deva +0 -12
- package/examples/index.deva +0 -63
- package/examples/lfo.deva +0 -9
- package/examples/loop.deva +0 -10
- package/examples/pattern.deva +0 -8
- package/examples/plugin.deva +0 -16
- package/examples/routing.deva +0 -23
- package/examples/samples/hat-808.wav +0 -0
- package/examples/samples/kick-808.wav +0 -0
- package/examples/synth.deva +0 -24
- package/examples/synth_types.deva +0 -17
- package/examples/variables.deva +0 -9
- package/out-tsc/bin/project-version.json +0 -6
- package/out-tsc/core/functions/index.d.ts +0 -42
- package/out-tsc/core/functions/index.js +0 -87
- package/out-tsc/core/index.d.ts +0 -6
- package/out-tsc/core/types/index.d.ts +0 -4
- package/out-tsc/core/types/index.js +0 -20
- package/out-tsc/core/types/plugin.d.ts +0 -18
- package/out-tsc/core/types/plugin.js +0 -2
- package/out-tsc/core/types/result.d.ts +0 -27
- package/out-tsc/core/types/result.js +0 -2
- package/out-tsc/core/types/statement.d.ts +0 -106
- package/out-tsc/core/types/statement.js +0 -2
- package/out-tsc/core/types/value.d.ts +0 -43
- package/out-tsc/pkg/devalang_core.d.ts +0 -15
- package/out-tsc/pkg/devalang_core.js +0 -65
- package/out-tsc/pkg/devalang_core_bg.wasm.d.ts +0 -34
- package/out-tsc/scripts/version/copy-to-binary.d.ts +0 -1
- package/out-tsc/scripts/version/copy-to-binary.js +0 -79
- package/project-version.json +0 -6
- package/rust/bindings/Cargo.toml +0 -9
- package/rust/bindings/src/lib.rs +0 -86
- package/rust/cli/addon/commands.rs +0 -35
- package/rust/cli/addon/download.rs +0 -234
- package/rust/cli/addon/install.rs +0 -33
- package/rust/cli/addon/list.rs +0 -224
- package/rust/cli/addon/metadata.rs +0 -124
- package/rust/cli/addon/mod.rs +0 -8
- package/rust/cli/addon/remove.rs +0 -271
- package/rust/cli/addon/update.rs +0 -305
- package/rust/cli/addon/utils.rs +0 -109
- package/rust/cli/build/commands.rs +0 -153
- package/rust/cli/build/mod.rs +0 -2
- package/rust/cli/build/process.rs +0 -165
- package/rust/cli/check/mod.rs +0 -208
- package/rust/cli/discover/commands.rs +0 -275
- package/rust/cli/discover/config.rs +0 -109
- package/rust/cli/discover/fs.rs +0 -19
- package/rust/cli/discover/install.rs +0 -214
- package/rust/cli/discover/metadata.rs +0 -48
- package/rust/cli/discover/mod.rs +0 -5
- package/rust/cli/init/commands.rs +0 -88
- package/rust/cli/init/mod.rs +0 -1
- package/rust/cli/login/commands.rs +0 -124
- package/rust/cli/login/mod.rs +0 -1
- package/rust/cli/me/commands.rs +0 -52
- package/rust/cli/me/mod.rs +0 -1
- package/rust/cli/mod.rs +0 -12
- package/rust/cli/parser.rs +0 -320
- package/rust/cli/play/commands.rs +0 -375
- package/rust/cli/play/io.rs +0 -17
- package/rust/cli/play/mod.rs +0 -5
- package/rust/cli/play/process.rs +0 -159
- package/rust/cli/play/realtime.rs +0 -91
- package/rust/cli/play/utils.rs +0 -23
- package/rust/cli/telemetry/commands.rs +0 -22
- package/rust/cli/telemetry/event_creator.rs +0 -80
- package/rust/cli/telemetry/mod.rs +0 -3
- package/rust/cli/telemetry/send.rs +0 -51
- package/rust/cli/template/commands.rs +0 -69
- package/rust/cli/template/mod.rs +0 -1
- package/rust/cli/update/commands.rs +0 -6
- package/rust/cli/update/mod.rs +0 -1
- package/rust/config/driver.rs +0 -112
- package/rust/config/mod.rs +0 -3
- package/rust/config/ops.rs +0 -26
- package/rust/config/settings.rs +0 -101
- package/rust/core/audio/engine/driver.rs +0 -237
- package/rust/core/audio/engine/export.rs +0 -169
- package/rust/core/audio/engine/helpers.rs +0 -178
- package/rust/core/audio/engine/mod.rs +0 -56
- package/rust/core/audio/engine/notes/dsp.rs +0 -88
- package/rust/core/audio/engine/notes/mod.rs +0 -53
- package/rust/core/audio/engine/notes/params.rs +0 -294
- package/rust/core/audio/engine/sample/insert.rs +0 -300
- package/rust/core/audio/engine/sample/mod.rs +0 -40
- package/rust/core/audio/engine/sample/padding.rs +0 -170
- package/rust/core/audio/evaluator/condition.rs +0 -61
- package/rust/core/audio/evaluator/mod.rs +0 -9
- package/rust/core/audio/evaluator/numeric.rs +0 -152
- package/rust/core/audio/evaluator/rhs.rs +0 -16
- package/rust/core/audio/evaluator/string_expr.rs +0 -94
- package/rust/core/audio/interpreter/driver.rs +0 -574
- package/rust/core/audio/interpreter/mod.rs +0 -2
- package/rust/core/audio/interpreter/statements/arrow_call/interprete.rs +0 -179
- package/rust/core/audio/interpreter/statements/arrow_call/methods/chord.rs +0 -398
- package/rust/core/audio/interpreter/statements/arrow_call/methods/effects.rs +0 -323
- package/rust/core/audio/interpreter/statements/arrow_call/methods/mod.rs +0 -3
- package/rust/core/audio/interpreter/statements/arrow_call/methods/note.rs +0 -371
- package/rust/core/audio/interpreter/statements/arrow_call/mod.rs +0 -3
- package/rust/core/audio/interpreter/statements/arrow_call/types/arp.rs +0 -192
- package/rust/core/audio/interpreter/statements/arrow_call/types/mod.rs +0 -24
- package/rust/core/audio/interpreter/statements/arrow_call/types/pad.rs +0 -116
- package/rust/core/audio/interpreter/statements/arrow_call/types/pluck.rs +0 -97
- package/rust/core/audio/interpreter/statements/arrow_call/types/sub.rs +0 -100
- package/rust/core/audio/interpreter/statements/automate.rs +0 -16
- package/rust/core/audio/interpreter/statements/call.rs +0 -325
- package/rust/core/audio/interpreter/statements/condition.rs +0 -72
- package/rust/core/audio/interpreter/statements/function.rs +0 -24
- package/rust/core/audio/interpreter/statements/let_.rs +0 -36
- package/rust/core/audio/interpreter/statements/load.rs +0 -17
- package/rust/core/audio/interpreter/statements/loop_.rs +0 -115
- package/rust/core/audio/interpreter/statements/mod.rs +0 -12
- package/rust/core/audio/interpreter/statements/sleep.rs +0 -28
- package/rust/core/audio/interpreter/statements/spawn.rs +0 -302
- package/rust/core/audio/interpreter/statements/tempo.rs +0 -40
- package/rust/core/audio/interpreter/statements/trigger.rs +0 -242
- package/rust/core/audio/loader/mod.rs +0 -1
- package/rust/core/audio/loader/trigger.rs +0 -98
- package/rust/core/audio/mod.rs +0 -6
- package/rust/core/audio/player.rs +0 -70
- package/rust/core/audio/special/easing.rs +0 -189
- package/rust/core/audio/special/env.rs +0 -45
- package/rust/core/audio/special/math.rs +0 -134
- package/rust/core/audio/special/mod.rs +0 -9
- package/rust/core/audio/special/modulator.rs +0 -143
- package/rust/core/builder/mod.rs +0 -129
- package/rust/core/debugger/lexer.rs +0 -27
- package/rust/core/debugger/logs.rs +0 -52
- package/rust/core/debugger/mod.rs +0 -30
- package/rust/core/debugger/preprocessor.rs +0 -27
- package/rust/core/debugger/store.rs +0 -38
- package/rust/core/error/mod.rs +0 -269
- package/rust/core/lexer/driver.rs +0 -59
- package/rust/core/lexer/handler/arrow.rs +0 -82
- package/rust/core/lexer/handler/at.rs +0 -21
- package/rust/core/lexer/handler/brace.rs +0 -41
- package/rust/core/lexer/handler/colon.rs +0 -21
- package/rust/core/lexer/handler/comment.rs +0 -30
- package/rust/core/lexer/handler/dot.rs +0 -21
- package/rust/core/lexer/handler/driver.rs +0 -337
- package/rust/core/lexer/handler/identifier.rs +0 -47
- package/rust/core/lexer/handler/indent.rs +0 -66
- package/rust/core/lexer/handler/mod.rs +0 -15
- package/rust/core/lexer/handler/newline.rs +0 -23
- package/rust/core/lexer/handler/number.rs +0 -31
- package/rust/core/lexer/handler/operator.rs +0 -46
- package/rust/core/lexer/handler/parenthesis.rs +0 -41
- package/rust/core/lexer/handler/slash.rs +0 -21
- package/rust/core/lexer/handler/string.rs +0 -63
- package/rust/core/lexer/mod.rs +0 -3
- package/rust/core/lexer/token.rs +0 -91
- package/rust/core/mod.rs +0 -9
- package/rust/core/parser/driver/block.rs +0 -111
- package/rust/core/parser/driver/cursor.rs +0 -82
- package/rust/core/parser/driver/driver_impl.rs +0 -159
- package/rust/core/parser/driver/mod.rs +0 -6
- package/rust/core/parser/driver/parse_array.rs +0 -120
- package/rust/core/parser/driver/parse_map.rs +0 -247
- package/rust/core/parser/driver/parser.rs +0 -160
- package/rust/core/parser/handler/arrow_call.rs +0 -328
- package/rust/core/parser/handler/at.rs +0 -279
- package/rust/core/parser/handler/bank.rs +0 -104
- package/rust/core/parser/handler/condition.rs +0 -83
- package/rust/core/parser/handler/dot.rs +0 -148
- package/rust/core/parser/handler/identifier/automate.rs +0 -254
- package/rust/core/parser/handler/identifier/call.rs +0 -91
- package/rust/core/parser/handler/identifier/emit.rs +0 -70
- package/rust/core/parser/handler/identifier/function.rs +0 -113
- package/rust/core/parser/handler/identifier/group.rs +0 -89
- package/rust/core/parser/handler/identifier/let_.rs +0 -173
- package/rust/core/parser/handler/identifier/mod.rs +0 -55
- package/rust/core/parser/handler/identifier/on.rs +0 -107
- package/rust/core/parser/handler/identifier/print.rs +0 -49
- package/rust/core/parser/handler/identifier/sleep.rs +0 -96
- package/rust/core/parser/handler/identifier/spawn.rs +0 -91
- package/rust/core/parser/handler/identifier/synth.rs +0 -171
- package/rust/core/parser/handler/loop_.rs +0 -194
- package/rust/core/parser/handler/mod.rs +0 -9
- package/rust/core/parser/handler/pattern.rs +0 -97
- package/rust/core/parser/handler/tempo.rs +0 -105
- package/rust/core/parser/mod.rs +0 -3
- package/rust/core/parser/statement.rs +0 -10
- package/rust/core/plugin/loader.rs +0 -137
- package/rust/core/plugin/mod.rs +0 -2
- package/rust/core/plugin/runner/mod.rs +0 -11
- package/rust/core/plugin/runner/non_wasm.rs +0 -481
- package/rust/core/plugin/runner/wasm32.rs +0 -44
- package/rust/core/preprocessor/loader/inject.rs +0 -313
- package/rust/core/preprocessor/loader/loader_helpers.rs +0 -110
- package/rust/core/preprocessor/loader/mod.rs +0 -235
- package/rust/core/preprocessor/mod.rs +0 -4
- package/rust/core/preprocessor/module.rs +0 -55
- package/rust/core/preprocessor/processor/handlers.rs +0 -107
- package/rust/core/preprocessor/processor/mod.rs +0 -1
- package/rust/core/preprocessor/resolver/bank.rs +0 -49
- package/rust/core/preprocessor/resolver/call.rs +0 -124
- package/rust/core/preprocessor/resolver/condition.rs +0 -95
- package/rust/core/preprocessor/resolver/driver.rs +0 -324
- package/rust/core/preprocessor/resolver/function.rs +0 -69
- package/rust/core/preprocessor/resolver/group.rs +0 -122
- package/rust/core/preprocessor/resolver/let_.rs +0 -32
- package/rust/core/preprocessor/resolver/loop_.rs +0 -318
- package/rust/core/preprocessor/resolver/mod.rs +0 -16
- package/rust/core/preprocessor/resolver/pattern.rs +0 -95
- package/rust/core/preprocessor/resolver/spawn.rs +0 -99
- package/rust/core/preprocessor/resolver/synth.rs +0 -54
- package/rust/core/preprocessor/resolver/tempo.rs +0 -48
- package/rust/core/preprocessor/resolver/trigger.rs +0 -116
- package/rust/core/preprocessor/resolver/value.rs +0 -176
- package/rust/core/store/global.rs +0 -57
- package/rust/core/store/mod.rs +0 -1
- package/rust/lib.rs +0 -323
- package/rust/macros/Cargo.toml +0 -14
- package/rust/macros/src/lib.rs +0 -52
- package/rust/main.rs +0 -557
- package/rust/types/Cargo.toml +0 -11
- package/rust/types/src/addons.rs +0 -57
- package/rust/types/src/ast.rs +0 -202
- package/rust/types/src/config.rs +0 -82
- package/rust/types/src/lib.rs +0 -15
- package/rust/types/src/plugin.rs +0 -20
- package/rust/types/src/store.rs +0 -139
- package/rust/types/src/telemetry.rs +0 -85
- package/rust/utils/Cargo.toml +0 -29
- package/rust/utils/src/error.rs +0 -186
- package/rust/utils/src/file.rs +0 -477
- package/rust/utils/src/first_usage.rs +0 -97
- package/rust/utils/src/lib.rs +0 -9
- package/rust/utils/src/logger.rs +0 -200
- package/rust/utils/src/path.rs +0 -158
- package/rust/utils/src/signature.rs +0 -41
- package/rust/utils/src/spinner.rs +0 -20
- package/rust/utils/src/version.rs +0 -58
- package/rust/utils/src/watcher.rs +0 -46
- package/rust/web/api.rs +0 -5
- package/rust/web/auth.rs +0 -5
- package/rust/web/cdn.rs +0 -34
- package/rust/web/forge.rs +0 -5
- package/rust/web/mod.rs +0 -5
- package/rust/web/sso.rs +0 -5
- package/templates/minimal/.devalang +0 -5
- package/templates/minimal/README.md +0 -218
- package/templates/minimal/src/index.deva +0 -2
- package/templates/welcome/.devalang +0 -5
- package/templates/welcome/README.md +0 -218
- package/templates/welcome/samples/kick-808.wav +0 -0
- package/templates/welcome/src/index.deva +0 -61
- package/templates/welcome/src/variables.deva +0 -3
- package/tests/integration.rs +0 -21
- package/tests/rust/cli_check_build.rs +0 -21
- package/tests/rust/cli_help.rs +0 -12
- package/tests/rust/cli_template_list.rs +0 -10
- package/tests/rust/cli_version.rs +0 -11
- package/tests/typescript/index.spec.ts +0 -136
- package/tests/typescript/playhead.spec.ts +0 -36
- package/tests/typescript/render_e2e.spec.ts +0 -77
- package/tsconfig.json +0 -115
- package/typescript/bin/index.ts +0 -28
- package/typescript/core/functions/index.ts +0 -94
- package/typescript/core/index.ts +0 -6
- package/typescript/core/types/index.ts +0 -4
- package/typescript/core/types/plugin.ts +0 -19
- package/typescript/core/types/result.ts +0 -29
- package/typescript/core/types/statement.ts +0 -47
- package/typescript/core/types/value.ts +0 -29
- package/typescript/index.ts +0 -8
- package/typescript/pkg/devalang_core.d.ts +0 -4
- package/typescript/pkg/devalang_core.ts +0 -65
- package/typescript/scripts/copy-wasm-dts.ts +0 -41
- package/typescript/scripts/postinstall.ts +0 -85
- package/typescript/scripts/version/bump.ts +0 -44
- package/typescript/scripts/version/copy-to-binary.ts +0 -82
- package/typescript/scripts/version/fetch.ts +0 -18
- package/typescript/scripts/version/index.ts +0 -25
- package/typescript/scripts/version/sync.ts +0 -24
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parse = parse;
|
|
4
|
-
exports.debug_render = debug_render;
|
|
5
|
-
exports.render_audio = render_audio;
|
|
6
|
-
exports.register_playhead_callback = register_playhead_callback;
|
|
7
|
-
exports.collect_playhead_events = collect_playhead_events;
|
|
8
|
-
exports.unregister_playhead_callback = unregister_playhead_callback;
|
|
9
|
-
let wasmPkg = undefined;
|
|
10
|
-
try {
|
|
11
|
-
// prefer runtime pkg generated by wasm-pack when available
|
|
12
|
-
// require at runtime so the package can be used even if wasm hasn't been built
|
|
13
|
-
// (this keeps tests and consumers robust).
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
15
|
-
wasmPkg = require("../../pkg/devalang_core");
|
|
16
|
-
}
|
|
17
|
-
catch (_e) {
|
|
18
|
-
wasmPkg = undefined;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Parses the user code.
|
|
22
|
-
* @param entry_path The entry path for the code.
|
|
23
|
-
* @param source The source code to parse.
|
|
24
|
-
* @returns ParseResult | any
|
|
25
|
-
*/
|
|
26
|
-
function parse(entry_path, source) {
|
|
27
|
-
if (wasmPkg && typeof wasmPkg.parse === "function") {
|
|
28
|
-
return wasmPkg.parse(entry_path, source);
|
|
29
|
-
}
|
|
30
|
-
throw new Error("WASM binding 'parse' not available. Build the wasm package or use the JS runtime.");
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Renders the debug information for the user code.
|
|
34
|
-
* @param user_code The user-provided code to render debug information for.
|
|
35
|
-
* @returns DebugResult | any
|
|
36
|
-
*/
|
|
37
|
-
function debug_render(user_code) {
|
|
38
|
-
if (wasmPkg && typeof wasmPkg.debug_render === "function") {
|
|
39
|
-
return wasmPkg.debug_render(user_code);
|
|
40
|
-
}
|
|
41
|
-
throw new Error("WASM binding 'debug_render' not available. Build the wasm package or use the JS runtime.");
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Renders audio from the user code.
|
|
45
|
-
* @param user_code The user-provided code to render audio from.
|
|
46
|
-
* @returns Float32Array
|
|
47
|
-
*/
|
|
48
|
-
function render_audio(user_code) {
|
|
49
|
-
if (wasmPkg && typeof wasmPkg.render_audio === "function") {
|
|
50
|
-
return wasmPkg.render_audio(user_code);
|
|
51
|
-
}
|
|
52
|
-
// Fallback: indicate missing wasm with an empty buffer rather than breaking consumers.
|
|
53
|
-
return new Float32Array(0);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Register a JS callback to receive playhead events { time, line, column } during playback.
|
|
57
|
-
* The callback will be called with a single object argument.
|
|
58
|
-
* @param cb The callback function to register.
|
|
59
|
-
* @returns void
|
|
60
|
-
*/
|
|
61
|
-
function register_playhead_callback(cb) {
|
|
62
|
-
if (wasmPkg && typeof wasmPkg.register_playhead_callback === "function") {
|
|
63
|
-
return wasmPkg.register_playhead_callback(cb);
|
|
64
|
-
}
|
|
65
|
-
// no-op fallback
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Collects playhead events that have been recorded during playback.
|
|
70
|
-
* @returns Array of playhead events { time, line, column }.
|
|
71
|
-
*/
|
|
72
|
-
function collect_playhead_events() {
|
|
73
|
-
if (wasmPkg && typeof wasmPkg.collect_playhead_events === "function") {
|
|
74
|
-
return wasmPkg.collect_playhead_events();
|
|
75
|
-
}
|
|
76
|
-
return [];
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Unregisters the JS callback for playhead events.
|
|
80
|
-
* @returns void
|
|
81
|
-
*/
|
|
82
|
-
function unregister_playhead_callback() {
|
|
83
|
-
if (wasmPkg && typeof wasmPkg.unregister_playhead_callback === "function") {
|
|
84
|
-
return wasmPkg.unregister_playhead_callback();
|
|
85
|
-
}
|
|
86
|
-
return;
|
|
87
|
-
}
|
package/out-tsc/core/index.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./result"), exports);
|
|
18
|
-
__exportStar(require("./statement"), exports);
|
|
19
|
-
__exportStar(require("./value"), exports);
|
|
20
|
-
__exportStar(require("./plugin"), exports);
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Represents a plugin export.
|
|
3
|
-
*/
|
|
4
|
-
export interface PluginExport {
|
|
5
|
-
name: string;
|
|
6
|
-
kind: string;
|
|
7
|
-
default?: any;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Represents a plugin.
|
|
11
|
-
*/
|
|
12
|
-
export interface PluginInfo {
|
|
13
|
-
author: string;
|
|
14
|
-
name: string;
|
|
15
|
-
version?: string;
|
|
16
|
-
description?: string;
|
|
17
|
-
exports: PluginExport[];
|
|
18
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Represents an error that occurred during parsing.
|
|
3
|
-
*/
|
|
4
|
-
export interface ErrorResult {
|
|
5
|
-
message: string;
|
|
6
|
-
line: number;
|
|
7
|
-
column: number;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Represents the result of parsing user code.
|
|
11
|
-
*/
|
|
12
|
-
export interface ParseResult {
|
|
13
|
-
ok: boolean;
|
|
14
|
-
ast: string;
|
|
15
|
-
errors: ErrorResult[];
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Represents the result of debugging user code.
|
|
19
|
-
*/
|
|
20
|
-
export interface DebugResult {
|
|
21
|
-
samples_len: number;
|
|
22
|
-
any_nonzero: boolean;
|
|
23
|
-
ast: string;
|
|
24
|
-
note_count: number;
|
|
25
|
-
global_vars: string[];
|
|
26
|
-
statements_count: number;
|
|
27
|
-
}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { Value, Duration } from "./value";
|
|
2
|
-
/**
|
|
3
|
-
* Represents a statement kind in the code.
|
|
4
|
-
*/
|
|
5
|
-
export type StatementKind = {
|
|
6
|
-
kind: "Tempo";
|
|
7
|
-
} | {
|
|
8
|
-
kind: "Bank";
|
|
9
|
-
alias?: string;
|
|
10
|
-
} | {
|
|
11
|
-
kind: "Print";
|
|
12
|
-
} | {
|
|
13
|
-
kind: "Load";
|
|
14
|
-
source: string;
|
|
15
|
-
alias: string;
|
|
16
|
-
} | {
|
|
17
|
-
kind: "Use";
|
|
18
|
-
name: string;
|
|
19
|
-
alias?: string;
|
|
20
|
-
} | {
|
|
21
|
-
kind: "Let";
|
|
22
|
-
name: string;
|
|
23
|
-
} | {
|
|
24
|
-
kind: "Automate";
|
|
25
|
-
target: string;
|
|
26
|
-
} | {
|
|
27
|
-
kind: "ArrowCall";
|
|
28
|
-
target: string;
|
|
29
|
-
method: string;
|
|
30
|
-
args: Value[];
|
|
31
|
-
} | {
|
|
32
|
-
kind: "Function";
|
|
33
|
-
name: string;
|
|
34
|
-
parameters: string[];
|
|
35
|
-
body: Statement[];
|
|
36
|
-
} | {
|
|
37
|
-
kind: "Synth";
|
|
38
|
-
} | {
|
|
39
|
-
kind: "Trigger";
|
|
40
|
-
entity: string;
|
|
41
|
-
duration: Duration;
|
|
42
|
-
effects?: Value;
|
|
43
|
-
} | {
|
|
44
|
-
kind: "Sleep";
|
|
45
|
-
} | {
|
|
46
|
-
kind: "Call";
|
|
47
|
-
name: string;
|
|
48
|
-
args: Value[];
|
|
49
|
-
} | {
|
|
50
|
-
kind: "Spawn";
|
|
51
|
-
name: string;
|
|
52
|
-
args: Value[];
|
|
53
|
-
} | {
|
|
54
|
-
kind: "Loop";
|
|
55
|
-
} | {
|
|
56
|
-
kind: "Group";
|
|
57
|
-
} | {
|
|
58
|
-
kind: "Include";
|
|
59
|
-
path: string;
|
|
60
|
-
} | {
|
|
61
|
-
kind: "Export";
|
|
62
|
-
names: string[];
|
|
63
|
-
source: string;
|
|
64
|
-
} | {
|
|
65
|
-
kind: "Import";
|
|
66
|
-
names: string[];
|
|
67
|
-
source: string;
|
|
68
|
-
} | {
|
|
69
|
-
kind: "If";
|
|
70
|
-
} | {
|
|
71
|
-
kind: "Else";
|
|
72
|
-
} | {
|
|
73
|
-
kind: "ElseIf";
|
|
74
|
-
} | {
|
|
75
|
-
kind: "Comment";
|
|
76
|
-
} | {
|
|
77
|
-
kind: "Indent";
|
|
78
|
-
} | {
|
|
79
|
-
kind: "Dedent";
|
|
80
|
-
} | {
|
|
81
|
-
kind: "NewLine";
|
|
82
|
-
} | {
|
|
83
|
-
kind: "On";
|
|
84
|
-
event: string;
|
|
85
|
-
args?: Value[];
|
|
86
|
-
body: Statement[];
|
|
87
|
-
} | {
|
|
88
|
-
kind: "Emit";
|
|
89
|
-
event: string;
|
|
90
|
-
payload?: Value;
|
|
91
|
-
} | {
|
|
92
|
-
kind: "Unknown";
|
|
93
|
-
} | {
|
|
94
|
-
kind: "Error";
|
|
95
|
-
message: string;
|
|
96
|
-
};
|
|
97
|
-
/**
|
|
98
|
-
* Represents a statement in the code.
|
|
99
|
-
*/
|
|
100
|
-
export interface Statement {
|
|
101
|
-
kind: StatementKind;
|
|
102
|
-
value: Value;
|
|
103
|
-
indent: number;
|
|
104
|
-
line: number;
|
|
105
|
-
column: number;
|
|
106
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Statement } from "./statement";
|
|
2
|
-
/**
|
|
3
|
-
* Represents a duration in the code.
|
|
4
|
-
*/
|
|
5
|
-
export type Duration = {
|
|
6
|
-
Number: number;
|
|
7
|
-
} | {
|
|
8
|
-
Identifier: string;
|
|
9
|
-
} | {
|
|
10
|
-
Beat: string;
|
|
11
|
-
} | {
|
|
12
|
-
Auto: null;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Represents a value in the code.
|
|
16
|
-
*/
|
|
17
|
-
export type Value = {
|
|
18
|
-
Boolean: boolean;
|
|
19
|
-
} | {
|
|
20
|
-
Number: number;
|
|
21
|
-
} | {
|
|
22
|
-
Duration: Duration;
|
|
23
|
-
} | {
|
|
24
|
-
Identifier: string;
|
|
25
|
-
} | {
|
|
26
|
-
String: string;
|
|
27
|
-
} | {
|
|
28
|
-
Array: Value[];
|
|
29
|
-
} | {
|
|
30
|
-
Map: Record<string, Value>;
|
|
31
|
-
} | {
|
|
32
|
-
Block: Statement[];
|
|
33
|
-
} | {
|
|
34
|
-
Sample: string;
|
|
35
|
-
} | {
|
|
36
|
-
Beat: string;
|
|
37
|
-
} | {
|
|
38
|
-
Statement: Statement;
|
|
39
|
-
} | {
|
|
40
|
-
StatementKind: any;
|
|
41
|
-
} | {
|
|
42
|
-
Unknown: null;
|
|
43
|
-
} | null;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare function parse(...args: any[]): any;
|
|
2
|
-
export declare function debug_render(...args: any[]): any;
|
|
3
|
-
export declare function render_audio(...args: any[]): any;
|
|
4
|
-
export declare function register_playhead_callback(cb?: any): any;
|
|
5
|
-
export declare function collect_playhead_events(): any;
|
|
6
|
-
export declare function unregister_playhead_callback(): any;
|
|
7
|
-
declare const pkg: {
|
|
8
|
-
parse: typeof parse;
|
|
9
|
-
debug_render: typeof debug_render;
|
|
10
|
-
render_audio: typeof render_audio;
|
|
11
|
-
register_playhead_callback: typeof register_playhead_callback;
|
|
12
|
-
collect_playhead_events: typeof collect_playhead_events;
|
|
13
|
-
unregister_playhead_callback: typeof unregister_playhead_callback;
|
|
14
|
-
};
|
|
15
|
-
export default pkg;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parse = parse;
|
|
4
|
-
exports.debug_render = debug_render;
|
|
5
|
-
exports.render_audio = render_audio;
|
|
6
|
-
exports.register_playhead_callback = register_playhead_callback;
|
|
7
|
-
exports.collect_playhead_events = collect_playhead_events;
|
|
8
|
-
exports.unregister_playhead_callback = unregister_playhead_callback;
|
|
9
|
-
/**
|
|
10
|
-
* Shim TypeScript source that re-exports the runtime wasm-pack package when
|
|
11
|
-
* available, or provides safe stubs when not present. Compiles to
|
|
12
|
-
* out-tsc/pkg/devalang_core.js so compiled code can require("./pkg/devalang_core").
|
|
13
|
-
*/
|
|
14
|
-
let runtimePkg;
|
|
15
|
-
try {
|
|
16
|
-
// prefer runtime pkg generated by wasm-pack when available
|
|
17
|
-
// require at runtime so the package can be used even if wasm hasn't been built
|
|
18
|
-
// (this keeps tests and consumers robust).
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
20
|
-
runtimePkg = require("../../pkg/devalang_core");
|
|
21
|
-
}
|
|
22
|
-
catch (e) {
|
|
23
|
-
runtimePkg = undefined;
|
|
24
|
-
}
|
|
25
|
-
function parse(...args) {
|
|
26
|
-
if (runtimePkg && typeof runtimePkg.parse === "function")
|
|
27
|
-
return runtimePkg.parse(...args);
|
|
28
|
-
throw new Error("WASM package not built: pkg/devalang_core not found");
|
|
29
|
-
}
|
|
30
|
-
function debug_render(...args) {
|
|
31
|
-
if (runtimePkg && typeof runtimePkg.debug_render === "function")
|
|
32
|
-
return runtimePkg.debug_render(...args);
|
|
33
|
-
throw new Error("WASM package not built: pkg/devalang_core not found");
|
|
34
|
-
}
|
|
35
|
-
function render_audio(...args) {
|
|
36
|
-
if (runtimePkg && typeof runtimePkg.render_audio === "function")
|
|
37
|
-
return runtimePkg.render_audio(...args);
|
|
38
|
-
return new Float32Array(0);
|
|
39
|
-
}
|
|
40
|
-
function register_playhead_callback(cb) {
|
|
41
|
-
if (runtimePkg && typeof runtimePkg.register_playhead_callback === "function")
|
|
42
|
-
return runtimePkg.register_playhead_callback(cb);
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
function collect_playhead_events() {
|
|
46
|
-
if (runtimePkg && typeof runtimePkg.collect_playhead_events === "function") {
|
|
47
|
-
return runtimePkg.collect_playhead_events();
|
|
48
|
-
}
|
|
49
|
-
return [];
|
|
50
|
-
}
|
|
51
|
-
function unregister_playhead_callback() {
|
|
52
|
-
if (runtimePkg &&
|
|
53
|
-
typeof runtimePkg.unregister_playhead_callback === "function")
|
|
54
|
-
return runtimePkg.unregister_playhead_callback();
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const pkg = {
|
|
58
|
-
parse,
|
|
59
|
-
debug_render,
|
|
60
|
-
render_audio,
|
|
61
|
-
register_playhead_callback,
|
|
62
|
-
collect_playhead_events,
|
|
63
|
-
unregister_playhead_callback,
|
|
64
|
-
};
|
|
65
|
-
exports.default = pkg;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/* tslint:disable */
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
export const memory: WebAssembly.Memory;
|
|
4
|
-
export const collect_playhead_events: () => [number, number, number];
|
|
5
|
-
export const debug_render: (a: number, b: number) => [number, number, number];
|
|
6
|
-
export const parse: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
7
|
-
export const register_playhead_callback: (a: any) => void;
|
|
8
|
-
export const render_audio: (a: number, b: number) => [number, number, number];
|
|
9
|
-
export const unregister_playhead_callback: () => void;
|
|
10
|
-
export const rust_lzma_wasm_shim_calloc: (a: number, b: number) => number;
|
|
11
|
-
export const rust_lzma_wasm_shim_free: (a: number) => void;
|
|
12
|
-
export const rust_lzma_wasm_shim_malloc: (a: number) => number;
|
|
13
|
-
export const rust_lzma_wasm_shim_memchr: (a: number, b: number, c: number) => number;
|
|
14
|
-
export const rust_lzma_wasm_shim_memcmp: (a: number, b: number, c: number) => number;
|
|
15
|
-
export const rust_lzma_wasm_shim_memcpy: (a: number, b: number, c: number) => number;
|
|
16
|
-
export const rust_lzma_wasm_shim_memmove: (a: number, b: number, c: number) => number;
|
|
17
|
-
export const rust_lzma_wasm_shim_memset: (a: number, b: number, c: number) => number;
|
|
18
|
-
export const rust_lzma_wasm_shim_strlen: (a: number) => number;
|
|
19
|
-
export const rust_zstd_wasm_shim_calloc: (a: number, b: number) => number;
|
|
20
|
-
export const rust_zstd_wasm_shim_free: (a: number) => void;
|
|
21
|
-
export const rust_zstd_wasm_shim_malloc: (a: number) => number;
|
|
22
|
-
export const rust_zstd_wasm_shim_memcmp: (a: number, b: number, c: number) => number;
|
|
23
|
-
export const rust_zstd_wasm_shim_memcpy: (a: number, b: number, c: number) => number;
|
|
24
|
-
export const rust_zstd_wasm_shim_memmove: (a: number, b: number, c: number) => number;
|
|
25
|
-
export const rust_zstd_wasm_shim_memset: (a: number, b: number, c: number) => number;
|
|
26
|
-
export const rust_zstd_wasm_shim_qsort: (a: number, b: number, c: number, d: number) => void;
|
|
27
|
-
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
28
|
-
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
29
|
-
export const __wbindgen_exn_store: (a: number) => void;
|
|
30
|
-
export const __externref_table_alloc: () => number;
|
|
31
|
-
export const __wbindgen_export_4: WebAssembly.Table;
|
|
32
|
-
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
33
|
-
export const __externref_table_dealloc: (a: number) => void;
|
|
34
|
-
export const __wbindgen_start: () => void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const fs_1 = __importDefault(require("fs"));
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const argv = process.argv.slice(2);
|
|
9
|
-
let sourceArg;
|
|
10
|
-
let binaryArg;
|
|
11
|
-
let outDirArg;
|
|
12
|
-
for (let i = 0; i < argv.length; i++) {
|
|
13
|
-
const a = argv[i];
|
|
14
|
-
if (a === "--source") {
|
|
15
|
-
sourceArg = argv[++i];
|
|
16
|
-
}
|
|
17
|
-
else if (a === "--binary") {
|
|
18
|
-
binaryArg = argv[++i];
|
|
19
|
-
}
|
|
20
|
-
else if (a === "--out-dir") {
|
|
21
|
-
outDirArg = argv[++i];
|
|
22
|
-
}
|
|
23
|
-
else if (a === "--help" || a === "-h") {
|
|
24
|
-
process.exit(0);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
console.error(`Unknown arg: ${a}`);
|
|
28
|
-
process.exit(1);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
// Default source: attempt to locate project-version.json at repo root
|
|
32
|
-
const defaultSource = path_1.default.resolve(__dirname, "..", "..", "..", "project-version.json");
|
|
33
|
-
const sourcePath = sourceArg ? path_1.default.resolve(sourceArg) : defaultSource;
|
|
34
|
-
if (!fs_1.default.existsSync(sourcePath)) {
|
|
35
|
-
console.error(`Source project-version.json not found at '${sourcePath}'. Please provide --source or ensure file exists.`);
|
|
36
|
-
process.exit(2);
|
|
37
|
-
}
|
|
38
|
-
let destDir = null;
|
|
39
|
-
if (binaryArg) {
|
|
40
|
-
const binPath = path_1.default.resolve(binaryArg);
|
|
41
|
-
// If it's an existing file, use its directory, otherwise assume user passed target path and use its parent
|
|
42
|
-
if (fs_1.default.existsSync(binPath) && fs_1.default.statSync(binPath).isFile()) {
|
|
43
|
-
destDir = path_1.default.dirname(binPath);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
// If binPath looks like a file path (has extension) use parent, else treat as dir
|
|
47
|
-
const ext = path_1.default.extname(binPath);
|
|
48
|
-
if (ext) {
|
|
49
|
-
destDir = path_1.default.dirname(binPath);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
destDir = binPath;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
else if (outDirArg) {
|
|
57
|
-
destDir = path_1.default.resolve(outDirArg);
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
// Default: try to copy next to the running node current working dir (useful when packaging)
|
|
61
|
-
destDir = process.cwd();
|
|
62
|
-
}
|
|
63
|
-
if (!destDir) {
|
|
64
|
-
console.error("Could not resolve destination directory");
|
|
65
|
-
process.exit(3);
|
|
66
|
-
}
|
|
67
|
-
try {
|
|
68
|
-
if (!fs_1.default.existsSync(destDir)) {
|
|
69
|
-
fs_1.default.mkdirSync(destDir, { recursive: true });
|
|
70
|
-
}
|
|
71
|
-
const destPath = path_1.default.join(destDir, "project-version.json");
|
|
72
|
-
fs_1.default.copyFileSync(sourcePath, destPath);
|
|
73
|
-
console.log(`project-version.json copied to '${destPath}'`);
|
|
74
|
-
process.exit(0);
|
|
75
|
-
}
|
|
76
|
-
catch (err) {
|
|
77
|
-
console.error("Failed to copy project-version.json:", err);
|
|
78
|
-
process.exit(4);
|
|
79
|
-
}
|
package/project-version.json
DELETED
package/rust/bindings/Cargo.toml
DELETED
package/rust/bindings/src/lib.rs
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
//! Minimal, focused bindings helpers for writing custom render functions in
|
|
2
|
-
//! plugin crates.
|
|
3
|
-
//!
|
|
4
|
-
//! The core runtime already handles registration and FFI bridging. This crate
|
|
5
|
-
//! only exports the types and function-signature aliases that plugin authors
|
|
6
|
-
//! should implement in safe Rust. The host will convert raw buffers/pointers
|
|
7
|
-
//! into these safe types before calling the plugin function.
|
|
8
|
-
//!
|
|
9
|
-
//! Guiding principle: plugin authors write purely safe Rust functions with
|
|
10
|
-
//! clear parameters (slices and small structs). No registration helpers or
|
|
11
|
-
//! global registries are provided here.
|
|
12
|
-
|
|
13
|
-
/// Lightweight representation of a musical note.
|
|
14
|
-
#[derive(Debug, Clone, Copy)]
|
|
15
|
-
pub struct Note {
|
|
16
|
-
/// MIDI pitch 0..127
|
|
17
|
-
pub pitch: u8,
|
|
18
|
-
/// Velocity 0..127
|
|
19
|
-
pub velocity: u8,
|
|
20
|
-
/// Note duration in milliseconds (approximate)
|
|
21
|
-
pub duration_ms: u32,
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
impl Default for Note {
|
|
25
|
-
fn default() -> Self {
|
|
26
|
-
Self { pitch: 60, velocity: 100, duration_ms: 500 }
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/// Parameters describing the output buffer and audio context.
|
|
31
|
-
#[derive(Debug, Clone, Copy)]
|
|
32
|
-
pub struct BufferParams {
|
|
33
|
-
/// Sample rate in Hz
|
|
34
|
-
pub sample_rate: u32,
|
|
35
|
-
/// Number of channels (1 = mono, 2 = stereo, ...)
|
|
36
|
-
pub channels: u32,
|
|
37
|
-
/// Number of frames (samples per channel) available in the buffer
|
|
38
|
-
pub frames: u32,
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/// Helper to compute expected buffer length (frames * channels).
|
|
42
|
-
impl BufferParams {
|
|
43
|
-
/// Returns the expected length of the interleaved buffer (frames * channels)
|
|
44
|
-
/// as a host-friendly `usize`. The host is responsible for converting
|
|
45
|
-
/// its platform-sized integers into these explicit-width fields.
|
|
46
|
-
pub fn buffer_len(&self) -> usize {
|
|
47
|
-
(self.frames as usize).saturating_mul(self.channels as usize)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/// Quick validation helper that plugins can call to ensure the provided
|
|
51
|
-
/// output slice matches the declared `params` length.
|
|
52
|
-
pub fn validate_buffer(out: &mut [f32], params: BufferParams) -> Result<(), &'static str> {
|
|
53
|
-
let expected = params.buffer_len();
|
|
54
|
-
if out.len() < expected { Err("output buffer too small") } else { Ok(()) }
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
impl Default for BufferParams {
|
|
59
|
-
fn default() -> Self {
|
|
60
|
-
Self { sample_rate: 44100, channels: 1, frames: 0 }
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/// Common render function signature plugin authors should implement.
|
|
65
|
-
///
|
|
66
|
-
/// - `out` is a mutable slice of f32 samples (interleaved if channels > 1).
|
|
67
|
-
/// - `params` provides sample rate / channels / frames info.
|
|
68
|
-
/// - `note` is the Note descriptor.
|
|
69
|
-
/// - `freq`/`amp` give additional voice parameters the host may pass.
|
|
70
|
-
pub type RenderFn = fn(out: &mut [f32], params: BufferParams, note: Note, freq: f32, amp: f32);
|
|
71
|
-
|
|
72
|
-
/// A more complete signature used by synth-style plugins that also need
|
|
73
|
-
/// access to extra controls (e.g. voice index or time offset).
|
|
74
|
-
pub type RenderFnExt = fn(
|
|
75
|
-
out: &mut [f32],
|
|
76
|
-
params: BufferParams,
|
|
77
|
-
note: Note,
|
|
78
|
-
freq: f32,
|
|
79
|
-
amp: f32,
|
|
80
|
-
voice_index: u32,
|
|
81
|
-
time_ms: u64,
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
/// Optional signature for control parameter setters. The host can call these
|
|
85
|
-
/// safely by converting raw values into primitives.
|
|
86
|
-
pub type SetParamFn = fn(param_name: &str, value: f32);
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
use crate::cli::addon::{
|
|
2
|
-
install::install_addon, list::list_addons, remove::remove_addon, update::update_addon,
|
|
3
|
-
};
|
|
4
|
-
|
|
5
|
-
pub async fn handle_install_addon_command(name: String, no_clear_tmp: bool) -> Result<(), String> {
|
|
6
|
-
if let Err(e) = install_addon(name, no_clear_tmp).await {
|
|
7
|
-
return Err(format!("Failed to install addon: {}", e));
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
Ok(())
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
pub async fn handle_list_addon_command() -> Result<(), String> {
|
|
14
|
-
if let Err(e) = list_addons().await {
|
|
15
|
-
return Err(format!("Failed to list addons: {}", e));
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
Ok(())
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
pub async fn handle_remove_addon_command(name: String) -> Result<(), String> {
|
|
22
|
-
if let Err(e) = remove_addon(name).await {
|
|
23
|
-
return Err(format!("Failed to remove addon: {}", e));
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
Ok(())
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
pub async fn handle_update_addon_command(name: String) -> Result<(), String> {
|
|
30
|
-
if let Err(e) = update_addon(name).await {
|
|
31
|
-
return Err(format!("Failed to update addon: {}", e));
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
Ok(())
|
|
35
|
-
}
|