faiface/beep

feature request: add to wav package functions and types to directly work with wav header

ilyapashuk opened this issue · 2 comments

hello.

please add to wav package functions and types to parse and generate wav file headers directly, without decoding other data.

this can be very usefull for internet streamming when we need to send header to each new client and then start to transmit raw data from some source

WAV's header contains a filesize. For streaming audio the size isn't known so this wouldn't work.

What you could do is use the functions on the Format struct to encode audio samples manually. You just have to make sure that the client and server agree on the format by either hardcoding it or sending your own custom header. You can use the wav encoding/decoding implementation for an example on how to use Format.

Normally a more compact format is used to stream audio like mp3 (I think). But beep can't encode that so yeah...

for example, when size of the data is not known, sox sets it to 0 and is able to understand this.

please simply add type, parsing and writing functions for wav header without direct bound to Format type.