Home Reference Source
public class | source

ServerState

Holds state for a Server such as node/bus/buffer allocators, node status and SynthDefs compiled.

Each server is stored by its unique address, so multiple Servers can store state in the same global Store object.

Constructor Summary

Public Constructor
public

constructor(server: Server, store: Store)

Member Summary

Public Members
public

server: *

public

store: *

Method Summary

Public Methods
public

allocAudioBus(numChannels: number): int

Allocate an audio bus.

public

allocBufferID(numConsecutive: int): int

Allocate a buffer id.

public

allocControlBus(numChannels: number): int

Allocate a control bus.

public

freeAudioBus(index: int, numChannels: int)

Free a previously allocate audio bus

public

freeBuffer(index: int, numConsecutive: int)

Free a previously allocated buffer id.

public

freeControlBus(index: int, numChannels: int)

Free a previously allocated control bus

public

getIn(keys: String, notSetValue: any): any

Get current state value for the server using an array of keys.

public

mutate(key: String, fn: Function)

Mutate a value or object in the server state.

public

nextNodeID(): int

Allocates a node ID to be used for making a synth or group

public

Public Constructors

public constructor(server: Server, store: Store) source

Params:

NameTypeAttributeDescription
server Server
store Store

optional parent Store to use.

Public Members

public server: * source

public store: * source

Public Methods

public allocAudioBus(numChannels: number): int source

Allocate an audio bus.

Params:

NameTypeAttributeDescription
numChannels number
  • optional
  • default: 1

Return:

int

numChannels

public allocBufferID(numConsecutive: int): int source

Allocate a buffer id.

Note that numChannels is specified when creating the buffer. This allocator makes sure that the neighboring buffers are empty.

Params:

NameTypeAttributeDescription
numConsecutive int

consecutively numbered buffers are needed by VOsc and VOsc3.

Return:

int

buffer id

public allocControlBus(numChannels: number): int source

Allocate a control bus.

Params:

NameTypeAttributeDescription
numChannels number
  • optional
  • default: 1

Return:

int

numChannels

public freeAudioBus(index: int, numChannels: int) source

Free a previously allocate audio bus

These require you to remember the channels and it messes it up if you free it wrong. will change to higher level storage.

Params:

NameTypeAttributeDescription
index int
numChannels int

public freeBuffer(index: int, numConsecutive: int) source

Free a previously allocated buffer id.

Note that numChannels is specified when creating the buffer.

Params:

NameTypeAttributeDescription
index int
numConsecutive int

consecutively numbered buffers are needed by VOsc and VOsc3.

public freeControlBus(index: int, numChannels: int) source

Free a previously allocated control bus

These require you to remember the channels and it messes it up if you free it wrong. will change to higher level storage.

Params:

NameTypeAttributeDescription
index int
numChannels int

public getIn(keys: String, notSetValue: any): any source

Get current state value for the server using an array of keys.

Params:

NameTypeAttributeDescription
keys String

list of keys eg. ['NODE_WATCHER', 'n_go', 1000]

notSetValue any

default value to return if empty

Return:

any

public mutate(key: String, fn: Function) source

Mutate a value or object in the server state.

Params:

NameTypeAttributeDescription
key String

top level key eg. nodeAllocator, controlBufAllocator

fn Function

will receive current state or an empty Map, returns the altered state.

public nextNodeID(): int source

Allocates a node ID to be used for making a synth or group

Return:

int

public resetState() source