import { PropertyValues } from "lit"; import { ReadonlySignal } from "@lit-labs/preact-signals"; import { RenderWindow } from "../../models/rendering"; import { Seconds, UnitConverter } from "../../models/unitConverters"; import { WindowFunctionName } from "fft-windowing-ts"; import { PowerTwoWindowSize } from "../../helpers/audio/models"; import { ColorMapName } from "../../helpers/audio/colors"; import { ISpectrogramOptions, SpectrogramCanvasScale, SpectrogramOptions } from "./spectrogramOptions"; export interface IPlayEvent { play: boolean; keyboardShortcut: boolean; } declare const SpectrogramComponent_base: import("../../helpers/types/mixins").Component & { tagName: string; }; /** * @description * A spectrogram component that can be used with the open ecoacoustics components * * @csspart canvas - Allows you to size the spectrogram component from the size of the canvas * * @fires loading * @fires loaded * @fires play * @fires options-change * * @slot - A `` element to provide the audio source */ export declare class SpectrogramComponent extends SpectrogramComponent_base { static styles: import("lit").CSSResult; static readonly playEventName = "play"; static readonly loadingEventName = "loading"; static readonly loadedEventName = "loaded"; static readonly optionsChangeEventName = "options-change"; private static readonly defaultOptions; constructor(); ancestorOptions?: ISpectrogramOptions; domRenderWindow?: RenderWindow; /** Whether the spectrogram is paused */ paused: boolean; /** The source of the audio file */ src: string; /** * The aspect ratio of the spectrogram * stretch should scale without aspect ratio * natural should scale with the correct aspect ratio to fill the container it * is in. One dimension will be constrained by the container, the other by the * aspect ratio. * original will set the spectrogram to the native resolution of the FFT output. * It will not scale the image at all. * * @values stretch | natural | original */ scaling: SpectrogramCanvasScale; /** * The size of the fft window * * @default 512 */ windowSize?: PowerTwoWindowSize; /** * The window function to use for the spectrogram * * @default "hann" */ windowFunction?: WindowFunctionName; /** * The amount of overlap between fft windows * * @default 0 */ windowOverlap?: number; /** * A boolean attribute representing if the spectrogram should be shown in * mel-scale. * * @default false */ melScale?: boolean; /** * A color map to use for the spectrogram * * @default "grayscale" */ colorMap?: ColorMapName; /** * An increase in brightness * * @default 0 */ brightness?: number; /** * A scalar multiplier that should be applied to fft values * * @default 1 */ contrast?: number; /** * An offset (seconds) from the start of a larger audio recording * * @default 0 */ offset: Seconds; mediaControlOptions: ISpectrogramOptions; slottedSourceElements: ReadonlyArray; private spectrogramContainer; private mediaElement; private canvas; get currentTime(): ReadonlySignal; private set currentTime(value); get unitConverters(): ReadonlySignal; get possibleWindowOverlaps(): ReadonlyArray; /** * @description * Creates a SpectrogramOptions object from the current component attributes. * Because spectrogram option attributes are optional, this SpectrogramOptions * model may be partially complete. */ private get componentOptions(); private set componentOptions(value); get spectrogramOptions(): SpectrogramOptions; private get renderedSource(); private get hasSource(); readonly possibleWindowSizes: [128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]; private readonly renderWindow; private readonly audio; private readonly renderCanvasSize; private readonly _unitConverters; private readonly _currentTime; private readonly audioHelper; private readonly audioContext; private readonly highAccuracyTimeBuffer; private readonly currentTimeBuffer; private readonly canvasResizeCallback; private interpolationCancelReference; private doneFirstRender; disconnectedCallback(): Promise; firstUpdated(change: PropertyValues): Promise; willUpdate(change: PropertyValues): void; updated(change: PropertyValues): Promise; setComponentOption(option: T, value: this[T]): void; setMediaControlsOption(option: T, value: ISpectrogramOptions[T]): void; /** * @description * Removes all settings applied to the spectrogram through the media controls * component. * This does NOT reset the any attribute or ancestor spectrogram options. */ resetMediaControlSettings(): void; play(keyboardShortcut?: boolean): void; pause(keyboardShortcut?: boolean): void; stop(): void; private renderSpectrogram; private regenerateSpectrogram; private regenerateSpectrogramOptions; private initializeUnitConverter; private isValidWindowSize; private originalFftSize; private naturalSize; private stretchSize; private handleResize; private resizeCanvas; /** * Specifies if the spectrogram is invalidated with the new parameters * This method can be used to check if the spectrogram needs to be re-rendered */ private invalidateSpectrogramOptions; private invalidateSpectrogramSource; /** * Returns the amount of time processed by the high accuracy time processor * It is important to note that the time does not represent the actual time * of the audio element, but is actually a very accurate amount of time that * has passed since the worklet node started processing audio */ private highAccuracyElapsedTime; private updateCurrentTime; private pollUpdateHighAccuracyTime; private setPaused; private parseRenderWindow; renderSurface(): import("lit").TemplateResult<1>; } declare global { interface HTMLElementTagNameMap { "oe-spectrogram": SpectrogramComponent; } } export {};