pixeltone.js
Version:
An auditory creation tool that turns your images into sounds.
41 lines (40 loc) • 1.68 kB
TypeScript
import { PixeltoneOptions } from "./core/options/PixeltoneOptions";
/**
* Pixeltone class provides functionality to generate audio files from image data.
*/
declare class Pixeltone {
private _imageLoader;
private _pixelToFrequencyMapper;
private _rgbToAudioSampleGenerator;
private _wavFileFactory;
constructor();
/**
* Converts an image into an audio file by mapping pixel data (RGB) to audio frequencies.
*
* @param {PixeltoneOptions} options - Configuration options for generating audio.
* @param {string} options.inputImagePath - Path to the input image file.
* @param {string} options.outputAudioPath - Path where the output audio file will be saved.
* @param {number} [options.sampleRate=DEFAULT_SAMPLE_RATE] - The audio sample rate in Hz.
* @param {number} [options.duration=DEFAULT_DURATION] - Duration of the each pixel sample in seconds.
* @param {number[][]} [options.rgbFrequencyRange=DEFAULT_RGB_FREQUENCY_RANGES] - Frequency range for RGB channels.
*
* @returns {Promise<void>} Resolves when the audio file has been successfully created.
*
* @example
* const pixeltone = new Pixeltone();
* await pixeltone.createAudioFromImage({
* inputImagePath: './input.png',
* outputAudioPath: './output.wav',
* sampleRate: 44100,
* duration: 10,
* rgbFrequencyRange: {
* r: { min: 30, max: 500, offset: 60 },
* g: { min: 500, max: 2000, offset: 250 },
* b: { min: 2000, max: 10000, offset: 1000 },
* }
* });
*/
createAudioFromImage(options: PixeltoneOptions): Promise<void>;
destroy(): void;
}
export { Pixeltone };