FLAC Agent Build: Difference between revisions

From mywiki
Jump to navigation Jump to search
 
(19 intermediate revisions by the same user not shown)
Line 116: Line 116:
# [https://xiph.org/flac/format.html#metadata_block_streaminfo Flac format]
# [https://xiph.org/flac/format.html#metadata_block_streaminfo Flac format]
====Decompose test.flac====
====Decompose test.flac====
# 0-4 "fLaC" ID Bytes
# '''0-4 "fLaC" ID Bytes'''
# Metadata Block Header
=====Metadata Block 0 Streaminfo (Mandatory)=====
{|
{|class="wikitable" style="margin:auto"
|+ Metadata Block Header
|+ Metadata Block Header 0 (Streaminfo)
|-
|-
! Value !!Hex !!Description !!Number Bits
! Value !!Hex !!Description !!Number Bits
|-  
|-  
|0 || "0(b)" || Not last Metadata Block || 1 Bit
|-
|0 || "0000000(b)"|| Streaminfo Block type || 7 Bits
|-
|34 || "000022" || Metadata Block length hex 22 || 24 Bits
|}
{|class="wikitable" style="margin:auto"
|+ Metadata Block Data
|-
! Value !!Hex !!Description !!Number Bits
|-
|4,096|| "1000" || The minimum block size (in samples) used in the stream. || 16 Bits
|-
|4,096|| "1000" || The maximum block size (in samples) used in the stream. || 16 Bits
|-
|345|| "000159"|| The minimum frame size (in bytes) used in the stream. May be 0 to imply the value is not known. || 24 Bits
|-
|7,560|| "001D88"|| The minimum frame size (in bytes) used in the stream. May be 0 to imply the value is not known. || 24 Bits
|-
|192,000|| "2EE00" ||Sample rate in Hz. Though 20 bits are available, the maximum sample rate is limited by the structure of frame headers to 655350Hz. Also, a value of 0 is invalid.  || 20 Bits
|-
|2|| "001(b)"||(number of channels)'''-1'''. FLAC supports from 1 to 8 channels  || 3 Bits
|-
|24|| "10111(b)" ||(bits per sample)'''-1'''. FLAC supports from 4 to 32 bits per sample.  || 5 Bits
|-
|79573200|| "004BE30D0" ||Total samples in stream. 'Samples' means inter-channel sample, i.e. one second of 44.1Khz audio will have 44100 samples regardless of the number of channels. A value of zero here means the number of total samples is unknown.  || 36 Bits
|-
|NA|| "4FCA4AC4B196E4DE2BA3C866BD20A431" ||MD5 signature of the unencoded audio data. This allows the decoder to determine if an error exists in the audio data even when the error does not result in an invalid bitstream.  || 128 Bits
|}
=====Metadata Block 1 SeekTable =====
{|class="wikitable" style="margin:auto"
|+ SeekTable The number of seek points is implied by the metadata header 'length' field, i.e. equal to length / 18.
|-
! Value !!Hex !!Description !!Number Bits
|- 
|0 || "0" || Not last Metadata Block || 1 Bit
|0 || "0" || Not last Metadata Block || 1 Bit
|-  
|-  
|0 || "000"|| Streaminfo Block type || 7 Bits  
|3 ||"0000011(b)"|| SeekTable Block type || 7 Bits
|-
|756 || "0002F4" || Number of seek points 42 || 24 Bits
|}
{|class="wikitable" style="margin:auto"
|+ Metadata Block Data
|-
! Value !!Hex !!Description !!Number Bits
|-
| '''0''' Seek point
|-
|0|| "0000000000000000" || 0 Seek Point Sample number of first sample in the target frame. || 64 Bits
|-
|0|| "0000000000000000" || Offset (in bytes) from the first byte of the first frame header to the first byte of the target frame's header.  || 64 Bits
|-
|4,096|| "1000"|| Number of samples in the target frame.  || 16 Bits
|-
|'''1''' Seek Point
|-
|1916928|| "00000000001D4000" || 1 Seek Point Sample number of first sample in the target frame. || 64 Bits
|-
|2900681|| "00000000002C42C9" || Offset (in bytes) from the first byte of the first frame header to the first byte of the target frame's header.  || 64 Bits
|-
|4,096|| "1000"|| Number of samples in the target frame.  || 16 Bits
|-
|'''2''' Seek Point
|-
|3837952|| "00000000003A9000" || 2 Seek Point Sample number of first sample in the target frame. || 64 Bits
|-
|5943977|| "00000000005AB2A9" || Offset (in bytes) from the first byte of the first frame header to the first byte of the target frame's header.  || 64 Bits
|-
|0|| "1000"|| Number of samples in the target frame.  || 16 Bits
|-
|'''3''' Seek Point
|-
|5758976|| "000000000057E000" || 3 Seek Point Sample number of first sample in the target frame. || 64 Bits
|-
|9001272|| "0000000000895938" || Offset (in bytes) from the first byte of the first frame header to the first byte of the target frame's header.  || 64 Bits
|-
|4,096|| "1000"|| Number of samples in the target frame.  || 16 Bits
|-
|...'''Last''' Seek Point
|-
|78716928|| "0000000004B12000" || Last Seek Point Sample number of first sample in the target frame. || 64 Bits
|-
|127574074|| "00000000079AA03A" || Offset (in bytes) from the first byte of the first frame header to the first byte of the target frame's header.  || 64 Bits
|-
|4,096|| "1000"|| Number of samples in the target frame.  || 16 Bits
|}
 
=====Metadata Block 2 Vorbis=====
{|class="wikitable" style="margin:auto"
|+ Metadata Block Header 2 (Voorbis)
|-
! Value !!Hex !!Description !!Number Bits
|-
|0 || "0(b)" || Not last Metadata Block || 1 Bit
|-
|4 || "0000100(b)"|| Voorbis Block type || 7 Bits
|-
|40 || "000028" || Metadata Block length || 24 Bits
|}
'''Block Data not Pertinent at this time
 
=====Metadata Block 3 Padding =====
{|class="wikitable" style="margin:auto"
|+ Metadata Block Header 1 (Padding)
|-
! Value !!Hex !!Description !!Number Bits
|-
|1 || "1" || Is last Metadata Block || 1 Bit
|-
|1 ||"0000001(b)"|| Padding Block type || 7 Bits  
|-  
|-  
|22 || "000022" || Metadata Block length hex 22 || 24 Bits
|8192 || "002000" || Metadata Block length || 24 Bits
|}
|}
Block Data not pertinent


==Manual Configure FLAC in Eclipse==
==Manual Configure FLAC in Eclipse==

Latest revision as of 16:18, 31 October 2024


EditDate 2024-08-06

Related Threads: FLAC Agent

I am building a self-learning FLAC Agent and this will track the trials and tribulations of the build here.

I decided to loose my agent against flac files on the NVDIA GPU I have so closed on using C/C++ and CUDA.

Got linker to work. created a.out in Debug directory

Corrected the linker so it's now debuggable and gdb allows me to see assembler code so I'm finally talking directly to the machine again.

Brings me back.Web References https://developer.nvidia.com/cuda-toolkit, https://xiph.org/flac/, https://ftp.osuosl.org/pub/xiph/releases/flac/

I want to build an agent that will read flac music files and identify patterns in them. Once it has the patterns identified I want to see if can draw images in line with the evolving songs and long term improvise based on optimum patterns. Very long term may play sounds that draw a message the machine wants to tell us.

Log

--Johnny (talk) 11:02, 29 October 2024 (UTC) Reading the flac file and starting to breakdown metadata. Expect to lift and streamline decoding code. Just found out we can create our own metadata bloc and hope to store successive passes of agent there. --Johnny (talk) 20:51, 6 August 2024 (UTC) Got linker to work. --Johnny (talk) 19:14, 6 August 2024 (UTC) First had to get a working version of Eclipse that ran on the version of Ubuntu I had. This required updating Eclipse to include the development version so I am currently running Eclipse version=4.32.0 and Ubuntu Oracular Oriole (development branch) which was the only version I found that allowed my instruction debug due to comaptibility issues after Ubuntu updated to Wayland from X11.

Once I had a working development environment I install [ttps://ftp.osuosl.org/pub/xiph/releases/flac/ libFLAC] Unfortunately I've been unable to get a clean link in the development environment so I'm now trying Configure C project with cmake in eclipse manual method to assemble and successfully compile decoder.

Analyze flac stream

0000:0000 | 66 4C 61 43  00 00 00 22  10 00 10 00  00 01 59 00 | fLaC..."......Y.
0000:0010 | 1D 88 2E E0  03 70 04 BE  30 D0 4F CA  4A C4 B1 96 | ...à.p.¾0ÐOÊJı.
0000:0020 | E4 DE 2B A3  C8 66 BD 20  A4 31 03 00  02 F4 00 00 | äÞ+£Èf½ ¤1...ô..
0000:0030 | 00 00 00 00  00 00 00 00  00 00 00 00  00 00 10 00 | ................
0000:0040 | 00 00 00 00  00 1D 40 00  00 00 00 00  00 2C 42 C9 | ......@......,BÉ
0000:0050 | 10 00 00 00  00 00 00 3A  90 00 00 00  00 00 00 5A | .......:.......Z
0000:0060 | B2 A9 10 00  00 00 00 00  00 57 E0 00  00 00 00 00 | ²©.......Wà.....
0000:0070 | 00 89 59 38  10 00 00 00  00 00 00 75  30 00 00 00 | ..Y8.......u0...
0000:0080 | 00 00 00 B8  D2 F6 10 00  00 00 00 00  00 92 70 00 | ...¸Òö........p.
0000:0090 | 00 00 00 00  00 E7 CB 21  10 00 00 00  00 00 00 AF | .....çË!.......¯
0000:00A0 | C0 00 00 00  00 00 01 17  62 29 10 00  00 00 00 00 | À.......b)......
0000:00B0 | 00 CD 10 00  00 00 00 00  01 46 C7 46  10 00 00 00 | .Í.......FÇF....
0000:00C0 | 00 00 00 EA  60 00 00 00  00 00 01 76  C5 7E 10 00 | ...ê`......vÅ~..
0000:00D0 | 00 00 00 00  01 07 A0 00  00 00 00 00  01 A6 43 11 | ...... ......¦C.
0000:00E0 | 10 00 00 00  00 00 01 24  F0 00 00 00  00 00 01 D6 | .......$ð......Ö
0000:00F0 | 3E CE 10 00  00 00 00 00  01 42 40 00  00 00 00 00 | >Î.......B@.....
0000:0100 | 02 06 0E DF  10 00 00 00  00 00 01 5F  90 00 00 00 | ...ß......._....
0000:0110 | 00 00 02 35  51 2A 10 00  00 00 00 00  01 7C D0 00 | ...5Q*.......|Ð.
0000:0120 | 00 00 00 00  02 64 C4 5D  10 00 00 00  00 00 01 9A | .....dÄ]........
0000:0130 | 20 00 00 00  00 00 02 94  36 7C 10 00  00 00 00 00 |  .......6|......
0000:0140 | 01 B7 70 00  00 00 00 00  02 C3 E5 15  10 00 00 00 | .·p......Ãå.....
0000:0150 | 00 00 01 D4  C0 00 00 00  00 00 02 F3  EE 56 10 00 | ...ÔÀ......óîV..
0000:0160 | 00 00 00 00  01 F2 00 00  00 00 00 00  03 23 B2 77 | .....ò.......#²w
0000:0170 | 10 00 00 00  00 00 02 0F  50 00 00 00  00 00 03 53 | ........P......S
0000:0180 | 78 02 10 00  00 00 00 00  02 2C A0 00  00 00 00 00 | x........, .....
0000:0190 | 03 83 A9 4D  10 00 00 00  00 00 02 49  F0 00 00 00 | ..©M.......Ið...
0000:01A0 | 00 00 03 B2  CA 1E 10 00  00 00 00 00  02 67 30 00 | ...²Ê........g0.
0000:01B0 | 00 00 00 00  03 E2 21 59  10 00 00 00  00 00 02 84 | .....â!Y........
0000:01C0 | 80 00 00 00  00 00 04 11  6A 20 10 00  00 00 00 00 | ........j ......
0000:01D0 | 02 A1 D0 00  00 00 00 00  04 40 99 8E  10 00 00 00 | .¡Ð......@......
0000:01E0 | 00 00 02 BF  20 00 00 00  00 00 04 70  26 72 10 00 | ...¿ ......p&r..
0000:01F0 | 00 00 00 00  02 DC 60 00  00 00 00 00  04 9F AC 04 | .....Ü`.......¬.
0000:0200 | 10 00 00 00  00 00 02 F9  B0 00 00 00  00 00 04 CF | .......ù°......Ï
0000:0210 | 68 DE 10 00  00 00 00 00  03 17 00 00  00 00 00 00 | hÞ..............
0000:0220 | 04 FF BB 39  10 00 00 00  00 00 03 34  50 00 00 00 | .ÿ»9.......4P...
0000:0230 | 00 00 05 30  0F 68 10 00  00 00 00 00  03 51 90 00 | ...0.h.......Q..
0000:0240 | 00 00 00 00  05 5F BE 20  10 00 00 00  00 00 03 6E | ....._¾ .......n
0000:0250 | E0 00 00 00  00 00 05 8F  2A F4 10 00  00 00 00 00 | à.......*ô......
0000:0260 | 03 8C 30 00  00 00 00 00  05 BE CE 03  10 00 00 00 | ..0......¾Î.....
0000:0270 | 00 00 03 A9  80 00 00 00  00 00 05 EE  42 EF 10 00 | ...©.......îBï..
0000:0280 | 00 00 00 00  03 C6 C0 00  00 00 00 00  06 1E 70 80 | .....ÆÀ.......p.
0000:0290 | 10 00 00 00  00 00 03 E4  10 00 00 00  00 00 06 4E | .......ä.......N
0000:02A0 | 24 95 10 00  00 00 00 00  04 01 60 00  00 00 00 00 | $.........`.....
0000:02B0 | 06 7E 2E 0E  10 00 00 00  00 00 04 1E  B0 00 00 00 | .~..........°...
0000:02C0 | 00 00 06 AE  5B CB 10 00  00 00 00 00  04 3B F0 00 | ...®[Ë.......;ð.
0000:02D0 | 00 00 00 00  06 DD 86 77  10 00 00 00  00 00 04 59 | .....Ý.w.......Y
0000:02E0 | 40 00 00 00  00 00 07 0D  D9 09 10 00  00 00 00 00 | @.......Ù.......
0000:02F0 | 04 76 90 00  00 00 00 00  07 3D 1D 71  10 00 00 00 | .v.......=.q....
0000:0300 | 00 00 04 93  E0 00 00 00  00 00 07 6C  91 E0 10 00 | ....à......l.à..
0000:0310 | 00 00 00 00  04 B1 20 00  00 00 00 00  07 9A A0 3A | .....± ....... :
0000:0320 | 10 00 04 00  00 28 20 00  00 00 72 65  66 65 72 65 | .....( ...refere
0000:0330 | 6E 63 65 20  6C 69 62 46  4C 41 43 20  31 2E 34 2E | nce libFLAC 1.4.
0000:0340 | 33 20 32 30  32 33 30 36  32 33 00 00  00 00 81 00 | 3 20230623......
0000:0350 | 20 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00 |  ...............
0000:0360 | 00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00 | ................
...
0000:2350 | 00 00 FF F8  C3 8C 00 F0  4E FF 89 81  FF 8E 74 FF | ..ÿøÃ..ðNÿ..ÿ.tÿ
0000:2360 | 92 E9 FF 95  46 FF 91 DF  FF 8E A2 FF  86 61 FF 7B | .éÿ.Fÿ.ßÿ.¢ÿ.aÿ{
0000:2370 | 71 E6 9D E5  5C 51 8B 82  7F A0 C1 74  22 E0 5C B9 | qæ.å\Q... Át"à\¹
0000:2380 | 37 01 44 FD  4F D1 7F 19  7F F6 EE B2  25 0A 26 56 | 7.DýOÑ...öî²%.&V
0000:2390 | 9F 5B 33 62  79 5D 10 9D  13 35 7A 15  24 65 0E B4 | .[3by]...5z.$e.´
0000:23A0 | 2A 4B E2 CB  CE E3 CE 5F  29 4C 5D 64  19 3A 10 10 | *KâËÎãÎ_)L]d.:..
0000:23B0 | 59 1D D1 05  A1 08 D6 D0  48 55 8A 5E  6A 7B A4 C2 | Y.Ñ.¡.ÖÐHU.^j{¤Â
0000:23C0 | 40 12 67 E4  60 3E 4B CB  E3 AD 01 86  B8 6B 7B 62 | @.gä`>KËã...¸k{b

Flac overview

  1. Metadata Block Header
    1. <1> Last-metadata-block flag: '1' if this block is the last metadata block before the audio blocks, '0' otherwise.
    2. <7> BLOCK_TYPE
      1. 0 : STREAMINFO
      2. 1 : PADDING
      3. 2 : APPLICATION
      4. 3 : SEEKTABLE
      5. 4 : VORBIS_COMMENT
      6. 5 : CUESHEET
      7. 6 : PICTURE
      8. 7-126 : reserved
      9. 127 : invalid, to avoid confusion with a frame sync code
    3. <24> Length (in bytes) of metadata to follow (does not include the size of the METADATA_BLOCK_HEADER)
  2. Streaminfo Mandatory Metadata Block
    1. <16> The minimum block size (in samples) used in the stream.
    2. <16> The maximum block size (in samples) used in the stream. (Minimum blocksize == maximum blocksize) implies a fixed-blocksize stream.
    3. <24> The minimum frame size (in bytes) used in the stream. May be 0 to imply the value is not known.
    4. <24> The maximum frame size (in bytes) used in the stream. May be 0 to imply the value is not known.
    5. <20> Sample rate in Hz. Though 20 bits are available, the maximum sample rate is limited by the structure of frame headers to 655350Hz. Also, a value of 0 is invalid.
    6. <3> (number of channels)-1. FLAC supports from 1 to 8 channels
    7. <5> (bits per sample)-1. FLAC supports from 4 to 32 bits per sample.
    8. <36> Total samples in stream. 'Samples' means inter-channel sample, i.e. one second of 44.1Khz audio will have 44100 samples regardless of the number of channels. A value of zero here means the number of total samples is unknown.
    9. <128> MD5 signature of the unencoded audio data. This allows the decoder to determine if an error exists in the audio data even when the error does not result in an invalid bitstream.
    10. NOTES
    11. FLAC specifies a minimum block size of 16 and a maximum block size of 65535, meaning the bit patterns corresponding to the numbers 0-15 in the minimum blocksize and maximum blocksize fields are invalid.
  3. Flac format

Decompose test.flac

  1. 0-4 "fLaC" ID Bytes
Metadata Block 0 Streaminfo (Mandatory)
Metadata Block Header 0 (Streaminfo)
Value Hex Description Number Bits
0 "0(b)" Not last Metadata Block 1 Bit
0 "0000000(b)" Streaminfo Block type 7 Bits
34 "000022" Metadata Block length hex 22 24 Bits
Metadata Block Data
Value Hex Description Number Bits
4,096 "1000" The minimum block size (in samples) used in the stream. 16 Bits
4,096 "1000" The maximum block size (in samples) used in the stream. 16 Bits
345 "000159" The minimum frame size (in bytes) used in the stream. May be 0 to imply the value is not known. 24 Bits
7,560 "001D88" The minimum frame size (in bytes) used in the stream. May be 0 to imply the value is not known. 24 Bits
192,000 "2EE00" Sample rate in Hz. Though 20 bits are available, the maximum sample rate is limited by the structure of frame headers to 655350Hz. Also, a value of 0 is invalid. 20 Bits
2 "001(b)" (number of channels)-1. FLAC supports from 1 to 8 channels 3 Bits
24 "10111(b)" (bits per sample)-1. FLAC supports from 4 to 32 bits per sample. 5 Bits
79573200 "004BE30D0" Total samples in stream. 'Samples' means inter-channel sample, i.e. one second of 44.1Khz audio will have 44100 samples regardless of the number of channels. A value of zero here means the number of total samples is unknown. 36 Bits
NA "4FCA4AC4B196E4DE2BA3C866BD20A431" MD5 signature of the unencoded audio data. This allows the decoder to determine if an error exists in the audio data even when the error does not result in an invalid bitstream. 128 Bits
Metadata Block 1 SeekTable
SeekTable The number of seek points is implied by the metadata header 'length' field, i.e. equal to length / 18.
Value Hex Description Number Bits
0 "0" Not last Metadata Block 1 Bit
3 "0000011(b)" SeekTable Block type 7 Bits
756 "0002F4" Number of seek points 42 24 Bits
Metadata Block Data
Value Hex Description Number Bits
0 Seek point
0 "0000000000000000" 0 Seek Point Sample number of first sample in the target frame. 64 Bits
0 "0000000000000000" Offset (in bytes) from the first byte of the first frame header to the first byte of the target frame's header. 64 Bits
4,096 "1000" Number of samples in the target frame. 16 Bits
1 Seek Point
1916928 "00000000001D4000" 1 Seek Point Sample number of first sample in the target frame. 64 Bits
2900681 "00000000002C42C9" Offset (in bytes) from the first byte of the first frame header to the first byte of the target frame's header. 64 Bits
4,096 "1000" Number of samples in the target frame. 16 Bits
2 Seek Point
3837952 "00000000003A9000" 2 Seek Point Sample number of first sample in the target frame. 64 Bits
5943977 "00000000005AB2A9" Offset (in bytes) from the first byte of the first frame header to the first byte of the target frame's header. 64 Bits
0 "1000" Number of samples in the target frame. 16 Bits
3 Seek Point
5758976 "000000000057E000" 3 Seek Point Sample number of first sample in the target frame. 64 Bits
9001272 "0000000000895938" Offset (in bytes) from the first byte of the first frame header to the first byte of the target frame's header. 64 Bits
4,096 "1000" Number of samples in the target frame. 16 Bits
...Last Seek Point
78716928 "0000000004B12000" Last Seek Point Sample number of first sample in the target frame. 64 Bits
127574074 "00000000079AA03A" Offset (in bytes) from the first byte of the first frame header to the first byte of the target frame's header. 64 Bits
4,096 "1000" Number of samples in the target frame. 16 Bits
Metadata Block 2 Vorbis
Metadata Block Header 2 (Voorbis)
Value Hex Description Number Bits
0 "0(b)" Not last Metadata Block 1 Bit
4 "0000100(b)" Voorbis Block type 7 Bits
40 "000028" Metadata Block length 24 Bits

Block Data not Pertinent at this time

Metadata Block 3 Padding
Metadata Block Header 1 (Padding)
Value Hex Description Number Bits
1 "1" Is last Metadata Block 1 Bit
1 "0000001(b)" Padding Block type 7 Bits
8192 "002000" Metadata Block length 24 Bits

Block Data not pertinent

Manual Configure FLAC in Eclipse

  1. cmake project in Eclipse manual confiure. Johnny (talk) 19:16, 6 August 2024 (UTC)
  2. Follow full directions and do CMake first to populate directories.
  3. When updating make command include -C ${ConfigName} om behavior page.
  4. Debugging now.