Skip to content

Commit

Permalink
feat(dryads): static constructors SynthDef.fromSource SynthDef.fromFile
Browse files Browse the repository at this point in the history
  • Loading branch information
crucialfelix committed Dec 6, 2019
1 parent f96f51f commit 029d67b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions packages/dryads/src/SCSynthDef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ const StateKeys = {
* `synthDef` is returned from compilation by sclang and
* is set in the context for children Dryads to access.
*/
interface CompiledSynthDef {
export interface CompiledSynthDef {
name: string;
bytes: Buffer;
// object with descriptive meta data
synthDesc: SynthDesc;
}
interface LoadedSynthDef {
export interface LoadedSynthDef {
name: string;
}
export type SynthDef = CompiledSynthDef | LoadedSynthDef;
Expand Down Expand Up @@ -56,6 +56,19 @@ interface Context {
* Note that the synthDefName is not known until after the source code is compiled.
*/
export default class SCSynthDef extends Dryad<Properties> {
static fromSource(source: string): SCSynthDef {
return new SCSynthDef({
source,
watch: false,
});
}
static fromFile(path: string): SCSynthDef {
return new SCSynthDef({
compileFrom: path,
watch: true,
});
}

defaultProperties(): Properties {
return { watch: false };
}
Expand Down

0 comments on commit 029d67b

Please sign in to comment.