import { SonicWeaveValue } from './stdlib'; import { Interval } from './interval'; import { TimeMonzo } from './monzo'; import { MosConfig } from './diamond-mos'; /** * Root context of a SonicWeave runtime containing the scale title, root pitch, value of the 'up' inflection etc. */ export declare class RootContext { /** * Title of the scale. */ title: string; /** * Absolute frequency associated with 1/1 (linear) or P1 (logarithmic perfect unison). */ unisonFrequency?: TimeMonzo; /** * The remaining computational budget. */ gas: number; /** * Values that depend on the current root pitch or up/lift inflections. */ fragiles: Interval[]; /** * Current tracking ID. */ trackingIndex: number; /** * Values passed to a [tagged template literal](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates) converted to types understood by the SonicWeave runtime. */ templateArguments: SonicWeaveValue[]; private C4_; private up_; private lift_; private mosConfig_?; /** * Create a new root context. * @param gas Computational budget for evaluating the program. */ constructor(gas?: number); /** * Current value of middle C. With respect to the unison frequency if relative or with respect to 1 Hz if absolute. */ get C4(): TimeMonzo; set C4(value: TimeMonzo); /** * Current value of the 'up' `^` inflection and conversely of the 'down' `v` inflection. */ get up(): Interval; set up(value: Interval); /** * Current value of the 'lift' `/` inflection and conversely of the 'drop' `\ ` inflection. */ get lift(): Interval; set lift(value: Interval); /** * MOS declaration result. */ get mosConfig(): MosConfig | undefined; set mosConfig(value: MosConfig | undefined); /** * Create an independent clone of the context useable as a cache of runtime state. * @returns A {@link RootContext} in the same state as this one. */ clone(): RootContext; /** * Update the internal counter when spending computational resources. * @param amount How many ticks to spend. * @throws An error if the context runs out of gas. */ spendGas(amount?: number): void; private breakFragiles; /** * Convert the state of this context into a block of text in the SonicWeave DSL. * @param defaults Root context for determining if the root pitch etc. has changed. * @returns A string that when evaluated should recreate the same runtime context. */ expand(defaults: RootContext): string; /** * Obtain the next free tracking ID and advance the counter. * @returns An identifier for tracking the evolution of a {@link Interval} instance. */ nextTrackingId(): number; }