Repository navigation
Expand file tree
/
Copy pathflo_audio.ksy
More file actions
381 lines (310 loc) · 11.8 KB
/
Copy pathflo_audio.ksy
File metadata and controls
381 lines (310 loc) · 11.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
meta:
id: flo_audio
title: flo Audio Format
file-extension: flo
endian: le
license: Apache-2.0
doc: |
flo (Fast Layered Object): A modern dual-mode audio format
Design principles:
- HEAD contains all chunk offsets (single source of truth)
- Fixed-duration frames (1 second) with variable size
- Dual-mode: Lossless (ALPC) or Lossy (Transform/MDCT)
- MessagePack metadata for flexibility
Encoding modes:
- Lossless (ALPC): Adaptive Linear Predictive Coding with Rice entropy coding
- Achieves ~2-3x compression
- Perfect bit-for-bit reconstruction
- Frame types 1-12 indicate LPC order
- Lossy (Transform): MDCT-based psychoacoustic compression
- Achieves ~10-30x compression depending on quality
- Uses 2048-sample MDCT blocks with 50% overlap
- Psychoacoustic masking discards inaudible frequencies
- Frame type 253 indicates transform mode
- Quality levels: Low(0), Medium(1), High(2), VeryHigh(3), Transparent(4)
seq:
- id: header
type: flo_header
doc: Main header containing format info and chunk offsets
- id: toc
type: toc_chunk
size: header.toc_size
doc: Table of contents with seek points
- id: data
type: data_chunk
size: header.data_size
doc: Compressed audio frames
- id: extra
type: extra_chunk
size: header.extra_size
doc: Reserved for future extensions
- id: meta
type: meta_chunk
size: header.meta_size
doc: MessagePack metadata (artist, album, etc)
types:
flo_header:
seq:
- id: magic
contents: [0x46, 0x4C, 0x4F, 0x21] # "FLO!"
doc: Magic number identifier
- id: version_major
type: u1
doc: Format major version
- id: version_minor
type: u1
doc: Format minor version
- id: flags
type: u2
doc: |
Bit flags:
Bit 0: Lossy mode enabled (0=lossless, 1=lossy)
Bits 8-11: Lossy quality level (0=Low, 1=Medium, 2=High, 3=VeryHigh, 4=Transparent)
Other bits: Reserved
- id: sample_rate
type: u4
doc: Sample rate in Hz (e.g., 44100, 48000)
- id: channels
type: u1
doc: Number of audio channels (1=mono, 2=stereo)
- id: bit_depth
type: u1
doc: Bits per sample (16, 24, or 32)
- id: total_samples
type: u8
doc: Total sample-frames (samples per channel). This is the number of sample
instants per channel (not interleaved samples). Use metadata.length_ms
for a quick duration lookup.
- id: compression_level
type: u1
doc: Global compression hint (0-9, affects ALPC order selection)
- id: reserved
size: 3
doc: Reserved for future use (must be 0)
# Integrity Check
- id: data_crc32
type: u4
doc: CRC32 checksum of the DATA chunk integrity
# Sizes
- id: header_size
type: u8
doc: Size of this header in bytes (excludes magic)
- id: toc_size
type: u8
doc: Size of TOC chunk in bytes
- id: data_size
type: u8
doc: Size of DATA chunk in bytes
- id: extra_size
type: u8
doc: Size of EXTRA chunk in bytes
- id: meta_size
type: u8
doc: Size of META chunk in bytes
instances:
is_lossy:
value: (flags & 0x01) != 0
doc: True if lossy compression is enabled
lossy_quality:
value: (flags >> 8) & 0x0F
doc: Lossy quality level (0=Low, 1=Medium, 2=High, 3=VeryHigh, 4=Transparent)
toc_chunk:
seq:
- id: num_entries
type: u4
doc: Number of seek points
- id: entries
type: toc_entry
repeat: expr
repeat-expr: num_entries
toc_entry:
seq:
- id: frame_index
type: u4
doc: Frame number (0-based)
- id: byte_offset
type: u8
doc: Byte offset from start of DATA chunk
- id: frame_size
type: u4
doc: Size of this frame in bytes
- id: timestamp_ms
type: u4
doc: Timestamp in milliseconds
data_chunk:
seq:
- id: frames
type: audio_frame
repeat: eos
doc: Sequence of 1-second audio frames
audio_frame:
seq:
- id: frame_header
type: frame_header
- id: channels
type: channel_wrapper
repeat: expr
repeat-expr: _root.header.channels
channel_wrapper:
doc: Each channel is prefixed with its size for variable-length support
seq:
- id: channel_size
type: u4
doc: Size of this channel's data in bytes
- id: channel_data
type: channel_data
size: channel_size
frame_header:
seq:
- id: frame_type
type: u1
enum: frame_type_enum
doc: |
0 = Silence
1-12 = ALPC with order N (lossless)
253 = Transform (MDCT-based lossy)
254 = Raw PCM
255 = Reserved
- id: frame_samples
type: u4
doc: Number of samples in this frame (usually sample_rate)
- id: flags
type: u1
doc: Per-frame flags (reserved)
enums:
frame_type_enum:
0: silence
1: alpc_order_1
2: alpc_order_2
3: alpc_order_3
4: alpc_order_4
5: alpc_order_5
6: alpc_order_6
7: alpc_order_7
8: alpc_order_8
9: alpc_order_9
10: alpc_order_10
11: alpc_order_11
12: alpc_order_12
253: transform
254: raw_pcm
255: reserved
channel_data:
doc: |
Channel data format depends on frame type.
ALPC (types 1-12): LPC-based lossless compression
- coeff_count, predictor_coeffs, shift_bits, residual_encoding, rice_parameter, residuals
Transform (type 253): MDCT-based lossy compression
- block_size (1 byte): 0=Long(2048), 1=Short(256), 2=Start, 3=Stop
- scale_factors (25 bands * 2 bytes): Log-scale u16 per Bark band
- coefficient_length (4 bytes): Size of sparse coefficient data
- coefficients: Sparse RLE encoded i16 MDCT coefficients
Raw (type 254): Uncompressed PCM samples
Silence (type 0): No data (frame represents silence)
seq:
# ALPC fields (frame types 1-12)
- id: coeff_count
type: u1
if: _parent._parent.frame_header.frame_type.to_i >= 1 and _parent._parent.frame_header.frame_type.to_i <= 12
doc: Actual number of LPC coefficients (may differ from frame_type due to stability fallback)
- id: predictor_coeffs
type: s4
repeat: expr
repeat-expr: coeff_count
if: _parent._parent.frame_header.frame_type.to_i >= 1 and _parent._parent.frame_header.frame_type.to_i <= 12
doc: LPC coefficients (quantized as i32)
- id: shift_bits
type: u1
if: _parent._parent.frame_header.frame_type.to_i >= 1 and _parent._parent.frame_header.frame_type.to_i <= 12
doc: Bit shift for coefficient dequantization
- id: residual_encoding
type: u1
if: _parent._parent.frame_header.frame_type.to_i >= 1 and _parent._parent.frame_header.frame_type.to_i <= 12
doc: |
Residual encoding method:
0 = Rice coding (parameter in next byte)
1 = Golomb coding
2 = Raw residuals
- id: rice_parameter
type: u1
if: _parent._parent.frame_header.frame_type.to_i >= 1 and _parent._parent.frame_header.frame_type.to_i <= 12 and residual_encoding == 0
doc: Rice coding parameter (k value)
- id: residuals
size-eos: true
doc: |
For ALPC: Rice/Golomb coded or raw residuals
For Transform: MDCT coefficient data (block_size + scale_factors + sparse coefficients)
For Raw: Uncompressed PCM samples
extra_chunk:
seq:
- id: data
size-eos: true
doc: Reserved for future use
meta_chunk:
seq:
- id: msgpack_data
size-eos: true
doc: |
MessagePack encoded metadata (FloMetadata struct)
IDENTIFICATION (ID3v2.4 compatible):
title, subtitle, content_group, album, original_album, set_subtitle
track_number, track_total, disc_number, disc_total, isrc
INVOLVED PERSONS:
artist, album_artist, conductor, remixer, original_artist
composer, lyricist, original_lyricist, encoded_by
involved_people: [(role, name), ...]
musician_credits: [(instrument, name), ...]
PROPERTIES:
genre, mood, bpm (u32), key, language, length_ms (u64)
DATES/TIMES:
year, recording_time, release_time, original_release_time
encoding_time, tagging_time
RIGHTS/LICENSE:
copyright, produced_notice, publisher, file_owner
radio_station, radio_station_owner
SORT ORDER:
album_sort, artist_sort, title_sort
URLS:
url_commercial, url_copyright, url_audio_file, url_artist
url_audio_source, url_radio_station, url_payment, url_publisher
user_urls: [{description, url}, ...]
COMPLEX FRAMES:
comments: [{language?, description?, text}, ...]
lyrics: [{language?, description?, text}, ...] # USLT
synced_lyrics: [{language?, content_type, description?, lines}, ...] # SYLT
pictures: [{mime_type, picture_type, description?, data}, ...] # APIC
user_text: [{description, value}, ...] # TXXX
play_count, popularimeter: {email?, rating, play_count?} # PCNT, POPM
SYNCED LYRICS (content_type):
other, lyrics, text_transcription, part_name, events, chord, trivia, webpage_url, image_url
PICTURE TYPES:
other, file_icon, other_file_icon, cover_front, cover_back
leaflet_page, media, lead_artist, artist, conductor, band
composer, lyricist, recording_location, during_recording
during_performance, video_screen_capture, bright_coloured_fish
illustration, band_logo, publisher_logo
VISUALIZATION (flo-unique):
waveform_data: {peaks_per_second, peaks: [f32], channels}
spectrum_fingerprint: bytes
TIMING & ANALYSIS (flo-unique):
bpm_map: [{timestamp_ms, bpm}, ...]
key_changes: [{timestamp_ms, key}, ...]
loudness_profile: [{timestamp_ms, lufs}, ...]
integrated_loudness_lufs, loudness_range_lu, true_peak_dbtp (f32)
section_markers: [{timestamp_ms, section_type, label?}, ...]
SECTION TYPES:
intro, verse, pre_chorus, chorus, post_chorus, bridge
breakdown, drop, buildup, solo, instrumental, outro, silence, other
CREATOR INFO (flo-unique):
creator_notes: [{timestamp_ms?, text}, ...]
collaboration_credits: [{role, name, timestamp_ms?}, ...]
remix_chain: [{title, artist, year?, isrc?, relationship}, ...]
COVERS (flo-unique):
animated_cover: {mime_type, data, duration_ms?, loop_count?}
cover_variants: [{variant_type, mime_type, data, description?}, ...]
artist_signature: Picture (same as pictures entry)
COVER VARIANT TYPES:
standard, explicit, clean, remix, deluxe, limited, vinyl, cassette, digital, other
flo-SPECIFIC:
flo_encoder_version, source_format
custom: {key: value, ...}