phip1611 / audio-visualizer

Simple audio visualization library which is especially useful for developers to visually check audio algorithms against the waveform.
MIT License
51 stars 5 forks source link

Would be good to extend to 8, 24 and 32 bit audio #6

Closed SeanEClarke closed 1 year ago

phip1611 commented 1 year ago

Hi, thanks for the issue.

Personally, I do not see the benefit. The goal of this library is not high-quality visualization. In fact, the description says:

Super basic and simple audio visualization library which is especially useful for developers to visually check audio samples, e.g. by waveform or spectrum. (So far) this library is not capable of doing nice visualizations for end users. Contributions are welcome.

Hence, adding support for 24 or 32bit wouldn't bring any visible quality change. Furthermore, performing a transformation from {8,24,32}bit to 16 bit is trivial.

For example:

let my_high_res_audio_samples: Vec<i32> = ...;

// not tested but the transformation would look like something like this
let bit16_audio_samples = my_high_res_audio_samples
    .map(|sample| (sample as f64 / i32::MAX as f64) * i16::max as f64)
    .map(|sample| sample as i32)
    .collect::<Vec<_>>()

If you see any big benefit that I missed, feel free to comment.