experimental strudel audio engine support
This commit is contained in:
@ -16,6 +16,7 @@
|
|||||||
"@codemirror/lang-javascript": "^6.1.9",
|
"@codemirror/lang-javascript": "^6.1.9",
|
||||||
"@codemirror/theme-one-dark": "^6.1.2",
|
"@codemirror/theme-one-dark": "^6.1.2",
|
||||||
"@replit/codemirror-vim": "^6.0.14",
|
"@replit/codemirror-vim": "^6.0.14",
|
||||||
|
"@strudel.cycles/webaudio": "^0.8.2",
|
||||||
"autoprefixer": "^10.4.14",
|
"autoprefixer": "^10.4.14",
|
||||||
"codemirror": "^6.0.1",
|
"codemirror": "^6.0.1",
|
||||||
"postcss": "^8.4.27",
|
"postcss": "^8.4.27",
|
||||||
|
|||||||
27
src/API.ts
27
src/API.ts
@ -3,14 +3,28 @@ import { scale } from './Scales';
|
|||||||
import { tryEvaluate } from "./Evaluator";
|
import { tryEvaluate } from "./Evaluator";
|
||||||
import { MidiConnection } from "./IO/MidiConnection";
|
import { MidiConnection } from "./IO/MidiConnection";
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
import { webaudioOutput, samples } from '@strudel.cycles/webaudio';
|
||||||
|
// @ts-ignore
|
||||||
import { ZZFX, zzfx } from "zzfx";
|
import { ZZFX, zzfx } from "zzfx";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const sound = (value: any) => ({
|
||||||
|
value,
|
||||||
|
context: {},
|
||||||
|
ensureObjectValue: () => { }
|
||||||
|
});
|
||||||
|
|
||||||
export class UserAPI {
|
export class UserAPI {
|
||||||
|
|
||||||
variables: { [key: string]: any } = {}
|
variables: { [key: string]: any } = {}
|
||||||
MidiConnection: MidiConnection = new MidiConnection()
|
MidiConnection: MidiConnection = new MidiConnection()
|
||||||
|
strudelSound = webaudioOutput()
|
||||||
|
load: samples
|
||||||
|
|
||||||
constructor(public app: Editor) { }
|
constructor(public app: Editor) {
|
||||||
|
this.load = samples("github:tidalcycles/Dirt-Samples/master");
|
||||||
|
}
|
||||||
|
|
||||||
// =============================================================
|
// =============================================================
|
||||||
// Utility functions
|
// Utility functions
|
||||||
@ -28,8 +42,10 @@ export class UserAPI {
|
|||||||
r = this.rate
|
r = this.rate
|
||||||
|
|
||||||
script(...args: number[]): void {
|
script(...args: number[]): void {
|
||||||
args.forEach(arg => { tryEvaluate(this.app, this.app.universes[
|
args.forEach(arg => {
|
||||||
this.app.selected_universe].locals[arg]) })
|
tryEvaluate(this.app, this.app.universes[
|
||||||
|
this.app.selected_universe].locals[arg])
|
||||||
|
})
|
||||||
}
|
}
|
||||||
s = this.script
|
s = this.script
|
||||||
|
|
||||||
@ -229,4 +245,9 @@ export class UserAPI {
|
|||||||
// Small ZZFX interface for playing with this synth
|
// Small ZZFX interface for playing with this synth
|
||||||
zzfx = (...thing: number[]) => zzfx(...thing);
|
zzfx = (...thing: number[]) => zzfx(...thing);
|
||||||
|
|
||||||
|
playSound = async (values: object) => {
|
||||||
|
await this.load;
|
||||||
|
webaudioOutput(sound(values), 0.01)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
20
yarn.lock
20
yarn.lock
@ -301,6 +301,21 @@
|
|||||||
resolved "https://registry.yarnpkg.com/@replit/codemirror-vim/-/codemirror-vim-6.0.14.tgz#8f44740b0497406b551726946c9b30f21c867671"
|
resolved "https://registry.yarnpkg.com/@replit/codemirror-vim/-/codemirror-vim-6.0.14.tgz#8f44740b0497406b551726946c9b30f21c867671"
|
||||||
integrity sha512-wwhqhvL76FdRTdwfUWpKCbv0hkp2fvivfMosDVlL/popqOiNLtUhL02ThgHZH8mus/NkVr5Mj582lyFZqQrjOA==
|
integrity sha512-wwhqhvL76FdRTdwfUWpKCbv0hkp2fvivfMosDVlL/popqOiNLtUhL02ThgHZH8mus/NkVr5Mj582lyFZqQrjOA==
|
||||||
|
|
||||||
|
"@strudel.cycles/core@0.8.2":
|
||||||
|
version "0.8.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/@strudel.cycles/core/-/core-0.8.2.tgz#62e957a3636b39938d1c4ecc3fd766d02fc523bb"
|
||||||
|
integrity sha512-rmtrDfy6S/NH9HgFy4rVRRAwVXzYvR85Qwqr/WQqEZQh6OCBW9yXQQWGOZYiBi85Y2FZqwWppBImyGVA6ZzuyA==
|
||||||
|
dependencies:
|
||||||
|
fraction.js "^4.2.0"
|
||||||
|
|
||||||
|
"@strudel.cycles/webaudio@^0.8.2":
|
||||||
|
version "0.8.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/@strudel.cycles/webaudio/-/webaudio-0.8.2.tgz#90e7254544d9601f4365a21f3e0dcdfbc952aded"
|
||||||
|
integrity sha512-IdjSuqd8BUYJ8BOl3lJ8uJCR4G5g0W1YryhPp3uUQ7NaVDlaM4ZnC8qejEI8yoBF+ntWKHInjf5qpj7v5+ttbA==
|
||||||
|
dependencies:
|
||||||
|
"@strudel.cycles/core" "0.8.2"
|
||||||
|
nanostores "^0.8.1"
|
||||||
|
|
||||||
any-promise@^1.0.0:
|
any-promise@^1.0.0:
|
||||||
version "1.3.0"
|
version "1.3.0"
|
||||||
resolved "https://registry.yarnpkg.com/any-promise/-/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f"
|
resolved "https://registry.yarnpkg.com/any-promise/-/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f"
|
||||||
@ -651,6 +666,11 @@ nanoid@^3.3.6:
|
|||||||
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.6.tgz#443380c856d6e9f9824267d960b4236ad583ea4c"
|
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.6.tgz#443380c856d6e9f9824267d960b4236ad583ea4c"
|
||||||
integrity sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==
|
integrity sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==
|
||||||
|
|
||||||
|
nanostores@^0.8.1:
|
||||||
|
version "0.8.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/nanostores/-/nanostores-0.8.1.tgz#963577028ac10eeb50bec376535f4762ab5af9be"
|
||||||
|
integrity sha512-1ZCfQtII2XeFDrtqXL2cdQ/diGrLxzRB3YMyQjn8m7GSGQrJfGST2iuqMpWnS/ZlifhtjgR/SX0Jy6Uij6lRLA==
|
||||||
|
|
||||||
node-releases@^2.0.12:
|
node-releases@^2.0.12:
|
||||||
version "2.0.13"
|
version "2.0.13"
|
||||||
resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.13.tgz#d5ed1627c23e3461e819b02e57b75e4899b1c81d"
|
resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.13.tgz#d5ed1627c23e3461e819b02e57b75e4899b1c81d"
|
||||||
|
|||||||
Reference in New Issue
Block a user