Format
#struct FormatWhat a WAVE file's fmt chunk says: which codec, how many channels, the rate and the depth.
| Name | Type | Description |
|---|---|---|
codec | int = 0 | Which codec the samples use, one of the Codec numbers. |
channels | int = 0 | How many channels. |
rate | int = 0 | Frames per second. |
bits | int = 0 | Bits per sample. |
block_align | int = 0 | How many bytes one frame takes. |
byte_rate | int = 0 | Bytes per second of audio. |
import audio
import audio.wav
import compress
func main:
mut c := audio.New(22050, 2, 100)
audio.SetSample(c, 7, 1, 0.5)
mut buf := wav.EncodeWAVBits(c, 24)
println wav.IsWAV(buf.data, buf.len), wav.IsWAV(buf.data, 4)
mut f := wav.Format {}
println wav.ReadFormat(buf.data, buf.len, f)
println f.codec == wav.CodecPCM, f.channels, f.rate, f.bits, f.block_align, f.byte_rate
chunks := wav.Chunks(buf.data, buf.len)
println chunks.Len()
mut ck := wav.Chunk {}
println wav.FindChunk(buf.data, buf.len, wav.Tag("data"), ck), ck.offset, ck.size
mut miss := wav.Chunk {}
println wav.FindChunk(buf.data, buf.len, wav.Tag("cue "), miss)
mut ok := false
info := wav.ProbeWAV(buf.data, buf.len, ok)
println ok, info.rate, info.channels, info.bits, info.frames, info.lossless
mut dok := false
back := wav.DecodeWAV(buf.data, buf.len, dok)
println dok, back.frames, back.bits, audio.Sample(back, 7, 1)
compress.BufFree(buf)
audio.Free(c)
endtrue false true true 2 22050 24 6 132300 2 true 44 600 false true 22050 2 24 100 true true 100 24 0.5