FrameInfo
#struct FrameInfoWhat a frame header says, which may differ from the stream header.
| Name | Type | Description |
|---|---|---|
block_size | int = 0 | How many frames this block holds. |
rate | int = 0 | Frames per second. |
channels | int = 0 | How many channels this frame carries. |
bits | int = 0 | Bits per sample. |
assignment | int = 0 | How the channels are stored: independent, or left/side, right/side or mid/side. |
variable | bool = false | True when the frame is numbered by sample rather than by frame. |
number | i64 = 0 | The frame or sample number this frame starts at. |
import audio
import audio.flac
import audio.synth
import compress
func main:
mut src := synth.Tone(440.0, 0.1, 44100, synth.WaveSine)
mut q := audio.ToBits(src, 16)
q.bits = 16
mut enc := flac.EncodeFLAC(q)
println flac.IsFLAC(enc.data, enc.len), flac.IsFLAC(enc.data, 4)
println audio.FormatName(audio.DetectFormat(enc.data, enc.len))
blocks := flac.Blocks(enc.data, enc.len)
println blocks.Len(),
blocks.Get(0).kind == flac.BlockStreamInfo,
blocks.Get(0).last,
blocks.Get(0).size
mut si := flac.StreamInfo {}
println flac.ReadStreamInfo(enc.data, enc.len, si)
println si.rate, si.channels, si.bits, si.total as int
println si.md5.len, si.audio_offset
println si.min_block, si.max_block
mut fi := flac.FrameInfo {}
head := flac.ReadFrameHeader(enc.data, enc.len, si.audio_offset, si, fi)
println head > 0, fi.channels, fi.bits, fi.rate, fi.block_size
mut ok := false
mut back := flac.DecodeFLAC(enc.data, enc.len, ok)
println ok, back.frames, back.channels, back.bits
println audio.Sample(back, 100, 0) == audio.Sample(q, 100, 0)
mut pok := false
info := flac.ProbeFLAC(enc.data, enc.len, pok)
println pok, info.rate, info.channels, info.bits, info.frames, info.lossless
println flac.MaxChannels, flac.MaxBlockSize
mut junk := compress.NewByteBuf()
compress.BufPush(junk, 1)
println flac.CRC8(junk.data, 0, 0), flac.CRC16Buf(junk, 0, 1) == flac.CRC16(junk.data, 0, 1)
mut bad := false
flac.DecodeFLAC(junk.data, junk.len, bad)
println bad
flac.FreeStreamInfo(si)
blocks.Free()
compress.BufFree(enc)
compress.BufFree(junk)
audio.Free(src)
audio.Free(q)
audio.Free(back)
endtrue false flac 1 true true 34 true 44100 1 16 4410 16 42 4096 4096 true 1 16 44100 4096 true 4410 1 16 true true 44100 1 16 4410 true 8 65535 0 true false