import { AudioRange, Cents, Degrees, Frequency, Positive, Time } from "../../core/type/Units"; import { Signal } from "../../signal/Signal"; import { Source } from "../Source"; import { AMOscillator } from "./AMOscillator"; import { FatOscillator } from "./FatOscillator"; import { FMOscillator } from "./FMOscillator"; import { Oscillator } from "./Oscillator"; import { OmniOscillatorConstructorOptions, OmniOscillatorOptions, OmniOscillatorType, ToneOscillatorInterface, ToneOscillatorType } from "./OscillatorInterface"; import { PulseOscillator } from "./PulseOscillator"; import { PWMOscillator } from "./PWMOscillator"; export { OmniOscillatorOptions } from "./OscillatorInterface"; /** * All of the oscillator types that OmniOscillator can take on */ declare type AnyOscillator = Oscillator | PWMOscillator | PulseOscillator | FatOscillator | AMOscillator | FMOscillator; /** * All of the Oscillator constructor types mapped to their name. */ interface OmniOscillatorSource { "fm": FMOscillator; "am": AMOscillator; "pwm": PWMOscillator; "pulse": PulseOscillator; "oscillator": Oscillator; "fat": FatOscillator; } /** * The available oscillator types. */ export declare type OmniOscSourceType = keyof OmniOscillatorSource; declare type IsAmOrFmOscillator = Osc extends AMOscillator ? Ret : Osc extends FMOscillator ? Ret : undefined; declare type IsFatOscillator = Osc extends FatOscillator ? Ret : undefined; declare type IsPWMOscillator = Osc extends PWMOscillator ? Ret : undefined; declare type IsPulseOscillator = Osc extends PulseOscillator ? Ret : undefined; declare type IsFMOscillator = Osc extends FMOscillator ? Ret : undefined; /** * OmniOscillator aggregates Tone.Oscillator, Tone.PulseOscillator, * Tone.PWMOscillator, Tone.FMOscillator, Tone.AMOscillator, and Tone.FatOscillator * into one class. The oscillator class can be changed by setting the `type`. * `omniOsc.type = "pwm"` will set it to the Tone.PWMOscillator. Prefixing * any of the basic types ("sine", "square4", etc.) with "fm", "am", or "fat" * will use the FMOscillator, AMOscillator or FatOscillator respectively. * For example: `omniOsc.type = "fatsawtooth"` will create set the oscillator * to a FatOscillator of type "sawtooth". * @example * var omniOsc = new OmniOscillator("C#4", "pwm"); * @category Source */ export declare class OmniOscillator extends Source implements Omit { readonly name: string; /** * The frequency control. */ readonly frequency: Signal; /** * The detune control. */ readonly detune: Signal; /** * The oscillator that can switch types */ private _oscillator; /** * the type of the oscillator source */ private _sourceType; /** * @param frequency The initial frequency of the oscillator. * @param type The type of the oscillator. */ constructor(frequency?: Frequency, type?: OmniOscillatorType); constructor(options?: Partial); static getDefaults(): OmniOscillatorOptions; /** * start the oscillator */ protected _start(time: Time): void; /** * start the oscillator */ protected _stop(time: Time): void; restart(time?: Time): this; /** * The type of the oscillator. Can be any of the basic types: sine, square, triangle, sawtooth. Or * prefix the basic types with "fm", "am", or "fat" to use the FMOscillator, AMOscillator or FatOscillator * types. The oscillator could also be set to "pwm" or "pulse". All of the parameters of the * oscillator's class are accessible when the oscillator is set to that type, but throws an error * when it's not. * @example * omniOsc.type = "pwm"; * //modulationFrequency is parameter which is available * //only when the type is "pwm". * omniOsc.modulationFrequency.value = 0.5; * @example * //an square wave frequency modulated by a sawtooth * omniOsc.type = "fmsquare"; * omniOsc.modulationType = "sawtooth"; */ type: OmniOscillatorType; /** * The partials of the waveform. A partial represents * the amplitude at a harmonic. The first harmonic is the * fundamental frequency, the second is the octave and so on * following the harmonic series. * Setting this value will automatically set the type to "custom". * The value is an empty array when the type is not "custom". * This is not available on "pwm" and "pulse" oscillator types. * @example * osc.partials = [1, 0.2, 0.01]; */ partials: number[]; /** * The partial count of the oscillator. This is not available on "pwm" and "pulse" oscillator types. * @example * //set the maximum number of partials * osc.partialCount = 0; */ partialCount: number; /** * Set the parameters at once. Either pass in an * object mapping parameters to values, or to set a * single parameter, by passing in a string and value. * The last argument is an optional ramp time which * will ramp any signal values to their destination value * over the duration of the rampTime. * @param params * @example * //set values using an object * filter.set({ * "frequency" : 300, * "type" : "highpass" * }); */ set(props: Partial): this; /** * connect the oscillator to the frequency and detune signals */ private _createNewOscillator; /** * The phase of the oscillator in degrees. */ phase: Degrees; /** * The source type of the oscillator. * @example * var omniOsc = new OmniOscillator(440, "fmsquare"); * omniOsc.sourceType // 'fm' */ sourceType: OmniOscSourceType; private _getOscType; /** * The base type of the oscillator. * @example * var omniOsc = new OmniOscillator(440, "fmsquare4"); * omniOsc.sourceType // 'fm' * omniOsc.baseType //'square' * omniOsc.partialCount //4 */ baseType: OscillatorType | "pwm" | "pulse"; /** * The width of the oscillator when sourceType === "pulse". * @example * var omniOsc = new OmniOscillator(440, "pulse"); * //can access the width attribute only if type === "pulse" * omniOsc.width.value = 0.2; */ readonly width: IsPulseOscillator>; /** * The number of detuned oscillators, when sourceType === "fat". */ count: IsFatOscillator; /** * The detune spread between the oscillators. If "count" is * set to 3 oscillators and the "spread" is set to 40, * the three oscillators would be detuned like this: [-20, 0, 20] * for a total detune spread of 40 cents. See Tone.FatOscillator * for more info. */ spread: IsFatOscillator; /** * The type of the modulator oscillator. Only if the oscillator * is set to "am" or "fm" types. see. Tone.AMOscillator or Tone.FMOscillator * for more info. */ modulationType: IsAmOrFmOscillator; /** * The modulation index which is in essence the depth or amount of the modulation. In other terms it is the * ratio of the frequency of the modulating signal (mf) to the amplitude of the * modulating signal (ma) -- as in ma/mf. * See Tone.FMOscillator for more info. */ readonly modulationIndex: IsFMOscillator>; /** * Harmonicity is the frequency ratio between the carrier and the modulator oscillators. * A harmonicity of 1 gives both oscillators the same frequency. * Harmonicity = 2 means a change of an octave. See Tone.AMOscillator or Tone.FMOscillator * for more info. */ readonly harmonicity: IsAmOrFmOscillator>; /** * The modulationFrequency Signal of the oscillator * (only if the oscillator type is set to pwm). See * Tone.PWMOscillator for more info. * @example * var omniOsc = new OmniOscillator(440, "pwm"); * //can access the modulationFrequency attribute only if type === "pwm" * omniOsc.modulationFrequency.value = 0.2; */ readonly modulationFrequency: IsPWMOscillator>; dispose(): this; }