libsndfile/libsamplerate

Provide conversion functions from/to unsigned char

Closed this issue · 4 comments

WAV files might be uint8 PCM format. For those it would be helpful to have conversion functions too.

erikd commented

The audio data in WAV files can be unsigned 8 bit, signed 16 bit, signed 24 bit, signed 32 bit, 32 bit floating point, 64 bit floating point, u-law, A-law, IMA ADPCM, MS ADPAM and probably close to 100 other forrmats. Of all of those formats uint8 is acrually the most lo-fi and low quality.

Why would you add support for uint8 and not any of ther others, especially when libsndfile supports WAV, AIFF and bunch of other functions?

This is simply not a good idea.

unsigned 8 bit, signed 16 bit, signed 24 bit, signed 32 bit, 32 bit floating point, 64 bit floating point

Those are the easiest and (probably) most common types to handle.
int16, int32, float32 are already supported (float natively, the rest via conversion) and float64 can probably be simply converted to float32, so int24 and uint8 are missing. There is no C type for int24 but there is one for uint8. So to provide support for a wider range with low costs adding uint8 is reasonable.
So why support uint8 and not the others? Because of costs: Support for uint8, int16, int32 conversion to float can have a uniform interface, while other formats can't (int24 doesn't have a type, u-law may even need something completely different where uint8 is just a cast with linear rescaling)

Reason why I'm asking: We want to use this library for a game/mod/remake using original resources which are (kind of) uint8 WAV files. Of course we can implement uint8->float32 ourselves but given that others might need that too I was thinking it might be a good fit for upstream as the interface already exists (standard C-array to float array)

erikd commented

Sorry, this library is for professional audio quality sample rate conversion, nothing more.

Closing as (more) conversions are out of scope of this library, see #71 (comment)