import { AudioSettings } from '../../compile/types'; import { Engine, EngineMetadata, FloatArray } from '../../run/types'; import { CoreRawModule } from '../../stdlib/core/bindings-assemblyscript'; import { MsgRawModule } from '../../stdlib/msg/bindings-assemblyscript'; import { CommonsRawModule } from '../../stdlib/commons/bindings-assemblyscript'; import { EngineLifecycleRawModule } from './engine-lifecycle-bindings'; import { IoRawModule } from './io-bindings'; import { FsRawModule } from '../../stdlib/fs/bindings-assemblyscript'; import { FsImportsAssemblyScript } from '../../stdlib/fs/types'; export type StringPointer = number; export type MessagePointer = number; /** Pointer to a float array. */ export type FloatArrayPointer = number; /** Pointer to data of unknown type that stays in the wasm space (`Message` for example). */ export type InternalPointer = number; /** * Pointer to an array buffer that contains i32 integers. * This is what we use to pass generic data back and forth from the module. * Because the memory layout is not fixed for data types other than strings * REF : https://www.assemblyscript.org/runtime.html#memory-layout */ export type ArrayBufferOfIntegersPointer = number; export interface BaseRawEngine { __new: (length: number, classType: number) => InternalPointer; memory: WebAssembly.Memory; } /** * Interface for members that are exported in the WASM module resulting from compilation of * WebPd assemblyscript code. */ export type RawEngine = BaseRawEngine & EngineLifecycleRawModule & IoRawModule & CommonsRawModule & CoreRawModule & MsgRawModule & FsRawModule; export type AssemblyScriptWasmImports = FsImportsAssemblyScript; export interface EngineContext { /** * When declaring imported functions, we use objects that will be only available * once compilation is done. * Therefore we use these forward references in imported functions, and fill them up * once compilation is done. */ readonly refs: { engine?: Engine; rawModule?: RawModuleType; }; /** Values that are accessed frequently are cached here */ readonly cache: { wasmOutput: FloatArray; wasmInput: FloatArray; arrayType: typeof Float32Array | typeof Float64Array; bitDepth: AudioSettings['bitDepth']; blockSize: EngineMetadata['settings']['audio']['blockSize']; }; readonly metadata: EngineMetadata; }