import { DspGraph } from '../dsp-graph'; import { CompilationSettings, VariableNamesIndex } from '../compile/types'; import { FsApi } from '../stdlib/fs/types'; import { FS_OPERATION_FAILURE, FS_OPERATION_SUCCESS } from '../stdlib/fs/constants'; import { CommonsApi } from '../stdlib/commons/types'; import { CustomMetadataType } from '../types'; interface BindingSpecRaw { type: 'raw'; } interface BindingSpecBinding { type: 'proxy'; value: ValueType; } interface BindingSpecCallback { type: 'callback'; value: ValueType; } export type BindingSpec = BindingSpecRaw | BindingSpecBinding | BindingSpecCallback; /** Thin wrapper around a RawModule that makes it easier to be consumed by a third party */ export type Bindings = { [Property in keyof ModuleType]: BindingSpec; }; export type fs_OperationStatus = typeof FS_OPERATION_SUCCESS | typeof FS_OPERATION_FAILURE; export type FloatArrayConstructor = typeof Float32Array | typeof Float64Array; export type FloatArray = InstanceType; export type MessageToken = string | number; /** Type for messages sent through the control flow. */ export type Message = Array; /** [channelCount, sampleRate, bitDepth, encodingFormat, endianness, extraOptions] */ export type SoundFileInfo = [ number, number, number, string, 'b' | 'l' | '', string ]; /** Type for values sent through the signal flow. */ export type Signal = number; export interface EngineMetadata { readonly libVersion: string; readonly customMetadata: CustomMetadataType; readonly settings: { readonly audio: CompilationSettings['audio'] & { sampleRate: number; blockSize: number; }; readonly io: CompilationSettings['io']; }; readonly compilation: { readonly variableNamesIndex: { readonly io: VariableNamesIndex['io']; readonly globals: VariableNamesIndex['globals']; }; }; } /** Base interface for DSP engine */ export interface Engine { metadata: EngineMetadata; initialize: (sampleRate: number, blockSize: number) => void; dspLoop: (input: Array, output: Array) => void; io: { messageReceivers: { [nodeId: DspGraph.NodeId]: { [inletId: DspGraph.PortletId]: (message: Message) => void; }; }; messageSenders: { [nodeId: DspGraph.NodeId]: { [outletId: DspGraph.PortletId]: (message: Message) => void; }; }; }; globals: { /** API for all shared resources, global events, etc ... */ commons: CommonsApi; /** Filesystem API for the engine */ fs?: FsApi; }; } export {};