SampleData is HCodecs’ representation of audio samples, backed internally by arrays. It converts a Signal into data that can become part of an Audio value for WAV export. section 10.1.2
A practical conversion follows these steps:
- Use listArray with bounds from 0 through the final sample index to build SampleData from a list. section 10.1.2
- Convert each Sample with fromSample, and clamp the signal before conversion so values remain safely within the audio range. section 10.1.2
Converting and exporting a signal
signalToSampleData signal = listArray (0, n) $ map fromSample signal, where n = length signal - 1. The WAV-writing pipeline applies limit first, then stores the result as mono audio.
