FLAC on ARM Cortex-M4

Kenny Koller <[email protected]> Thu, 19 Oct 2017 03:25:18 +0000
Newsgroups gmane.comp.audio.compression.flac.user
Message-ID <CAPtqgUxvtAD6DnHG-s9JMEsqUFAwqYwtCzYqpFTPt97YqsVFHg@mail.gmail.com>
--===============2505714383291352033==
Content-Type: multipart/alternative; boundary="001a114dc4c6743216055bdde8be"

--001a114dc4c6743216055bdde8be
Content-Type: text/plain; charset="UTF-8"

I'd like to compress a 32 kHz 16-bit mono using an STM32F4 microcontroller.
My plan is to capture from 500-1000 ms of data, compress, and send the
result over a UART.

I have the arm-none-eabi tools installed on MacOS. I used homebrew to
install autoconf, automake, and libtool. autogen.sh succeeded and I was
able to create my makefiles using the following:


*./configure --build=x86_64-apple-darwin16.7.0 --host=arm-none-eabi
--prefix=$PWD/export CFLAGS="-O3 -mthumb -mcpu=cortex-m4 -lc -lrdimon
-specs=rdimon.specs" --disable-cpplibs --disable-ogg --disable-oggtest
--disable-examples --disable-xmms-plugin*

*  Configuration summary :*

*    FLAC version : ........................ 1.3.2*

*    Host CPU : ............................ arm*
*    Host Vendor : ......................... none*
*    Host OS : ............................. eabi*

*    Compiler is GCC : ..................... yes*
*    GCC version : ......................... 5.4.1*
*    Compiler is Clang : ................... no*
*    SSE optimizations : ................... yes*
*    Asm optimizations : ................... no*
*    Ogg/FLAC support : .................... no*

I'm getting some errors around type mismatches between the declarations and
definitions for example:

*grabbag/cuesheet.c:32:10: error: conflicting types for
'grabbag__cuesheet_msf_to_frame'*
* uint32_t grabbag__cuesheet_msf_to_frame(uint32_t minutes, uint32_t
seconds, uint32_t frames)*
*          ^*
*In file included from ../../include/share/grabbag.h:24:0,*
*                 from grabbag/cuesheet.c:29:*
*../../include/share/grabbag/cuesheet.h:32:10: note: previous declaration
of 'grabbag__cuesheet_msf_to_frame' was here*
* unsigned grabbag__cuesheet_msf_to_frame(unsigned minutes, unsigned
seconds, unsigned frames);*

I can see that the variables in the header are not declared using the
<stdint.h> values.

More broadly though: Assuming I can sort out these errors, am I on the
right track/ My experiments have shown that a compression level of zero
will meet my needs and I have read that encoding is faster than real-time.
Once I have the library built I plan to measure things. But I'm seeing
calls to fprintf etc that I don't need. If I just want encodying functions
but not the general purpose flac tool is there any advice as to how to pare
this back further so I'm only building what I need. I'm not too concerned
about library size as the linker should just pull in what is needed. It's
more that I would like fewer things to debug in the build.

Is it possible to encode on-the-fly? I have 192 KB of RAM. It'd be nice if
I could compress straight to a buffer.

Thanks for reading,

Kenny

--001a114dc4c6743216055bdde8be
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I&#39;d like to compress a 32 kHz 16-bit mono using an STM=
32F4 microcontroller. My plan is to capture from 500-1000 ms of data, compr=
ess, and send the result over a UART.<div><br></div><div>I have the arm-non=
e-eabi tools installed on MacOS. I used homebrew to install autoconf, autom=
ake, and libtool. autogen.sh succeeded and I was able to create my makefile=
s using the following:</div><div><br></div><div><font face=3D"monospace" co=
lor=3D"#38761d"><b>./configure --build=3Dx86_64-apple-darwin16.7.0 --host=
=3Darm-none-eabi --prefix=3D$PWD/export CFLAGS=3D&quot;-O3 -mthumb -mcpu=3D=
cortex-m4 -lc -lrdimon -specs=3Drdimon.specs&quot; --disable-cpplibs --disa=
ble-ogg --disable-oggtest --disable-examples --disable-xmms-plugin<br></b><=
/font></div><div><br></div><div><div><font face=3D"monospace" color=3D"#387=
61d"><b style=3D"">=C2=A0 Configuration summary :</b></font></div><div><fon=
t face=3D"monospace" color=3D"#38761d"><b><br></b></font></div><div><font f=
ace=3D"monospace" color=3D"#38761d"><b>=C2=A0 =C2=A0 FLAC version : .......=
................. 1.3.2</b></font></div><div><font face=3D"monospace" color=
=3D"#38761d"><b><br></b></font></div><div><font face=3D"monospace" color=3D=
"#38761d"><b>=C2=A0 =C2=A0 Host CPU : ............................ arm</b><=
/font></div><div><font face=3D"monospace" color=3D"#38761d"><b>=C2=A0 =C2=
=A0 Host Vendor : ......................... none</b></font></div><div><font=
 face=3D"monospace" color=3D"#38761d"><b>=C2=A0 =C2=A0 Host OS : ..........=
................... eabi</b></font></div><div><font face=3D"monospace" colo=
r=3D"#38761d"><b><br></b></font></div><div><font face=3D"monospace" color=
=3D"#38761d"><b>=C2=A0 =C2=A0 Compiler is GCC : ..................... yes</=
b></font></div><div><font face=3D"monospace" color=3D"#38761d"><b>=C2=A0 =
=C2=A0 GCC version : ......................... 5.4.1</b></font></div><div><=
font face=3D"monospace" color=3D"#38761d"><b>=C2=A0 =C2=A0 Compiler is Clan=
g : ................... no</b></font></div><div><font face=3D"monospace" co=
lor=3D"#38761d"><b>=C2=A0 =C2=A0 SSE optimizations : ................... ye=
s</b></font></div><div><font face=3D"monospace" color=3D"#38761d"><b>=C2=A0=
 =C2=A0 Asm optimizations : ................... no</b></font></div><div><fo=
nt face=3D"monospace" color=3D"#38761d"><b>=C2=A0 =C2=A0 Ogg/FLAC support :=
 .................... no</b></font></div></div><div><br></div><div>I&#39;m =
getting some errors around type mismatches between the declarations and def=
initions for example:</div><div><br></div><div><div><b><font color=3D"#3876=
1d" face=3D"monospace">grabbag/cuesheet.c:32:10: error: conflicting types f=
or &#39;grabbag__cuesheet_msf_to_frame&#39;</font></b></div><div><b><font c=
olor=3D"#38761d" face=3D"monospace">=C2=A0uint32_t grabbag__cuesheet_msf_to=
_frame(uint32_t minutes, uint32_t seconds, uint32_t frames)</font></b></div=
><div><b><font color=3D"#38761d" face=3D"monospace">=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 ^</font></b></div><div><b><font color=3D"#38761d" face=3D"mon=
ospace">In file included from ../../include/share/grabbag.h:24:0,</font></b=
></div><div><b><font color=3D"#38761d" face=3D"monospace">=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0from grabbag/cuesheet.c:29:</f=
ont></b></div><div><b><font color=3D"#38761d" face=3D"monospace">../../incl=
ude/share/grabbag/cuesheet.h:32:10: note: previous declaration of &#39;grab=
bag__cuesheet_msf_to_frame&#39; was here</font></b></div><div><b><font colo=
r=3D"#38761d" face=3D"monospace">=C2=A0unsigned grabbag__cuesheet_msf_to_fr=
ame(unsigned minutes, unsigned seconds, unsigned frames);</font></b></div><=
div><br></div></div><div>I can see that the variables in the header are not=
 declared using the &lt;stdint.h&gt; values.</div><div><br></div><div>More =
broadly though: Assuming I can sort out these errors, am I on the right tra=
ck/ My experiments have shown that a compression level of zero will meet my=
 needs and I have read that encoding is faster than real-time. Once I have =
the library built I plan to measure things. But I&#39;m seeing calls to fpr=
intf etc that I don&#39;t need. If I just want encodying functions but not =
the general purpose flac tool is there any advice as to how to pare this ba=
ck further so I&#39;m only building what I need. I&#39;m not too concerned =
about library size as the linker should just pull in what is needed. It&#39=
;s more that I would like fewer things to debug in the build.</div><div><br=
></div><div>Is it possible to encode on-the-fly? I have 192 KB of RAM. It&#=
39;d be nice if I could compress straight to a buffer.</div><div><br></div>=
<div>Thanks for reading,</div><div><br></div><div>Kenny</div></div>

--001a114dc4c6743216055bdde8be--

--===============2505714383291352033==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KRmxhYyBtYWls
aW5nIGxpc3QKRmxhY0B4aXBoLm9yZwpodHRwOi8vbGlzdHMueGlwaC5vcmcvbWFpbG1hbi9saXN0
aW5mby9mbGFjCg==

--===============2505714383291352033==--