import { Dryad , Command , CallOrder } from "dryadic" ; import Server from "@supercollider/server" ; interface Properties { numChannels : number ; } interface Context { scserver : Server ; out : number ; } /**
 * Allocates an audio bus, making it available in the children's context as .out (integer)
 * and .numChannels (integer)
 */ export default class AudioBus extends Dryad < Properties > { defaultProperties ( ) { return { numChannels : 1 , } ; } /**
     * If there is no SCServer in the parent context,
     * then this will wrap itself in an SCServer
     */ requireParent ( ) { return "SCServer" ; } prepareForAdd ( ) { return { callOrder : CallOrder . SELF_THEN_CHILDREN , updateContext : ( context , properties ) => ( { out : context . scserver . state . allocAudioBus ( properties . numChannels ) , numChannels : properties . numChannels , } ) , } ; } remove ( ) { return { run : ( context , properties ) => context . scserver . state . freeAudioBus ( context . out , properties . numChannels ) , } ; } }