faiface / beep

A little package that brings sound to any Go application. Suitable for playback and audio-processing.
MIT License
2.08k stars 152 forks source link

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

Open ilyapashuk opened 3 years ago

ilyapashuk commented 3 years ago

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

MarkKremer commented 3 years ago

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...

ilyapashuk commented 3 years ago

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.