Sample Rate: Hz | Duration: seconds
Current Seed:
Audio of Babel generates unique audio samples based on a seed value. Here's a detailed explanation of the process:
- If the user doesn't provide a seed, a random Unicode string is generated.
- The seed can contain any Unicode character, allowing for a vast number of possible inputs.
- The seed is used to initialize a seeded random number generator (RNG) using the SeedRandom library.
- This ensures that the same seed always produces the same audio output.
- The seed is used to determine the duration of the audio clip.
- Duration ranges from 0.001 second (1 millisecond) to 30 seconds, calculated as:
duration = 0.001 + seededRandom() * 29.999
- An AudioContext is created to handle audio processing.
- The number of samples (frameCount) is calculated based on the sample rate and duration.
- An AudioBuffer is created with these specifications.
- For each sample in the buffer:
sample = seededRandom() * 2 - 1
- This generates values between -1 and 1, creating white noise.
- An OfflineAudioContext is used to render the audio without real-time playback.
- This allows for faster processing and generation of the complete audio file.
- The rendered audio buffer is converted to a WAV file format.
- This involves creating a proper WAV header and encoding the audio data.
- The WAV file is set as the source for the audio player.
- WaveSurfer.js is used to create a visual representation of the audio waveform.
- The current seed, sample rate, and duration are displayed to the user.
- Deterministic: The same seed always produces the same audio.
- Unicode Support: Seeds can include any Unicode character, vastly expanding possible inputs.
- Variable Duration: Each seed produces a unique duration between 0.001 and 30 seconds.
- White Noise Generation: The audio consists of random samples, creating white noise.
- Client-Side Processing: All audio generation happens in the user's browser, ensuring privacy and reducing server load.