removed codecs to save memory

This commit is contained in:
Stefan Ostermann 2025-07-06 21:25:41 +02:00
parent 6022655198
commit fe04474ed8
104 changed files with 64077 additions and 0 deletions

View File

@ -0,0 +1,9 @@
get_filename_component(dir ${CMAKE_CURRENT_LIST_FILE} PATH)
FILE(GLOB_RECURSE app_sources ${dir}/src/*.cpp)
idf_component_register(SRCS ${app_sources}
REQUIRES "ESP32-audioI2S"
INCLUDE_DIRS "src"
REQUIRES wear_levelling Arduino
)

674
lib/ESP32-audioI2S/LICENSE Normal file
View File

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

View File

@ -0,0 +1,184 @@
# ESP32-audioI2S
:warning: **This library only works on multi-core chips like ESP32, ESP32-S3 and ESP32-P4. It does not work on the ESP32-S2, ESP32-C3 etc** :warning:
Plays mp3, m4a and wav files from SD card via I2S with external hardware.
HELIX-mp3 and -aac decoder is included. There is also an OPUS decoder for Fullband, n VORBIS decoder and a FLAC decoder.
Works with MAX98357A (3 Watt amplifier with DAC), connected three lines (DOUT, BLCK, LRC) to I2S.
For stereo are two MAX98357A necessary. AudioI2S works with UDA1334A (Adafruit I2S Stereo Decoder Breakout Board), PCM5102A and CS4344.
Other HW may work but not tested. Plays also icy-streams and GoogleTTS. Can be compiled with Arduino IDE. [WIKI](https://github.com/schreibfaul1/ESP32-audioI2S/wiki)
```` c++
#include "Arduino.h"
#include "WiFi.h"
#include "Audio.h"
#include "SD.h"
#include "FS.h"
// Digital I/O used
#define SD_CS 5
#define SPI_MOSI 23
#define SPI_MISO 19
#define SPI_SCK 18
#define I2S_DOUT 25
#define I2S_BCLK 27
#define I2S_LRC 26
Audio audio;
String ssid = "*******";
String password = "*******";
void setup() {
pinMode(SD_CS, OUTPUT); digitalWrite(SD_CS, HIGH);
SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI);
Serial.begin(115200);
SD.begin(SD_CS);
WiFi.disconnect();
WiFi.mode(WIFI_STA);
WiFi.begin(ssid.c_str(), password.c_str());
while (WiFi.status() != WL_CONNECTED) delay(1500);
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
audio.setVolume(21); // default 0...21
// or alternative
// audio.setVolumeSteps(64); // max 255
// audio.setVolume(63);
//
// *** radio streams ***
audio.connecttohost("http://stream.antennethueringen.de/live/aac-64/stream.antennethueringen.de/"); // aac
// audio.connecttohost("http://mcrscast.mcr.iol.pt/cidadefm"); // mp3
// audio.connecttohost("http://www.wdr.de/wdrlive/media/einslive.m3u"); // m3u
// audio.connecttohost("https://stream.srg-ssr.ch/rsp/aacp_48.asx"); // asx
// audio.connecttohost("http://tuner.classical102.com/listen.pls"); // pls
// audio.connecttohost("http://stream.radioparadise.com/flac"); // flac
// audio.connecttohost("http://stream.sing-sing-bis.org:8000/singsingFlac"); // flac (ogg)
// audio.connecttohost("http://s1.knixx.fm:5347/dein_webradio_vbr.opus"); // opus (ogg)
// audio.connecttohost("http://stream2.dancewave.online:8080/dance.ogg"); // vorbis (ogg)
// audio.connecttohost("http://26373.live.streamtheworld.com:3690/XHQQ_FMAAC/HLSTS/playlist.m3u8"); // HLS
// audio.connecttohost("http://eldoradolive02.akamaized.net/hls/live/2043453/eldorado/master.m3u8"); // HLS (ts)
// *** web files ***
// audio.connecttohost("https://github.com/schreibfaul1/ESP32-audioI2S/raw/master/additional_info/Testfiles/Pink-Panther.wav"); // wav
// audio.connecttohost("https://github.com/schreibfaul1/ESP32-audioI2S/raw/master/additional_info/Testfiles/Santiano-Wellerman.flac"); // flac
// audio.connecttohost("https://github.com/schreibfaul1/ESP32-audioI2S/raw/master/additional_info/Testfiles/Olsen-Banden.mp3"); // mp3
// audio.connecttohost("https://github.com/schreibfaul1/ESP32-audioI2S/raw/master/additional_info/Testfiles/Miss-Marple.m4a"); // m4a (aac)
// audio.connecttohost("https://github.com/schreibfaul1/ESP32-audioI2S/raw/master/additional_info/Testfiles/Collide.ogg"); // vorbis
// audio.connecttohost("https://github.com/schreibfaul1/ESP32-audioI2S/raw/master/additional_info/Testfiles/sample.opus"); // opus
// *** local files ***
// audio.connecttoFS(SD, "/test.wav"); // SD
// audio.connecttoFS(SD_MMC, "/test.wav"); // SD_MMC
// audio.connecttoFS(SPIFFS, "/test.wav"); // SPIFFS
// audio.connecttospeech("Wenn die Hunde schlafen, kann der Wolf gut Schafe stehlen.", "de"); // Google TTS
}
void loop(){
audio.loop();
vTaskDelay(1);
}
// optional
void audio_info(const char *info){
Serial.print("info "); Serial.println(info);
}
void audio_id3data(const char *info){ //id3 metadata
Serial.print("id3data ");Serial.println(info);
}
void audio_eof_mp3(const char *info){ //end of file
Serial.print("eof_mp3 ");Serial.println(info);
}
void audio_showstation(const char *info){
Serial.print("station ");Serial.println(info);
}
void audio_showstreamtitle(const char *info){
Serial.print("streamtitle ");Serial.println(info);
}
void audio_bitrate(const char *info){
Serial.print("bitrate ");Serial.println(info);
}
void audio_commercial(const char *info){ //duration in sec
Serial.print("commercial ");Serial.println(info);
}
void audio_icyurl(const char *info){ //homepage
Serial.print("icyurl ");Serial.println(info);
}
void audio_lasthost(const char *info){ //stream URL played
Serial.print("lasthost ");Serial.println(info);
}
void audio_eof_speech(const char *info){
Serial.print("eof_speech ");Serial.println(info);
}
````
````c++
/* ESP32-S3, ESP32-P4 EXAMPLE */
#include "Arduino.h"
#include "Audio.h"
#include "WiFi.h"
#include "SD_MMC.h"
#define I2S_DOUT 9
#define I2S_BCLK 3
#define I2S_LRC 1
#define SD_MMC_D0 11
#define SD_MMC_CLK 13
#define SD_MMC_CMD 14
Audio audio;
String ssid = "*****";
String password = "*****";
void setup() {
Serial.begin(115200);
// WiFi.begin(ssid.c_str(), password.c_str());
// while (WiFi.status() != WL_CONNECTED) delay(1500);
pinMode(SD_MMC_D0, INPUT_PULLUP);
SD_MMC.setPins(SD_MMC_CLK, SD_MMC_CMD, SD_MMC_D0);
SD_MMC.begin("/sdcard", true);
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
audio.setVolume(12); // default 0...21
// audio.connecttohost("http://stream.antennethueringen.de/live/aac-64/stream.antennethueringen.de/"); // aac
audio.connecttoFS(SD_MMC, "/test.wav");
}
void loop() {
audio.loop();
vTaskDelay(1);
}
// optional
void audio_info(const char *info){
Serial.print("info "); Serial.println(info);
}
````
<br>
|Codec |ESP32 |ESP32 PSRAM |ESP32-S3 or ESP32-P4 + PSRAM | |
|------------|-------|-------------|-----------------------------|--------------------------|
| mp3 | y | y | y | |
| aac | n | y | y | |
| aacp | n | y (mono) | y (+SBR, +Parametric Stereo)| |
| wav | y | y | y | |
| flac | n | y | y |blocksize max 24576 bytes |
| vorbis | n | y | y | <=196Kbit/s |
| m4a | n | y | y | |
| opus | n | y | y |celt only |
<br>
***
Wiring
![Wiring ESP32-S3](https://github.com/user-attachments/assets/15dd1766-0fc1-4079-b378-bc566583e80d)
***
Impulse diagram
![Impulse diagram](https://github.com/schreibfaul1/ESP32-audioI2S/blob/master/additional_info/Impulsdiagramm.jpg)
***
Yellobyte has developed an all-in-one board. It includes an ESP32-S3 N8R2, 2x MAX98357 and an SD card adapter.
Documentation, circuit diagrams and examples can be found here: https://github.com/yellobyte/ESP32-DevBoards-Getting-Started
![image](https://github.com/user-attachments/assets/4002d09e-8e76-4e08-9265-188fed7628d3)

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 309 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 337 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 177 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 381 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

View File

@ -0,0 +1,5 @@
#EXTM3U
#EXTINF:18,Bjarne Liller - Olsen Banden (Titelmusik der Olsenbande) - Olsen-Banden.mp3
https://raw.githubusercontent.com/schreibfaul1/ESP32-audioI2S/master/additional_info/Testfiles/Olsen-Banden.mp3
#EXTINF:10,Santiano-Wellermann - Santiano-Wellerman.flac
https://raw.githubusercontent.com/schreibfaul1/ESP32-audioI2S/master/additional_info/Testfiles/Santiano-Wellerman.flac

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -0,0 +1,352 @@
/*
AC101 - An AC101 Codec driver library for Arduino
Copyright (C) 2019, Ivo Pullens, Emmission
Inspired by:
https://github.com/donny681/esp-adf/tree/master/components/audio_hal/driver/AC101
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Febr 2021 modified by schreibfaul1 - set correct pll values
March 2021 modified by schreibfaul1 - can handle two i2c instances
May 2021 modified by schreibfaul1 - constructor changed
Oct 2021 modified by schreibfaul1 - I2C wrong ACK in ReadReg
Jan 2022 modified by schreibfaul1 - left right channel swapped
Jan 2022 modified by schreibfaul1 - suppress compiler warning: left shift of negative value
examples:
//one I2C bus: (default behaviour)
AC101 ac;
ac.begin(sda, scl);
//two I2C busses:
TwoWire i2cBusOne = TwoWire(0);
TwoWire i2cBusTwo = TwoWire(1);
AC101 ac(&i2cBusOne);
i2cBusOne.begin(sda, scl, 400000);
*/
#include "AC101.h"
#define BCLK // clock over BCLK comment out: clock over MCLK
#define AC101_ADDR 0x1A // Device address
#define CHIP_AUDIO_RS 0x00
#define PLL_CTRL1 0x01
#define PLL_CTRL2 0x02
#define SYSCLK_CTRL 0x03
#define MOD_CLK_ENA 0x04
#define MOD_RST_CTRL 0x05
#define I2S_SR_CTRL 0x06
#define I2S1LCK_CTRL 0x10
#define I2S1_SDOUT_CTRL 0x11
#define I2S1_SDIN_CTRL 0x12
#define I2S1_MXR_SRC 0x13
#define I2S1_VOL_CTRL1 0x14
#define I2S1_VOL_CTRL2 0x15
#define I2S1_VOL_CTRL3 0x16
#define I2S1_VOL_CTRL4 0x17
#define I2S1_MXR_GAIN 0x18
#define ADC_DIG_CTRL 0x40
#define ADC_VOL_CTRL 0x41
#define HMIC_CTRL1 0x44
#define HMIC_CTRL2 0x45
#define HMIC_STATUS 0x46
#define DAC_DIG_CTRL 0x48
#define DAC_VOL_CTRL 0x49
#define DAC_MXR_SRC 0x4C
#define DAC_MXR_GAIN 0x4D
#define ADC_APC_CTRL 0x50
#define ADC_SRC 0x51
#define ADC_SRCBST_CTRL 0x52
#define OMIXER_DACA_CTRL 0x53
#define OMIXER_SR 0x54
#define OMIXER_BST1_CTRL 0x55
#define HPOUT_CTRL 0x56
#define SPKOUT_CTRL 0x58
#define AC_DAC_DAPCTRL 0xA0
#define AC_DAC_DAPHHPFC 0xA1
#define AC_DAC_DAPLHPFC 0xA2
#define AC_DAC_DAPLHAVC 0xA3
#define AC_DAC_DAPLLAVC 0xA4
#define AC_DAC_DAPRHAVC 0xA5
#define AC_DAC_DAPRLAVC 0xA6
#define AC_DAC_DAPHGDEC 0xA7
#define AC_DAC_DAPLGDEC 0xA8
#define AC_DAC_DAPHGATC 0xA9
#define AC_DAC_DAPLGATC 0xAA
#define AC_DAC_DAPHETHD 0xAB
#define AC_DAC_DAPLETHD 0xAC
#define AC_DAC_DAPHGKPA 0xAD
#define AC_DAC_DAPLGKPA 0xAE
#define AC_DAC_DAPHGOPA 0xAF
#define AC_DAC_DAPLGOPA 0xB0
#define AC_DAC_DAPOPT 0xB1
#define DAC_DAP_ENA 0xB5
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
const uint8_t regs[] = {
CHIP_AUDIO_RS ,
PLL_CTRL1 ,
PLL_CTRL2 ,
SYSCLK_CTRL ,
MOD_CLK_ENA ,
MOD_RST_CTRL ,
I2S_SR_CTRL ,
I2S1LCK_CTRL ,
I2S1_SDOUT_CTRL ,
I2S1_SDIN_CTRL ,
I2S1_MXR_SRC ,
I2S1_VOL_CTRL1 ,
I2S1_VOL_CTRL2 ,
I2S1_VOL_CTRL3 ,
I2S1_VOL_CTRL4 ,
I2S1_MXR_GAIN ,
ADC_DIG_CTRL ,
ADC_VOL_CTRL ,
HMIC_CTRL1 ,
HMIC_CTRL2 ,
HMIC_STATUS ,
DAC_DIG_CTRL ,
DAC_VOL_CTRL ,
DAC_MXR_SRC ,
DAC_MXR_GAIN ,
ADC_APC_CTRL ,
ADC_SRC ,
ADC_SRCBST_CTRL ,
OMIXER_DACA_CTRL ,
OMIXER_SR ,
OMIXER_BST1_CTRL ,
HPOUT_CTRL ,
SPKOUT_CTRL ,
AC_DAC_DAPCTRL ,
AC_DAC_DAPHHPFC ,
AC_DAC_DAPLHPFC ,
AC_DAC_DAPLHAVC ,
AC_DAC_DAPLLAVC ,
AC_DAC_DAPRHAVC ,
AC_DAC_DAPRLAVC ,
AC_DAC_DAPHGDEC ,
AC_DAC_DAPLGDEC ,
AC_DAC_DAPHGATC ,
AC_DAC_DAPLGATC ,
AC_DAC_DAPHETHD ,
AC_DAC_DAPLETHD ,
AC_DAC_DAPHGKPA ,
AC_DAC_DAPLGKPA ,
AC_DAC_DAPHGOPA ,
AC_DAC_DAPLGOPA ,
AC_DAC_DAPOPT ,
DAC_DAP_ENA
};
//----------------------------------------------------------------------------------------------------------------------
bool AC101::WriteReg(uint8_t reg, uint16_t val)
{
_TwoWireInstance->beginTransmission(AC101_ADDR);
_TwoWireInstance->write(reg);
_TwoWireInstance->write(uint8_t((val >> 8) & 0xff));
_TwoWireInstance->write(uint8_t(val & 0xff));
return 0 == _TwoWireInstance->endTransmission(true);
}
uint16_t AC101::ReadReg(uint8_t reg)
{
_TwoWireInstance->beginTransmission(AC101_ADDR);
_TwoWireInstance->write(reg);
_TwoWireInstance->endTransmission(false);
uint16_t val = 0u;
if (2 == _TwoWireInstance->requestFrom(uint16_t(AC101_ADDR), uint8_t(2)))
{
val = uint16_t(_TwoWireInstance->read() << 8) + uint16_t(_TwoWireInstance->read());
}
_TwoWireInstance->endTransmission(true);
return val;
}
//----------------------------------------------------------------------------------------------------------------------
AC101::AC101( TwoWire *TwoWireInstance ){
_TwoWireInstance = TwoWireInstance;
}
//----------------------------------------------------------------------------------------------------------------------
bool AC101::begin(int32_t sda, int32_t scl, uint32_t frequency) {
bool ok;
if((sda >= 0) && (scl >= 0)){
ok = _TwoWireInstance->begin(sda, scl, frequency);
}
else {
ok = true;
}
// Reset all registers, readback default as sanity check
ok &= WriteReg(CHIP_AUDIO_RS, 0x123);
delay(100);
ok &= 0x0101 == ReadReg(CHIP_AUDIO_RS);
ok &= WriteReg(SPKOUT_CTRL, 0xe880);
// Enable the PLL from 256*44.1KHz MCLK source
ok &= WriteReg(PLL_CTRL1, 0x0141);
uint16_t N = 48 << 4; /* 512 / (M * (2*K+1)) / (CHANNELS * WORD_SIZE) -> 512 / 3 * (2 * 16) */
uint16_t PLL_EN = 1 << 15;
uint16_t N_f = 0<<0; /* 0.2 N */
ok &= WriteReg(PLL_CTRL2, N | PLL_EN | N_f);
// Clocking system
uint16_t PLLCLK_ENA = 1<<15; /* 0: Disable, 1: Enable */
#ifdef BCLK
uint16_t PLL_CLK = 0x2 << 12; /* bclk1 */
uint16_t I2S1CLK_SRC = 0x3<<8; /* PLL */
#else
uint16_t PLL_CLK = 0x0 << 12; /* MCLK1 */
uint16_t I2S1CLK_SRC = 0x0<<8; /* MLCK1 */
#endif
uint16_t I2S1CLK_ENA = 1<<11; /* 0: Disable, 1: Enable */
uint16_t SYSCLK_ENA = 1<<3;
ok &= WriteReg(SYSCLK_CTRL, PLLCLK_ENA|PLL_CLK| I2S1CLK_ENA|I2S1CLK_SRC|SYSCLK_ENA/*0x8b08*/);
ok &= WriteReg(MOD_CLK_ENA, 0x800c);
ok &= WriteReg(MOD_RST_CTRL, 0x800c);
// Set default at I2S, 44.1KHz, 16bit
ok &= SetI2sSampleRate(SAMPLE_RATE_44100);
ok &= SetI2sClock(BCLK_DIV_8, false, LRCK_DIV_32, false);
ok &= SetI2sMode(MODE_SLAVE);
ok &= SetI2sWordSize(WORD_SIZE_16_BITS);
ok &= SetI2sFormat(DATA_FORMAT_I2S);
// AIF config
ok &= WriteReg(I2S1_SDOUT_CTRL, 0xc000);
ok &= WriteReg(I2S1_SDIN_CTRL, 0xc000);
ok &= WriteReg(I2S1_MXR_SRC, 0x2200);
ok &= WriteReg(ADC_SRCBST_CTRL, 0xccc4);
ok &= WriteReg(ADC_SRC, 0x1040);
ok &= WriteReg(ADC_DIG_CTRL, 0x8000);
ok &= WriteReg(ADC_APC_CTRL, 0xbbc3);
// Path Configuration
ok &= WriteReg(DAC_MXR_SRC, 0xcc00);
ok &= WriteReg(DAC_DIG_CTRL, 0x8000);
ok &= WriteReg(OMIXER_SR, 0x0081);
ok &= WriteReg(OMIXER_DACA_CTRL, 0xf080);
ok &= SetMode( MODE_DAC );
return ok;
}
//----------------------------------------------------------------------------------------------------------------------
void AC101::DumpRegisters() {
for (size_t i = 0; i < ARRAY_SIZE(regs); ++i){
Serial.print(regs[i], HEX);
Serial.print(" = ");
Serial.println(ReadReg(regs[i]), HEX);
}
}
//----------------------------------------------------------------------------------------------------------------------
uint8_t AC101::GetVolumeSpeaker() {
// Times 2, to scale to same range as headphone volume
return (ReadReg(SPKOUT_CTRL) & 31) * 2;
}
bool AC101::SetVolumeSpeaker(uint8_t volume) {
// Divide by 2, as it is scaled to same range as headphone volume
volume /= 2;
if(volume > 31) volume = 31;
uint16_t val = ReadReg(SPKOUT_CTRL);
val &= ~31;
val |= volume;
return WriteReg(SPKOUT_CTRL, val);
}
//----------------------------------------------------------------------------------------------------------------------
uint8_t AC101::GetVolumeHeadphone() {
return (ReadReg(HPOUT_CTRL) >> 4) & 63;
}
bool AC101::SetVolumeHeadphone(uint8_t volume) {
if(volume > 63) volume = 63;
uint16_t val = ReadReg(HPOUT_CTRL);
val &= ~63U << 4;
val |= volume << 4;
return WriteReg(HPOUT_CTRL, val);
}
//----------------------------------------------------------------------------------------------------------------------
bool AC101::SetI2sSampleRate(I2sSampleRate_t rate) {
return WriteReg(I2S_SR_CTRL, rate);
}
//----------------------------------------------------------------------------------------------------------------------
bool AC101::SetI2sMode(I2sMode_t mode) {
uint16_t val = ReadReg(I2S1LCK_CTRL);
val &= ~0x8000;
val |= uint16_t(mode) << 15;
return WriteReg(I2S1LCK_CTRL, val);
}
//----------------------------------------------------------------------------------------------------------------------
bool AC101::SetI2sWordSize(I2sWordSize_t size) {
uint16_t val = ReadReg(I2S1LCK_CTRL);
val &= ~0x0030;
val |= uint16_t(size) << 4;
return WriteReg(I2S1LCK_CTRL, val);
}
//----------------------------------------------------------------------------------------------------------------------
bool AC101::SetI2sFormat(I2sFormat_t format) {
uint16_t val = ReadReg(I2S1LCK_CTRL);
val &= ~0x000C;
val |= uint16_t(format) << 2;
return WriteReg(I2S1LCK_CTRL, val);
}
//----------------------------------------------------------------------------------------------------------------------
bool AC101::SetI2sClock(I2sBitClockDiv_t bitClockDiv, bool bitClockInv, I2sLrClockDiv_t lrClockDiv, bool lrClockInv) {
uint16_t val = ReadReg(I2S1LCK_CTRL);
val &= ~0x7FC0;
val |= uint16_t(bitClockInv ? 1 : 0) << 14;
val |= uint16_t(bitClockDiv) << 9;
val |= uint16_t(lrClockInv ? 1 : 0) << 13;
val |= uint16_t(lrClockDiv) << 6;
return WriteReg(I2S1LCK_CTRL, val);
}
//----------------------------------------------------------------------------------------------------------------------
bool AC101::SetMode(Mode_t mode) {
bool ok = true;
if(MODE_LINE == mode) {
ok &= WriteReg(ADC_SRC, 0x0408);
ok &= WriteReg(ADC_DIG_CTRL, 0x8000);
ok &= WriteReg(ADC_APC_CTRL, 0x3bc0);
}
if((MODE_ADC == mode) or (MODE_ADC_DAC == mode) or (MODE_LINE == mode)) {
ok &= WriteReg(MOD_CLK_ENA, 0x800c);
ok &= WriteReg(MOD_RST_CTRL, 0x800c);
}
if((MODE_DAC == mode) or (MODE_ADC_DAC == mode) or (MODE_LINE == mode)) {
// Enable Headphone output
ok &= WriteReg(OMIXER_DACA_CTRL, 0xff80);
ok &= WriteReg(HPOUT_CTRL, 0xc3c1);
ok &= WriteReg(HPOUT_CTRL, 0xcb00);
delay(100);
ok &= WriteReg(HPOUT_CTRL, 0xfbc0);
ok &= SetVolumeHeadphone(30);
// Enable Speaker output
ok &= WriteReg(SPKOUT_CTRL, 0xeabd);
delay(10);
ok &= SetVolumeSpeaker(30);
}
return ok;
}

View File

@ -0,0 +1,166 @@
/*
AC101 - An AC101 Codec driver library for Arduino
Copyright (C) 2019, Ivo Pullens, Emmission
Inspired by:
https://github.com/donny681/esp-adf/tree/master/components/audio_hal/driver/AC101
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef AC101_H
#define AC101_H
#include <Arduino.h>
#include <inttypes.h>
#include <Wire.h>
class AC101
{
public:
typedef enum {
SAMPLE_RATE_8000 = 0x0000,
SAMPLE_RATE_11052 = 0x1000,
SAMPLE_RATE_12000 = 0x2000,
SAMPLE_RATE_16000 = 0x3000,
SAMPLE_RATE_22050 = 0x4000,
SAMPLE_RATE_24000 = 0x5000,
SAMPLE_RATE_32000 = 0x6000,
SAMPLE_RATE_44100 = 0x7000,
SAMPLE_RATE_48000 = 0x8000,
SAMPLE_RATE_96000 = 0x9000,
SAMPLE_RATE_192000 = 0xa000,
} I2sSampleRate_t;
typedef enum {
MODE_MASTER = 0x00,
MODE_SLAVE = 0x01,
} I2sMode_t;
typedef enum {
WORD_SIZE_8_BITS = 0x00,
WORD_SIZE_16_BITS = 0x01,
WORD_SIZE_20_BITS = 0x02,
WORD_SIZE_24_BITS = 0x03,
} I2sWordSize_t;
typedef enum {
DATA_FORMAT_I2S = 0x00,
DATA_FORMAT_LEFT = 0x01,
DATA_FORMAT_RIGHT = 0x02,
DATA_FORMAT_DSP = 0x03,
} I2sFormat_t;
typedef enum {
BCLK_DIV_1 = 0x0,
BCLK_DIV_2 = 0x1,
BCLK_DIV_4 = 0x2,
BCLK_DIV_6 = 0x3,
BCLK_DIV_8 = 0x4,
BCLK_DIV_12 = 0x5,
BCLK_DIV_16 = 0x6,
BCLK_DIV_24 = 0x7,
BCLK_DIV_32 = 0x8,
BCLK_DIV_48 = 0x9,
BCLK_DIV_64 = 0xa,
BCLK_DIV_96 = 0xb,
BCLK_DIV_128 = 0xc,
BCLK_DIV_192 = 0xd,
} I2sBitClockDiv_t;
typedef enum {
LRCK_DIV_16 = 0x0,
LRCK_DIV_32 = 0x1,
LRCK_DIV_64 = 0x2,
LRCK_DIV_128 = 0x3,
LRCK_DIV_256 = 0x4,
} I2sLrClockDiv_t;
typedef enum {
MODE_ADC,
MODE_DAC,
MODE_ADC_DAC,
MODE_LINE
} Mode_t;
// Constructor.
AC101(TwoWire *TwoWireInstance = &Wire);
// Initialize codec, using provided I2C pins and bus frequency.
// @return True on success, false on failure.
bool begin(int32_t sda = -1, int32_t scl = -1, uint32_t frequency = 400000);
// Get speaker volume.
// @return Speaker volume, [63..0] for [0..-43.5] [dB], in increments of 2.
uint8_t GetVolumeSpeaker();
// Set speaker volume.
// @param volume Target volume, [63..0] for [0..-43.5] [dB], in increments of 2.
// @return True on success, false on failure.
bool SetVolumeSpeaker(uint8_t volume);
// Get headphone volume.
// @return Headphone volume, [63..0] for [0..-62] [dB]
uint8_t GetVolumeHeadphone();
// Set headphone volume
// @param volume Target volume, [63..0] for [0..-62] [dB]
// @return True on success, false on failure.
bool SetVolumeHeadphone(uint8_t volume);
// Configure I2S samplerate.
// @param rate Samplerate.
// @return True on success, false on failure.
bool SetI2sSampleRate(I2sSampleRate_t rate);
// Configure I2S mode (master/slave).
// @param mode Mode.
// @return True on success, false on failure.
bool SetI2sMode(I2sMode_t mode);
// Configure I2S word size (8/16/20/24 bits).
// @param size Word size.
// @return True on success, false on failure.
bool SetI2sWordSize(I2sWordSize_t size);
// Configure I2S format (I2S/Left/Right/Dsp).
// @param format I2S format.
// @return True on success, false on failure.
bool SetI2sFormat(I2sFormat_t format);
// Configure I2S clock.
// @param bitClockDiv I2S1CLK/BCLK1 ratio.
// @param bitClockInv I2S1 BCLK Polarity.
// @param lrClockDiv BCLK1/LRCK ratio.
// @param lrClockInv I2S1 LRCK Polarity.
// @return True on success, false on failure.
bool SetI2sClock(I2sBitClockDiv_t bitClockDiv, bool bitClockInv, I2sLrClockDiv_t lrClockDiv, bool lrClockInv);
// Configure the mode (Adc/Dac/Adc+Dac/Line)
// @param mode Operating mode.
// @return True on success, false on failure.
bool SetMode(Mode_t mode);
// Dumpt the current register configuration to serial.
void DumpRegisters();
protected:
bool WriteReg(uint8_t reg, uint16_t val);
uint16_t ReadReg(uint8_t reg);
private:
TwoWire *_TwoWireInstance = NULL; // TwoWire Instance
};
#endif

View File

@ -0,0 +1,116 @@
#include "Arduino.h"
#include "WiFi.h"
#include "SPI.h"
#include "SD.h"
#include "FS.h"
#include "Wire.h"
#include "AC101.h"
#include "Audio.h"
// I2S GPIOs, the names refer on AC101, AS1 Audio Kit V2.2 2379
#define I2S_DSIN 35 // pin not used
#define I2S_BCLK 27
#define I2S_LRC 26
#define I2S_MCLK 0
#define I2S_DOUT 25
// I2C GPIOs
#define IIC_CLK 32
#define IIC_DATA 33
// amplifier enable
#define GPIO_PA_EN 21
//Switch S1: 1-OFF, 2-ON, 3-ON, 4-OFF, 5-OFF
String ssid = "*****";
String password = "*****";
static AC101 dac; // AC101
int volume = 40; // 0...100
Audio audio;
//#####################################################################
void setup()
{
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid.c_str(), password.c_str());
while (WiFi.status() != WL_CONNECTED)
{
Serial.print(".");
delay(100);
}
Serial.printf_P(PSTR("Connected\r\nRSSI: "));
Serial.print(WiFi.RSSI());
Serial.print(" IP: ");
Serial.println(WiFi.localIP());
Serial.printf("Connect to DAC codec... ");
while (not dac.begin(IIC_DATA, IIC_CLK))
{
Serial.printf("Failed!\n");
delay(1000);
}
Serial.printf("OK\n");
dac.SetVolumeSpeaker(volume);
dac.SetVolumeHeadphone(volume);
// ac.DumpRegisters();
// Enable amplifier
pinMode(GPIO_PA_EN, OUTPUT);
digitalWrite(GPIO_PA_EN, HIGH);
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT, I2S_MCLK);
audio.setVolume(10); // 0...21
audio.connecttohost("http://mp3channels.webradio.antenne.de:80/oldies-but-goldies");
// audio.connecttohost("http://dg-rbb-http-dus-dtag-cdn.cast.addradio.de/rbb/antennebrandenburg/live/mp3/128/stream.mp3");
// audio.connecttospeech("Wenn die Hunde schlafen, kann der Wolf gut Schafe stehlen.", "de");
}
//-----------------------------------------------------------------------
void loop(){
vTaskDelay(1);
audio.loop();
}
// optional
void audio_info(const char *info){
Serial.print("info "); Serial.println(info);
}
void audio_id3data(const char *info){ //id3 metadata
Serial.print("id3data ");Serial.println(info);
}
void audio_eof_mp3(const char *info){ //end of file
Serial.print("eof_mp3 ");Serial.println(info);
}
void audio_showstation(const char *info){
Serial.print("station ");Serial.println(info);
}
void audio_showstreamtitle(const char *info){
Serial.print("streamtitle ");Serial.println(info);
}
void audio_bitrate(const char *info){
Serial.print("bitrate ");Serial.println(info);
}
void audio_commercial(const char *info){ //duration in sec
Serial.print("commercial ");Serial.println(info);
}
void audio_icyurl(const char *info){ //homepage
Serial.print("icyurl ");Serial.println(info);
}
void audio_lasthost(const char *info){ //stream URL played
Serial.print("lasthost ");Serial.println(info);
}
void audio_eof_speech(const char *info){
Serial.print("eof_speech ");Serial.println(info);
}

View File

@ -0,0 +1,504 @@
//
// !!! WARNING !!! AUTO-GENERATED FILE!
// PLEASE DO NOT MODIFY IT AND USE "platformio.ini":
// https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags
//
{
"configurations": [
{
"name": "PlatformIO",
"includePath": [
"/media/wolle/DRIVE-N-GO/platformio-workspace/ESP32_WebServer/include",
"/media/wolle/DRIVE-N-GO/platformio-workspace/ESP32_WebServer/src",
"/media/wolle/DRIVE-N-GO/platformio-workspace/ESP32_WebServer/lib/websrv",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/SD/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/SPI/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/FS/src",
"/media/wolle/DRIVE-N-GO/platformio-workspace/ESP32_WebServer/.pio/libdeps/esp32dev/Arduino_JSON/src",
"/media/wolle/DRIVE-N-GO/platformio-workspace/ESP32_WebServer/.pio/libdeps/esp32dev/SoapESP32/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/WiFi/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/newlib/platform_include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/freertos/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/freertos/include/esp_additions/freertos",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/freertos/port/xtensa/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/freertos/include/esp_additions",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_hw_support/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_hw_support/include/soc",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_hw_support/port/esp32",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_hw_support/port/esp32/private_include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/heap/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/log/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/lwip/include/apps",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/lwip/include/apps/sntp",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/lwip/lwip/src/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/lwip/port/esp32/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/lwip/port/esp32/include/arch",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/soc/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/soc/esp32",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/soc/esp32/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/hal/esp32/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/hal/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/hal/platform_port/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_rom/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_rom/include/esp32",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_rom/esp32",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_common/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_system/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_system/port/soc",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_system/port/public_compat",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp32/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/xtensa/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/xtensa/esp32/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/driver/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/driver/esp32/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_pm/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_ringbuf/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/efuse/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/efuse/esp32/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/vfs/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_wifi/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_event/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_netif/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_eth/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/tcpip_adapter/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_phy/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_phy/esp32/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_ipc/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/app_trace/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_timer/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/mbedtls/port/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/mbedtls/mbedtls/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/mbedtls/esp_crt_bundle/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/app_update/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/spi_flash/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bootloader_support/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/nvs_flash/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/pthread/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_gdbstub/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_gdbstub/xtensa",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_gdbstub/esp32",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/espcoredump/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/espcoredump/include/port/xtensa",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/wpa_supplicant/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/wpa_supplicant/port/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/wpa_supplicant/esp_supplicant/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/ieee802154/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/console",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/asio/asio/asio/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/asio/port/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/common/osi/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/include/esp32/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/common/api/include/api",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/common/btc/profile/esp/blufi/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/common/btc/profile/esp/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/storage",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/esp_ble_mesh/btc/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/common/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/client/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/server/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/esp_ble_mesh/api/core/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/esp_ble_mesh/api/models/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/esp_ble_mesh/api",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/cbor/port/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/unity/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/unity/unity/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/cmock/CMock/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/coap/port/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/coap/libcoap/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/nghttp/port/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/nghttp/nghttp2/lib/includes",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-tls",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-tls/esp-tls-crypto",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_adc_cal/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_hid/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/tcp_transport/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_http_client/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_http_server/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_https_ota/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_https_server/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_lcd/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_lcd/interface",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/protobuf-c/protobuf-c",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/protocomm/include/common",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/protocomm/include/security",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/protocomm/include/transports",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/mdns/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_local_ctrl/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/sdmmc/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_serial_slave_link/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_websocket_client/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/expat/expat/expat/lib",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/expat/port/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/wear_levelling/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/fatfs/diskio",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/fatfs/vfs",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/fatfs/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/freemodbus/common/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/idf_test/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/idf_test/include/esp32",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/jsmn/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/json/cJSON",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/libsodium/libsodium/src/libsodium/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/libsodium/port_include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/mqtt/esp-mqtt/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/openssl/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/perfmon/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/spiffs/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/ulp/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/wifi_provisioning/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/rmaker_common/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/json_parser/upstream/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/json_parser/upstream",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/json_generator/upstream",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_schedule/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_rainmaker/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/gpio_button/button/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/qrcode/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/ws2812_led",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/dotprod/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/support/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/windows/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/windows/hann/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/windows/blackman/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/windows/blackman_harris/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/windows/blackman_nuttall/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/windows/nuttall/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/windows/flat_top/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/iir/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/fir/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/math/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/math/add/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/math/sub/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/math/mul/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/math/addc/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/math/mulc/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/math/sqrt/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/matrix/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/fft/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/dct/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/conv/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/common/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/kalman/ekf/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/kalman/ekf_imu13states/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_littlefs/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dl/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dl/include/tool",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dl/include/typedef",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dl/include/image",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dl/include/math",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dl/include/nn",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dl/include/layer",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dl/include/detect",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dl/include/model_zoo",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-sr/src/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-sr/esp-tts/esp_tts_chinese/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-sr/include/esp32",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp32-camera/driver/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp32-camera/conversions/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/fb_gfx/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/qio_qspi/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/cores/esp32",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/variants/esp32",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/ArduinoOTA/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/AsyncUDP/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/BLE/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/BluetoothSerial/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/DNSServer/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/EEPROM/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/ESP32/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/ESPmDNS/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/Ethernet/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/FFat/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/HTTPClient/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/HTTPUpdate/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/HTTPUpdateServer/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/I2S/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/LittleFS/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/NetBIOS/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/Preferences/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/RainMaker/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/SD_MMC/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/SPIFFS/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/SimpleBLE/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/Ticker/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/USB/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/Update/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/WebServer/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/WiFiClientSecure/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/WiFiProv/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/Wire/src",
""
],
"browse": {
"limitSymbolsToIncludedHeaders": true,
"path": [
"/media/wolle/DRIVE-N-GO/platformio-workspace/ESP32_WebServer/include",
"/media/wolle/DRIVE-N-GO/platformio-workspace/ESP32_WebServer/src",
"/media/wolle/DRIVE-N-GO/platformio-workspace/ESP32_WebServer/lib/websrv",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/SD/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/SPI/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/FS/src",
"/media/wolle/DRIVE-N-GO/platformio-workspace/ESP32_WebServer/.pio/libdeps/esp32dev/Arduino_JSON/src",
"/media/wolle/DRIVE-N-GO/platformio-workspace/ESP32_WebServer/.pio/libdeps/esp32dev/SoapESP32/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/WiFi/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/newlib/platform_include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/freertos/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/freertos/include/esp_additions/freertos",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/freertos/port/xtensa/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/freertos/include/esp_additions",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_hw_support/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_hw_support/include/soc",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_hw_support/port/esp32",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_hw_support/port/esp32/private_include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/heap/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/log/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/lwip/include/apps",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/lwip/include/apps/sntp",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/lwip/lwip/src/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/lwip/port/esp32/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/lwip/port/esp32/include/arch",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/soc/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/soc/esp32",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/soc/esp32/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/hal/esp32/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/hal/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/hal/platform_port/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_rom/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_rom/include/esp32",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_rom/esp32",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_common/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_system/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_system/port/soc",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_system/port/public_compat",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp32/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/xtensa/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/xtensa/esp32/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/driver/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/driver/esp32/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_pm/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_ringbuf/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/efuse/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/efuse/esp32/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/vfs/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_wifi/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_event/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_netif/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_eth/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/tcpip_adapter/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_phy/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_phy/esp32/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_ipc/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/app_trace/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_timer/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/mbedtls/port/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/mbedtls/mbedtls/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/mbedtls/esp_crt_bundle/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/app_update/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/spi_flash/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bootloader_support/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/nvs_flash/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/pthread/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_gdbstub/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_gdbstub/xtensa",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_gdbstub/esp32",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/espcoredump/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/espcoredump/include/port/xtensa",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/wpa_supplicant/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/wpa_supplicant/port/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/wpa_supplicant/esp_supplicant/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/ieee802154/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/console",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/asio/asio/asio/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/asio/port/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/common/osi/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/include/esp32/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/common/api/include/api",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/common/btc/profile/esp/blufi/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/common/btc/profile/esp/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/storage",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/esp_ble_mesh/btc/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/common/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/client/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/server/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/esp_ble_mesh/api/core/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/esp_ble_mesh/api/models/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/bt/esp_ble_mesh/api",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/cbor/port/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/unity/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/unity/unity/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/cmock/CMock/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/coap/port/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/coap/libcoap/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/nghttp/port/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/nghttp/nghttp2/lib/includes",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-tls",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-tls/esp-tls-crypto",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_adc_cal/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_hid/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/tcp_transport/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_http_client/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_http_server/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_https_ota/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_https_server/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_lcd/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_lcd/interface",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/protobuf-c/protobuf-c",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/protocomm/include/common",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/protocomm/include/security",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/protocomm/include/transports",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/mdns/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_local_ctrl/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/sdmmc/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_serial_slave_link/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_websocket_client/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/expat/expat/expat/lib",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/expat/port/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/wear_levelling/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/fatfs/diskio",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/fatfs/vfs",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/fatfs/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/freemodbus/common/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/idf_test/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/idf_test/include/esp32",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/jsmn/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/json/cJSON",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/libsodium/libsodium/src/libsodium/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/libsodium/port_include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/mqtt/esp-mqtt/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/openssl/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/perfmon/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/spiffs/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/ulp/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/wifi_provisioning/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/rmaker_common/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/json_parser/upstream/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/json_parser/upstream",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/json_generator/upstream",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_schedule/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_rainmaker/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/gpio_button/button/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/qrcode/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/ws2812_led",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/dotprod/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/support/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/windows/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/windows/hann/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/windows/blackman/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/windows/blackman_harris/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/windows/blackman_nuttall/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/windows/nuttall/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/windows/flat_top/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/iir/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/fir/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/math/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/math/add/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/math/sub/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/math/mul/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/math/addc/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/math/mulc/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/math/sqrt/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/matrix/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/fft/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/dct/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/conv/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/common/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/kalman/ekf/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dsp/modules/kalman/ekf_imu13states/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp_littlefs/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dl/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dl/include/tool",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dl/include/typedef",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dl/include/image",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dl/include/math",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dl/include/nn",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dl/include/layer",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dl/include/detect",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-dl/include/model_zoo",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-sr/src/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-sr/esp-tts/esp_tts_chinese/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp-sr/include/esp32",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp32-camera/driver/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/esp32-camera/conversions/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/include/fb_gfx/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/tools/sdk/esp32/qio_qspi/include",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/cores/esp32",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/variants/esp32",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/ArduinoOTA/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/AsyncUDP/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/BLE/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/BluetoothSerial/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/DNSServer/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/EEPROM/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/ESP32/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/ESPmDNS/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/Ethernet/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/FFat/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/HTTPClient/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/HTTPUpdate/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/HTTPUpdateServer/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/I2S/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/LittleFS/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/NetBIOS/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/Preferences/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/RainMaker/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/SD_MMC/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/SPIFFS/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/SimpleBLE/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/Ticker/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/USB/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/Update/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/WebServer/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/WiFiClientSecure/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/WiFiProv/src",
"/home/wolle/.platformio/packages/framework-arduinoespressif32@src-f2ea83e2545300b10a69ff44ef9dc6cd/libraries/Wire/src",
""
]
},
"defines": [
"PLATFORMIO=60105",
"ARDUINO_ESP32_DEV",
"CORE_DEBUG_LEVEL=3",
"CONFIG_ARDUHAL_LOG_COLORS",
"BOARD_HAS_PSRAM",
"ARDUINO_RUNNING_CORE=3",
"ARDUINO_EVENT_RUNNING_CORE=1",
"HAVE_CONFIG_H",
"MBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\"",
"UNITY_INCLUDE_CONFIG_H",
"WITH_POSIX",
"_GNU_SOURCE",
"IDF_VER=\"v4.4.2\"",
"ESP_PLATFORM",
"_POSIX_READER_WRITER_LOCKS",
"ARDUINO_ARCH_ESP32",
"ESP32",
"F_CPU=240000000L",
"ARDUINO=10812",
"ARDUINO_VARIANT=\"esp32\"",
"ARDUINO_BOARD=\"Espressif ESP32 Dev Module\"",
"ARDUINO_PARTITION_default",
""
],
"cStandard": "c99",
"cppStandard": "c++11",
"compilerPath": "/home/wolle/.platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc",
"compilerArgs": [
"-mlongcalls",
""
]
}
],
"version": 4
}

View File

@ -0,0 +1,10 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
],
"unwantedRecommendations": [
"ms-vscode.cpptools-extension-pack"
]
}

View File

@ -0,0 +1,44 @@
// AUTOMATICALLY GENERATED FILE. PLEASE DO NOT MODIFY IT MANUALLY
//
// PIO Unified Debugger
//
// Documentation: https://docs.platformio.org/page/plus/debugging.html
// Configuration: https://docs.platformio.org/page/projectconf/section_env_debug.html
{
"version": "0.2.0",
"configurations": [
{
"type": "platformio-debug",
"request": "launch",
"name": "PIO Debug",
"executable": "/media/wolle/DRIVE-N-GO/platformio-workspace/ESP32_WebServer/.pio/build/esp32dev/firmware.elf",
"projectEnvName": "esp32dev",
"toolchainBinDir": "/home/wolle/.platformio/packages/toolchain-xtensa-esp32/bin",
"internalConsoleOptions": "openOnSessionStart",
"preLaunchTask": {
"type": "PlatformIO",
"task": "Pre-Debug"
}
},
{
"type": "platformio-debug",
"request": "launch",
"name": "PIO Debug (skip Pre-Debug)",
"executable": "/media/wolle/DRIVE-N-GO/platformio-workspace/ESP32_WebServer/.pio/build/esp32dev/firmware.elf",
"projectEnvName": "esp32dev",
"toolchainBinDir": "/home/wolle/.platformio/packages/toolchain-xtensa-esp32/bin",
"internalConsoleOptions": "openOnSessionStart"
},
{
"type": "platformio-debug",
"request": "launch",
"name": "PIO Debug (without uploading)",
"executable": "/media/wolle/DRIVE-N-GO/platformio-workspace/ESP32_WebServer/.pio/build/esp32dev/firmware.elf",
"projectEnvName": "esp32dev",
"toolchainBinDir": "/home/wolle/.platformio/packages/toolchain-xtensa-esp32/bin",
"internalConsoleOptions": "openOnSessionStart",
"loadMode": "manual"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

View File

@ -0,0 +1,39 @@
This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.
```src/main.c
#include "header.h"
int main (void)
{
...
}
```
Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.
In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.
Read more about using header files in official GCC documentation:
* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html

View File

@ -0,0 +1,46 @@
This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.
The source code of each library should be placed in a an own separate directory
("lib/your_library_name/[here are source files]").
For example, see a structure of the following two libraries `Foo` and `Bar`:
|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c
and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>
int main (void)
{
...
}
```
PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.
More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html

View File

@ -0,0 +1,721 @@
/*
* websrv.cpp
*
* Created on: 09.07.2017
* updated on: 19.10.2022
* Author: Wolle
*/
#include "websrv.h"
//--------------------------------------------------------------------------------------------------------------
WebSrv::WebSrv(String Name, String Version){
_Name=Name; _Version=Version;
method = HTTP_NONE;
}
//--------------------------------------------------------------------------------------------------------------
void WebSrv::show_not_found(){
cmdclient.print("HTTP/1.1 404 Not Found\n\n");
return;
}
//--------------------------------------------------------------------------------------------------------------
String WebSrv::calculateWebSocketResponseKey(String sec_WS_key){
// input Sec-WebSocket-Key from client
// output Sec-WebSocket-Accept-Key (used in response message to client)
uint8_t sha1_result[20];
String concat = sec_WS_key + WS_sec_conKey;
mbedtls_sha1((unsigned char*)concat.c_str(), concat.length(), (unsigned char*) sha1_result );
return base64::encode(sha1_result, 20);
}
//--------------------------------------------------------------------------------------------------------------
void WebSrv::printWebSocketHeader(String wsRespKey){
String wsHeader = (String)"HTTP/1.1 101 Switching Protocols\r\n" +
"Upgrade: websocket\r\n" +
"Connection: Upgrade\r\n" +
"Sec-WebSocket-Accept: " + wsRespKey + "\r\n" +
"Access-Control-Allow-Origin: \r\n\r\n";
// "Sec-WebSocket-Protocol: chat\r\n\r\n";
//log_i("wsheader %s", wsHeader.c_str());
webSocketClient.print(wsHeader) ; // header sent
}
//--------------------------------------------------------------------------------------------------------------
void WebSrv::show(const char* pagename, int16_t len){
uint TCPCHUNKSIZE = 1024; // Max number of bytes per write
size_t pagelen=0, res=0; // Size of requested page
const unsigned char* p;
p = reinterpret_cast<const unsigned char*>(pagename);
if(len==-1){
pagelen=strlen(pagename);
}
else{
if(len>0) pagelen = len;
}
while((*p=='\n') && (pagelen>0)){ // If page starts with newline:
p++; // Skip first character
pagelen--;
}
// HTTP header
String httpheader="";
httpheader += "HTTP/1.1 200 OK\r\n";
httpheader += "Connection: close\r\n";
httpheader += "Content-type: text/html\r\n";
httpheader += "Content-Length: " + String(pagelen, 10) + "\r\n";
httpheader += "Server: " + _Name+ "\r\n";
httpheader += "Cache-Control: max-age=86400\r\n";
httpheader += "Last-Modified: " + _Version + "\r\n\r\n";
cmdclient.print(httpheader) ; // header sent
sprintf(buff, "Length of page is %d", pagelen);
if(WEBSRV_onInfo) WEBSRV_onInfo(buff);
// The content of the HTTP response follows the header:
while(pagelen){ // Loop through the output page
if (pagelen <= TCPCHUNKSIZE){ // Near the end?
res=cmdclient.write(p, pagelen); // Yes, send last part
if(res!=pagelen){
log_e("write error in webpage");
cmdclient.clearWriteError();
return;
}
pagelen = 0;
}
else{
res=cmdclient.write(p, TCPCHUNKSIZE); // Send part of the page
if(res!=TCPCHUNKSIZE){
log_e("write error in webpage");
cmdclient.clearWriteError();
return;
}
p += TCPCHUNKSIZE; // Update startpoint and rest of bytes
pagelen -= TCPCHUNKSIZE;
}
}
return;
}
//--------------------------------------------------------------------------------------------------------------
boolean WebSrv::streamfile(fs::FS &fs,const char* path){ // transfer file from SD to webbrowser
size_t bytesPerTransaction = 1024;
uint8_t transBuf[bytesPerTransaction], i=0;
size_t wIndex = 0, res=0, leftover=0;
if(!cmdclient.connected()){log_e("not connected"); return false;}
while(path[i] != 0){ // protect SD for invalid signs to avoid a crash!!
if(path[i] < 32)return false;
i++;
}
if(!fs.exists(path)) return false;
File file = fs.open(path, "r");
if(!file){
sprintf(buff, "Failed to open file for reading %s", path);
if(WEBSRV_onInfo) WEBSRV_onInfo(buff);
show_not_found();
return false;
}
sprintf(buff, "Length of file %s is %d", path, file.size());
if(WEBSRV_onInfo) WEBSRV_onInfo(buff);
// HTTP header
String httpheader="";
httpheader += "HTTP/1.1 200 OK\r\n";
httpheader += "Connection: close\r\n";
httpheader += "Content-type: " + getContentType(String(path)) +"\r\n";
httpheader += "Content-Length: " + String(file.size(),10) + "\r\n";
httpheader += "Server: " + _Name+ "\r\n";
httpheader += "Cache-Control: max-age=86400\r\n";
httpheader += "Last-Modified: " + _Version + "\r\n\r\n";
cmdclient.print(httpheader) ; // header sent
while(wIndex+bytesPerTransaction < file.size()){
file.read(transBuf, bytesPerTransaction);
res=cmdclient.write(transBuf, bytesPerTransaction);
wIndex+=res;
if(res!=bytesPerTransaction){
log_i("write error %s", path);
cmdclient.clearWriteError();
return false;
}
}
leftover=file.size()-wIndex;
file.read(transBuf, leftover);
res=cmdclient.write(transBuf, leftover);
wIndex+=res;
if(res!=leftover){
log_i("write error %s", path);
cmdclient.clearWriteError();
return false;
}
if(wIndex!=file.size()) log_e("file %s not correct sent", path);
file.close();
return true;
}
//--------------------------------------------------------------------------------------------------------------
boolean WebSrv::send(String msg, uint8_t opcode) { // sends text messages via websocket
return send(msg.c_str(), opcode);
}
//--------------------------------------------------------------------------------------------------------------
boolean WebSrv::send(const char *msg, uint8_t opcode) { // sends text messages via websocket
uint8_t headerLen = 2;
if(!hasclient_WS) {
// log_e("can't send, websocketserver not connected");
return false;
}
size_t msgLen = strlen(msg);
if(msgLen > UINT16_MAX) {
log_e("send: message too long, greather than 64kB");
return false;
}
uint8_t fin = 1;
uint8_t rsv1 = 0;
uint8_t rsv2 = 0;
uint8_t rsv3 = 0;
uint8_t mask = 0;
buff[0] = (128 * fin) + (64 * rsv1) + (32 * rsv2) + (16 * rsv3) + opcode;
if(msgLen < 126) {
buff[1] = (128 * mask) + msgLen;
}
else {
headerLen = 4;
buff[1] = (128 * mask) + 126;
buff[2] = (msgLen >> 8) & 0xFF;
buff[3] = msgLen & 0xFF;
}
webSocketClient.write(buff, headerLen);
webSocketClient.write(msg, msgLen);
return true;
}
//--------------------------------------------------------------------------------------------------------------
void WebSrv::sendPing(){ // heartbeat, keep alive via websockets
if(!hasclient_WS) {
return;
}
uint8_t fin = 1;
uint8_t rsv1 = 0;
uint8_t rsv2 = 0;
uint8_t rsv3 = 0;
uint8_t mask = 0;
buff[0] = (128 * fin) + (64 * rsv1) + (32 * rsv2) + (16 * rsv3) + Ping_Frame;
buff[1] = (128 * mask) + 0;
webSocketClient.write(buff,2);
}
//--------------------------------------------------------------------------------------------------------------
void WebSrv::sendPong(){ // heartbeat, keep alive via websockets
if(!hasclient_WS) {
return;
}
uint8_t fin = 1;
uint8_t rsv1 = 0;
uint8_t rsv2 = 0;
uint8_t rsv3 = 0;
uint8_t mask = 0;
buff[0] = (128 * fin) + (64 * rsv1) + (32 * rsv2) + (16 * rsv3) + Pong_Frame;
buff[1] = (128 * mask) + 0;
webSocketClient.write(buff,2);
}
//--------------------------------------------------------------------------------------------------------------
boolean WebSrv::uploadB64image(fs::FS &fs,const char* path, uint32_t contentLength){ // transfer imagefile from webbrowser to SD
size_t bytesPerTransaction = 1024;
uint8_t tBuf[bytesPerTransaction];
uint16_t av, i, j;
uint32_t len = contentLength;
boolean f_werror=false;
String str="";
int n=0;
File file;
fs.remove(path); // Remove a previous version, otherwise data is appended the file again
file = fs.open(path, FILE_WRITE); // Open the file for writing (create it, if doesn't exist)
log_i("ContentLength %i", contentLength);
str = str + cmdclient.readStringUntil(','); // data:image/jpeg;base64,
len -= str.length();
while(cmdclient.available()){
av=cmdclient.available();
if(av==0) break;
if(av>bytesPerTransaction) av=bytesPerTransaction;
if(av>len) av=len;
len -= av;
i=0; j=0;
cmdclient.read(tBuf, av); // b64 decode
while(i<av){
if(tBuf[i]==0)break; // ignore all other stuff
n=B64index[tBuf[i]]<<18 | B64index[tBuf[i+1]]<<12 | B64index[tBuf[i+2]]<<6 | B64index[tBuf[i+3]];
tBuf[j ]= n>>16;
tBuf[j+1]= n>>8 & 0xFF;
tBuf[j+2]= n & 0xFF;
i+=4;
j+=3;
}
if(tBuf[j]=='=') j--;
if(tBuf[j]=='=') j--; // remove =
if(file.write(tBuf, j)!=j) f_werror=true; // write error?
if(len == 0) break;
}
cmdclient.readStringUntil('\n'); // read the remains, first \n
cmdclient.readStringUntil('\n'); // read the remains webkit\n
file.close();
if(f_werror) {
sprintf(buff, "File: %s write error", path);
if(WEBSRV_onInfo) WEBSRV_onInfo(buff);
return false;
}
sprintf(buff, "File: %s written, FileSize: %d", path, contentLength);
//log_i(buff);
if(WEBSRV_onInfo) WEBSRV_onInfo(buff);
return true;
}
//--------------------------------------------------------------------------------------------------------------
boolean WebSrv::uploadfile(fs::FS &fs,const char* path, uint32_t contentLength){ // transfer file from webbrowser to sd
size_t bytesPerTransaction = 1024;
uint8_t tBuf[bytesPerTransaction];
uint16_t av;
uint32_t len = contentLength;
boolean f_werror=false;
String str="";
File file;
if(fs.exists(path)) fs.remove(path); // Remove a previous version, otherwise data is appended the file again
file = fs.open(path, FILE_WRITE); // Open the file for writing in SD (create it, if doesn't exist)
while(cmdclient.available()){
av=cmdclient.available();
if(av>bytesPerTransaction) av=bytesPerTransaction;
if(av>len) av=len;
len -= av;
cmdclient.read(tBuf, av);
if(file.write(tBuf, av)!=av) f_werror=true; // write error?
if(len == 0) break;
}
cmdclient.readStringUntil('\n'); // read the remains, first \n
cmdclient.readStringUntil('\n'); // read the remains webkit\n
file.close();
if(f_werror) {
sprintf(buff, "File: %s write error", path);
if(WEBSRV_onInfo) WEBSRV_onInfo(buff);
return false;
}
sprintf(buff, "File: %s written, FileSize %d: ", path, contentLength);
if(WEBSRV_onInfo) WEBSRV_onInfo(buff);
return true;
}
//--------------------------------------------------------------------------------------------------------------
void WebSrv::begin(uint16_t http_port, uint16_t websocket_port) {
cmdserver.begin(http_port);
webSocketServer.begin(websocket_port);
}
//--------------------------------------------------------------------------------------------------------------
void WebSrv::stop() {
cmdclient.stop();
webSocketClient.stop();
}
//--------------------------------------------------------------------------------------------------------------
String WebSrv::getContentType(String filename){
if (filename.endsWith(".html")) return "text/html" ;
else if (filename.endsWith(".htm" )) return "text/html";
else if (filename.endsWith(".css" )) return "text/css";
else if (filename.endsWith(".txt" )) return "text/plain";
else if (filename.endsWith(".js" )) return "application/javascript";
else if (filename.endsWith(".json")) return "application/json";
else if (filename.endsWith(".svg" )) return "image/svg+xml";
else if (filename.endsWith(".ttf" )) return "application/x-font-ttf";
else if (filename.endsWith(".otf" )) return "application/x-font-opentype";
else if (filename.endsWith(".xml" )) return "text/xml";
else if (filename.endsWith(".pdf" )) return "application/pdf";
else if (filename.endsWith(".png" )) return "image/png" ;
else if (filename.endsWith(".bmp" )) return "image/bmp" ;
else if (filename.endsWith(".gif" )) return "image/gif" ;
else if (filename.endsWith(".jpg" )) return "image/jpeg" ;
else if (filename.endsWith(".ico" )) return "image/x-icon" ;
else if (filename.endsWith(".css" )) return "text/css" ;
else if (filename.endsWith(".zip" )) return "application/x-zip" ;
else if (filename.endsWith(".gz" )) return "application/x-gzip" ;
else if (filename.endsWith(".xls" )) return "application/msexcel" ;
else if (filename.endsWith(".mp3" )) return "audio/mpeg" ;
return "text/plain" ;
}
//--------------------------------------------------------------------------------------------------------------
boolean WebSrv::handlehttp() { // HTTPserver, message received
bool wswitch=true;
int16_t inx0, inx1, inx2, inx3; // Pos. of search string in currenLine
String currentLine = ""; // Build up to complete line
String ct; // contentType
uint32_t contentLength = 0; // contentLength
uint8_t count = 0;
if (!cmdclient.connected()){
log_e("cmdclient schould be connected but is not!");
return false;
}
while (wswitch==true){ // first while
if(!cmdclient.available()){
log_e("Command client schould be available but is not!");
return false;
}
currentLine = cmdclient.readStringUntil('\n');
// log_i("currLine %s", currentLine.c_str());
// If the current line is blank, you got two newline characters in a row.
// that's the end of the client HTTP request, so send a response:
if (currentLine.length() == 1) { // contains '\n' only
wswitch=false; // use second while
if (http_cmd.length()) {
if(WEBSRV_onInfo) WEBSRV_onInfo(URLdecode(http_cmd).c_str());
if(WEBSRV_onCommand) WEBSRV_onCommand(URLdecode(http_cmd), URLdecode(http_param), URLdecode(http_arg));
}
else if(http_rqfile.length()){
if(WEBSRV_onInfo) WEBSRV_onInfo(URLdecode(http_rqfile).c_str());
if(WEBSRV_onCommand) WEBSRV_onCommand(URLdecode(http_rqfile), URLdecode(http_param), URLdecode(http_arg));
}
else { // An empty "GET"?
if(WEBSRV_onInfo) WEBSRV_onInfo("Filename is: index.html");
if(WEBSRV_onCommand) WEBSRV_onCommand("index.html", URLdecode(http_param), URLdecode(http_arg));
}
currentLine = "";
http_cmd = "";
http_param = "";
http_arg = "";
http_rqfile = "";
method = HTTP_NONE;
break;
} else {
// Newline seen
inx0 = 0;
if (currentLine.startsWith("Content-Length:")) contentLength = currentLine.substring(15).toInt();
if (currentLine.startsWith("GET /")) {method = HTTP_GET; inx0 = 5;} // GET request?
if (currentLine.startsWith("POST /")){method = HTTP_PUT; inx0 = 6;} // POST request?
if (inx0 == 0) method = HTTP_NONE;
if(inx0>0){
inx1 = currentLine.indexOf("?"); // Search for 1st parameter
inx2 = currentLine.lastIndexOf("&"); // Search for 2nd parameter
inx3 = currentLine.indexOf(" HTTP");// Search for 3th parameter
if(inx1 > inx0){ // it is a command
http_cmd = currentLine.substring(inx0, inx1);//isolate the command
http_rqfile = ""; // No file
}
if((inx1>0) && (inx1+1 < inx3)){ // it is a parameter
http_param = currentLine.substring(inx1+1, inx3);//isolate the parameter
if(inx2>0){
http_arg = currentLine.substring(inx2+1, inx3);//isolate the arguments
http_param = currentLine.substring(inx1+1, inx2);//cut the parameter
}
http_rqfile = ""; // No file
}
if(inx1 < 0 && inx2 < 0){ // it is a filename
http_rqfile = currentLine.substring(inx0, inx3);
http_cmd = "";
http_param = "";
http_arg = "";
}
}
currentLine = "";
}
} //end first while
while(wswitch==false){ // second while
if(cmdclient.available()) {
//log_i("%i", cmdclient.available());
currentLine = cmdclient.readStringUntil('\n');
//log_i("currLine %s", currentLine.c_str());
contentLength -= currentLine.length();
}
else{
currentLine = "";
}
if(!currentLine.length()){
return true;
}
if((currentLine.length() == 1 && count == 0) || count >= 2){
wswitch=true; // use first while
currentLine = "";
count = 0;
break;
}
else{ // its the requestbody
if(currentLine.length() > 1){
if(WEBSRV_onRequest) WEBSRV_onRequest(currentLine, 0);
if(WEBSRV_onInfo) WEBSRV_onInfo(currentLine.c_str());
}
if(currentLine.startsWith("------")) {
count++; // WebKitFormBoundary header
contentLength -= (currentLine.length() + 2); // WebKitFormBoundary footer ist 2 chars longer
}
if(currentLine.length() == 1 && count == 1){
contentLength -= 6; // "\r\n\r\n..."
if(WEBSRV_onRequest) WEBSRV_onRequest("fileUpload", contentLength);
count++;
}
}
} // end second while
cmdclient.stop();
return true;
}
//--------------------------------------------------------------------------------------------------------------
boolean WebSrv::handleWS() { // Websocketserver, receive messages
String currentLine = ""; // Build up to complete line
if (!webSocketClient.connected()){
log_e("webSocketClient schould be connected but is not!");
hasclient_WS = false;
return false;
}
if(!hasclient_WS){
while(true){
currentLine = webSocketClient.readStringUntil('\n');
if (currentLine.length() == 1) { // contains '\n' only
if(ws_conn_request_flag){
ws_conn_request_flag = false;
printWebSocketHeader(WS_resp_Key);
hasclient_WS = true;
}
break;
}
if (currentLine.startsWith("Sec-WebSocket-Key:")) { // Websocket connection request
WS_sec_Key = currentLine.substring(18);
WS_sec_Key.trim();
WS_resp_Key = calculateWebSocketResponseKey(WS_sec_Key);
ws_conn_request_flag = true;
}
}
}
int av = webSocketClient.available();
if(av){
parseWsMessage(av);
}
return true;
}
//--------------------------------------------------------------------------------------------------------------
void WebSrv::parseWsMessage(uint32_t len){
uint8_t headerLen = 2;
uint16_t paylodLen;
uint8_t maskingKey[4];
if(len > UINT16_MAX){
log_e("Websocketmessage too long");
return;
}
webSocketClient.readBytes(buff, 1);
uint8_t fin = ((buff[0] >> 7) & 0x01); (void)fin;
uint8_t rsv1 = ((buff[0] >> 6) & 0x01); (void)rsv1;
uint8_t rsv2 = ((buff[0] >> 5) & 0x01); (void)rsv2;
uint8_t rsv3 = ((buff[0] >> 4) & 0x01); (void)rsv3;
uint8_t opcode = (buff[0] & 0x0F);
webSocketClient.readBytes(buff, 1);
uint8_t mask = ((buff[0]>>7) & 0x01);
paylodLen = (buff[0] & 0x7F);
if(paylodLen == 126){
headerLen = 4;
webSocketClient.readBytes(buff, 2);
paylodLen = buff[0] << 8;
paylodLen += buff[1];
}
(void)headerLen;
if(mask){
maskingKey[0] = webSocketClient.read();
maskingKey[1] = webSocketClient.read();
maskingKey[2] = webSocketClient.read();
maskingKey[3] = webSocketClient.read();
}
if(opcode == 0x08) { // denotes a connection close
hasclient_WS = false;
webSocketClient.stop();
return;
}
if(opcode == 0x09) { // denotes a ping
if(WEBSRV_onCommand) WEBSRV_onCommand("ping received, send pong", "", "");
if(WEBSRV_onInfo) WEBSRV_onInfo("pong received, send pong");
sendPong();
}
if(opcode == 0x0A) { // denotes a pong
if(WEBSRV_onCommand) WEBSRV_onCommand("pong received", "", "");
if(WEBSRV_onInfo) WEBSRV_onInfo("pong received");
return;
}
if(opcode == 0x01) { // denotes a text frame
int plen;
while(paylodLen){
if(paylodLen > 255){
plen = 255;
paylodLen -= webSocketClient.readBytes(buff, plen);
}
else{
plen = paylodLen;
paylodLen = 0;
webSocketClient.readBytes(buff, plen);
}
if(mask){
for(int i = 0; i < plen; i++){
buff[i] = (buff[i] ^ maskingKey[i % 4]);
}
}
buff[plen] = 0;
if(WEBSRV_onInfo) WEBSRV_onInfo(buff);
if(len < 256){ // can be a command like "mute=1"
char *ret;
ret = strchr((const char*)buff, '=');
if(ret){
*ret = 0;
// log_i("cmd=%s, para=%s", buff, ret);
if(WEBSRV_onCommand) WEBSRV_onCommand((const char*) buff, ret + 1, "");
buff[0] = 0;
return;
}
}
if(WEBSRV_onCommand) WEBSRV_onCommand((const char*) buff, "", "");
}
buff[0] = 0;
}
}
//--------------------------------------------------------------------------------------------------------------
boolean WebSrv::loop() {
cmdclient = cmdserver.available();
if (cmdclient.available()){ // Check Input from client?
if(WEBSRV_onInfo) WEBSRV_onInfo("Command client available");
return handlehttp();
}
if(!webSocketClient.connected()){
hasclient_WS = false;
}
if(!hasclient_WS) webSocketClient = webSocketServer.available();
if (webSocketClient.available()){
if(WEBSRV_onInfo) WEBSRV_onInfo("WebSocket client available");
return handleWS();
}
return false;
}
//--------------------------------------------------------------------------------------------------------------
void WebSrv::reply(const String &response, bool header){
if(header==true) {
int l= response.length();
// HTTP header
String httpheader="";
httpheader += "HTTP/1.1 200 OK\r\n";
httpheader += "Connection: close\r\n";
httpheader += "Content-type: text/html\r\n";
httpheader += "Content-Length: " + String(l, 10) + "\r\n";
httpheader += "Server: " + _Name+ "\r\n";
httpheader += "Cache-Control: max-age=3600\r\n";
httpheader += "Last-Modified: " + _Version + "\r\n\r\n";
cmdclient.print(httpheader) ; // header sent
}
cmdclient.print(response);
}
//--------------------------------------------------------------------------------------------------------------
String WebSrv::UTF8toASCII(String str){
uint16_t i=0;
String res="";
char tab[96]={
96,173,155,156, 32,157, 32, 32, 32, 32,166,174,170, 32, 32, 32,248,241,253, 32,
32,230, 32,250, 32, 32,167,175,172,171, 32,168, 32, 32, 32, 32,142,143,146,128,
32,144, 32, 32, 32, 32, 32, 32, 32,165, 32, 32, 32, 32,153, 32, 32, 32, 32, 32,
154, 32, 32,225,133,160,131, 32,132,134,145,135,138,130,136,137,141,161,140,139,
32,164,149,162,147, 32,148,246, 32,151,163,150,129, 32, 32,152
};
while(str[i]!=0){
if(str[i]==0xC2){ // compute unicode from utf8
i++;
if((str[i]>159)&&(str[i]<192)) res+=char(tab[str[i]-160]);
else res+=char(32);
}
else if(str[i]==0xC3){
i++;
if((str[i]>127)&&(str[i]<192)) res+=char(tab[str[i]-96]);
else res+=char(32);
}
else res+=str[i];
i++;
}
return res;
}
//--------------------------------------------------------------------------------------------------------------
String WebSrv::URLdecode(String str){
String hex="0123456789ABCDEF";
String res="";
uint16_t i=0;
while(str[i]!=0){
if((str[i]=='%') && isHexadecimalDigit(str[i+1]) && isHexadecimalDigit(str[i+2])){
res+=char((hex.indexOf(str[i+1])<<4) + hex.indexOf(str[i+2])); i+=3;}
else{res+=str[i]; i++;}
}
return res;
}
//--------------------------------------------------------------------------------------------------------------
String WebSrv::responseCodeToString(int code) {
switch (code) {
case 100: return F("Continue");
case 101: return F("Switching Protocols");
case 200: return F("OK");
case 201: return F("Created");
case 202: return F("Accepted");
case 203: return F("Non-Authoritative Information");
case 204: return F("No Content");
case 205: return F("Reset Content");
case 206: return F("Partial Content");
case 300: return F("Multiple Choices");
case 301: return F("Moved Permanently");
case 302: return F("Found");
case 303: return F("See Other");
case 304: return F("Not Modified");
case 305: return F("Use Proxy");
case 307: return F("Temporary Redirect");
case 400: return F("Bad Request");
case 401: return F("Unauthorized");
case 402: return F("Payment Required");
case 403: return F("Forbidden");
case 404: return F("Not Found");
case 405: return F("Method Not Allowed");
case 406: return F("Not Acceptable");
case 407: return F("Proxy Authentication Required");
case 408: return F("Request Time-out");
case 409: return F("Conflict");
case 410: return F("Gone");
case 411: return F("Length Required");
case 412: return F("Precondition Failed");
case 413: return F("Request Entity Too Large");
case 414: return F("Request-URI Too Large");
case 415: return F("Unsupported Media Type");
case 416: return F("Requested range not satisfiable");
case 417: return F("Expectation Failed");
case 500: return F("Internal Server Error");
case 501: return F("Not Implemented");
case 502: return F("Bad Gateway");
case 503: return F("Service Unavailable");
case 504: return F("Gateway Time-out");
case 505: return F("HTTP Version not supported");
default: return "";
}
}
//--------------------------------------------------------------------------------------------------------------

View File

@ -0,0 +1,96 @@
/*
* websrv.h
*
* Created on: 09.07.2017
* updated on: 11.04.2022
* Author: Wolle
*/
#ifndef WEBSRV_H_
#define WEBSRV_H_
#include "Arduino.h"
#include "WiFi.h"
#include "SD.h"
#include "FS.h"
#include "mbedtls/sha1.h"
#include "base64.h"
extern __attribute__((weak)) void WEBSRV_onInfo(const char*);
extern __attribute__((weak)) void WEBSRV_onCommand(const String cmd, const String param, const String arg);
extern __attribute__((weak)) void WEBSRV_onRequest(const String, uint32_t contentLength);
class WebSrv
{
protected:
WiFiClient cmdclient; // An instance of the client for commands
WiFiClient webSocketClient ;
WiFiServer cmdserver;
WiFiServer webSocketServer;
private:
bool http_reponse_flag = false ; // Response required
bool ws_conn_request_flag = false; // websocket connection attempt
bool hasclient_WS = false;
String http_rqfile ; // Requested file
String http_cmd ; // Content of command
String http_param; // Content of parameter
String http_arg; // Content of argument
String _Name;
String _Version;
String contenttype;
char buff[256];
uint8_t method;
String WS_sec_Key;
String WS_resp_Key;
String WS_sec_conKey = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
protected:
String calculateWebSocketResponseKey(String sec_WS_key);
void printWebSocketHeader(String wsRespKey);
String getContentType(String filename);
boolean handlehttp();
boolean handleWS();
void parseWsMessage(uint32_t len);
uint8_t inbyte();
String URLdecode(String str);
String UTF8toASCII(String str);
String responseCodeToString(int code);
public:
enum { HTTP_NONE = 0, HTTP_GET = 1, HTTP_PUT = 2 };
enum { Continuation_Frame = 0x00, Text_Frame = 0x01, Binary_Frame = 0x02, Connection_Close_Frame = 0x08,
Ping_Frame = 0x09, Pong_Frame = 0x0A };
WebSrv(String Name="WebSrv library", String Version="1.0");
void begin(uint16_t http_port = 80, uint16_t websocket_port = 81);
void stop();
boolean loop();
void show(const char* pagename, int16_t len=-1);
void show_not_found();
boolean streamfile(fs::FS &fs,const char* path);
boolean send(String msg, uint8_t opcode = Text_Frame);
boolean send(const char* msg, uint8_t opcode = Text_Frame);
void sendPing();
void sendPong();
boolean uploadfile(fs::FS &fs,const char* path, uint32_t contentLength);
boolean uploadB64image(fs::FS &fs,const char* path, uint32_t contentLength);
void reply(const String &response, boolean header=true);
const char* ASCIItoUTF8(const char* str);
private:
const int B64index[123] ={
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 63, 62, 62, 63,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 0, 0, 0, 0, 0, 0,
0, 0, 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, 0, 0, 0, 0, 63,
0, 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
};
};
#endif /* WEBSRV_H_ */

View File

@ -0,0 +1,4 @@
# Name, Type, SubType, Offset, Size
nvs, data, nvs, 0x9000, 0x4000
phy_init, data, phy, 0xd000, 0x1000
factory, app, factory, 0x10000, 3M,
1 # Name, Type, SubType, Offset, Size
2 nvs, data, nvs, 0x9000, 0x4000
3 phy_init, data, phy, 0xd000, 0x1000
4 factory, app, factory, 0x10000, 3M,

View File

@ -0,0 +1,61 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/en/latest/platforms/espressif32.html
[env:esp32dev]
platform = https://github.com/platformio/platform-espressif32.git#v6.5.0
board = esp32dev ;chipmodel ESP32, 4M FLASH, USBtoTTL
board_build.f_cpu = 240000000L
board_build.flash_size=4MB
board_build.flash_freq=80M
board_build.spiram_mode=2
framework = arduino
monitor_speed = 115200
monitor_filters = esp32_exception_decoder
board_build.partitions = default.csv
upload_speed = 460800 ; 921600, 512000, 460800, 256000, 115200
lib_deps =
https://github.com/schreibfaul1/ESP32-audioI2S.git#3.0.8
https://github.com/yellobyte/SoapESP32.git#1.1.4
https://github.com/arduino-libraries/Arduino_JSON.git
platform_packages =
framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.14
board_upload.maximum_size = 3145728
board_upload.flash_size = 4MB
board_build.flash_mode = qio
board_build.bootloader = dio
;build_flags = -DCORE_DEBUG_LEVEL=0 ; None
;build_flags = -DCORE_DEBUG_LEVEL=1 ; Error
;build_flags = -DCORE_DEBUG_LEVEL=2 ; Warn
;build_flags = -DCORE_DEBUG_LEVEL=3 ; Info
;build_flags = -DCORE_DEBUG_LEVEL=4 ; Debug
;build_flags = -DCORE_DEBUG_LEVEL=5 ; Verbose
build_flags =
; -Wall
; -Wextra
-Wdouble-promotion ; double to float warnings
-Wimplicit-fallthrough ; switch case without break
-DCORE_DEBUG_LEVEL=3
-DCONFIG_ARDUHAL_LOG_COLORS
-DBOARD_HAS_PSRAM
-DARDUINO_RUNNING_CORE=3 ; Arduino Runs On Core (setup, loop)
-DARDUINO_EVENT_RUNNING_CORE=1 ; Events Run On Core
; -DAUDIO_LOG
build_unflags =
; -DARDUINO_USB_CDC_ON_BOOT=0 ; traditional log
; -DBOARD_HAS_PSRAM

View File

@ -0,0 +1,5 @@
# DLNA
DLNA servers are available in many home networks. Many Internet routers (e.g. Fritzbox) have an integrated DLNA service. It is also easy to set up a own DLNA server (e.g. miniDLNA on a Raspberry Pi). The SoapESP32 library https://github.com/yellobyte/SoapESP32 used here automatically recognizes the DLNA servers available in the home network. Thanks to yellobyte for this library. Since the SW is too extensive for a sketch, I have published a complete project here. Simply download the repository and unzip the DLNA folder. You can open the project with PlatformIO. Change the access data and, if necessary, the GPIOs in main.cpp. If a DLNA server was detected, its content will be displayed in the browser. If an audio file is selected, the playback process begins using the audioI2S library.
<br>
Webpage
![Webpage](https://github.com/schreibfaul1/ESP32-audioI2S/blob/master/examples/DLNA/additional_info/DLNA_web.jpg)

View File

@ -0,0 +1,287 @@
/*
* index.h
*
* Created on: 13.12.2022
* Updated on: 20.12.2022
* Author: Wolle
*
* ESP32 - DLNA
*
*/
#ifndef INDEX_H_
#define INDEX_H_
#include "Arduino.h"
// file in raw data format for PROGMEM
const char index_html[] PROGMEM = R"=====(
<!DOCTYPE HTML>
<html>
<head>
<title>ESP32 - DLNA</title>
<style type="text/css"> /* optimized with csstidy */
html { /* This is the groundplane */
font-family : serif;
height : 100%;
font-size: 16px;
color : DarkSlateGray;
background-color : navy;
margin : 0;
padding : 0;
}
#content {
min-height : 540px;
min-width : 725px;
overflow : hidden;
background-color : lightskyblue;
margin : 0;
padding : 5px;
}
#tab-content1 {
margin : 20px;
}
.boxstyle {
height : 36px;
padding-top : 0;
padding-left : 15px;
padding-bottom : 0;
background-color: white;
font-size : 16px;
line-height : normal;
border-color: black;
border-style: solid;
border-width: thin;
border-radius : 5px;
}
#BODY { display:block; }
</style>
</head>
<script>
// global variables and functions
// ---- websocket section------------------------
var socket = undefined
var host = location.hostname
var tm
function ping() {
if (socket.readyState == 1) { // reayState 'open'
socket.send("ping")
console.log("send ping")
tm = setTimeout(function () {
console.log('The connection to the ESP32 is interrupted! Please reload the page!')
}, 10000)
}
}
function connect() {
socket = new WebSocket('ws://'+window.location.hostname+':81/');
socket.onopen = function () {
console.log("Websocket connected")
socket.send('DLNA_getServer')
setInterval(ping, 20000)
};
socket.onclose = function (e) {
console.log(e)
console.log('Socket is closed. Reconnect will be attempted in 1 second.', e)
socket = null
setTimeout(function () {
connect()
}, 1000)
}
socket.onerror = function (err) {
console.log(err)
}
socket.onmessage = function(event) {
var socketMsg = event.data
var n = socketMsg.indexOf('=')
var msg = ''
var val = ''
if (n >= 0) {
var msg = socketMsg.substring(0, n)
var val = socketMsg.substring(n + 1)
// console.log("para ",msg, " val ",val)
}
else {
msg = socketMsg
}
switch(msg) {
case "pong": clearTimeout(tm)
break
case "DLNA_Names": showServer(val)
break
case "Level1": show_DLNA_Content(val, 1)
break
case "Level2": show_DLNA_Content(val, 2)
break
case "Level3": show_DLNA_Content(val, 3)
break
case "Level4": show_DLNA_Content(val, 4)
break
case "Level5": show_DLNA_Content(val, 5)
break
default: console.log('unknown message', msg, val)
}
}
}
// ---- end websocket section------------------------
document.addEventListener('readystatechange', event => {
if (event.target.readyState === 'interactive') { // same as: document.addEventListener('DOMContentLoaded'...
// same as jQuery.ready
console.log('All HTML DOM elements are accessible')
// document.getElementById('dialog').style.display = 'none' // hide the div (its only a template)
}
if (event.target.readyState === 'complete') {
console.log('Now external resources are loaded too, like css,src etc... ')
connect(); // establish websocket connection
}
})
function showServer(val){
console.log(val)
var select = document.getElementById('server')
select.options.length = 0;
var server = val.split(",")
for (i = -1; i < (server.length); i++) {
opt = document.createElement('OPTION')
if(i == -1){
opt.value = ""
opt.text = "Select a DLNA Server here"
}
else{
console.log(server[i])
opt.value = server[i]
opt.text = server[i]
}
select.add(opt)
}
}
function show_DLNA_Content(val, level){
var select
if(level == 1) select = document.getElementById('level1')
if(level == 2) select = document.getElementById('level2')
if(level == 3) select = document.getElementById('level3')
if(level == 4) select = document.getElementById('level4')
if(level == 5) select = document.getElementById('level5')
content =JSON.parse(val)
//console.log(ct[1].name)
select.options.length = 0;
for (i = -1; i < (content.length); i++) {
opt = document.createElement('OPTION')
if(i == -1){
opt.value = ""
opt.text = "Select level " + level.toString()
}
else{
var n
var c
if(content[i].isDir == true){
n = content[i].name.concat('\xa0\xa0', '<DIR>'); // more than one space
c = 'D=' + content[i].id // is directory
}
else{
n = content[i].name + '\xa0\xa0' + content[i].size;
c = 'F=' + content[i].id // is file
}
opt.value = c
opt.text = n
}
select.add(opt)
}
}
function selectserver (presctrl) { // preset, select a server, root, level0
socket.send('DLNA_getContent0=' + presctrl.value)
select = document.getElementById('level1'); select.options.length = 0; // clear next level
select = document.getElementById('level2'); select.options.length = 0;
select = document.getElementById('level3'); select.options.length = 0;
select = document.getElementById('level4'); select.options.length = 0;
select = document.getElementById('level5'); select.options.length = 0;
console.log('DLNA_getContent0=' + presctrl.value)
}
function select_l1 (presctrl) { // preset, select root
socket.send('DLNA_getContent1=' + presctrl.value)
select = document.getElementById('level2'); select.options.length = 0; // clear next level
select = document.getElementById('level3'); select.options.length = 0;
select = document.getElementById('level4'); select.options.length = 0;
select = document.getElementById('level5'); select.options.length = 0;
console.log('DLNA_getContent1=' + presctrl.value)
}
function select_l2 (presctrl) { // preset, select level 1
socket.send('DLNA_getContent2=' + presctrl.value)
select = document.getElementById('level3'); select.options.length = 0;
select = document.getElementById('level4'); select.options.length = 0;
select = document.getElementById('level5'); select.options.length = 0;
console.log('DLNA_getContent2=' + presctrl.value)
}
function select_l3 (presctrl) { // preset, select level 2
socket.send('DLNA_getContent3=' + presctrl.value)
select = document.getElementById('level4'); select.options.length = 0;
select = document.getElementById('level5'); select.options.length = 0;
console.log('DLNA_getContent3=' + presctrl.value)
}
function select_l4 (presctrl) { // preset, select level 3
socket.send('DLNA_getContent4=' + presctrl.value)
select = document.getElementById('level5'); select.options.length = 0;
console.log('DLNA_getContent4=' + presctrl.value)
}
function select_l5 (presctrl) { // preset, select level 4
socket.send('DLNA_getContent5=' + presctrl.value)
console.log('DLNA_getContent5=' + presctrl.value)
}
</script>
<body id="BODY">
<!--==============================================================================================-->
<div id="content">
<div id="content1">
<div style="font-size: 50px; text-align: center; flex: 1;">
ESP32 - DLNA
</div>
<div style="display: flex;">
<div style="flex: 0 0 calc(100% - 0px);">
<select class="boxstyle" style="width: 100%;" onchange="selectserver(this)" id="server">
<option value="-1">Select a DLNA Server here</option>
</select>
<select class="boxstyle" style="width: 100%; margin-top: 5px;" onchange="select_l1(this)" id="level1">
<option value="-1"> </option>
</select>
<select class="boxstyle" style="width: 100%; margin-top: 5px;" onchange="select_l2(this)" id="level2">
<option value="-1"> </option>
</select>
<select class="boxstyle" style="width: 100%; margin-top: 5px;" onchange="select_l3(this)" id="level3">
<option value="-1"> </option>
</select>
<select class="boxstyle" style="width: 100%; margin-top: 5px;" onchange="select_l4(this)" id="level4">
<option value="-1"> </option>
</select>
<select class="boxstyle" style="width: 100%; margin-top: 5px;" onchange="select_l5(this)" id="level5">
<option value="-1"> </option>
</select>
</div>
</div>
<hr>
</div>
</div>
<!--==============================================================================================-->
</body>
</html>
)=====";
#endif /* INDEX_H_ */

View File

@ -0,0 +1,189 @@
#include <Arduino.h>
#include <WiFi.h>
#include "websrv.h"
#include "index.h"
#include "Audio.h"
#include "SoapESP32.h"
#include "Arduino_JSON.h"
#include <vector>
using namespace std;
#define I2S_DOUT 25
#define I2S_BCLK 27
#define I2S_LRC 26
char SSID[] = "xxxxx";
char PASS[] = "xxxxx";
WebSrv webSrv;
WiFiClient client;
WiFiUDP udp;
SoapESP32 soap(&client, &udp);
Audio audio;
uint numServers = 0;
int currentServer = -1;
uint32_t media_downloadPort = 0;
String media_downloadIP = "";
vector<String> names{};
//----------------------------------------------------------------------------------------------------------------------
int DLNA_setCurrentServer(String serverName){
int serverNum = -1;
for(int i = 0; i < names.size(); i++){
if(names[i] == serverName) serverNum = i;
}
currentServer = serverNum;
return serverNum;
}
void DLNA_showServer(){ // Show connection details of all discovered, usable media servers
String msg = "DLNA_Names=";
soapServer_t srv;
names.clear();
for(int i = 0; i < numServers; i++){
soap.getServerInfo(i, &srv);
Serial.printf("Server[%d]: IP address: %s port: %d name: %s -> controlURL: %s\n",
i, srv.ip.toString().c_str(), srv.port, srv.friendlyName.c_str(), srv.controlURL.c_str());
msg += srv.friendlyName;
if(i < numServers - 1) msg += ',';
names.push_back(srv.friendlyName);
}
log_i("msg %s", msg.c_str());
webSrv.send(msg);
}
void DLNA_browseServer(String objectId, uint8_t level){
JSONVar myObject;
soapObjectVect_t browseResult;
soapObject_t object;
// Here the user selects the DLNA server whose content he wants to see, level 0 is root
if(level == 0){
if(DLNA_setCurrentServer(objectId) < 0) {log_e("DLNA Server not found"); return;}
objectId = "0";
}
soap.browseServer(currentServer, objectId.c_str(), &browseResult);
if(browseResult.size() == 0){
log_i("no content!"); // then the directory is empty
return;
}
log_v("objectID: %s", objectId.c_str());
for (int i = 0; i < browseResult.size(); i++){
object = browseResult[i];
myObject[i]["name"]= object.name;
myObject[i]["isDir"] = object.isDirectory;
if(object.isDirectory){
myObject[i]["id"] = object.id;
}
else {
myObject[i]["id"] = object.uri;
media_downloadPort = object.downloadPort;
media_downloadIP = object.downloadIp.toString();
}
myObject[i]["size"] = (uint32_t)object.size;
myObject[i]["uri"] = object.id;
log_v("objectName %s", browseResult[i].name.c_str());
log_v("objectId %s", browseResult[i].artist.c_str());
}
level++;
String msg = "Level" + String(level,10) + "=" + JSON.stringify(myObject);
log_v("msg = %s", msg.c_str());
webSrv.send(msg);
browseResult.clear();
}
void DLNA_getFileItems(String uri){
soapObjectVect_t browseResult;
log_v("uri: %s", uri.c_str());
log_v("downloadIP: %s", media_downloadIP.c_str());
log_v("downloadport: %d", media_downloadPort);
String URL = "http://" + media_downloadIP + ":" + media_downloadPort + "/" + uri;
log_i("URL=%s", URL.c_str());
audio.connecttohost(URL.c_str());
}
void DLNA_showContent(String objectId, uint8_t level){
log_v("obkId=%s", objectId.c_str());
if(level == 0){
DLNA_browseServer(objectId, level);
}
if(objectId.startsWith("D=")) {
objectId = objectId.substring(2);
DLNA_browseServer(objectId, level);
}
if(objectId.startsWith("F=")) {
objectId = objectId.substring(2);
DLNA_getFileItems(objectId);
}
}
//----------------------------------------------------------------------------------------------------------------------
// S E T U P
//----------------------------------------------------------------------------------------------------------------------
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.begin(SSID, PASS);
while (WiFi.status() != WL_CONNECTED) delay(1500);
log_i("connected, IP=%s", WiFi.localIP().toString().c_str());
webSrv.begin(80, 81); // HTTP port, WebSocket port
soap.seekServer();
numServers = soap.getServerCount();
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
audio.setVolume(21); // 0...21
}
//----------------------------------------------------------------------------------------------------------------------
// L O O P
//----------------------------------------------------------------------------------------------------------------------
void loop() {
vTaskDelay(1);
if(webSrv.loop()) return; // if true: ignore all other for faster response to web
audio.loop();
}
//----------------------------------------------------------------------------------------------------------------------
// E V E N T S
//----------------------------------------------------------------------------------------------------------------------
void WEBSRV_onCommand(const String cmd, const String param, const String arg){ // called from html
log_d("WS_onCmd: cmd=\"%s\", params=\"%s\", arg=\"%s\"", cmd.c_str(),param.c_str(), arg.c_str());
if(cmd == "index.html"){ webSrv.show(index_html); return;}
if(cmd == "ping"){webSrv.send("pong"); return;}
if(cmd == "favicon.ico") return;
if(cmd == "DLNA_getServer") {DLNA_showServer(); return;}
if(cmd == "DLNA_getContent0"){DLNA_showContent(param, 0); return;}
if(cmd == "DLNA_getContent1"){DLNA_showContent(param, 1); return;} // search for level 1 content
if(cmd == "DLNA_getContent2"){DLNA_showContent(param, 2); return;} // search for level 2 content
if(cmd == "DLNA_getContent3"){DLNA_showContent(param, 3); return;} // search for level 3 content
if(cmd == "DLNA_getContent4"){DLNA_showContent(param, 4); return;} // search for level 4 content
if(cmd == "DLNA_getContent5"){DLNA_showContent(param, 5); return;} // search for level 5 content
log_e("unknown HTMLcommand %s, param=%s", cmd.c_str(), param.c_str());
}
void WEBSRV_onRequest(const String request, uint32_t contentLength){
log_d("WS_onReq: %s contentLength %d", request.c_str(), contentLength);
if(request.startsWith("------")) return; // uninteresting WebKitFormBoundaryString
if(request.indexOf("form-data") > 0) return; // uninteresting Info
log_e("unknown request: %s",request.c_str());
}
void WEBSRV_onInfo(const char* info){
log_v("HTML_info: %s", info); // infos for debug
}
void audio_info(const char *info){
Serial.print("info "); Serial.println(info);
}
void audio_id3data(const char *info){ //id3 metadata
Serial.print("id3data ");Serial.println(info);
}
void audio_eof_stream(const char* info){ // The webstream comes to an end
Serial.print("end of stream: ");Serial.println(info);
}
void audio_bitrate(const char *info){
Serial.print("bitrate ");Serial.println(info);
}
void audio_lasthost(const char *info){ //stream URL played
Serial.print("lasthost ");Serial.println(info);
}

View File

@ -0,0 +1,11 @@
This directory is intended for PlatformIO Test Runner and project tests.
Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.
More information about PlatformIO Unit Testing:
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html

Binary file not shown.

View File

@ -0,0 +1,316 @@
/*
ES8311 - An ES8311 Codec driver library for Arduino
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
examples:
//one I2C bus: (default behaviour)
ES8311 es;
es.begin(sda, scl);
//two I2C busses:
TwoWire i2cBusOne = TwoWire(0);
TwoWire i2cBusTwo = TwoWire(1);
ES8311 es(&i2cBusOne);
i2cBusOne.begin(sda, scl, 400000);
*/
#include "es8311.h"
/* codec hifi mclk clock divider coefficients */
static const struct _coeff_div coeff_div[] = {
/*!<mclk rate pre_div mult adc_div dac_div fs_mode lrch lrcl bckdiv osr */
/* 8k */
{12288000, 8000, 0x06, 0x00, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{18432000, 8000, 0x03, 0x01, 0x03, 0x03, 0x00, 0x05, 0xff, 0x18, 0x10, 0x10},
{16384000, 8000, 0x08, 0x00, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{8192000, 8000, 0x04, 0x00, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{6144000, 8000, 0x03, 0x00, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{4096000, 8000, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{3072000, 8000, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{2048000, 8000, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{1536000, 8000, 0x03, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{1024000, 8000, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
/* 11.025k */
{11289600, 11025, 0x04, 0x00, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{5644800, 11025, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{2822400, 11025, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{1411200, 11025, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
/* 12k */
{12288000, 12000, 0x04, 0x00, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{6144000, 12000, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{3072000, 12000, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{1536000, 12000, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
/* 16k */
{12288000, 16000, 0x03, 0x00, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{18432000, 16000, 0x03, 0x01, 0x03, 0x03, 0x00, 0x02, 0xff, 0x0c, 0x10, 0x10},
{16384000, 16000, 0x04, 0x00, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{8192000, 16000, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{6144000, 16000, 0x03, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{4096000, 16000, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{3072000, 16000, 0x03, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{2048000, 16000, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{1536000, 16000, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{1024000, 16000, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
/* 22.05k */
{11289600, 22050, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{5644800, 22050, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{2822400, 22050, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{1411200, 22050, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{705600, 22050, 0x01, 0x03, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
/* 24k */
{12288000, 24000, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{18432000, 24000, 0x03, 0x00, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{6144000, 24000, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{3072000, 24000, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{1536000, 24000, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
/* 32k */
{12288000, 32000, 0x03, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{18432000, 32000, 0x03, 0x02, 0x03, 0x03, 0x00, 0x02, 0xff, 0x0c, 0x10, 0x10},
{16384000, 32000, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{8192000, 32000, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{6144000, 32000, 0x03, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{4096000, 32000, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{3072000, 32000, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{2048000, 32000, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{1536000, 32000, 0x03, 0x03, 0x01, 0x01, 0x01, 0x00, 0x7f, 0x02, 0x10, 0x10},
{1024000, 32000, 0x01, 0x03, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
/* 44.1k */
{11289600, 44100, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{5644800, 44100, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{2822400, 44100, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{1411200, 44100, 0x01, 0x03, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
/* 48k */
{12288000, 48000, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{18432000, 48000, 0x03, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{6144000, 48000, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{3072000, 48000, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{1536000, 48000, 0x01, 0x03, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
/* 64k */
{12288000, 64000, 0x03, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{18432000, 64000, 0x03, 0x02, 0x03, 0x03, 0x01, 0x01, 0x7f, 0x06, 0x10, 0x10},
{16384000, 64000, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{8192000, 64000, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{6144000, 64000, 0x01, 0x02, 0x03, 0x03, 0x01, 0x01, 0x7f, 0x06, 0x10, 0x10},
{4096000, 64000, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{3072000, 64000, 0x01, 0x03, 0x03, 0x03, 0x01, 0x01, 0x7f, 0x06, 0x10, 0x10},
{2048000, 64000, 0x01, 0x03, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{1536000, 64000, 0x01, 0x03, 0x01, 0x01, 0x01, 0x00, 0xbf, 0x03, 0x18, 0x18},
{1024000, 64000, 0x01, 0x03, 0x01, 0x01, 0x01, 0x00, 0x7f, 0x02, 0x10, 0x10},
/* 88.2k */
{11289600, 88200, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{5644800, 88200, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{2822400, 88200, 0x01, 0x03, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{1411200, 88200, 0x01, 0x03, 0x01, 0x01, 0x01, 0x00, 0x7f, 0x02, 0x10, 0x10},
/* 96k */
{12288000, 96000, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{18432000, 96000, 0x03, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{6144000, 96000, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{3072000, 96000, 0x01, 0x03, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
{1536000, 96000, 0x01, 0x03, 0x01, 0x01, 0x01, 0x00, 0x7f, 0x02, 0x10, 0x10},
};
ES8311::ES8311(TwoWire *TwoWireInstance){
_TwoWireInstance = TwoWireInstance;
}
ES8311::~ES8311(){
if (_TwoWireInstance != NULL) {
_TwoWireInstance->end();
}
}
/*
* look for the coefficient in coeff_div[] table
*/
int ES8311::get_coeff(uint32_t mclk, uint32_t rate){
for (int i = 0; i < (sizeof(coeff_div) / sizeof(coeff_div[0])); i++) {
if (coeff_div[i].rate == rate && coeff_div[i].mclk == mclk) {
return i;
}
}
return -1;
}
bool ES8311::begin(int32_t sda, int32_t scl, uint32_t frequency) {
bool ok = true;
uint8_t reg = 0;
if((sda >= 0) && (scl >= 0)){
ok = _TwoWireInstance->begin(sda, scl, frequency);
_TwoWireInstance->beginTransmission(ES8311_ADDR);
ok = (Wire.endTransmission() == 0);
if(!ok) {
_TwoWireInstance->end();
log_e("ES8311 not found"); return false;
}
}
else {
log_e("Invalid SDA/SCL pins");
return false;
}
ok |= WriteReg(0x00, 0x1F); // Reset
vTaskDelay(20 / portTICK_PERIOD_MS);
ok |= WriteReg(0x00, 0x00); // Release reset
ok |= WriteReg(0x00, 0x80); // Power on
ok |= WriteReg(0x01, 0x3F); // Enable all clocks
reg = ReadReg(0x06);
reg &= ~BIT(5); // SCLK (BCLK) pin not inverted
ok |= WriteReg(0x06, reg); //
ok |= setSampleRate(ES8311_SAMPLE_RATE48); // default
ok |= setBitsPerSample(ES8311_BITS_PER_SAMPLE16); // default
ok |= WriteReg(0x0D, 0x01); // Power up analog circuitry
ok |= WriteReg(0x0E, 0x02); // Enable analog PGA, enable ADC modulator
ok |= WriteReg(0x12, 0x00); // Power-up DAC
ok |= WriteReg(0x13, 0x10); // Enable output to HP drive
ok |= WriteReg(0x1C, 0x6A); // ADC Equalizer bypass, cancel DC offset in digital domain
ok |= WriteReg(0x37, 0x08); // Bypass DAC equalizer
return ok;
}
bool ES8311::setVolume(uint8_t volume){ // 0...100
if (volume > 100) {volume = 100;}
int reg32;
if (volume == 0) {reg32 = 0;}
else { reg32 = ((volume) * 256 / 100) - 1;}
return WriteReg(0x32, reg32);
}
uint8_t ES8311::getVolume(){
uint8_t reg32 = ReadReg(0x32);
uint8_t volume;
if (reg32 == 0) {
volume = 0;
} else {
volume = ((reg32 * 100) / 256) + 1;
}
return volume;
}
bool ES8311::setSampleRate(uint32_t sample_rate){
uint8_t reg = 0;
bool ok = true;
_mclk_hz = sample_rate * 256; // default MCLK frequency
if(sample_rate > 64000) _mclk_hz /= 2;
int coeff = get_coeff(_mclk_hz, sample_rate);
if (coeff < 0) {log_e("Invalid sample rate %i", sample_rate); return false;}
const struct _coeff_div *const selected_coeff = &coeff_div[coeff];
reg = ReadReg(0x02);
reg |= (selected_coeff->pre_div - 1) << 5;
reg |= selected_coeff->pre_multi << 3;
ok |= WriteReg(0x02, reg); // Set pre_div and pre_multi
const uint8_t reg03 = (selected_coeff->fs_mode << 6) | selected_coeff->adc_osr;
ok |= WriteReg(0x03, reg03); // Set fs_mode and adc_osr
ok |= WriteReg(0x04, selected_coeff->dac_osr); // Set dac_osr
const uint8_t reg05 = ((selected_coeff->adc_div - 1) << 4) | (selected_coeff->dac_div - 1);
ok |= WriteReg(0x05, reg05); // Set adc_div and dac_div
reg = ReadReg(0x06);
reg &= 0xE0;
if (selected_coeff->bclk_div < 19) {reg |= (selected_coeff->bclk_div - 1) << 0;}
else { reg |= (selected_coeff->bclk_div) << 0;}
ok |= WriteReg(0x06, reg); // Set bclk_div
reg = ReadReg(0x07);
reg &= 0xC0;
reg |= selected_coeff->lrck_h << 0;
ok |= WriteReg(0x07, reg); // Set lrck_h
ok |= WriteReg(0x08, selected_coeff->lrck_l); // Set lrck_l
return ok;
}
bool ES8311::setBitsPerSample(uint8_t bps){
uint8_t reg09 = ReadReg(0x09);
uint8_t reg0A = ReadReg(0x0A);
switch (bps) {
case 16: reg09 |= (3 << 2); reg0A |= (3 << 2); break;
case 18: reg09 |= (2 << 2); reg0A |= (2 << 2); break;
case 20: reg09 |= (1 << 2); reg0A |= (1 << 2); break;
case 24: reg09 |= (0 << 2); reg0A |= (0 << 2); break;
case 32: reg09 |= (4 << 2); reg0A |= (4 << 2); break;
default: return false; // Invalid bits per sample
}
bool ok = WriteReg(0x09, reg09);
ok |= WriteReg(0x0A, reg0A);
return ok;
}
bool ES8311::enableMicrophone(bool enable){
uint8_t reg = 0x1A; // enable analog MIC and max PGA gain
if (enable) {
reg |= BIT(6);
}
bool ok = WriteReg(0x17, 0xC8); // ADC_VOLUME
ok |= WriteReg(0x14, reg); // Enable MIC
return ok;
}
bool ES8311::setMicrophoneGain(uint8_t gain){ // 0...7
uint8_t reg = ReadReg(0x16);
reg &= 0xF8; // Clear gain bits
if (gain > 7) {gain = 7;}
reg |= gain; // Set gain bits
bool ok = WriteReg(0x16, gain); // ADC_VOLUME
return ok;
}
uint8_t ES8311::getMicrophoneGain(){
uint8_t reg = ReadReg(0x16);
return (reg & 0x07); // Get gain bits
}
bool ES8311::WriteReg(uint8_t reg, uint8_t val){
_TwoWireInstance->beginTransmission(ES8311_ADDR);
_TwoWireInstance->write(reg);
_TwoWireInstance->write(val);
return _TwoWireInstance->endTransmission() == 0;
}
uint8_t ES8311::ReadReg(uint8_t reg){
_TwoWireInstance->beginTransmission(ES8311_ADDR);
_TwoWireInstance->write(reg);
_TwoWireInstance->endTransmission(false);
uint8_t val = 0u;
_TwoWireInstance->requestFrom(uint16_t(ES8311_ADDR), (uint8_t)1, true);
if(_TwoWireInstance->available() >= 1){
val = _TwoWireInstance->read();
}
_TwoWireInstance->endTransmission();
return val;
}
void ES8311::read_all(){
for (uint8_t i = 0; i < 0x4A; i++) {
Serial.printf("0x%02X: 0x%02X\n", i, ReadReg(i));
}
}

View File

@ -0,0 +1,48 @@
#pragma once
#include <Arduino.h>
#include <Wire.h>
#define ES8311_ADDR 0x18
#define ES8311_SAMPLE_RATE48 48000
#define ES8311_BITS_PER_SAMPLE16 16
struct _coeff_div { /* Clock coefficient structure */
uint32_t mclk; /* mclk frequency */
uint32_t rate; /* sample rate */
uint8_t pre_div; /* the pre divider with range from 1 to 8 */
uint8_t pre_multi; /* the pre multiplier with 0: 1x, 1: 2x, 2: 4x, 3: 8x selection */
uint8_t adc_div; /* adcclk divider */
uint8_t dac_div; /* dacclk divider */
uint8_t fs_mode; /* double speed or single speed, =0, ss, =1, ds */
uint8_t lrck_h; /* adclrck divider and daclrck divider */
uint8_t lrck_l;
uint8_t bclk_div; /* sclk divider */
uint8_t adc_osr; /* adc osr */
uint8_t dac_osr; /* dac osr */
};
class ES8311{
private:
TwoWire *_TwoWireInstance = NULL; // TwoWire Instance
uint32_t _mclk_hz = 48000 * 256; // default MCLK frequency
public:
// Constructor.
ES8311(TwoWire *TwoWireInstance = &Wire);
~ES8311();
bool begin(int32_t sda, int32_t scl, uint32_t frequency);
bool setVolume(uint8_t volume);
uint8_t getVolume();
bool setSampleRate(uint32_t sample_rate);
bool setBitsPerSample(uint8_t bps);
bool enableMicrophone(bool enable);
bool setMicrophoneGain(uint8_t gain);
uint8_t getMicrophoneGain();
void read_all();
protected:
int get_coeff(uint32_t mclk, uint32_t rate);
bool WriteReg(uint8_t reg, uint8_t val);
uint8_t ReadReg(uint8_t reg);
};

View File

@ -0,0 +1,62 @@
#include "Arduino.h"
#include "Audio.h"
#include "WiFi.h"
#include "es8311.h"
#include "Wire.h"
#define I2S_DOUT 9
#define I2S_BCLK 12
#define I2S_MCLK 13
#define I2S_LRC 10
#define I2C_SCL 8
#define I2C_SDA 7
#define PA_ENABLE 53
Audio audio;
ES8311 es;
String ssid = "*****";
String password = "*****";
void setup() {
Serial.begin(115200);
Serial.print("\n\n");
Serial.println("----------------------------------");
Serial.printf("ESP32 Chip: %s\n", ESP.getChipModel());
Serial.printf("Arduino Version: %d.%d.%d\n", ESP_ARDUINO_VERSION_MAJOR, ESP_ARDUINO_VERSION_MINOR, ESP_ARDUINO_VERSION_PATCH);
Serial.printf("ESP-IDF Version: %d.%d.%d\n", ESP_IDF_VERSION_MAJOR, ESP_IDF_VERSION_MINOR, ESP_IDF_VERSION_PATCH);
Serial.printf("ARDUINO_LOOP_STACK_SIZE %d words (32 bit)\n", CONFIG_ARDUINO_LOOP_STACK_SIZE);
Serial.println("----------------------------------");
Serial.print("\n\n");
WiFi.begin(ssid.c_str(), password.c_str());
while (WiFi.status() != WL_CONNECTED) {delay(1500); Serial.print(".");}
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT, I2S_MCLK);
audio.setVolume(21); // default 0...21
pinMode(PA_ENABLE, OUTPUT);
digitalWrite(PA_ENABLE, HIGH);
if(!es.begin(I2C_SDA, I2C_SCL, 400000)) log_e("ES8311 begin failed");
es.setVolume(50);
es.setBitsPerSample(16);
// es.setSampleRate(22050);
// es.read_all();
// audio.connecttohost("http://www.wdr.de/wdrlive/media/einslive.m3u");
audio.connecttohost("http://stream.antennethueringen.de/live/aac-64/stream.antennethueringen.de/"); // aac
}
void loop() {
audio.loop();
vTaskDelay(1);
}
// optional
void audio_info(const char *info){
Serial.print("info "); Serial.println(info);
}

View File

@ -0,0 +1,270 @@
#include <Arduino.h>
#include "ES8388.h"
#include <Wire.h>
#define ES8388_ADDR 0x10
/* ES8388 register */
#define ES8388_CONTROL1 0x00
#define ES8388_CONTROL2 0x01
#define ES8388_CHIPPOWER 0x02
#define ES8388_ADCPOWER 0x03
#define ES8388_DACPOWER 0x04
#define ES8388_CHIPLOPOW1 0x05
#define ES8388_CHIPLOPOW2 0x06
#define ES8388_ANAVOLMANAG 0x07
#define ES8388_MASTERMODE 0x08
/* ADC */
#define ES8388_ADCCONTROL1 0x09
#define ES8388_ADCCONTROL2 0x0a
#define ES8388_ADCCONTROL3 0x0b
#define ES8388_ADCCONTROL4 0x0c
#define ES8388_ADCCONTROL5 0x0d
#define ES8388_ADCCONTROL6 0x0e
#define ES8388_ADCCONTROL7 0x0f
#define ES8388_ADCCONTROL8 0x10
#define ES8388_ADCCONTROL9 0x11
#define ES8388_ADCCONTROL10 0x12
#define ES8388_ADCCONTROL11 0x13
#define ES8388_ADCCONTROL12 0x14
#define ES8388_ADCCONTROL13 0x15
#define ES8388_ADCCONTROL14 0x16
/* DAC */
#define ES8388_DACCONTROL1 0x17
#define ES8388_DACCONTROL2 0x18
#define ES8388_DACCONTROL3 0x19
#define ES8388_DACCONTROL4 0x1a
#define ES8388_DACCONTROL5 0x1b
#define ES8388_DACCONTROL6 0x1c
#define ES8388_DACCONTROL7 0x1d
#define ES8388_DACCONTROL8 0x1e
#define ES8388_DACCONTROL9 0x1f
#define ES8388_DACCONTROL10 0x20
#define ES8388_DACCONTROL11 0x21
#define ES8388_DACCONTROL12 0x22
#define ES8388_DACCONTROL13 0x23
#define ES8388_DACCONTROL14 0x24
#define ES8388_DACCONTROL15 0x25
#define ES8388_DACCONTROL16 0x26
#define ES8388_DACCONTROL17 0x27
#define ES8388_DACCONTROL18 0x28
#define ES8388_DACCONTROL19 0x29
#define ES8388_DACCONTROL20 0x2a
#define ES8388_DACCONTROL21 0x2b
#define ES8388_DACCONTROL22 0x2c
#define ES8388_DACCONTROL23 0x2d
#define ES8388_DACCONTROL24 0x2e
#define ES8388_DACCONTROL25 0x2f
#define ES8388_DACCONTROL26 0x30
#define ES8388_DACCONTROL27 0x31
#define ES8388_DACCONTROL28 0x32
#define ES8388_DACCONTROL29 0x33
#define ES8388_DACCONTROL30 0x34
bool ES8388::write_reg(uint8_t slave_add, uint8_t reg_add, uint8_t data)
{
Wire.beginTransmission(slave_add);
Wire.write(reg_add);
Wire.write(data);
return Wire.endTransmission() == 0;
}
bool ES8388::read_reg(uint8_t slave_add, uint8_t reg_add, uint8_t &data)
{
bool retval = false;
Wire.beginTransmission(slave_add);
Wire.write(reg_add);
Wire.endTransmission(false);
Wire.requestFrom((uint16_t)slave_add, (uint8_t)1, true);
if (Wire.available() >= 1)
{
data = Wire.read();
retval = true;
}
return retval;
}
bool ES8388::begin(int32_t sda, int32_t scl, uint32_t frequency)
{
bool res = identify(sda, scl, frequency);
if (res == true)
{
/* mute DAC during setup, power up all systems, slave mode */
res &= write_reg(ES8388_ADDR, ES8388_DACCONTROL3, 0x04);
res &= write_reg(ES8388_ADDR, ES8388_CONTROL2, 0x50);
res &= write_reg(ES8388_ADDR, ES8388_CHIPPOWER, 0x00);
res &= write_reg(ES8388_ADDR, ES8388_MASTERMODE, 0x00);
/* power up DAC and enable LOUT1+2 / ROUT1+2, ADC sample rate = DAC sample rate */
res &= write_reg(ES8388_ADDR, ES8388_DACPOWER, 0x3e);
res &= write_reg(ES8388_ADDR, ES8388_CONTROL1, 0x12);
/* DAC I2S setup: 16 bit word length, I2S format; MCLK / Fs = 256*/
res &= write_reg(ES8388_ADDR, ES8388_DACCONTROL1, 0x18);
res &= write_reg(ES8388_ADDR, ES8388_DACCONTROL2, 0x02);
/* DAC to output route mixer configuration: ADC MIX TO OUTPUT */
res &= write_reg(ES8388_ADDR, ES8388_DACCONTROL16, 0x1B);
res &= write_reg(ES8388_ADDR, ES8388_DACCONTROL17, 0x90);
res &= write_reg(ES8388_ADDR, ES8388_DACCONTROL20, 0x90);
/* DAC and ADC use same LRCK, enable MCLK input; output resistance setup */
res &= write_reg(ES8388_ADDR, ES8388_DACCONTROL21, 0x80);
res &= write_reg(ES8388_ADDR, ES8388_DACCONTROL23, 0x00);
/* DAC volume control: 0dB (maximum, unattenuated) */
res &= write_reg(ES8388_ADDR, ES8388_DACCONTROL5, 0x00);
res &= write_reg(ES8388_ADDR, ES8388_DACCONTROL4, 0x00);
/* power down ADC while configuring; volume: +9dB for both channels */
res &= write_reg(ES8388_ADDR, ES8388_ADCPOWER, 0xff);
res &= write_reg(ES8388_ADDR, ES8388_ADCCONTROL1, 0x88); // +24db
/* select LINPUT2 / RINPUT2 as ADC input; stereo; 16 bit word length, format right-justified, MCLK / Fs = 256 */
res &= write_reg(ES8388_ADDR, ES8388_ADCCONTROL2, 0xf0); // 50
res &= write_reg(ES8388_ADDR, ES8388_ADCCONTROL3, 0x80); // 00
res &= write_reg(ES8388_ADDR, ES8388_ADCCONTROL4, 0x0e);
res &= write_reg(ES8388_ADDR, ES8388_ADCCONTROL5, 0x02);
/* set ADC volume */
res &= write_reg(ES8388_ADDR, ES8388_ADCCONTROL8, 0x20);
res &= write_reg(ES8388_ADDR, ES8388_ADCCONTROL9, 0x20);
/* set LOUT1 / ROUT1 volume: 0dB (unattenuated) */
res &= write_reg(ES8388_ADDR, ES8388_DACCONTROL24, 0x1e);
res &= write_reg(ES8388_ADDR, ES8388_DACCONTROL25, 0x1e);
/* set LOUT2 / ROUT2 volume: 0dB (unattenuated) */
res &= write_reg(ES8388_ADDR, ES8388_DACCONTROL26, 0x1e);
res &= write_reg(ES8388_ADDR, ES8388_DACCONTROL27, 0x1e);
/* power up and enable DAC; power up ADC (no MIC bias) */
res &= write_reg(ES8388_ADDR, ES8388_DACPOWER, 0x3c);
res &= write_reg(ES8388_ADDR, ES8388_DACCONTROL3, 0x00);
res &= write_reg(ES8388_ADDR, ES8388_ADCPOWER, 0x00);
/* set up MCLK) */
#ifdef FUNC_GPIO0_CLK_OUT1
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0_CLK_OUT1);
#endif
WRITE_PERI_REG(PIN_CTRL, 0xFFF0);
}
return res;
}
/**
* @brief (un)mute one of the two outputs or main dac output of the ES8388 by switching of the output register bits. Does not really mute the selected output, causes an attenuation.
* hence should be used in conjunction with appropriate volume setting. Main dac output mute does mute both outputs
*
* @param out
* @param muted
*/
void ES8388::mute(const ES8388_OUT out, const bool muted)
{
uint8_t reg_addr;
uint8_t mask_mute;
uint8_t mask_val;
switch (out)
{
case ES_OUT1:
reg_addr = ES8388_DACPOWER;
mask_mute = (3 << 4);
mask_val = muted ? 0 : mask_mute;
break;
case ES_OUT2:
reg_addr = ES8388_DACPOWER;
mask_mute = (3 << 2);
mask_val = muted ? 0 : mask_mute;
break;
case ES_MAIN:
default:
reg_addr = ES8388_DACCONTROL3;
mask_mute = 1 << 2;
mask_val = muted ? mask_mute : 0;
break;
}
uint8_t reg;
if (read_reg(ES8388_ADDR, reg_addr, reg))
{
reg = (reg & ~mask_mute) | (mask_val & mask_mute);
write_reg(ES8388_ADDR, reg_addr, reg);
}
}
/**
* @brief Set volume gain for the main dac, or for one of the two output channels. Final gain = main gain + out channel gain
*
* @param out which gain setting to control
* @param vol 0-100 (100 is max)
*/
void ES8388::volume(const ES8388_OUT out, const uint8_t vol)
{
const uint32_t max_vol = 100; // max input volume value
const int32_t max_vol_val = out == ES8388_OUT::ES_MAIN ? 96 : 0x21; // max register value for ES8388 out volume
uint8_t lreg = 0, rreg = 0;
switch (out)
{
case ES_MAIN:
lreg = ES8388_DACCONTROL4;
rreg = ES8388_DACCONTROL5;
break;
case ES_OUT1:
lreg = ES8388_DACCONTROL24;
rreg = ES8388_DACCONTROL25;
break;
case ES_OUT2:
lreg = ES8388_DACCONTROL26;
rreg = ES8388_DACCONTROL27;
break;
}
uint8_t vol_val = vol > max_vol ? max_vol_val : (max_vol_val * vol) / max_vol;
// main dac volume control is reverse scale (lowest value is loudest)
// hence we reverse the calculated value
if (out == ES_MAIN)
{
vol_val = max_vol_val - vol_val;
}
write_reg(ES8388_ADDR, lreg, vol_val);
write_reg(ES8388_ADDR, rreg, vol_val);
}
void ES8388::SetVolumeSpeaker(uint8_t vol) {
vol = vol * 1.6;
volume(ES_OUT1, vol);
volume(ES_MAIN, 100);
}
void ES8388::SetVolumeHeadphone(uint8_t vol){
vol = vol * 1.6;
volume(ES_OUT2, vol);
volume(ES_MAIN, 100);
}
/**
* @brief Test if device with I2C address for ES8388 is connected to the I2C bus
*
* @param sda which pin to use for I2C SDA
* @param scl which pin to use for I2C SCL
* @param frequency which frequency to use as I2C bus frequency
* @return true device was found
* @return false device was not found
*/
bool ES8388::identify(int32_t sda, int32_t scl, uint32_t frequency)
{
Wire.begin(sda, scl, frequency);
Wire.beginTransmission(ES8388_ADDR);
return Wire.endTransmission() == 0;
}

View File

@ -0,0 +1,27 @@
#pragma once
#include <stdint.h>
class ES8388
{
bool write_reg(uint8_t slave_add, uint8_t reg_add, uint8_t data);
bool read_reg(uint8_t slave_add, uint8_t reg_add, uint8_t &data);
bool identify(int32_t sda, int32_t scl, uint32_t frequency);
public:
bool begin(int32_t sda = -1, int32_t scl = -1, uint32_t frequency = 400000U);
enum ES8388_OUT
{
ES_MAIN, // this is the DAC output volume (both outputs)
ES_OUT1, // this is the additional gain for OUT1
ES_OUT2 // this is the additional gain for OUT2
};
void SetVolumeSpeaker(uint8_t vol);
void SetVolumeHeadphone(uint8_t vol);
void mute(const ES8388_OUT out, const bool muted);
void volume(const ES8388_OUT out, const uint8_t vol);
};

View File

@ -0,0 +1,139 @@
#include "Arduino.h"
#include "WiFi.h"
#include "SPI.h"
#include "SD.h"
#include "FS.h"
#include "Wire.h"
#include "ES8388.h"
#include "Audio.h"
// SPI GPIOs
#define SD_CS 13
#define SPI_MOSI 15
#define SPI_MISO 2
#define SPI_SCK 14
// I2S GPIOs, the names refer on ES8388, AS1 Audio Kit V2.2 3378
#define I2S_DSIN 35 // pin not used
#define I2S_BCLK 27
#define I2S_LRC 25
#define I2S_MCLK 0
#define I2S_DOUT 26
// I2C GPIOs
#define IIC_CLK 32
#define IIC_DATA 33
// buttons
// #define BUTTON_2_PIN 13 // shared mit SPI_CS
#define BUTTON_3_PIN 19
#define BUTTON_4_PIN 23
#define BUTTON_5_PIN 18 // Stop
#define BUTTON_6_PIN 5 // Play
// amplifier enable
#define GPIO_PA_EN 21
//Switch S1: 1-OFF, 2-ON, 3-ON, 4-OFF, 5-OFF
String ssid = "*****";
String password = "*****";
ES8388 dac; // ES8388 (new board)
int volume = 40; // 0...100
Audio audio;
//#####################################################################
void setup()
{
Serial.begin(115200);
Serial.println("\r\nReset");
Serial.printf_P(PSTR("Free mem=%l\n"), ESP.getFreeHeap());
pinMode(SD_CS, OUTPUT);
digitalWrite(SD_CS, HIGH);
SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI);
SPI.setFrequency(1000000);
SD.begin(SD_CS);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid.c_str(), password.c_str());
while (WiFi.status() != WL_CONNECTED)
{
Serial.print(".");
delay(100);
}
Serial.printf_P(PSTR("Connected\r\nRSSI: "));
Serial.print(WiFi.RSSI());
Serial.print(" IP: ");
Serial.println(WiFi.localIP());
Serial.printf("Connect to DAC codec... ");
while (not dac.begin(IIC_DATA, IIC_CLK))
{
Serial.printf("Failed!\n");
delay(1000);
}
Serial.printf("OK\n");
dac.SetVolumeSpeaker(volume);
dac.SetVolumeHeadphone(volume);
// ac.DumpRegisters();
// Enable amplifier
pinMode(GPIO_PA_EN, OUTPUT);
digitalWrite(GPIO_PA_EN, HIGH);
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT, I2S_MCLK);
audio.setVolume(10); // 0...21
audio.connecttohost("http://mp3channels.webradio.antenne.de:80/oldies-but-goldies");
// audio.connecttohost("http://dg-rbb-http-dus-dtag-cdn.cast.addradio.de/rbb/antennebrandenburg/live/mp3/128/stream.mp3");
// audio.connecttospeech("Wenn die Hunde schlafen, kann der Wolf gut Schafe stehlen.", "de");
}
//-----------------------------------------------------------------------
void loop(){
vTaskDelay(1);
audio.loop();
}
// optional
void audio_info(const char *info){
Serial.print("info "); Serial.println(info);
}
void audio_id3data(const char *info){ //id3 metadata
Serial.print("id3data ");Serial.println(info);
}
void audio_eof_mp3(const char *info){ //end of file
Serial.print("eof_mp3 ");Serial.println(info);
}
void audio_showstation(const char *info){
Serial.print("station ");Serial.println(info);
}
void audio_showstreamtitle(const char *info){
Serial.print("streamtitle ");Serial.println(info);
}
void audio_bitrate(const char *info){
Serial.print("bitrate ");Serial.println(info);
}
void audio_commercial(const char *info){ //duration in sec
Serial.print("commercial ");Serial.println(info);
}
void audio_icyurl(const char *info){ //homepage
Serial.print("icyurl ");Serial.println(info);
}
void audio_lasthost(const char *info){ //stream URL played
Serial.print("lasthost ");Serial.println(info);
}
void audio_eof_speech(const char *info){
Serial.print("eof_speech ");Serial.println(info);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

View File

@ -0,0 +1,86 @@
// Copied from https://github.com/LilyGO/TTGO-TAudio/issues/12
// Required Libraries (Download zips and add to the Arduino IDE library).
#include "Arduino.h"
#include <WM8978.h> // https://github.com/CelliesProjects/wm8978-esp32
#include <Audio.h> // https://github.com/schreibfaul1/ESP32-audioI2S
// T-Audio 1.6 WM8978 I2C pins.
#define I2C_SDA 19
#define I2C_SCL 18
// T-Audio 1.6 WM8978 I2S pins.
#define I2S_BCK 33
#define I2S_WS 25
#define I2S_DOUT 26
// T-Audio 1.6 WM8978 MCLK gpio number
#define I2S_MCLKPIN 0
Audio audio;
WM8978 dac;
void setup() {
Serial.begin(115200);
// Setup wm8978 I2C interface.
if (!dac.begin(I2C_SDA, I2C_SCL)) {
ESP_LOGE(TAG, "Error setting up dac: System halted.");
while (1) delay(100);
}
// Select I2S pins
audio.setPinout(I2S_BCK, I2S_WS, I2S_DOUT);
audio.i2s_mclk_pin_select(I2S_MCLKPIN);
// WiFi Settings here.
WiFi.begin("EnterSSIDHere", "EnterPasswordHere");
while (!WiFi.isConnected()) {
delay(10);
}
ESP_LOGI(TAG, "Connected. Starting MP3...");
// Enter your Icecast station URL here.
audio.setVolume(21);
audio.connecttohost("http://hestia2.cdnstream.com/1458_128");
// Volume control.
dac.setSPKvol(63); // Change volume here for board speaker output (Max 63).
dac.setHPvol(63, 63); // Change volume here for headphone jack left, right channel.
}
void loop() {
vTaskDelay(1);
audio.loop();
}
// optional
void audio_info(const char *info){
Serial.print("info "); Serial.println(info);
}
void audio_id3data(const char *info){ //id3 metadata
Serial.print("id3data ");Serial.println(info);
}
void audio_eof_mp3(const char *info){ //end of file
Serial.print("eof_mp3 ");Serial.println(info);
}
void audio_showstation(const char *info){
Serial.print("station ");Serial.println(info);
}
void audio_showstreamtitle(const char *info){
Serial.print("streamtitle ");Serial.println(info);
}
void audio_bitrate(const char *info){
Serial.print("bitrate ");Serial.println(info);
}
void audio_commercial(const char *info){ //duration in sec
Serial.print("commercial ");Serial.println(info);
}
void audio_icyurl(const char *info){ //homepage
Serial.print("icyurl ");Serial.println(info);
}
void audio_lasthost(const char *info){ //stream URL played
Serial.print("lasthost ");Serial.println(info);
}
void audio_eof_speech(const char *info){
Serial.print("eof_speech ");Serial.println(info);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 KiB

View File

@ -0,0 +1,94 @@
#include "Arduino.h"
#include "Audio.h"
#include "ETH.h"
#define ETHERNET_IF
#ifdef CONFIG_IDF_TARGET_ESP32
#define I2S_DOUT 25
#define I2S_BCLK 27
#define I2S_LRC 26
#define ETH_PHY_TYPE ETH_PHY_TLK110
#define ETH_PHY_MDC 23
#define ETH_PHY_MDIO 18
#define ETH_PHY_POWER -1
#define ETH_CLK_MODE ETH_CLOCK_GPIO0_IN
#endif
#ifdef CONFIG_IDF_TARGET_ESP32P4
#define I2S_DOUT 22
#define I2S_BCLK 20
#define I2S_LRC 21
#define ETH_PHY_TYPE ETH_PHY_TLK110
#define ETH_PHY_MDC 31
#define ETH_PHY_MDIO 52
#define ETH_PHY_POWER 51
#define ETH_CLK_MODE EMAC_CLK_EXT_IN
#endif
Audio audio;
static bool eth_connected = false;
void onEvent(arduino_event_id_t event) {
switch (event) {
case ARDUINO_EVENT_ETH_START:
Serial.println("ETH Started");
// The hostname must be set after the interface is started, but needs
// to be set before DHCP, so set it from the event handler thread.
ETH.setHostname("esp32-ethernet");
break;
case ARDUINO_EVENT_ETH_CONNECTED: Serial.println("ETH Connected"); break;
case ARDUINO_EVENT_ETH_GOT_IP:
Serial.println("ETH Got IP");
Serial.println(ETH);
eth_connected = true;
break;
case ARDUINO_EVENT_ETH_LOST_IP:
Serial.println("ETH Lost IP");
eth_connected = false;
break;
case ARDUINO_EVENT_ETH_DISCONNECTED:
Serial.println("ETH Disconnected");
eth_connected = false;
break;
case ARDUINO_EVENT_ETH_STOP:
Serial.println("ETH Stopped");
eth_connected = false;
break;
default: break;
}
}
void setup() {
Serial.begin(115200);
Serial.print("A\n\n");
Serial.println("----------------------------------");
Serial.printf("ESP32 Chip: %s\n", ESP.getChipModel());
Serial.printf("Arduino Version: %d.%d.%d\n", ESP_ARDUINO_VERSION_MAJOR, ESP_ARDUINO_VERSION_MINOR, ESP_ARDUINO_VERSION_PATCH);
Serial.printf("ESP-IDF Version: %d.%d.%d\n", ESP_IDF_VERSION_MAJOR, ESP_IDF_VERSION_MINOR, ESP_IDF_VERSION_PATCH);
Serial.printf("ARDUINO_LOOP_STACK_SIZE %d words (32 bit)\n", CONFIG_ARDUINO_LOOP_STACK_SIZE);
Serial.println("----------------------------------");
Serial.print("\n\n");
Network.onEvent(onEvent);
ETH.begin();
while (!eth_connected) delay(100);
Serial.println("ETH Connected");
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
audio.setVolume(21); // default 0...21
audio.connecttohost("http://stream.antennethueringen.de/live/aac-64/stream.antennethueringen.de/"); // aac
pinMode(53, OUTPUT);
digitalWrite(53, HIGH);
}
void loop() {
audio.loop();
vTaskDelay(1);
}
// optional
void audio_info(const char *info){
Serial.print("info "); Serial.println(info);
}

View File

@ -0,0 +1,74 @@
#include "Arduino.h" // >= Arduino V3
#include <ETH.h>
#include <SPI.h>
#define ETHERNET_IF
#include "Audio.h"
Audio audio;
#define USE_TWO_ETH_PORTS 0
#define ETH_PHY_TYPE ETH_PHY_W5500
// GPIOs
#define ETH_PHY_ADDR 1
#define ETH_PHY_CS 3
#define ETH_PHY_IRQ 8
#define ETH_PHY_RST 4
#define ETH_SPI_SCK 7
#define ETH_SPI_MISO 6
#define ETH_SPI_MOSI 5
#define I2S_DOUT 12
#define I2S_BCLK 13
#define I2S_LRC 14
static bool eth_connected = false;
void onEvent(arduino_event_id_t event, arduino_event_info_t info) {
switch (event) {
case ARDUINO_EVENT_ETH_START:
Serial.println("ETH Started");
ETH.setHostname("esp32-eth0"); //set eth hostname here
break;
case ARDUINO_EVENT_ETH_CONNECTED: Serial.println("ETH Connected"); break;
case ARDUINO_EVENT_ETH_GOT_IP: Serial.printf("ETH Got IP: '%s'\n", esp_netif_get_desc(info.got_ip.esp_netif)); Serial.println(ETH);
eth_connected = true;
break;
case ARDUINO_EVENT_ETH_LOST_IP:
Serial.println("ETH Lost IP");
eth_connected = false;
break;
case ARDUINO_EVENT_ETH_DISCONNECTED:
Serial.println("ETH Disconnected");
eth_connected = false;
break;
case ARDUINO_EVENT_ETH_STOP:
Serial.println("ETH Stopped");
eth_connected = false;
break;
default: break;
}
}
void setup(){
Serial.begin(115200);
Serial.print("\n\n");
Network.onEvent(onEvent);
SPI.begin(ETH_SPI_SCK, ETH_SPI_MISO, ETH_SPI_MOSI);
ETH.begin(ETH_PHY_TYPE, ETH_PHY_ADDR, ETH_PHY_CS, ETH_PHY_IRQ, ETH_PHY_RST, SPI);
while (!eth_connected) delay(100);
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
audio.setVolume(21); // default 0...21
audio.connecttohost("https://wdr-wdr2-ruhrgebiet.icecastssl.wdr.de/wdr/wdr2/ruhrgebiet/mp3/128/stream.mp3"); // mp3
}
void loop(){
audio.loop();
vTaskDelay(5 /portTICK_PERIOD_MS);
}
void audio_info(const char *info){
Serial.print("info "); Serial.println(info);
}

View File

@ -0,0 +1,88 @@
#include "Arduino.h"
#include "Audio.h"
#include "SD.h"
#include "FS.h"
// Digital I/O used
#define SD_CS 5
#define SPI_MOSI 2
#define SPI_MISO 4
#define SPI_SCK 17
#define I2S_DOUT 12
#define I2S_BCLK 14
#define I2S_LRC 15
#define ETHERNET_IF
#define ETH_PHY_TYPE ETH_PHY_LAN8720
#define ETH_PHY_MDC 23
#define ETH_PHY_MDIO 18
#ifdef CONFIG_IDF_TARGET_ESP32
#define ETH_CLK_MODE ETH_CLOCK_GPIO0_IN
#endif
#ifdef CONFIG_IDF_TARGET_ESP32P4
#define ETH_CLK_MODE EMAC_CLK_EXT_IN
#endif
#include "ETH.h"
Audio audio;
static bool eth_connected = false;
void onEvent(arduino_event_id_t event) {
switch (event) {
case ARDUINO_EVENT_ETH_START:
Serial.println("ETH Started");
// The hostname must be set after the interface is started, but needs
// to be set before DHCP, so set it from the event handler thread.
ETH.setHostname("esp32-ethernet");
break;
case ARDUINO_EVENT_ETH_CONNECTED: Serial.println("ETH Connected"); break;
case ARDUINO_EVENT_ETH_GOT_IP:
Serial.println("ETH Got IP");
Serial.println(ETH);
eth_connected = true;
break;
case ARDUINO_EVENT_ETH_LOST_IP:
Serial.println("ETH Lost IP");
eth_connected = false;
break;
case ARDUINO_EVENT_ETH_DISCONNECTED:
Serial.println("ETH Disconnected");
eth_connected = false;
break;
case ARDUINO_EVENT_ETH_STOP:
Serial.println("ETH Stopped");
eth_connected = false;
break;
default: break;
}
}
void setup() {
pinMode(SD_CS, OUTPUT); digitalWrite(SD_CS, HIGH);
SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI);
Serial.begin(115200);
SD.begin(SD_CS);
Network.onEvent(onEvent);
ETH.begin();
while (!eth_connected) delay(100);
// Eth Connected,
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
audio.setVolume(21); // default 0...21
audio.connecttohost("https://wdr-wdr2-ruhrgebiet.icecastssl.wdr.de/wdr/wdr2/ruhrgebiet/mp3/128/stream.mp3"); // mp3
}
void loop(){
vTaskDelay(1);
audio.loop();
}
void audio_info(const char *info){
Serial.print("info "); Serial.println(info);
}

View File

@ -0,0 +1,100 @@
//**********************************************************************************************************
//* audioI2S-- I2S audiodecoder for ESP32, *
//**********************************************************************************************************
//
// first release on 11/2018
// Version 3 , Jul.02/2020
//
//
// THE SOFTWARE IS PROVIDED "AS IS" FOR PRIVATE USE ONLY, IT IS NOT FOR COMMERCIAL USE IN WHOLE OR PART OR CONCEPT.
// FOR PERSONAL USE IT IS SUPPLIED WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR
// OR COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
//
#include "Arduino.h"
#include "WiFiMulti.h"
#include "Audio.h"
#include "SPI.h"
#include "SD.h"
#include "FS.h"
// Digital I/O used
#define SD_CS 5
#define SPI_MOSI 23
#define SPI_MISO 19
#define SPI_SCK 18
#define I2S_DOUT 25
#define I2S_BCLK 27
#define I2S_LRC 26
Audio audio;
WiFiMulti wifiMulti;
String ssid = "xxxxx";
String password = "xxxxx";
void setup() {
pinMode(SD_CS, OUTPUT);
digitalWrite(SD_CS, HIGH);
SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI);
SPI.setFrequency(1000000);
Serial.begin(115200);
SD.begin(SD_CS);
WiFi.mode(WIFI_STA);
wifiMulti.addAP(ssid.c_str(), password.c_str());
wifiMulti.run();
if(WiFi.status() != WL_CONNECTED){
WiFi.disconnect(true);
wifiMulti.run();
}
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
audio.setVolume(12); // 0...21
// audio.connecttoFS(SD, "test.wav");
// audio.connecttohost("http://www.wdr.de/wdrlive/media/einslive.m3u");
// audio.connecttohost("http://somafm.com/wma128/missioncontrol.asx"); // asx
// audio.connecttohost("http://mp3.ffh.de/radioffh/hqlivestream.aac"); // 128k aac
audio.connecttohost("http://mp3.ffh.de/radioffh/hqlivestream.mp3"); // 128k mp3
}
void loop(){
vTaskDelay(1);
audio.loop();
if(Serial.available()){ // put streamURL in serial monitor
audio.stopSong();
String r=Serial.readString(); r.trim();
if(r.length()>5) audio.connecttohost(r.c_str());
log_i("free heap=%i", ESP.getFreeHeap());
}
}
// optional
void audio_info(const char *info){
Serial.print("info "); Serial.println(info);
}
void audio_id3data(const char *info){ //id3 metadata
Serial.print("id3data ");Serial.println(info);
}
void audio_eof_mp3(const char *info){ //end of file
Serial.print("eof_mp3 ");Serial.println(info);
}
void audio_showstation(const char *info){
Serial.print("station ");Serial.println(info);
}
void audio_showstreamtitle(const char *info){
Serial.print("streamtitle ");Serial.println(info);
}
void audio_bitrate(const char *info){
Serial.print("bitrate ");Serial.println(info);
}
void audio_commercial(const char *info){ //duration in sec
Serial.print("commercial ");Serial.println(info);
}
void audio_icyurl(const char *info){ //homepage
Serial.print("icyurl ");Serial.println(info);
}
void audio_lasthost(const char *info){ //stream URL played
Serial.print("lasthost ");Serial.println(info);
}

View File

@ -0,0 +1,104 @@
//**********************************************************************************************************
//* audioI2S-- I2S audiodecoder for M5Stack Core2 *
//**********************************************************************************************************
//
// first release on May.12/2021
//
//
// THE SOFTWARE IS PROVIDED "AS IS" FOR PRIVATE USE ONLY, IT IS NOT FOR COMMERCIAL USE IN WHOLE OR PART OR CONCEPT.
// FOR PERSONAL USE IT IS SUPPLIED WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR
// OR COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
//
#include <M5Core2.h>
#include "Audio.h"
// Digital I/O used
#define SD_CS 4
#define SD_MOSI 23
#define SD_MISO 38
#define SD_SCK 18
#define I2S_DOUT 2
#define I2S_BCLK 12
#define I2S_LRC 0
Audio audio;
String ssid = "xxxxxx";
String password = "xxxxxx";
void setup() {
M5.begin(true, true, true, true);
M5.Axp.SetSpkEnable(true);
M5.Lcd.fillScreen(BLACK);
M5.Lcd.setTextColor(WHITE);
M5.Lcd.setTextSize(2);
pinMode(SD_CS, OUTPUT);
digitalWrite(SD_CS, HIGH);
SPI.begin(SD_SCK, SD_MISO, SD_MOSI);
SPI.setFrequency(1000000);
SD.begin(SD_CS);
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
audio.setVolume(15); // 0...21
WiFi.mode(WIFI_STA);
WiFi.begin(ssid.c_str(), password.c_str());
while (!WiFi.isConnected()) {
delay(10);
}
ESP_LOGI(TAG, "Connected");
ESP_LOGI(TAG, "Starting MP3...\n");
// audio.connecttoFS(SD, "/320k_test.mp3");
// audio.connecttoFS(SD, "test.wav");
audio.connecttohost("http://air.ofr.fm:8008/jazz/mp3/128");
// audio.connecttospeech("Миска вареників з картоплею та шкварками, змащених салом!", "uk-UA");
}
void loop() {
vTaskDelay(1);
audio.loop();
if(Serial.available()){ // put streamURL in serial monitor
audio.stopSong();
String r=Serial.readString();
r.trim();
if(r.length()>5) audio.connecttohost(r.c_str());
log_i("free heap=%i", ESP.getFreeHeap());
}
}
// optional
void audio_info(const char *info){
Serial.print("info "); Serial.println(info);
}
void audio_id3data(const char *info){ //id3 metadata
Serial.print("id3data ");Serial.println(info);
}
void audio_eof_mp3(const char *info){ //end of file
Serial.print("eof_mp3 ");Serial.println(info);
}
void audio_showstation(const char *info){
Serial.print("station ");Serial.println(info);
}
void audio_showstreamtitle(const char *info){
Serial.print("streamtitle ");Serial.println(info);
}
void audio_bitrate(const char *info){
Serial.print("bitrate ");Serial.println(info);
}
void audio_commercial(const char *info){ //duration in sec
Serial.print("commercial ");Serial.println(info);
}
void audio_icyurl(const char *info){ //homepage
Serial.print("icyurl ");Serial.println(info);
}
void audio_lasthost(const char *info){ //stream URL played
Serial.print("lasthost ");Serial.println(info);
}
void audio_eof_speech(const char *info){
Serial.print("eof_speech ");Serial.println(info);
}

View File

@ -0,0 +1,48 @@
// M5Stack Node support
// thanks to Cellie - issue #35 25.Apr.2020
// M5Stack board with Node base also need a MCLK signal on GPIO0.
#include <WM8978.h> /* https://github.com/CelliesProjects/wm8978-esp32 */
#include <Audio.h> /* https://github.com/schreibfaul1/ESP32-audioI2S */
/* M5Stack Node WM8978 I2C pins */
#define I2C_SDA 21
#define I2C_SCL 22
/* M5Stack Node I2S pins */
#define I2S_BCK 5
#define I2S_WS 13
#define I2S_DOUT 2
#define I2S_DIN 34
/* M5Stack WM8978 MCLK gpio number */
#define I2S_MCLKPIN 0
WM8978 dac;
Audio audio;
void setup() {
/* Setup wm8978 I2C interface */
if (!dac.begin(I2C_SDA, I2C_SCL)) {
log_e("Error setting up dac. System halted");
while (1) delay(100);
}
dac.setSPKvol(40); /* max 63 */
dac.setHPvol(32, 32);
/* Setup wm8978 I2S interface */
audio.setPinout(I2S_BCK, I2S_WS, I2S_DOUT, I2S_MCLKPIN);
WiFi.begin("xxx", "xxx");
while (!WiFi.isConnected()) { delay(10); }
log_i("Connected\nStarting MP3...\n");
audio.connecttohost("http://icecast.omroep.nl/3fm-bb-mp3");
}
void loop() {
vTaskDelay(1);
audio.loop();
}

View File

@ -0,0 +1,86 @@
//**********************************************************************************************************
//* audioI2S-- I2S audiodecoder for M5StickC Plus and SPK HAT *
//**********************************************************************************************************
//
// first release on May.12/2021
//
//
// THE SOFTWARE IS PROVIDED "AS IS" FOR PRIVATE USE ONLY, IT IS NOT FOR COMMERCIAL USE IN WHOLE OR PART OR CONCEPT.
// FOR PERSONAL USE IT IS SUPPLIED WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR
// OR COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
//
#include <M5StickCPlus.h>
#include "Audio.h"
Audio audio = Audio(true);
String ssid = "xxxxxxxx";
String password = "xxxxxxxx";
void setup() {
M5.begin(false); // Lcd disabled to reduce noise
M5.Axp.ScreenBreath(1); // Lower Lcd backlight
pinMode(36, INPUT);
gpio_pulldown_dis(GPIO_NUM_25);
gpio_pullup_dis(GPIO_NUM_25);
M5.Beep.tone(44100); // Built-in buzzer tone
M5.Beep.end(); // disabled
audio.setVolume(15); // 0...21
WiFi.mode(WIFI_STA);
WiFi.begin(ssid.c_str(), password.c_str());
while (!WiFi.isConnected()) { delay(10); }
ESP_LOGI(TAG, "Connected");
ESP_LOGI(TAG, "Starting MP3...\n");
audio.connecttohost("http://air.ofr.fm:8008/jazz/mp3/128");
// audio.connecttospeech("Миска вареників з картоплею та шкварками, змащених салом!", "uk-UA");
}
void loop() {
vTaskDelay(1);
audio.loop();
if(Serial.available()){ // put streamURL in serial monitor
audio.stopSong();
String r=Serial.readString();
r.trim();
if(r.length()>5) audio.connecttohost(r.c_str());
log_i("free heap=%i", ESP.getFreeHeap());
}
}
// optional
void audio_info(const char *info){
Serial.print("info "); Serial.println(info);
}
void audio_id3data(const char *info){ //id3 metadata
Serial.print("id3data ");Serial.println(info);
}
void audio_eof_mp3(const char *info){ //end of file
Serial.print("eof_mp3 ");Serial.println(info);
}
void audio_showstation(const char *info){
Serial.print("station ");Serial.println(info);
}
void audio_showstreamtitle(const char *info){
Serial.print("streamtitle ");Serial.println(info);
}
void audio_bitrate(const char *info){
Serial.print("bitrate ");Serial.println(info);
}
void audio_commercial(const char *info){ //duration in sec
Serial.print("commercial ");Serial.println(info);
}
void audio_icyurl(const char *info){ //homepage
Serial.print("icyurl ");Serial.println(info);
}
void audio_lasthost(const char *info){ //stream URL played
Serial.print("lasthost ");Serial.println(info);
}
void audio_eof_speech(const char *info){
Serial.print("eof_speech ");Serial.println(info);
}

View File

@ -0,0 +1,162 @@
# OpenAI Speech
### platformio.ini - example for: [XIAO ESP32S3](https://www.seeedstudio.com/XIAO-ESP32S3-p-5627.html)
```ShellCheck Config
[env:seeed_xiao_esp32s3]
platform = espressif32
board = seeed_xiao_esp32s3
framework = arduino
monitor_speed = 115200
build_flags =
-Wall
-Wextra
-DCORE_DEBUG_LEVEL=3
-DBOARD_HAS_PSRAM
-DAUDIO_LOG
-DARDUINO_RUNNING_CORE=1 ; Arduino Runs On Core (setup, loop)
-DARDUINO_EVENT_RUNNING_CORE=1 ; Events Run On Core
lib_deps =
https://github.com/schreibfaul1/ESP32-audioI2S.git
```
### main.cpp - using xTask example:
```cpp
#include <Arduino.h>
#include "SPI.h"
#include <WiFi.h>
#include <WiFiMulti.h>
#include "Audio.h"
// WiFi credentials
#define WIFI_SSID "<YOUR_WIFI_SSID>"
#define PASSWORD "<YOUR_WIFI_PASSWORD>"
#define OPENAI_API_KEY "<YOUR_OPENAI_API_KEY>"
// Configure I2S pins
#define I2S_LRC D1
#define I2S_DOUT D2
#define I2S_BCLK D3
#define I2S_MCLK 0
// Vars
bool isWIFIConnected;
String result = "Added OpenAI Text to speech API support";
String instructions = "Voice: Gruff, fast-talking, and a little worn-out, like a New York cabbie who's seen it all but still keeps things moving.\n\n";
// Inits
WiFiMulti wifiMulti;
TaskHandle_t playaudio_handle;
QueueHandle_t audioQueue;
Audio audio;
// Declaration
void audio_info(const char *info);
void wifiConnect(void *pvParameters);
void playaudio(void *pvParameters);
// Default
void setup() {
Serial.begin(115200);
isWIFIConnected = false;
// Create queue
audioQueue = xQueueCreate(1, sizeof(int));
if (audioQueue == NULL) {
Serial.println("Failed to create audioQueue");
while(1);
}
// Create tasks
xTaskCreate(wifiConnect, "wifi_Connect", 4096, NULL, 0, NULL);
delay(500);
xTaskCreate(playaudio, "playaudio", 1024 * 8, NULL, 3, &playaudio_handle);
}
void loop(void) {
audio.loop();
}
void audio_info(const char *info) {
Serial.print("audio_info: ");
Serial.println(info);
}
void wifiConnect(void *pvParameters) {
while(1) {
if (!isWIFIConnected) {
wifiMulti.addAP(WIFI_SSID, PASSWORD);
Serial.println("Connecting to WiFi...");
while (wifiMulti.run() != WL_CONNECTED) {
vTaskDelay(500);
}
Serial.print("Connected to WiFi\nIP: ");
Serial.println(WiFi.localIP());
isWIFIConnected = true;
Serial.println("Sending result...");
int eventMessage;
if (xQueueSend(audioQueue, &eventMessage, 0) != pdPASS) {
Serial.println("Failed to send result to queue");
}
} else {
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}
}
void playaudio(void *pvParameters) {
while(1) {
if (isWIFIConnected && audioQueue != 0) {
int eventMessage;
Serial.println("Waiting for result...");
if (xQueueReceive(audioQueue, &eventMessage, portMAX_DELAY) == pdPASS) {
Serial.print("Received result: ");
Serial.println(result);
// Speech
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT, -1);
audio.setVolume(15); // 0...21
audio.openai_speech(OPENAI_API_KEY, "tts-1", result, instructions, "shimmer", "mp3", "1");
}
} else {
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}
}
```
---
### console output example:
```ShellSession
--- Terminal on /dev/ttyACM0 | 115200 8-N-1
--- Available filters and text transformations: colorize, debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at https://bit.ly/pio-monitor-filters
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H
[ 3911][I][WiFiMulti.cpp:114] run(): [WIFI] scan done
[ 3911][I][WiFiMulti.cpp:119] run(): [WIFI] 15 networks found
[ 3911][I][WiFiMulti.cpp:160] run(): [WIFI] Connecting BSSID: 26:AD:69:C2:AB:E8 SSID: OpwnSS Channel: 11 (-38)
[ 4000][I][WiFiMulti.cpp:174] run(): [WIFI] Connecting done.
Connected to WiFi
IP: 192.168.86.23
audio_info: Connect to new host: "api.openai.com"
audio_info: PSRAM found, inputBufferSize: 638965 bytes
[ 4698][I][Audio.cpp:5331] ts_parsePacket(): parseTS reset
audio_info: buffers freed, free Heap: 255068 bytes
audio_info: connect to api.openai.com on port 443 path /v1/audio/speech
audio_info: SSL has been established in 925 ms, free Heap: 213908 bytes
[ 6921][I][Audio.cpp:4000] parseContentType(): ContentType audio/mpeg, format is mp3
audio_info: MP3Decoder has been initialized, free Heap: 214564 bytes , free stack 3760 DWORDs
[ 6924][I][Audio.cpp:3846] parseHttpResponseHeader(): Switch to DATA, metaint is 0
audio_info: stream ready
audio_info: syncword found at pos 0
audio_info: Channels: 1
audio_info: SampleRate: 24000
audio_info: BitsPerSample: 16
audio_info: BitRate: 160000
audio_info: slow stream, dropouts are possible
audio_info: End of Stream.
```

View File

@ -0,0 +1,61 @@
#include <Arduino.h>
#include "SPI.h"
#include <WiFi.h>
#include <WiFiMulti.h>
#include "Audio.h"
// WiFi credentials
#define WIFI_SSID "<YOUR_WIFI_SSID>"
#define PASSWORD "<YOUR_WIFI_PASSWORD>"
#define OPENAI_API_KEY "<YOUR_OPENAI_API_KEY>" // https://platform.openai.com/api-keys
// Configure I2S pins
#define I2S_LRC D1
#define I2S_DOUT D2
#define I2S_BCLK D3
#define I2S_MCLK 0
// Inits
WiFiMulti wifiMulti;
Audio audio;
String input = "Added OpenAI Text to speech API support";
String instructions = "Voice: Gruff, fast-talking, and a little worn-out, like a New York cabbie who's seen it all but still keeps things moving.\n\n"
"Tone: Slightly exasperated but still functional, with a mix of sarcasm and no-nonsense efficiency.\n\n"
"Dialect: Strong New York accent, with dropped \"r\"s, sharp consonants, and classic phrases like whaddaya and lemme guess.\n\n"
"Pronunciation: Quick and clipped, with a rhythm that mimics the natural hustle of a busy city conversation.\n\n"
"Features: Uses informal, straight-to-the-point language, throws in some dry humor, and keeps the energy just on the edge of impatience but still";
// Declaration
void audio_info(const char *info);
// Default
void setup() {
Serial.begin(115200);
// Wifi
wifiMulti.addAP(WIFI_SSID, PASSWORD);
Serial.println("Connecting to WiFi...");
while (wifiMulti.run() != WL_CONNECTED) {
delay(500);
}
Serial.print("Connected to WiFi\nIP: ");
Serial.println(WiFi.localIP());
delay(500);
// Speech
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT, -1);
audio.setVolume(15); // 0...21
audio.openai_speech(OPENAI_API_KEY, "tts-1", input, instructions, "shimmer", "mp3", "1");
}
void loop(void) {
vTaskDelay(1);
audio.loop();
}
void audio_info(const char *info) {
Serial.print("audio_info: ");
Serial.println(info);
}

View File

@ -0,0 +1,232 @@
#include <Arduino.h>
#include <Preferences.h>
#include <SPI.h>
#include <WiFi.h>
#include "ili9486.h" //see my repository at github "https://github.com/schreibfaul1/ESP32-TFT-Library-ILI9486"
#include "Audio.h" //see my repository at github "https://github.com/schreibfaul1/ESP32-audioI2S"
#define TFT_CS 22
#define TFT_DC 21
#define TP_CS 5
#define TFT_BL 12
#define TP_IRQ 39
#define SPI_MOSI 23
#define SPI_MISO 19
#define SPI_SCK 18
#define I2S_DOUT 25
#define I2S_BCLK 27
#define I2S_LRC 26
Preferences pref;
TFT tft;
TP tp(TP_CS, TP_IRQ);
Audio audio;
String ssid = "Wolles-FRITZBOX";
String password = "40441061073895958449";
String stations[] ={
"http://0n-80s.radionetz.de:8000/0n-70s.mp3",
"http://mediaserv30.live-streams.nl:8000/stream",
"http://www.surfmusic.de/m3u/100-5-das-hitradio,4529.m3u",
"http://stream.1a-webradio.de/deutsch/mp3-128/vtuner-1a",
"http://mp3.ffh.de/radioffh/hqlivestream.aac", // 128k aac
"http://www.antenne.de/webradio/antenne.m3u",
"http://listen.rusongs.ru/ru-mp3-128",
"http://edge.audio.3qsdn.com/senderkw-mp3",
"https://stream.srg-ssr.ch/rsp/aacp_48.asx", // SWISS POP
};
//some global variables
uint8_t max_volume = 21;
uint8_t max_stations = 0; //will be set later
uint8_t cur_station = 0; //current station(nr), will be set later
uint8_t cur_volume = 0; //will be set from stored preferences
int8_t cur_btn =-1; //current button (, -1 means idle)
enum action{VOLUME_UP=0, VOLUME_DOWN=1, STATION_UP=2, STATION_DOWN=3};
enum staus {RELEASED=0, PRESSED=1};
struct _btns{
uint16_t x; //PosX
uint16_t y; //PosY
uint16_t w; //Width
uint16_t h; //Hight
uint8_t a; //Action
uint8_t s; //Status
};
typedef _btns btns;
btns btn[4];
void setTFTbrightness(uint8_t duty) { // duty 0...100 (min...max)
uint8_t d = round((double)duty * 2.55); // #186
ledcWrite(TFT_BL, d);
}
//**************************************************************************************************
// G U I *
//**************************************************************************************************
void draw_button(btns b){
uint16_t color=TFT_BLACK;
uint8_t r=4, o=r*3;
if(b.s==RELEASED) color=TFT_GOLD;
if(b.s==PRESSED) color=TFT_DEEPSKYBLUE;
tft.drawRoundRect(b.x, b.y, b.w, b.h, r, color);
switch(b.a){
case VOLUME_UP:
tft.fillTriangle(b.x+b.w/2, b.y+o, b.x+o, b.y+b.h-o, b.x+b.w-o, b.y+b.h-o, color); break;
case VOLUME_DOWN:
tft.fillTriangle(b.x+o, b.y+o, b.x+b.w/2, b.y+b.h-o, b.x+b.w-o, b.y+o, color); break;
case STATION_UP:
tft.fillTriangle(b.x+o, b.y+o, b.x+o, b.y+b.h-o, b.x+b.w-o, b.y+b.h/2, color); break;
case STATION_DOWN:
tft.fillTriangle(b.x+b.w-o, b.y+o, b.x+o, b.y+b.h/2, b.x+b.w-o, b.y+b.h-o, color); break;
}
}
void write_stationNr(uint8_t nr){
tft.fillRect(80, 250, 80, 60, TFT_BLACK);
String snr = String(nr);
if(snr.length()<2) snr = "0"+snr;
tft.setCursor(98, 255);
tft.setFont(Times_New_Roman66x53);
tft.setTextColor(TFT_YELLOW);
tft.print(snr);
}
void write_volume(uint8_t vol){
tft.fillRect(320, 250, 80, 60, TFT_BLACK);
String svol = String(vol);
if(svol.length()<2) svol = "0"+svol;
tft.setCursor(338, 255);
tft.setFont(Times_New_Roman66x53);
tft.setTextColor(TFT_YELLOW);
tft.print(svol);
}
void write_stationName(String sName){
tft.fillRect(0, 0, 480, 100, TFT_BLACK);
tft.setFont(Times_New_Roman43x35);
tft.setTextColor(TFT_CORNSILK);
tft.setCursor(20, 20);
tft.print(sName);
}
void write_streamTitle(String sTitle){
tft.fillRect(0, 100, 480, 150, TFT_BLACK);
tft.setFont(Times_New_Roman43x35);
tft.setTextColor(TFT_LIGHTBLUE);
tft.setCursor(20, 100);
int l = tft.writeText((const uint8_t*) sTitle.c_str(), 100 + 150); // do not write under y=250
if(l < sTitle.length()){
// sTitle has been shortened, is too long for the display
}
}
//**************************************************************************************************
// S E T U P *
//**************************************************************************************************
void setup() {
btn[0].x= 20; btn[0].y=250; btn[0].w=60; btn[0].h=60; btn[0].a=STATION_DOWN; btn[0].s=RELEASED;
btn[1].x=160; btn[1].y=250; btn[1].w=60; btn[1].h=60; btn[1].a=STATION_UP; btn[1].s=RELEASED;
btn[2].x=260; btn[2].y=250; btn[2].w=60; btn[2].h=60; btn[2].a=VOLUME_UP; btn[2].s=RELEASED;
btn[3].x=400; btn[3].y=250; btn[3].w=60; btn[3].h=60; btn[3].a=VOLUME_DOWN; btn[3].s=RELEASED;
max_stations= sizeof(stations)/sizeof(stations[0]); log_i("max stations %i", max_stations);
Serial.begin(115200);
pref.begin("WebRadio", false); // instance of preferences for defaults (station, volume ...)
if(pref.getShort("volume", 1000) == 1000){ // if that: pref was never been initialized
pref.putShort("volume", 10);
pref.putShort("station", 0);
}
else{ // get the stored values
cur_station = pref.getShort("station");
cur_volume = pref.getShort("volume");
}
WiFi.begin(ssid.c_str(), password.c_str());
while (WiFi.status() != WL_CONNECTED){
delay(2000);
Serial.print(".");
}
log_i("Connect to %s", WiFi.SSID().c_str());
ledcAttach(TFT_BL, 1200, 8); // 1200 Hz PWM and 8 bit resolution
setTFTbrightness(100);
tft.begin(TFT_CS, TFT_DC, VSPI, SPI_MOSI, SPI_MISO, SPI_SCK);
tft.setRotation(3);
tp.setRotation(3);
tft.setFont(Times_New_Roman43x35);
tft.fillScreen(TFT_BLACK);
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
audio.setVolume(cur_volume); // 0...21
audio.connecttohost(stations[cur_station].c_str());
for(uint8_t i=0; i<(sizeof(btn)/sizeof(*btn)); i++) draw_button(btn[i]);
write_volume(cur_volume);
write_stationNr(cur_station);
}
//**************************************************************************************************
// L O O P *
//**************************************************************************************************
void loop(){
vTaskDelay(1);
audio.loop();
tp.loop();
}
//**************************************************************************************************
// E V E N T S *
//**************************************************************************************************
void audio_info(const char *info){
Serial.print("audio_info: "); Serial.println(info);
}
void audio_showstation(const char *info){
write_stationName(String(info));
}
void audio_showstreamtitle(const char *info){
String sinfo=String(info);
sinfo.replace("|", "\n");
write_streamTitle(sinfo);
}
void tp_pressed(uint16_t x, uint16_t y){
for(uint8_t i=0; i<(sizeof(btn)/sizeof(*btn)); i++){
if(x>btn[i].x && (x<btn[i].x+btn[i].w)){
if(y>btn[i].y && (y<btn[i].y+btn[i].h)){
cur_btn=i;
btn[cur_btn].s=PRESSED;
draw_button(btn[cur_btn]);
}
}
}
}
void tp_released(){
if(cur_btn !=-1){
btn[cur_btn].s=RELEASED;
draw_button(btn[cur_btn]);
switch(btn[cur_btn].a){
case VOLUME_UP: if(cur_volume<max_volume){
cur_volume++;
write_volume(cur_volume);
audio.setVolume(cur_volume);
pref.putShort("volume", cur_volume);} // store the current volume in nvs
break;
case VOLUME_DOWN: if(cur_volume>0){
cur_volume-- ;
write_volume(cur_volume);
audio.setVolume(cur_volume);
pref.putShort("volume", cur_volume);} // store the current volume in nvs
break;
case STATION_UP: if(cur_station<max_stations-1){
cur_station++;
write_stationNr(cur_station);
tft.fillRect(0, 0, 480, 250, TFT_BLACK);
audio.connecttohost(stations[cur_station].c_str());
pref.putShort("station", cur_station);} // store the current station in nvs
break;
case STATION_DOWN:if(cur_station>0){
cur_station--;
write_stationNr(cur_station);
tft.fillRect(0, 0, 480, 250, TFT_BLACK);
audio.connecttohost(stations[cur_station].c_str());
pref.putShort("station", cur_station);} // store the current station in nvs
break;
}
}
cur_btn=-1;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 KiB

View File

@ -0,0 +1,10 @@
# Synchronised lyrics/text
Synchronized Lyrics or also called 'Lyrics3' is a format for storing lyrics in the ID3 metadata of audio files such as MP3s. The synchronized texts are saved in a special ID3 tag called **SYLT**.
Unlike plain lyrics, synced lyrics can contain not only the lyrics of the song, but also information about when each section of lyrics should be displayed. This information is stored in the form of timestamps that indicate when each piece of text should begin and end.
Once the synced lyrics are stored in the ID3 metadata, they can be viewed by a compatible audio player. The audio player reads the SYLT tags and displays the lyrics of the song in real time while the song is playing. This allows the listener to follow the lyrics of the song in real time and sing along.
@moononournation had the idea of reading the SYLT tag with the audioI2S library, and he also wrote the necessary source code.
The example shown here reads an mp3 file containing the SYLT tag, plays the mp3 file and displays the lyrics according to the timestamps in the serial terminal.

View File

@ -0,0 +1,96 @@
#include "Arduino.h"
#include "Audio.h"
#include "SD_MMC.h"
#include "Ticker.h"
Audio audio;
Ticker ticker;
char *lyricsText;
size_t lyricsTextSize = 0;
uint16_t lyricsPtr = 0;
uint32_t timeStamp = 0;
uint32_t ms = 0;
char chbuf[512];
#define I2S_LRC 26
#define I2S_DOUT 25
#define I2S_BCLK 27
#define I2S_MCLK 0
#define SD_MMC_D0 2
#define SD_MMC_CLK 14
#define SD_MMC_CMD 15
size_t bigEndian(char* base, uint8_t numBytes, uint8_t shiftLeft = 8){
uint64_t result = 0;
if(numBytes < 1 || numBytes > 8) return 0;
for (int i = 0; i < numBytes; i++) {
result += *(base + i) << (numBytes -i - 1) * shiftLeft;
}
if(result > SIZE_MAX) {log_e("range overflow"); result = 0;} // overflow
return (size_t)result;
}
void tckr(){ // caller every 100ms
if(audio.isRunning()){
ms += 100;
if(ms >= timeStamp){
Serial.print(chbuf);
strcpy(chbuf, lyricsText + lyricsPtr); lyricsPtr += strlen(chbuf) + 1; // strlen + '\0'
timeStamp = bigEndian(lyricsText + lyricsPtr, 4); lyricsPtr += 4;
}
}
else{
if(lyricsText) {free(lyricsText); lyricsText = NULL; lyricsTextSize = 0;}
ticker.detach();
}
}
void setup() {
pinMode(SD_MMC_D0, INPUT_PULLUP);
Serial.begin(115200);
if(!SD_MMC.begin( "/sdcard", true, false, 20000)){
Serial.println("Card Mount Failed");
return;
}
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
audio.setVolume(10); // 0...21
audio.connecttoFS(SD_MMC, "/Little London Girl(lyrics).mp3");
}
void loop(){
vTaskDelay(1);
audio.loop();
}
// optional
void audio_info(const char *info){
Serial.print("info "); Serial.println(info);
}
void audio_id3data(const char *info){ //id3 metadata
// if(strncmp(info, "Year: ", 6) == 0) Serial.println(info + 6);
Serial.print("id3data ");Serial.println(info);
}
void audio_eof_mp3(const char *info){ //end of file
Serial.print("eof_mp3 ");Serial.println(info);
}
void audio_id3lyrics(File &file, const size_t pos, const size_t size) {
Serial.printf("\naudio_id3lyrics, pos: %d, size: %d\n", pos, size);
lyricsText = (char *)malloc(size);
lyricsTextSize = size;
file.seek(pos);
file.read((uint8_t *)lyricsText, size);
Serial.printf("text encoding: %i\n", lyricsText[0]); // 0: ASCII, 3: UTF-8
char lang[14]; memcpy(lang, (const char*)lyricsText + 1, 3); lang[3] = '\0'; Serial.printf("language: %s\n", lang);
Serial.printf("time stamp format: %i\n", lyricsText[4]);
Serial.printf("content type: %i\n", lyricsText[5]);
Serial.printf("content descriptor: %i\n\n", lyricsText[6]);
lyricsPtr = 7;
strcpy(chbuf, lyricsText + lyricsPtr); lyricsPtr += strlen(chbuf) + 1; // strlen + '\0'
timeStamp = bigEndian(lyricsText + lyricsPtr, 4);
ticker.attach(0.1, tckr); lyricsPtr += 4;
}

View File

@ -0,0 +1,69 @@
#include "Arduino.h"
#include "Audio.h"
#include "SD.h"
#include "SPI.h"
#include "FS.h"
#include "Ticker.h"
// Digital I/O used
#define SD_CS 5
#define SPI_MOSI 23
#define SPI_MISO 19
#define SPI_SCK 18
#define I2S_DOUT 25
#define I2S_BCLK 27
#define I2S_LRC 26
Audio audio;
Ticker ticker;
struct tm timeinfo;
time_t now;
uint8_t hour = 6;
uint8_t minute = 59;
uint8_t sec = 45;
bool f_time = false;
int8_t timefile = -1;
char chbuf[100];
void tckr1s(){
sec++;
if(sec > 59) {sec = 0; minute++;}
if(minute > 59){minute = 0; hour++;}
if(hour > 23) {hour = 0;}
if(minute == 59 && sec == 50) f_time = true; // flag will be set 10s before full hour
Serial.printf("%02d:%02d:%02d\n", hour, minute, sec);
}
void setup() {
Serial.begin(115200);
SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI);
SD.begin(SD_CS);
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
audio.setVolume(10); // 0...21
ticker.attach(1, tckr1s);
}
void loop(){
vTaskDelay(1);
audio.loop();
if(f_time == true){
f_time = false;
timefile = 3;
uint8_t next_hour = hour + 1;
if(next_hour == 25) next_hour = 1;
sprintf(chbuf, "/voice_time/%03d.mp3", next_hour);
audio.connecttoFS(SD, chbuf);
}
}
void audio_eof_mp3(const char *info){ //end of file
//Serial.printf("file :%s\n", info);
if(timefile>0){
if(timefile==1){audio.connecttoFS(SD, "/voice_time/080.mp3"); timefile--;} // stroke
if(timefile==2){audio.connecttoFS(SD, "/voice_time/200.mp3"); timefile--;} // precisely
if(timefile==3){audio.connecttoFS(SD, "/voice_time/O'clock.mp3"); timefile--;}
}
}

View File

@ -0,0 +1,113 @@
#include "Arduino.h"
#include "Audio.h"
#include "SD_MMC.h"
#include "FS.h"
#include <vector>
#define I2S_LRC 26
#define I2S_DOUT 25
#define I2S_BCLK 27
#define SD_MMC_D0 2
#define SD_MMC_CLK 14
#define SD_MMC_CMD 15
void listDir(fs::FS &fs, const char * dirname, uint8_t levels); //proto
std::vector<char*> v_audioContent;
int pirPin = 4;
Audio audio;
File dir;
const char audioDir[] = "/mp3";
void setup() {
Serial.begin(115200);
pinMode(SD_MMC_D0, INPUT_PULLUP);
SD_MMC.setPins(SD_MMC_CLK,SD_MMC_CMD, SD_MMC_D0);
if(!SD_MMC.begin( "/sdmmc", true, false, 20000)){
Serial.println("Card Mount Failed");
return;
}
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
audio.setVolume(17); // 0...21 Will need to add a volume setting in the app
dir = SD_MMC.open(audioDir);
listDir(SD_MMC, audioDir, 1);
if(v_audioContent.size() > 0){
const char* s = (const char*)v_audioContent[v_audioContent.size() -1];
Serial.printf("playing %s\n", s);
audio.connecttoFS(SD_MMC, s);
v_audioContent.pop_back();
}
}
void loop(){
audio.loop();
vTaskDelay(1); // Audio is distoreted without this
}
void listDir(fs::FS &fs, const char * dirname, uint8_t levels){
Serial.printf("Listing directory: %s\n", dirname);
File root = fs.open(dirname);
if(!root){
Serial.println("Failed to open directory");
return;
}
if(!root.isDirectory()){
Serial.println("Not a directory");
return;
}
File file = root.openNextFile();
while(file){
if(file.isDirectory()){
Serial.print(" DIR : ");
Serial.println(file.name());
if(levels){
listDir(fs, file.path(), levels -1);
}
} else {
Serial.print(" FILE: ");
Serial.print(file.name());
Serial.print(" SIZE: ");
Serial.println(file.size());
v_audioContent.insert(v_audioContent.begin(), strdup(file.path()));
}
file = root.openNextFile();
}
Serial.printf("num files %i", v_audioContent.size());
root.close();
file.close();
}
void vector_clear_and_shrink(vector<char*>&vec){
uint size = vec.size();
for (int i = 0; i < size; i++) {
if(vec[i]){
free(vec[i]);
vec[i] = NULL;
}
}
vec.clear();
vec.shrink_to_fit();
}
// optional
void audio_info(const char *info){
Serial.print("info "); Serial.println(info);
}
void audio_id3data(const char *info){ //id3 metadata
Serial.print("id3data ");Serial.println(info);
}
void audio_eof_mp3(const char *info){ //end of file
Serial.print("eof_mp3 ");Serial.println(info);
if(v_audioContent.size() == 0){
vector_clear_and_shrink(v_audioContent); // free memory
return;
}
const char* s = (const char*)v_audioContent[v_audioContent.size() - 1];
Serial.printf("playing %s\n", s);
audio.connecttoFS(SD_MMC, s);
v_audioContent.pop_back();
}

View File

@ -0,0 +1,91 @@
// This arduino sketch for ESP32 announces the time every hour.
// A connection to the Internet is required
// 1) to synchronize with the internal RTC on startup
// 2) so that GoogleTTS can be reached
#include <Arduino.h>
#include "WiFiMulti.h"
#include "Audio.h"
#include "time.h"
#include "esp_sntp.h"
//------------------------USER SETTINGS / GPIOs-------------------------------------------------------------------------
String ssid = "xxxx";
String password = "xxxx";
uint8_t I2S_BCLK = 27;
uint8_t I2S_LRC = 26;
uint8_t I2S_DOUT = 25;
//------------------------OBJECTS /GLOBAL VARS--------------------------------------------------------------------------
Audio audio(false, 3, 0);
WiFiMulti wifiMulti;
uint32_t sec1 = millis();
String time_s = "";
char chbuf[200];
int timeIdx = 0;
//------------------------TIME / SNTP STUFF-----------------------------------------------------------------------------
#define TZName "CET-1CEST,M3.5.0,M10.5.0/3" // https://remotemonitoringsystems.ca/time-zone-abbreviations.php
char strftime_buf[64];
struct tm timeinfo;
time_t now;
boolean obtain_time(){
time_t now = 0;
int retry = 0;
Serial.println("Initializing SNTP");
sntp_setoperatingmode(SNTP_OPMODE_POLL);
sntp_setservername(0, "pool.ntp.org");
sntp_init();
const int retry_count = 10;
while(timeinfo.tm_year < (2016 - 1900) && ++retry < retry_count) {
Serial.printf("Waiting for system time to be set... (%d/%d)\n", retry, retry_count);
vTaskDelay(uint16_t(2000 / portTICK_PERIOD_MS));
time(&now);
localtime_r(&now, &timeinfo);
}
setenv("TZ", TZName, 1);
tzset();
localtime_r(&now, &timeinfo);
strftime(strftime_buf, sizeof(strftime_buf), "%c", &timeinfo);
if(retry < retry_count) return true;
else return false;
}
const char* gettime_s(){ // hh:mm:ss
time(&now);
localtime_r(&now, &timeinfo);
sprintf(strftime_buf,"%02d:%02d:%02d", timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec);
return strftime_buf;
}
//-----------------------SETUP------------------------------------------------------------------------------------------
void setup() {
Serial.begin(115200);
wifiMulti.addAP(ssid.c_str(), password.c_str());
wifiMulti.run();
obtain_time();
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
audio.setVolume(15);
}
//-----------------------LOOP-------------------------------------------------------------------------------------------
void loop() {
vTaskDelay(1);
audio.loop();
if(sec1 < millis()){ // every second
sec1 = millis() + 1000;
time_s = gettime_s();
Serial.println(time_s);
if(time_s.endsWith("00:00")){ // time announcement every full hour
char am_pm[5] = "am.";
int h = time_s.substring(0,2).toInt();
if(h > 12){h -= 12; strcpy(am_pm,"pm.");}
sprintf(chbuf, "It is now %i%s and %i minutes", h, am_pm, time_s.substring(3,5).toInt());
Serial.println(chbuf);
audio.connecttospeech(chbuf, "en");
}
}
}
//------------------EVENTS----------------------------------------------------------------------------------------------
void audio_info(const char *info){
Serial.printf("info: %s\n", info);
}

View File

@ -0,0 +1,20 @@
{
"name": "ESP32-audioI2S",
"version": "3.0.13",
"description": "With this library You can easily build a WebRadio with a ESP32 board and a I2S-module",
"keywords": "audio, i2s, esp32",
"repository": {
"type": "git",
"url": "https://github.com/schreibfaul1/ESP32-audioI2S.git"
},
"authors": [
{
"name": "schreibfaul1"
}
],
"license": "GPL-3.0",
"homepage": "https://github.com/schreibfaul1/ESP32-audioI2S",
"dependencies": {},
"frameworks": ["arduino", "espidf"],
"platforms": "espressif32"
}

View File

@ -0,0 +1,9 @@
name=ESP32-audioI2S-master
version=3.2.1
author=schreibfaul1
maintainer=schreibfaul1
sentence=With this library You can easily build a WebRadio with a ESP32 board and a I2S-module.
paragraph=Plays webradio, playlists can be m3u, pls or asx. Data format can be only mp3, aac, flac, opus, vorbis or m4a. It can also play files from a SD Card.
category=Device Control
url=https://github.com/schreibfaul1/ESP32-audioI2S
architectures=esp32

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,763 @@
/*
* Audio.h
*
*/
#pragma once
#pragma GCC optimize ("Ofast")
#include "esp_arduino_version.h"
#include <vector>
#include <Arduino.h>
#include <libb64/cencode.h>
#include <esp32-hal-log.h>
#include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiClientSecure.h>
#include <SD.h>
#include <SD_MMC.h>
#include <SPIFFS.h>
#include <FS.h>
#include <FFat.h>
#include <atomic>
#include <codecvt>
#include <locale>
#if ESP_ARDUINO_VERSION_MAJOR >= 3
#include <NetworkClient.h>
#include <NetworkClientSecure.h>
#endif
#if ESP_IDF_VERSION_MAJOR == 5
#include <driver/i2s_std.h>
#else
#include <driver/i2s.h>
#endif
#ifndef I2S_GPIO_UNUSED
#define I2S_GPIO_UNUSED -1 // = I2S_PIN_NO_CHANGE in IDF < 5
#endif
extern __attribute__((weak)) void audio_info(const char*);
extern __attribute__((weak)) void audio_id3data(const char*); //ID3 metadata
extern __attribute__((weak)) void audio_id3image(File& file, const size_t pos, const size_t size); //ID3 metadata image
extern __attribute__((weak)) void audio_oggimage(File& file, std::vector<uint32_t> v); //OGG blockpicture
extern __attribute__((weak)) void audio_id3lyrics(File& file, const size_t pos, const size_t size); //ID3 metadata lyrics
extern __attribute__((weak)) void audio_eof_mp3(const char*); //end of mp3 file
extern __attribute__((weak)) void audio_showstreamtitle(const char*);
extern __attribute__((weak)) void audio_showstation(const char*);
extern __attribute__((weak)) void audio_bitrate(const char*);
extern __attribute__((weak)) void audio_commercial(const char*);
extern __attribute__((weak)) void audio_icyurl(const char*);
extern __attribute__((weak)) void audio_icylogo(const char*);
extern __attribute__((weak)) void audio_icydescription(const char*);
extern __attribute__((weak)) void audio_lasthost(const char*);
extern __attribute__((weak)) void audio_eof_speech(const char*);
extern __attribute__((weak)) void audio_eof_stream(const char*); // The webstream comes to an end
extern __attribute__((weak)) void audio_process_i2s(int16_t* outBuff, uint16_t validSamples, uint8_t bitsPerSample, uint8_t channels, bool *continueI2S); // record audiodata or send via BT
extern __attribute__((weak)) void audio_log(uint8_t logLevel, const char* msg, const char* arg);
//----------------------------------------------------------------------------------------------------------------------
class AudioBuffer {
// AudioBuffer will be allocated in PSRAM, If PSRAM not available or has not enough space AudioBuffer will be
// allocated in FlashRAM with reduced size
//
// m_buffer m_readPtr m_writePtr m_endPtr
// | |<------dataLength------->|<------ writeSpace ----->|
// ▼ ▼ ▼ ▼
// ---------------------------------------------------------------------------------------------------------------
// | <--m_buffSize--> | <--m_resBuffSize --> |
// ---------------------------------------------------------------------------------------------------------------
// |<-----freeSpace------->| |<------freeSpace-------->|
//
//
//
// if the space between m_readPtr and buffend < m_resBuffSize copy data from the beginning to resBuff
// so that the mp3/aac/flac frame is always completed
//
// m_buffer m_writePtr m_readPtr m_endPtr
// | |<-------writeSpace------>|<--dataLength-->|
// ▼ ▼ ▼ ▼
// ---------------------------------------------------------------------------------------------------------------
// | <--m_buffSize--> | <--m_resBuffSize --> |
// ---------------------------------------------------------------------------------------------------------------
// |<--- ------dataLength-- ------>|<-------freeSpace------->|
//
//
public:
AudioBuffer(size_t maxBlockSize = 0); // constructor
~AudioBuffer(); // frees the buffer
size_t init(); // set default values
bool isInitialized() { return m_f_init; };
int32_t getBufsize();
void setBufsize(size_t mbs); // default is m_buffSizePSRAM for psram, and m_buffSizeRAM without psram
void changeMaxBlockSize(uint16_t mbs); // is default 1600 for mp3 and aac, set 16384 for FLAC
uint16_t getMaxBlockSize(); // returns maxBlockSize
size_t freeSpace(); // number of free bytes to overwrite
size_t writeSpace(); // space fom writepointer to bufferend
size_t bufferFilled(); // returns the number of filled bytes
size_t getMaxAvailableBytes(); // max readable bytes in one block
void bytesWritten(size_t bw); // update writepointer
void bytesWasRead(size_t br); // update readpointer
uint8_t* getWritePtr(); // returns the current writepointer
uint8_t* getReadPtr(); // returns the current readpointer
uint32_t getWritePos(); // write position relative to the beginning
uint32_t getReadPos(); // read position relative to the beginning
void resetBuffer(); // restore defaults
bool havePSRAM() { return m_f_psram; };
protected:
size_t m_buffSizePSRAM = UINT16_MAX * 10; // most webstreams limit the advance to 100...300Kbytes
size_t m_buffSizeRAM = 1600 * 10;
size_t m_buffSize = 0;
size_t m_freeSpace = 0;
size_t m_writeSpace = 0;
size_t m_dataLength = 0;
size_t m_resBuffSizeRAM = 4096; // reserved buffspace, >= one wav frame
size_t m_resBuffSizePSRAM = 4096 * 6; // reserved buffspace, >= one flac frame
size_t m_maxBlockSize = 1600;
uint8_t* m_buffer = NULL;
uint8_t* m_writePtr = NULL;
uint8_t* m_readPtr = NULL;
uint8_t* m_endPtr = NULL;
bool m_f_init = false;
bool m_f_isEmpty = true;
bool m_f_psram = false; // PSRAM is available (and used...)
};
//----------------------------------------------------------------------------------------------------------------------
static const size_t AUDIO_STACK_SIZE = 3300;
static StaticTask_t __attribute__((unused)) xAudioTaskBuffer;
static StackType_t __attribute__((unused)) xAudioStack[AUDIO_STACK_SIZE];
extern char audioI2SVers[];
class Audio : private AudioBuffer{
AudioBuffer InBuff; // instance of input buffer
public:
Audio(uint8_t i2sPort = I2S_NUM_0);
~Audio();
bool openai_speech(const String& api_key, const String& model, const String& input, const String& instructions, const String& voice, const String& response_format, const String& speed);
bool connecttohost(const char* host, const char* user = "", const char* pwd = "");
bool connecttospeech(const char* speech, const char* lang);
bool connecttoFS(fs::FS &fs, const char* path, int32_t m_fileStartPos = -1);
void setConnectionTimeout(uint16_t timeout_ms, uint16_t timeout_ms_ssl);
bool setAudioPlayPosition(uint16_t sec);
bool setFilePos(uint32_t pos);
bool setTimeOffset(int sec);
bool setPinout(uint8_t BCLK, uint8_t LRC, uint8_t DOUT, int8_t MCLK = I2S_GPIO_UNUSED);
bool pauseResume();
bool isRunning() {return m_f_running;}
void loop();
uint32_t stopSong();
void forceMono(bool m);
void setBalance(int8_t bal = 0);
void setVolumeSteps(uint8_t steps);
void setVolume(uint8_t vol, uint8_t curve = 0);
uint8_t getVolume();
uint8_t maxVolume();
uint8_t getI2sPort();
uint32_t getAudioDataStartPos();
uint32_t getFileSize();
uint32_t getFilePos();
uint32_t getSampleRate();
uint8_t getBitsPerSample();
uint8_t getChannels();
uint32_t getBitRate(bool avg = false);
uint32_t getAudioFileDuration();
uint32_t getAudioCurrentTime();
uint32_t getTotalPlayingTime();
uint16_t getVUlevel();
uint32_t inBufferFilled(); // returns the number of stored bytes in the inputbuffer
uint32_t inBufferFree(); // returns the number of free bytes in the inputbuffer
uint32_t inBufferSize(); // returns the size of the inputbuffer in bytes
void setBufferSize(size_t mbs); // sets the size of the inputbuffer in bytes
void setTone(int8_t gainLowPass, int8_t gainBandPass, int8_t gainHighPass);
void setI2SCommFMT_LSB(bool commFMT);
int getCodec() {return m_codec;}
const char *getCodecname() {return codecname[m_codec];}
const char *getVersion() {return audioI2SVers;}
private:
#ifndef ESP_ARDUINO_VERSION_VAL
#define ESP_ARDUINO_VERSION_MAJOR 0
#define ESP_ARDUINO_VERSION_MINOR 0
#define ESP_ARDUINO_VERSION_PATCH 0
#endif
enum : int8_t { AUDIOLOG_PATH_IS_NULL = -1, AUDIOLOG_FILE_NOT_FOUND = -2, AUDIOLOG_OUT_OF_MEMORY = -3, AUDIOLOG_FILE_READ_ERR = -4,
AUDIOLOG_M4A_ATOM_NOT_FOUND = -5, AUDIOLOG_ERR_UNKNOWN = -127 };
void UTF8toASCII(char* str);
bool latinToUTF8(char* buff, size_t bufflen, bool UTF8check = true);
void htmlToUTF8(char* str);
void setDefaults(); // free buffers and set defaults
void initInBuff();
bool httpPrint(const char* host);
bool httpRange(const char* host, uint32_t range);
void processLocalFile();
void processWebStream();
void processWebFile();
void processWebStreamTS();
void processWebStreamHLS();
void playAudioData();
bool readPlayListData();
const char* parsePlaylist_M3U();
const char* parsePlaylist_PLS();
const char* parsePlaylist_ASX();
const char* parsePlaylist_M3U8();
const char* m3u8redirection(uint8_t* codec);
uint64_t m3u8_findMediaSeqInURL();
bool STfromEXTINF(char* str);
void showCodecParams();
int findNextSync(uint8_t* data, size_t len);
int sendBytes(uint8_t* data, size_t len);
void setDecoderItems();
void computeAudioTime(uint16_t bytesDecoderIn, uint16_t bytesDecoderOut);
void printProcessLog(int r, const char* s = "");
void printDecodeError(int r);
void showID3Tag(const char* tag, const char* val);
size_t readAudioHeader(uint32_t bytes);
int read_WAV_Header(uint8_t* data, size_t len);
int read_ID3_Header(uint8_t* data, size_t len);
int read_M4A_Header(uint8_t* data, size_t len);
size_t process_m3u8_ID3_Header(uint8_t* packet);
bool setSampleRate(uint32_t hz);
bool setBitsPerSample(int bits);
bool setChannels(int channels);
void reconfigI2S();
bool setBitrate(int br);
void playChunk();
void computeVUlevel(int16_t sample[2]);
void computeLimit();
void Gain(int16_t* sample);
void showstreamtitle(char* ml);
bool parseContentType(char* ct);
bool parseHttpResponseHeader();
bool initializeDecoder(uint8_t codec);
esp_err_t I2Sstart();
esp_err_t I2Sstop();
void zeroI2Sbuff();
void IIR_filterChain0(int16_t iir_in[2], bool clear = false);
void IIR_filterChain1(int16_t iir_in[2], bool clear = false);
void IIR_filterChain2(int16_t iir_in[2], bool clear = false);
inline uint32_t streamavail() { return _client ? _client->available() : 0; }
void IIR_calculateCoefficients(int8_t G1, int8_t G2, int8_t G3);
bool ts_parsePacket(uint8_t* packet, uint8_t* packetStart, uint8_t* packetLength);
uint32_t find_m4a_atom(uint32_t fileSize, const char* atomType, uint32_t depth = 0);
//+++ create a T A S K for playAudioData(), output via I2S +++
public:
void setAudioTaskCore(uint8_t coreID);
uint32_t getHighWatermark();
private:
void startAudioTask(); // starts a task for decode and play
void stopAudioTask(); // stops task for audio
static void taskWrapper(void *param);
void audioTask();
void performAudioTask();
//+++ W E B S T R E A M - H E L P F U N C T I O N S +++
uint16_t readMetadata(uint16_t b, bool first = false);
size_t readChunkSize(uint8_t* bytes);
bool readID3V1Tag();
boolean streamDetection(uint32_t bytesAvail);
void seek_m4a_stsz();
void seek_m4a_ilst();
uint32_t m4a_correctResumeFilePos();
uint32_t ogg_correctResumeFilePos();
int32_t mp3_correctResumeFilePos();
uint8_t determineOggCodec(uint8_t* data, uint16_t len);
//++++ implement several function with respect to the index of string ++++
void strlower(char* str) {
unsigned char* p = (unsigned char*)str;
while(*p) {
*p = tolower((unsigned char)*p);
p++;
}
}
void trim(char *str) {
char *start = str; // keep the original pointer
char *end;
while (isspace((unsigned char)*start)) start++; // find the first non-space character
if (*start == 0) { // all characters were spaces
str[0] = '\0'; // return a empty string
return;
}
end = start + strlen(start) - 1; // find the end of the string
while (end > start && isspace((unsigned char)*end)) end--;
end[1] = '\0'; // Null-terminate the string after the last non-space character
// Move the trimmed string to the beginning of the memory area
memmove(str, start, strlen(start) + 1); // +1 for '\0'
}
bool startsWith (const char* base, const char* str) {
//fb
char c;
while ( (c = *str++) != '\0' )
if (c != *base++) return false;
return true;
}
bool endsWith(const char *base, const char *searchString) {
int32_t slen = strlen(searchString);
if(slen == 0) return false;
const char *p = base + strlen(base);
// while(p > base && isspace(*p)) p--; // rtrim
p -= slen;
if(p < base) return false;
return (strncmp(p, searchString, slen) == 0);
}
int indexOf (const char* base, const char* str, int startIndex = 0) {
//fb
const char *p = base;
for (; startIndex > 0; startIndex--)
if (*p++ == '\0') return -1;
char* pos = strstr(p, str);
if (pos == nullptr) return -1;
return pos - base;
}
int indexOf (const char* base, char ch, int startIndex = 0) {
//fb
const char *p = base;
for (; startIndex > 0; startIndex--)
if (*p++ == '\0') return -1;
char *pos = strchr(p, ch);
if (pos == nullptr) return -1;
return pos - base;
}
int lastIndexOf(const char* haystack, const char* needle) {
//fb
int nlen = strlen(needle);
if (nlen == 0) return -1;
const char *p = haystack - nlen + strlen(haystack);
while (p >= haystack) {
int i = 0;
while (needle[i] == p[i])
if (++i == nlen) return p - haystack;
p--;
}
return -1;
}
int lastIndexOf(const char* haystack, const char needle) {
//fb
const char *p = strrchr(haystack, needle);
return (p ? p - haystack : -1);
}
int specialIndexOf (uint8_t* base, const char* str, int baselen, bool exact = false){
int result = 0; // seek for str in buffer or in header up to baselen, not nullterninated
if (strlen(str) > baselen) return -1; // if exact == true seekstr in buffer must have "\0" at the end
for (int i = 0; i < baselen - strlen(str); i++){
result = i;
for (int j = 0; j < strlen(str) + exact; j++){
if (*(base + i + j) != *(str + j)){
result = -1;
break;
}
}
if (result >= 0) break;
}
return result;
}
int32_t min3(int32_t a, int32_t b, int32_t c){
uint32_t min_val = a;
if (b < min_val) min_val = b;
if (c < min_val) min_val = c;
return min_val;
}
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
// some other functions
uint64_t bigEndian(uint8_t* base, uint8_t numBytes, uint8_t shiftLeft = 8) {
uint64_t result = 0; // Use uint64_t for greater caching
if(numBytes < 1 || numBytes > 8) return 0;
for (int i = 0; i < numBytes; i++) {
result |= (uint64_t)(*(base + i)) << ((numBytes - i - 1) * shiftLeft); //Make sure the calculation is done correctly
}
if(result > SIZE_MAX) {
log_e("range overflow");
return 0;
}
return result;
}
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
bool b64encode(const char* source, uint16_t sourceLength, char* dest){
size_t size = base64_encode_expected_len(sourceLength) + 1;
char * buffer = (char *) malloc(size);
if(buffer) {
base64_encodestate _state;
base64_init_encodestate(&_state);
int len = base64_encode_block(&source[0], sourceLength, &buffer[0], &_state);
base64_encode_blockend((buffer + len), &_state);
memcpy(dest, buffer, strlen(buffer));
dest[strlen(buffer)] = '\0';
free(buffer);
return true;
}
return false;
}
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
void vector_clear_and_shrink(std::vector<char*>&vec){
uint size = vec.size();
for (int i = 0; i < size; i++) {
if(vec[i]){
free(vec[i]);
vec[i] = NULL;
}
}
vec.clear();
vec.shrink_to_fit();
}
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
uint32_t simpleHash(const char* str){
if(str == NULL) return 0;
uint32_t hash = 0;
for(int i=0; i<strlen(str); i++){
if(str[i] < 32) continue; // ignore control sign
hash += (str[i] - 31) * i * 32;
}
return hash;
}
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
char* x_ps_malloc(uint16_t len) {
char* ps_str = NULL;
if(psramFound()){ps_str = (char*) ps_malloc(len);}
else {ps_str = (char*) malloc(len);}
if(!ps_str) log_e("oom");
return ps_str;
}
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
char* x_ps_calloc(uint16_t len, uint8_t size) {
char* ps_str = NULL;
if(psramFound()){ps_str = (char*) ps_calloc(len, size);}
else {ps_str = (char*) calloc(len, size);}
if(!ps_str) log_e("oom");
return ps_str;
}
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
char* x_ps_realloc(char* ptr, uint16_t len) {
char* ps_str = NULL;
if(psramFound()){ps_str = (char*) ps_realloc(ptr, len);}
else {ps_str = (char*) realloc(ptr, len);}
if(!ps_str) log_e("oom");
return ps_str;
}
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
char* x_ps_strdup(const char* str) {
if(!str) {log_e("Input str is NULL"); return NULL;};
char* ps_str = NULL;
if(psramFound()) { ps_str = (char*)ps_malloc(strlen(str) + 1); }
else { ps_str = (char*)malloc(strlen(str) + 1); }
if(!ps_str){log_e("oom"); return NULL;}
strcpy(ps_str, str);
return ps_str;
}
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
void x_ps_free(char** b){
if(*b){free(*b); *b = NULL;}
}
void x_ps_free_const(const char** b) {
if (b && *b) {
free((void*)*b); // remove const
*b = NULL;
}
}
void x_ps_free(int16_t** b){
if(*b){free(*b); *b = NULL;}
}
void x_ps_free(uint8_t** b){
if(*b){free(*b); *b = NULL;}
}
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
char* urlencode(const char* str, bool spacesOnly) {
if (str == NULL) {
return NULL; // Eingabe ist NULL
}
// Reserve memory for the result (3x the length of the input string, worst-case)
size_t inputLength = strlen(str);
size_t bufferSize = inputLength * 3 + 1; // Worst-case-Szenario
char *encoded = (char *)x_ps_malloc(bufferSize);
if (encoded == NULL) {
return NULL; // memory allocation failed
}
const char *p_input = str; // Copy of the input pointer
char *p_encoded = encoded; // pointer of the output buffer
size_t remainingSpace = bufferSize; // remaining space in the output buffer
while (*p_input) {
if (isalnum((unsigned char)*p_input)) {
// adopt alphanumeric characters directly
if (remainingSpace > 1) {
*p_encoded++ = *p_input;
remainingSpace--;
} else {
free(encoded);
return NULL; // security check failed
}
} else if (spacesOnly && *p_input != 0x20) {
// Nur Leerzeichen nicht kodieren
if (remainingSpace > 1) {
*p_encoded++ = *p_input;
remainingSpace--;
} else {
free(encoded);
return NULL; // security check failed
}
} else {
// encode unsafe characters as '%XX'
if (remainingSpace > 3) {
int written = snprintf(p_encoded, remainingSpace, "%%%02X", (unsigned char)*p_input);
if (written < 0 || written >= (int)remainingSpace) {
free(encoded);
return NULL; // error writing to buffer
}
p_encoded += written;
remainingSpace -= written;
} else {
free(encoded);
return NULL; // security check failed
}
}
p_input++;
}
// Null-terminieren
if (remainingSpace > 0) {
*p_encoded = '\0';
} else {
free(encoded);
return NULL; // security check failed
}
return encoded;
}
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
// Function to reverse the byte order of a 32-bit value (big-endian to little-endian)
uint32_t bswap32(uint32_t x) {
return ((x & 0xFF000000) >> 24) |
((x & 0x00FF0000) >> 8) |
((x & 0x0000FF00) << 8) |
((x & 0x000000FF) << 24);
}
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
// Function to reverse the byte order of a 64-bit value (big-endian to little-endian)
uint64_t bswap64(uint64_t x) {
return ((x & 0xFF00000000000000ULL) >> 56) |
((x & 0x00FF000000000000ULL) >> 40) |
((x & 0x0000FF0000000000ULL) >> 24) |
((x & 0x000000FF00000000ULL) >> 8) |
((x & 0x00000000FF000000ULL) << 8) |
((x & 0x0000000000FF0000ULL) << 24) |
((x & 0x000000000000FF00ULL) << 40) |
((x & 0x00000000000000FFULL) << 56);
}
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
private:
const char *codecname[10] = {"unknown", "WAV", "MP3", "AAC", "M4A", "FLAC", "AACP", "OPUS", "OGG", "VORBIS" };
enum : int { APLL_AUTO = -1, APLL_ENABLE = 1, APLL_DISABLE = 0 };
enum : int { EXTERNAL_I2S = 0, INTERNAL_DAC = 1, INTERNAL_PDM = 2 };
enum : int { FORMAT_NONE = 0, FORMAT_M3U = 1, FORMAT_PLS = 2, FORMAT_ASX = 3, FORMAT_M3U8 = 4}; // playlist formats
enum : int { AUDIO_NONE, HTTP_RESPONSE_HEADER, AUDIO_DATA, AUDIO_LOCALFILE,
AUDIO_PLAYLISTINIT, AUDIO_PLAYLISTHEADER, AUDIO_PLAYLISTDATA};
enum : int { FLAC_BEGIN = 0, FLAC_MAGIC = 1, FLAC_MBH =2, FLAC_SINFO = 3, FLAC_PADDING = 4, FLAC_APP = 5,
FLAC_SEEK = 6, FLAC_VORBIS = 7, FLAC_CUESHEET = 8, FLAC_PICTURE = 9, FLAC_OKAY = 100};
enum : int { M4A_BEGIN = 0, M4A_FTYP = 1, M4A_CHK = 2, M4A_MOOV = 3, M4A_FREE = 4, M4A_TRAK = 5, M4A_MDAT = 6,
M4A_ILST = 7, M4A_MP4A = 8, M4A_AMRDY = 99, M4A_OKAY = 100};
enum : int { CODEC_NONE = 0, CODEC_WAV = 1, CODEC_MP3 = 2, CODEC_AAC = 3, CODEC_M4A = 4, CODEC_FLAC = 5,
CODEC_AACP = 6, CODEC_OPUS = 7, CODEC_OGG = 8, CODEC_VORBIS = 9};
enum : int { ST_NONE = 0, ST_WEBFILE = 1, ST_WEBSTREAM = 2};
typedef enum { LEFTCHANNEL=0, RIGHTCHANNEL=1 } SampleIndex;
typedef enum { LOWSHELF = 0, PEAKEQ = 1, HIFGSHELF =2 } FilterType;
typedef struct _filter{
float a0;
float a1;
float a2;
float b1;
float b2;
} filter_t;
typedef struct _pis_array{
int number;
int pids[4];
} pid_array;
File audiofile;
#ifndef ETHERNET_IF
WiFiClient client;
WiFiClientSecure clientsecure;
WiFiClient* _client = nullptr;
#else
NetworkClient client;
NetworkClientSecure clientsecure;
NetworkClient* _client = nullptr;
#endif
SemaphoreHandle_t mutex_playAudioData;
SemaphoreHandle_t mutex_audioTask;
TaskHandle_t m_audioTaskHandle = nullptr;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#if ESP_IDF_VERSION_MAJOR == 5
i2s_chan_handle_t m_i2s_tx_handle = {};
i2s_chan_config_t m_i2s_chan_cfg = {}; // stores I2S channel values
i2s_std_config_t m_i2s_std_cfg = {}; // stores I2S driver values
#else
i2s_config_t m_i2s_config = {};
i2s_pin_config_t m_pin_config = {};
#endif
#pragma GCC diagnostic pop
std::vector<char*> m_playlistContent; // m3u8 playlist buffer
std::vector<char*> m_playlistURL; // m3u8 streamURLs buffer
std::vector<uint32_t> m_hashQueue;
const size_t m_frameSizeWav = 4096;
const size_t m_frameSizeMP3 = 1600;
const size_t m_frameSizeAAC = 1600;
const size_t m_frameSizeVORBIS = 4096 * 2;
const size_t m_outbuffSize = 4096 * 2;
static const uint8_t m_tsPacketSize = 188;
static const uint8_t m_tsHeaderSize = 4;
char* m_ibuff = nullptr; // used in audio_info()
char* m_chbuf = NULL;
uint16_t m_chbufSize = 0; // will set in constructor (depending on PSRAM)
uint16_t m_ibuffSize = 0; // will set in constructor (depending on PSRAM)
char* m_lastHost = NULL; // Store the last URL to a webstream
char* m_lastM3U8host = NULL;
char* m_playlistBuff = NULL; // stores playlistdata
char* m_speechtxt = NULL; // stores tts text
const uint16_t m_plsBuffEntryLen = 256; // length of each entry in playlistBuff
filter_t m_filter[3]; // digital filters
int m_LFcount = 0; // Detection of end of header
uint32_t m_sampleRate=16000;
uint32_t m_bitRate=0; // current bitrate given fom decoder
uint32_t m_avr_bitrate = 0; // average bitrate, median computed by VBR
int m_readbytes = 0; // bytes read
uint32_t m_metacount = 0; // counts down bytes between metadata
int m_controlCounter = 0; // Status within readID3data() and readWaveHeader()
int8_t m_balance = 0; // -16 (mute left) ... +16 (mute right)
uint16_t m_vol = 21; // volume
uint16_t m_vol_steps = 21; // default
double m_limit_left = 0; // limiter 0 ... 1, left channel
double m_limit_right = 0; // limiter 0 ... 1, right channel
uint8_t m_timeoutCounter = 0; // timeout counter
uint8_t m_curve = 0; // volume characteristic
uint8_t m_bitsPerSample = 16; // bitsPerSample
uint8_t m_channels = 2;
uint8_t m_i2s_num = I2S_NUM_0; // I2S_NUM_0 or I2S_NUM_1
uint8_t m_playlistFormat = 0; // M3U, PLS, ASX
uint8_t m_codec = CODEC_NONE; //
uint8_t m_m3u8Codec = CODEC_AAC; // codec of m3u8 stream
uint8_t m_expectedCodec = CODEC_NONE; // set in connecttohost (e.g. http://url.mp3 -> CODEC_MP3)
uint8_t m_expectedPlsFmt = FORMAT_NONE; // set in connecttohost (e.g. streaming01.m3u) -> FORMAT_M3U)
uint8_t m_filterType[2]; // lowpass, highpass
uint8_t m_streamType = ST_NONE;
uint8_t m_ID3Size = 0; // lengt of ID3frame - ID3header
uint8_t m_vuLeft = 0; // average value of samples, left channel
uint8_t m_vuRight = 0; // average value of samples, right channel
uint8_t m_audioTaskCoreId = 0;
uint8_t m_M4A_objectType = 0; // set in read_M4A_Header
uint8_t m_M4A_chConfig = 0; // set in read_M4A_Header
uint16_t m_M4A_sampleRate = 0; // set in read_M4A_Header
int16_t* m_outBuff = NULL; // Interleaved L/R
int16_t m_validSamples = {0}; // #144
int16_t m_curSample{0};
uint16_t m_dataMode{0}; // Statemaschine
int16_t m_decodeError = 0; // Stores the return value of the decoder
uint16_t m_streamTitleHash = 0; // remember streamtitle, ignore multiple occurence in metadata
uint16_t m_timeout_ms = 250;
uint16_t m_timeout_ms_ssl = 2700;
uint32_t m_metaint = 0; // Number of databytes between metadata
uint32_t m_chunkcount = 0 ; // Counter for chunked transfer
uint32_t m_t0 = 0; // store millis(), is needed for a small delay
uint32_t m_contentlength = 0; // Stores the length if the stream comes from fileserver
uint32_t m_bytesNotDecoded = 0; // pictures or something else that comes with the stream
uint32_t m_PlayingStartTime = 0; // Stores the milliseconds after the start of the audio
int32_t m_resumeFilePos = -1; // the return value from stopSong(), (-1) is idle
int32_t m_fileStartPos = -1; // may be set in connecttoFS()
uint16_t m_m3u8_targetDuration = 10; //
uint32_t m_stsz_numEntries = 0; // num of entries inside stsz atom (uint32_t)
uint32_t m_stsz_position = 0; // pos of stsz atom within file
uint32_t m_haveNewFilePos = 0; // user changed the file position
uint32_t m_sumBytesDecoded = 0; // used for streaming
uint32_t m_webFilePos = 0; // same as audiofile.position() for SD files
bool m_f_metadata = false; // assume stream without metadata
bool m_f_unsync = false; // set within ID3 tag but not used
bool m_f_exthdr = false; // ID3 extended header
bool m_f_ssl = false;
bool m_f_running = false;
bool m_f_firstCall = false; // InitSequence for processWebstream and processLokalFile
bool m_f_firstCurTimeCall = false; // InitSequence for computeAudioTime
bool m_f_firstPlayCall = false; // InitSequence for playAudioData
bool m_f_firstM3U8call = false; // InitSequence for m3u8 parsing
bool m_f_ID3v1TagFound = false; // ID3v1 tag found
bool m_f_chunked = false ; // Station provides chunked transfer
bool m_f_firstmetabyte = false; // True if first metabyte (counter)
bool m_f_playing = false; // valid mp3 stream recognized
bool m_f_tts = false; // text to speech
bool m_f_ogg = false; // OGG stream
bool m_f_forceMono = false; // if true stereo -> mono
bool m_f_rtsp = false; // set if RTSP is used (m3u8 stream)
bool m_f_m3u8data = false; // used in processM3U8entries
bool m_f_Log = false; // set in platformio.ini -DAUDIO_LOG and -DCORE_DEBUG_LEVEL=3 or 4
bool m_f_continue = false; // next m3u8 chunk is available
bool m_f_ts = true; // transport stream
bool m_f_m4aID3dataAreRead = false; // has the m4a-ID3data already been read?
bool m_f_psramFound = false; // set in constructor, result of psramInit()
bool m_f_timeout = false; //
bool m_f_commFMT = false; // false: default (PHILIPS), true: Least Significant Bit Justified (japanese format)
bool m_f_audioTaskIsRunning = false;
bool m_f_allDataReceived = false;
bool m_f_stream = false; // stream ready for output?
bool m_f_decode_ready = false; // if true data for decode are ready
bool m_f_eof = false; // end of file
bool m_f_lockInBuffer = false; // lock inBuffer for manipulation
bool m_f_audioTaskIsDecoding = false;
bool m_f_acceptRanges = false;
bool m_f_reset_m3u8Codec = true; // reset codec for m3u8 stream
uint8_t m_f_channelEnabled = 3; //
uint32_t m_audioFileDuration = 0;
float m_audioCurrentTime = 0;
uint32_t m_audioDataStart = 0; // in bytes
size_t m_audioDataSize = 0; //
float m_filterBuff[3][2][2][2]; // IIR filters memory for Audio DSP
float m_corr = 1.0; // correction factor for level adjustment
size_t m_i2s_bytesWritten = 0; // set in i2s_write() but not used
size_t m_fileSize = 0; // size of the file
uint16_t m_filterFrequency[2];
int8_t m_gain0 = 0; // cut or boost filters (EQ)
int8_t m_gain1 = 0;
int8_t m_gain2 = 0;
pid_array m_pidsOfPMT;
int16_t m_pidOfAAC;
uint8_t m_packetBuff[m_tsPacketSize];
int16_t m_pesDataLength = 0;
};
//----------------------------------------------------------------------------------------------------------------------

View File

@ -0,0 +1,189 @@
/*
* aac_decoder.cpp
* faad2 - ESP32 adaptation
* Created on: 12.09.2023
* Updated on: 14.01.2025
*/
#include "Arduino.h"
#include "aac_decoder.h"
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include "libfaad/neaacdec.h"
// Declaration of the required global variables
NeAACDecHandle hAac;
NeAACDecFrameInfo frameInfo;
NeAACDecConfigurationPtr conf;
const uint8_t SYNCWORDH = 0xff; /* 12-bit syncword */
const uint8_t SYNCWORDL = 0xf0;
bool f_decoderIsInit = false;
bool f_firstCall = false;
bool f_setRaWBlockParams = false;
uint32_t aacSamplerate = 0;
uint8_t aacChannels = 0;
uint8_t aacProfile = 0;
static uint16_t validSamples = 0;
clock_t before;
float compressionRatio = 1;
mp4AudioSpecificConfig* mp4ASC;
//----------------------------------------------------------------------------------------------------------------------
bool AACDecoder_IsInit(){
return f_decoderIsInit;
}
//----------------------------------------------------------------------------------------------------------------------
bool AACDecoder_AllocateBuffers(){
before = clock();
hAac = NeAACDecOpen();
conf = NeAACDecGetCurrentConfiguration(hAac);
if(hAac) f_decoderIsInit = true;
f_firstCall = false;
f_setRaWBlockParams = false;
return f_decoderIsInit;
}
//----------------------------------------------------------------------------------------------------------------------
void AACDecoder_FreeBuffers(){
NeAACDecClose(hAac);
hAac = NULL;
f_decoderIsInit = false;
f_firstCall = false;
clock_t difference = clock() - before;
int msec = difference / CLOCKS_PER_SEC; (void)msec;
// printf("ms %li\n", difference);
}
//----------------------------------------------------------------------------------------------------------------------
uint8_t AACGetFormat(){
return frameInfo.header_type; // RAW 0 /* No header */
// ADIF 1 /* single ADIF header at the beginning of the file */
// ADTS 2 /* ADTS header at the beginning of each frame */
}
//----------------------------------------------------------------------------------------------------------------------
uint8_t AACGetSBR(){
return frameInfo.sbr; // NO_SBR 0 /* no SBR used in this file */
// SBR_UPSAMPLED 1 /* upsampled SBR used */
// SBR_DOWNSAMPLED 2 /* downsampled SBR used */
// NO_SBR_UPSAMPLED 3 /* no SBR used, but file is upsampled by a factor 2 anyway */
}
//----------------------------------------------------------------------------------------------------------------------
uint8_t AACGetParametricStereo(){ // not used (0) or used (1)
// log_w("frameInfo.ps %i", frameInfo.isPS);
return frameInfo.isPS;
}
//----------------------------------------------------------------------------------------------------------------------
int AACFindSyncWord(uint8_t *buf, int nBytes){
const int MIN_ADTS_HEADER_SIZE = 7;
auto validate = [](const uint8_t *buf) -> bool { // check the ADTS header for validity
// Layer (bits 14-15) must be 00
if ((buf[1] & 0x06) != 0x00) {
return false;
}
// Sampling Frequency Index (Bits 18-21) cannot be invalid
uint8_t sampling_frequency_index = (buf[2] & 0x3C) >> 2;
if (sampling_frequency_index > 12) {
return false;
}
// Frame length (bits 30-42) must be at least the header size
int frame_length = ((buf[3] & 0x03) << 11) | (buf[4] << 3) | ((buf[5] & 0xE0) >> 5);
if (frame_length < MIN_ADTS_HEADER_SIZE) {
return false;
}
return true;
};
/* find byte-aligned syncword (12 bits = 0xFFF) */
for (int i = 0; i < nBytes - 1; i++) {
if ( (buf[i+0] & SYNCWORDH) == SYNCWORDH && (buf[i+1] & SYNCWORDL) == SYNCWORDL ){
int frame_length = ((buf[i + 3] & 0x03) << 11) | (buf[i + 4] << 3) | ((buf[i + 5] & 0xE0) >> 5);
if (i + frame_length + MIN_ADTS_HEADER_SIZE > nBytes) {
return -1; // Puffergrenze überschritten, kein gültiger Header
}
/* find a second byte-aligned syncword (12 bits = 0xFFF) */
if ( (buf[i + frame_length + 0] & SYNCWORDH) == SYNCWORDH && (buf[i + frame_length + 1] & SYNCWORDL) == SYNCWORDL ){
return validate(&buf[i]) ? i : -1;
}
}
}
return -1;
}
//----------------------------------------------------------------------------------------------------------------------
int AACSetRawBlockParams(int nChans, int sampRateCore, int profile){
f_setRaWBlockParams = true;
aacChannels = nChans; // 1: Mono, 2: Stereo
aacSamplerate = (uint32_t)sampRateCore; // 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000
aacProfile = profile; //1: AAC Main, 2: AAC LC (Low Complexity), 3: AAC SSR (Scalable Sample Rate), 4: AAC LTP (Long Term Prediction)
return 0;
}
//----------------------------------------------------------------------------------------------------------------------
int16_t AACGetOutputSamps(){
return validSamples;
}
//----------------------------------------------------------------------------------------------------------------------
int AACGetBitrate(){
uint32_t br = AACGetBitsPerSample() * AACGetChannels() * AACGetSampRate();
return (br / compressionRatio);;
}
//----------------------------------------------------------------------------------------------------------------------
int AACGetChannels(){
return aacChannels;
}
//----------------------------------------------------------------------------------------------------------------------
int AACGetSampRate(){
return aacSamplerate;
}
//----------------------------------------------------------------------------------------------------------------------
int AACGetBitsPerSample(){
return 16;
}
//----------------------------------------------------------------------------------------------------------------------
void createAudioSpecificConfig(uint8_t* config, uint8_t audioObjectType, uint8_t samplingFrequencyIndex, uint8_t channelConfiguration) {
config[0] = (audioObjectType << 3) | (samplingFrequencyIndex >> 1);
config[1] = (samplingFrequencyIndex << 7) | (channelConfiguration << 3);
}
//----------------------------------------------------------------------------------------------------------------------
extern uint8_t get_sr_index(const uint32_t samplerate);
int AACDecode(uint8_t *inbuf, int32_t *bytesLeft, short *outbuf){
uint8_t* ob = (uint8_t*)outbuf;
if (f_firstCall == false){
if(f_setRaWBlockParams){ // set raw AAC values, e.g. for M4A config.
f_setRaWBlockParams = false;
conf->defSampleRate = aacSamplerate;
conf->outputFormat = FAAD_FMT_16BIT;
conf->useOldADTSFormat = 1;
conf->defObjectType = 2;
int8_t ret = NeAACDecSetConfiguration(hAac, conf); (void)ret;
uint8_t specificInfo[2];
createAudioSpecificConfig(specificInfo, aacProfile, get_sr_index(aacSamplerate), aacChannels);
int8_t err = NeAACDecInit2(hAac, specificInfo, 2, &aacSamplerate, &aacChannels);(void)err;
}
else{
NeAACDecSetConfiguration(hAac, conf);
int8_t err = NeAACDecInit(hAac, inbuf, *bytesLeft, &aacSamplerate, &aacChannels); (void)err;
}
f_firstCall = true;
}
NeAACDecDecode2(hAac, &frameInfo, inbuf, *bytesLeft, (void**)&ob, 2048 * 2 * sizeof(int16_t));
*bytesLeft -= frameInfo.bytesconsumed;
validSamples = frameInfo.samples;
int8_t err = 0 - frameInfo.error;
compressionRatio = (float)frameInfo.samples * 2 / frameInfo.bytesconsumed;
return err;
}
//----------------------------------------------------------------------------------------------------------------------
const char* AACGetErrorMessage(int8_t err){
return NeAACDecGetErrorMessage(abs(err));
}
//----------------------------------------------------------------------------------------------------------------------

View File

@ -0,0 +1,34 @@
/*
* aac_decoder.h
* faad2 - ESP32 adaptation
* Created on: 12.09.2023
* Updated on: 13.08.2024
*/
#pragma once
#include <stdint.h>
#pragma GCC diagnostic warning "-Wunused-function"
struct AudioSpecificConfig {
uint8_t audioObjectType;
uint8_t samplingFrequencyIndex;
uint8_t channelConfiguration;
};
bool AACDecoder_IsInit();
bool AACDecoder_AllocateBuffers();
void AACDecoder_FreeBuffers();
uint8_t AACGetFormat();
uint8_t AACGetParametricStereo();
uint8_t AACGetSBR();
int AACFindSyncWord(uint8_t *buf, int nBytes);
int AACSetRawBlockParams(int nChans, int sampRateCore, int profile);
int16_t AACGetOutputSamps();
int AACGetBitrate();
int AACGetChannels();
int AACGetSampRate();
int AACGetBitsPerSample();
int AACDecode(uint8_t *inbuf, int32_t *bytesLeft, short *outbuf);
const char* AACGetErrorMessage(int8_t err);

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,859 @@
/*
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
**
** This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
** Any non-GPL usage of this software or parts of this software is strictly forbidden.
**
** The "appropriate copyright message" mentioned in section 2c of the GPLv2 must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
**
** Commercial non-GPL licensing of this software is possible.
** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
**/
// ESP32 Version 29.07.2024
// updated: 10.05.2025
#pragma once
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdio.h>
#include <math.h>
/* ----------------------COMPILE TIME DEFINITIONS ---------------- */
#define PREFER_POINTERS // Use if target platform has address generators with autoincrement
// #define BIG_IQ_TABLE
// #define USE_DOUBLE_PRECISION // use double precision
#define FIXED_POINT // use fixed point reals, undefs MAIN_DEC and SSR_DEC
#define ERROR_RESILIENCE 2
#define MAIN_DEC // Allow decoding of MAIN profile AAC
// #define SSR_DEC // Allow decoding of SSR profile AAC
#define LTP_DEC // Allow decoding of LTP (Long Term Prediction) profile AAC
#define LD_DEC // Allow decoding of LD (Low Delay) profile AAC
// #define DRM_SUPPORT // Allow decoding of Digital Radio Mondiale (DRM)
#if (defined CONFIG_IDF_TARGET_ESP32S3 && defined BOARD_HAS_PSRAM)
#define SBR_DEC // Allow decoding of SBR (Spectral Band Replication) profile AAC
#define PS_DEC // Allow decoding of PS (Parametric Stereo) profile AAC
#endif
// #define SBR_LOW_POWER
#define ALLOW_SMALL_FRAMELENGTH
// #define LC_ONLY_DECODER // if you want a pure AAC LC decoder (independant of SBR_DEC and PS_DEC)
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
#ifdef DRM_SUPPORT // Allow decoding of Digital Radio Mondiale (DRM)
#define DRM
#define DRM_PS
#endif
#ifdef LD_DEC /* LD can't do without LTP */
#ifndef ERROR_RESILIENCE
#define ERROR_RESILIENCE
#endif
#ifndef LTP_DEC
#define LTP_DEC
#endif
#endif
#ifdef LC_ONLY_DECODER
#undef LD_DEC
#undef LTP_DEC
#undef MAIN_DEC
#undef SSR_DEC
#undef DRM
#undef DRM_PS
#undef ALLOW_SMALL_FRAMELENGTH
#undef ERROR_RESILIENCE
#endif
#ifdef SBR_LOW_POWER
#undef PS_DEC
#endif
#ifdef FIXED_POINT /* No MAIN decoding */
#ifdef MAIN_DEC
#undef MAIN_DEC
#endif
#endif // FIXED_POINT
#ifdef DRM
#ifndef ALLOW_SMALL_FRAMELENGTH
#define ALLOW_SMALL_FRAMELENGTH
#endif
#undef LD_DEC
#undef LTP_DEC
#undef MAIN_DEC
#undef SSR_DEC
#endif
/* END COMPILE TIME DEFINITIONS */
#ifdef WORDS_BIGENDIAN
#define ARCH_IS_BIG_ENDIAN
#endif
/* FIXED_POINT doesn't work with MAIN and SSR yet */
#ifdef FIXED_POINT
#undef MAIN_DEC
#undef SSR_DEC
#endif
#if defined(FIXED_POINT)
#elif defined(USE_DOUBLE_PRECISION)
#else /* Normal floating point operation */
#ifdef HAVE_LRINTF
#define HAS_LRINTF
#define _ISOC9X_SOURCE 1
#define _ISOC99_SOURCE 1
#define __USE_ISOC9X 1
#define __USE_ISOC99 1
#endif
#endif
#ifndef HAS_LRINTF
/* standard cast */
// #define int32_t(f) ((int32_t)(f))
#endif
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
/* defines if an object type can be decoded by this library or not */
__unused static uint8_t ObjectTypesTable[32] = {
0, /* 0 NULL */
#ifdef MAIN_DEC
1, /* 1 AAC Main */
#else
0, /* 1 AAC Main */
#endif
1, /* 2 AAC LC */
#ifdef SSR_DEC
1, /* 3 AAC SSR */
#else
0, /* 3 AAC SSR */
#endif
#ifdef LTP_DEC
1, /* 4 AAC LTP */
#else
0, /* 4 AAC LTP */
#endif
#ifdef SBR_DEC
1, /* 5 SBR */
#else
0, /* 5 SBR */
#endif
0, /* 6 AAC Scalable */
0, /* 7 TwinVQ */
0, /* 8 CELP */
0, /* 9 HVXC */
0, /* 10 Reserved */
0, /* 11 Reserved */
0, /* 12 TTSI */
0, /* 13 Main synthetic */
0, /* 14 Wavetable synthesis */
0, /* 15 General MIDI */
0, /* 16 Algorithmic Synthesis and Audio FX */
/* MPEG-4 Version 2 */
#ifdef ERROR_RESILIENCE
1, /* 17 ER AAC LC */
0, /* 18 (Reserved) */
#ifdef LTP_DEC
1, /* 19 ER AAC LTP */
#else
0, /* 19 ER AAC LTP */
#endif
0, /* 20 ER AAC scalable */
0, /* 21 ER TwinVQ */
0, /* 22 ER BSAC */
#ifdef LD_DEC
1, /* 23 ER AAC LD */
#else
0, /* 23 ER AAC LD */
#endif
0, /* 24 ER CELP */
0, /* 25 ER HVXC */
0, /* 26 ER HILN */
0, /* 27 ER Parametric */
#else /* No ER defined */
0, /* 17 ER AAC LC */
0, /* 18 (Reserved) */
0, /* 19 ER AAC LTP */
0, /* 20 ER AAC scalable */
0, /* 21 ER TwinVQ */
0, /* 22 ER BSAC */
0, /* 23 ER AAC LD */
0, /* 24 ER CELP */
0, /* 25 ER HVXC */
0, /* 26 ER HILN */
0, /* 27 ER Parametric */
#endif
0, /* 28 (Reserved) */
#ifdef PS_DEC
1, /* 29 AAC LC + SBR + PS */
#else
0, /* 29 AAC LC + SBR + PS */
#endif
0, /* 30 (Reserved) */
0 /* 31 (Reserved) */
};
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
#define ZERO_HCB 0
#define FIRST_PAIR_HCB 5
#define ESC_HCB 11
#define QUAD_LEN 4
#define PAIR_LEN 2
#define NOISE_HCB 13
#define INTENSITY_HCB2 14
#define INTENSITY_HCB 15
#define DRC_REF_LEVEL 20 * 4 /* -20 dB */
#define DRM_PARAMETRIC_STEREO 0
#define DRM_NUM_SA_BANDS 8
#define DRM_NUM_PAN_BANDS 20
#define NUM_OF_LINKS 3
#define NUM_OF_QMF_CHANNELS 64
#define NUM_OF_SUBSAMPLES 30
#define MAX_SA_BAND 46
#define MAX_PAN_BAND 64
#define MAX_DELAY 5
#define EXTENSION_ID_PS 2
#define MAX_PS_ENVELOPES 5
#define NO_ALLPASS_LINKS 3
#define BYTE_NUMBIT 8
#define BYTE_NUMBIT_LD 3
#define bit2byte(a) ((a + 7) >> BYTE_NUMBIT_LD)
#define NUM_ERROR_MESSAGES 34
#define ESC_VAL 7
#define SSR_BANDS 4
#define PQFTAPS 96
#ifdef DRM
#define DECAY_CUTOFF 3
#define DECAY_SLOPE 0.05f
/* type definitaions */
typedef const int8_t (*drm_ps_huff_tab)[2];
#endif
#define FLOAT_SCALE (1.0f / (1 << 15))
#define DM_MUL REAL_CONST(0.3203772410170407) // 1/(1+sqrt(2) + 1/sqrt(2))
#define RSQRT2 REAL_CONST(0.7071067811865475244) // 1/sqrt(2)
#define NUM_CB 6
#define NUM_CB_ER 22
#define MAX_CB 32
#define VCB11_FIRST 16
#define VCB11_LAST 31
#define TNS_MAX_ORDER 20
#define MAIN 1
#define LC 2
#define SSR 3
#define LTP 4
#define HE_AAC 5
#define LD 23
#define ER_LC 17
#define ER_LTP 19
#define DRM_ER_LC 27 /* special object type for DRM */
/* header types */
#define RAW 0
#define ADIF 1
#define ADTS 2
#define LATM 3
/* SBR signalling */
#define NO_SBR 0
#define SBR_UPSAMPLED 1
#define SBR_DOWNSAMPLED 2
#define NO_SBR_UPSAMPLED 3
/* DRM channel definitions */
#define DRMCH_MONO 1
#define DRMCH_STEREO 2
#define DRMCH_SBR_MONO 3
#define DRMCH_SBR_STEREO 4
#define DRMCH_SBR_PS_STEREO 5
/* First object type that has ER */
#define ER_OBJECT_START 17
/* Bitstream */
#define LEN_SE_ID 3
#define LEN_TAG 4
#define LEN_BYTE 8
#define EXT_FIL 0
#define EXT_FILL_DATA 1
#define EXT_DATA_ELEMENT 2
#define EXT_DYNAMIC_RANGE 11
#define ANC_DATA 0
/* Syntax elements */
#define ID_SCE 0x0
#define ID_CPE 0x1
#define ID_CCE 0x2
#define ID_LFE 0x3
#define ID_DSE 0x4
#define ID_PCE 0x5
#define ID_FIL 0x6
#define ID_END 0x7
#define INVALID_ELEMENT_ID 255
#define ONLY_LONG_SEQUENCE 0x0
#define LONG_START_SEQUENCE 0x1
#define EIGHT_SHORT_SEQUENCE 0x2
#define LONG_STOP_SEQUENCE 0x3
#define ZERO_HCB 0
#define FIRST_PAIR_HCB 5
#define ESC_HCB 11
#define QUAD_LEN 4
#define PAIR_LEN 2
#define NOISE_HCB 13
#define INTENSITY_HCB2 14
#define INTENSITY_HCB 15
#define INVALID_SBR_ELEMENT 255
#define T_HFGEN 8
#define T_HFADJ 2
#define EXT_SBR_DATA 13
#define EXT_SBR_DATA_CRC 14
#define FIXFIX 0
#define FIXVAR 1
#define VARFIX 2
#define VARVAR 3
#define LO_RES 0
#define HI_RES 1
#define NO_TIME_SLOTS_960 15
#define NO_TIME_SLOTS 16
#define RATE 2
#define NOISE_FLOOR_OFFSET 6
#ifdef PS_DEC
#define NEGATE_IPD_MASK (0x1000)
#define DECAY_SLOPE FRAC_CONST(0.05)
#define COEF_SQRT2 COEF_CONST(1.4142135623731)
#endif // PS_DEC
#define MAX_NTSRHFG 40 /* MAX_NTSRHFG: maximum of number_time_slots * rate + HFGen. 16*2+8 */
#define MAX_NTSR 32 /* max number_time_slots * rate, ok for DRM and not DRM mode */
#define MAX_M 49 /* MAX_M: maximum value for M */
#define MAX_L_E 5 /* MAX_L_E: maximum value for L_E */
#ifdef SBR_DEC
#ifdef FIXED_POINT
#define _EPS (1) /* smallest number available in fixed point */
#else
#define _EPS (1e-12)
#endif
#endif // SBR_DEC
#ifdef FIXED_POINT /* int32_t */
#define LOG2_MIN_INF REAL_CONST(-10000)
#define COEF_BITS 28
#define COEF_PRECISION (1 << COEF_BITS)
#define REAL_BITS 14 // MAXIMUM OF 14 FOR FIXED POINT SBR
#define REAL_PRECISION (1 << REAL_BITS)
/* FRAC is the fractional only part of the fixed point number [0.0..1.0) */
#define FRAC_SIZE 32 /* frac is a 32 bit integer */
#define FRAC_BITS 31
#define FRAC_PRECISION ((uint32_t)(1 << FRAC_BITS))
#define FRAC_MAX 0x7FFFFFFF
typedef int32_t real_t;
#define REAL_CONST(A) (((A) >= 0) ? ((real_t)((A) * (REAL_PRECISION) + 0.5)) : ((real_t)((A) * (REAL_PRECISION) - 0.5)))
#define COEF_CONST(A) (((A) >= 0) ? ((real_t)((A) * (COEF_PRECISION) + 0.5)) : ((real_t)((A) * (COEF_PRECISION) - 0.5)))
#define FRAC_CONST(A) (((A) == 1.00) ? ((real_t)FRAC_MAX) : (((A) >= 0) ? ((real_t)((A) * (FRAC_PRECISION) + 0.5)) : ((real_t)((A) * (FRAC_PRECISION) - 0.5))))
// #define FRAC_CONST(A) (((A) >= 0) ? ((real_t)((A)*(FRAC_PRECISION)+0.5)) : ((real_t)((A)*(FRAC_PRECISION)-0.5)))
#define Q2_BITS 22
#define Q2_PRECISION (1 << Q2_BITS)
#define Q2_CONST(A) (((A) >= 0) ? ((real_t)((A) * (Q2_PRECISION) + 0.5)) : ((real_t)((A) * (Q2_PRECISION) - 0.5)))
/* multiply with real shift */
#define MUL_R(A, B) (real_t)(((int64_t)(A) * (int64_t)(B) + (1 << (REAL_BITS - 1))) >> REAL_BITS)
/* multiply with coef shift */
#define MUL_C(A, B) (real_t)(((int64_t)(A) * (int64_t)(B) + (1 << (COEF_BITS - 1))) >> COEF_BITS)
/* multiply with fractional shift */
#define _MulHigh(A, B) (real_t)(((int64_t)(A) * (int64_t)(B) + (1 << (FRAC_SIZE - 1))) >> FRAC_SIZE)
#define MUL_F(A, B) (real_t)(((int64_t)(A) * (int64_t)(B) + (1 << (FRAC_BITS - 1))) >> FRAC_BITS)
#define MUL_Q2(A, B) (real_t)(((int64_t)(A) * (int64_t)(B) + (1 << (Q2_BITS - 1))) >> Q2_BITS)
#define MUL_SHIFT6(A, B) (real_t)(((int64_t)(A) * (int64_t)(B) + (1 << (6 - 1))) >> 6)
#define MUL_SHIFT23(A, B) (real_t)(((int64_t)(A) * (int64_t)(B) + (1 << (23 - 1))) >> 23)
#define DIV_R(A, B) (((int64_t)A << REAL_BITS) / B)
#define DIV_C(A, B) (((int64_t)A << COEF_BITS) / B)
/* Complex multiplication */
static inline void ComplexMult(real_t* y1, real_t* y2, real_t x1, real_t x2, real_t c1, real_t c2) { // FIXED POINT
*y1 = (_MulHigh(x1, c1) + _MulHigh(x2, c2)) << (FRAC_SIZE - FRAC_BITS);
*y2 = (_MulHigh(x2, c1) - _MulHigh(x1, c2)) << (FRAC_SIZE - FRAC_BITS);
}
// static inline void ComplexMult(int32_t* y1, int32_t* y2, int32_t x1, int32_t x2, int32_t c1, int32_t c2) { // only XTENSA chips
// asm volatile (
// // y1 = (x1 * c1) + (x2 * c2)
// "mulsh a2, %2, %4\n" // a2 = x1 * c1 (Low 32 bits)
// "mulsh a3, %3, %5\n" // a3 = x2 * c2 (Low 32 bits)
// "add a2, a2, a3\n" // a2 = (x1 * c1) + (x2 * c2)
// "slli a2, a2, 1\n" // a2 = a2 >> 31 (Fixed-Point scaling)
// "s32i a2, %0 \n" // Store result in *y1
// // y2 = (x2 * c1) - (x1 * c2)
// "mulsh a2, %3, %4\n" // a2 = x2 * c1 (Low 32 bits)
// "mulsh a3, %2, %5\n" // a3 = x1 * c2 (Low 32 bits)
// "sub a2, a2, a3\n" // a2 = (x2 * c1) - (x1 * c2)
// "slli a2, a2, 1\n" // a2 = a2 >> 31 (Fixed-Point scaling)
// "s32i a2, %1 \n" // Store result in *y2
// : "=m" (*y1), "=m" (*y2) // Output
// : "r" (x1), "r" (x2), "r" (c1), "r" (c2) // Input
// : "a2", "a3" // Clobbers
// );
// }
#define DIV(A, B) (((int64_t)A << REAL_BITS) / B)
#define step(shift) \
if ((0x40000000l >> shift) + root <= value) { \
value -= (0x40000000l >> shift) + root; \
root = (root >> 1) | (0x40000000l >> shift); \
} else { \
root = root >> 1; \
}
real_t const pow2_table[] = {COEF_CONST(1.0), COEF_CONST(1.18920711500272), COEF_CONST(1.41421356237310), COEF_CONST(1.68179283050743)};
#endif // FIXED_POINT
#ifndef FIXED_POINT
#ifdef MAIN_DEC
#define ALPHA REAL_CONST(0.90625)
#define A REAL_CONST(0.953125)
#endif
#define IQ_TABLE_SIZE 8192
#define DIV_R(A, B) ((A) / (B))
#define DIV_C(A, B) ((A) / (B))
#ifdef USE_DOUBLE_PRECISION /* double */
typedef double real_t;
#include <math.h>
#define MUL_R(A, B) ((A) * (B))
#define MUL_C(A, B) ((A) * (B))
#define MUL_F(A, B) ((A) * (B))
/* Complex multiplication */
static void ComplexMult(real_t* y1, real_t* y2, real_t x1, real_t x2, real_t c1, real_t c2) {
*y1 = MUL_F(x1, c1) + MUL_F(x2, c2);
*y2 = MUL_F(x2, c1) - MUL_F(x1, c2);
}
#define REAL_CONST(A) ((real_t)(A))
#define COEF_CONST(A) ((real_t)(A))
#define Q2_CONST(A) ((real_t)(A))
#define FRAC_CONST(A) ((real_t)(A)) /* pure fractional part */
#else /* Normal floating point operation */
typedef float real_t;
#define MUL_R(A, B) ((A) * (B))
#define MUL_C(A, B) ((A) * (B))
#define MUL_F(A, B) ((A) * (B))
#define REAL_CONST(A) ((real_t)(A))
#define COEF_CONST(A) ((real_t)(A))
#define Q2_CONST(A) ((real_t)(A))
#define FRAC_CONST(A) ((real_t)(A)) /* pure fractional part */
/* Complex multiplication */
static void ComplexMult(real_t* y1, real_t* y2, real_t x1, real_t x2, real_t c1, real_t c2) {
*y1 = MUL_F(x1, c1) + MUL_F(x2, c2);
*y2 = MUL_F(x2, c1) - MUL_F(x1, c2);
}
#endif /* USE_DOUBLE_PRECISION */
#endif // FIXED_POINT
#ifdef SBR_LOW_POWER
#define qmf_t real_t
#define QMF_RE(A) (A)
#define QMF_IM(A)
#else
#define qmf_t complex_t
#define QMF_RE(A) RE(A)
#define QMF_IM(A) IM(A)
#endif
typedef real_t complex_t[2];
#define RE(A) A[0]
#define IM(A) A[1]
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#ifndef max
#define max(a, b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef min
#define min(a, b) (((a) < (b)) ? (a) : (b))
#endif
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
#include "structs.h"
#include "tables.h"
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
#ifndef FAAD2_VERSION
#define FAAD2_VERSION "unknown"
#endif
/* object types for AAC */
#define MAIN 1
#define LC 2
#define SSR 3
#define LTP 4
#define HE_AAC 5
#define ER_LC 17
#define ER_LTP 19
#define LD 23
#define DRM_ER_LC 27 /* special object type for DRM */
/* header types */
#define RAW 0
#define ADIF 1
#define ADTS 2
#define LATM 3
/* SBR signalling */
#define NO_SBR 0
#define SBR_UPSAMPLED 1
#define SBR_DOWNSAMPLED 2
#define NO_SBR_UPSAMPLED 3
/* library output formats */
#define FAAD_FMT_16BIT 1
#define FAAD_FMT_24BIT 2
#define FAAD_FMT_32BIT 3
#define FAAD_FMT_FLOAT 4
#define FAAD_FMT_FIXED FAAD_FMT_FLOAT
#define FAAD_FMT_DOUBLE 5
/* Capabilities */
#define LC_DEC_CAP (1<<0) /* Can decode LC */
#define MAIN_DEC_CAP (1<<1) /* Can decode MAIN */
#define LTP_DEC_CAP (1<<2) /* Can decode LTP */
#define LD_DEC_CAP (1<<3) /* Can decode LD */
#define ERROR_RESILIENCE_CAP (1<<4) /* Can decode ER */
#define FIXED_POINT_CAP (1<<5) /* Fixed point */
/* Channel definitions */
#define FRONT_CHANNEL_CENTER (1)
#define FRONT_CHANNEL_LEFT (2)
#define FRONT_CHANNEL_RIGHT (3)
#define SIDE_CHANNEL_LEFT (4)
#define SIDE_CHANNEL_RIGHT (5)
#define BACK_CHANNEL_LEFT (6)
#define BACK_CHANNEL_RIGHT (7)
#define BACK_CHANNEL_CENTER (8)
#define LFE_CHANNEL (9)
#define UNKNOWN_CHANNEL (0)
/* DRM channel definitions */
#define DRMCH_MONO 1
#define DRMCH_STEREO 2
#define DRMCH_SBR_MONO 3
#define DRMCH_SBR_STEREO 4
#define DRMCH_SBR_PS_STEREO 5
/* A decode call can eat up to FAAD_MIN_STREAMSIZE bytes per decoded channel,
so at least so much bytes per channel should be available in this stream */
#define FAAD_MIN_STREAMSIZE 768 /* 6144 bits/channel */
typedef void *NeAACDecHandle;
typedef struct mp4AudioSpecificConfig
{
/* Audio Specific Info */
unsigned char objectTypeIndex;
unsigned char samplingFrequencyIndex;
uint32_t samplingFrequency;
unsigned char channelsConfiguration;
/* GA Specific Info */
unsigned char frameLengthFlag;
unsigned char dependsOnCoreCoder;
unsigned short coreCoderDelay;
unsigned char extensionFlag;
unsigned char aacSectionDataResilienceFlag;
unsigned char aacScalefactorDataResilienceFlag;
unsigned char aacSpectralDataResilienceFlag;
unsigned char epConfig;
char sbr_present_flag;
char forceUpSampling;
char downSampledSBR;
} mp4AudioSpecificConfig;
typedef struct NeAACDecFrameInfo
{
uint32_t bytesconsumed;
uint32_t samples;
unsigned char channels;
unsigned char error;
uint32_t samplerate;
/* SBR: 0: off, 1: on; upsample, 2: on; downsampled, 3: off; upsampled */
unsigned char sbr;
/* MPEG-4 ObjectType */
unsigned char object_type;
/* AAC header type; MP4 will be signalled as RAW also */
unsigned char header_type;
/* multichannel configuration */
unsigned char num_front_channels;
unsigned char num_side_channels;
unsigned char num_back_channels;
unsigned char num_lfe_channels;
unsigned char channel_position[64];
/* PS: 0: off, 1: on */
unsigned char ps;
uint8_t isPS;
} NeAACDecFrameInfo;
uint8_t cpu_has_sse(void);
uint32_t ne_rng(uint32_t* __r1, uint32_t* __r2);
uint32_t wl_min_lzc(uint32_t x);
#ifdef FIXED_POINT
int32_t log2_int(uint32_t val);
int32_t log2_fix(uint32_t val);
int32_t pow2_int(real_t val);
real_t pow2_fix(real_t val);
#endif
uint8_t get_sr_index(const uint32_t samplerate);
uint8_t max_pred_sfb(const uint8_t sr_index);
uint8_t max_tns_sfb(const uint8_t sr_index, const uint8_t object_type, const uint8_t is_short);
uint32_t get_sample_rate(const uint8_t sr_index);
int8_t can_decode_ot(const uint8_t object_type);
void* faad_malloc(size_t size);
template <typename freeType>
void faad_free(freeType** b);
drc_info* drc_init(real_t cut, real_t boost);
void drc_end(drc_info* drc);
void drc_decode(drc_info* drc, real_t* spec);
sbr_info* sbrDecodeInit(uint16_t framelength, uint8_t id_aac, uint32_t sample_rate, uint8_t downSampledSBR, uint8_t IsDRM);
void sbrDecodeEnd(sbr_info* sbr);
void sbrReset(sbr_info* sbr);
uint8_t sbrDecodeCoupleFrame(sbr_info* sbr, real_t* left_chan, real_t* right_chan, const uint8_t just_seeked, const uint8_t downSampledSBR);
uint8_t sbrDecodeSingleFrame(sbr_info* sbr, real_t* channel, const uint8_t just_seeked, const uint8_t downSampledSBR);
uint16_t ps_data(ps_info* ps, bitfile* ld, uint8_t* header);
ps_info* ps_init(uint8_t sr_index, uint8_t numTimeSlotsRate);
void ps_free(ps_info* ps);
uint8_t ps_decode(ps_info* ps, qmf_t X_left[38][64], qmf_t X_right[38][64]);
void faad_initbits(bitfile* ld, const void* buffer, const uint32_t buffer_size);
void faad_endbits(bitfile* ld);
void faad_initbits_rev(bitfile* ld, void* buffer, uint32_t bits_in_buffer);
uint8_t faad_byte_align(bitfile* ld);
uint32_t faad_get_processed_bits(bitfile* ld);
void faad_flushbits_ex(bitfile* ld, uint32_t bits);
void faad_rewindbits(bitfile* ld);
void faad_resetbits(bitfile* ld, int bits);
uint8_t* faad_getbitbuffer(bitfile* ld, uint32_t bits);
void* faad_origbitbuffer(bitfile* ld);
uint32_t faad_origbitbuffer_size(bitfile* ld);
uint8_t faad_get1bit(bitfile* ld);
uint32_t faad_getbits(bitfile* ld, uint32_t n);
uint32_t faad_showbits_rev(bitfile* ld, uint32_t bits);
void faad_flushbits_rev(bitfile* ld, uint32_t bits);
uint32_t getdword(void* mem);
uint32_t getdword_n(void* mem, int n);
void faad_flushbits(bitfile* ld, uint32_t bits);
uint32_t faad_showbits(bitfile* ld, uint32_t bits);
uint32_t showbits_hcr(bits_t* ld, uint8_t bits);
uint32_t faad_getbits_rev(bitfile* ld, uint32_t n);
int8_t get1bit_hcr(bits_t* ld, uint8_t* result);
int8_t flushbits_hcr(bits_t* ld, uint8_t bits);
int8_t getbits_hcr(bits_t* ld, uint8_t n, uint32_t* result);
void cfftf(cfft_info* cfft, complex_t* c);
void cfftb(cfft_info* cfft, complex_t* c);
cfft_info* cffti(uint16_t n);
void cfftu(cfft_info* cfft);
NeAACDecHandle NeAACDecOpen(void);
const char* NeAACDecGetErrorMessage(unsigned const char errcode);
void* NeAACDecDecode2(NeAACDecHandle hpDecoder, NeAACDecFrameInfo* hInfo, unsigned char* buffer, uint32_t buffer_size, void** sample_buffer, uint32_t sample_buffer_size);
long NeAACDecInit(NeAACDecHandle hpDecoder, unsigned char* buffer, uint32_t buffer_size, uint32_t* samplerate, unsigned char* channels);
unsigned char NeAACDecSetConfiguration(NeAACDecHandle hpDecoder, NeAACDecConfigurationPtr config);
char NeAACDecInit2(NeAACDecHandle hpDecoder, unsigned char* pBuffer, uint32_t SizeOfDecoderSpecificInfo, uint32_t* samplerate, unsigned char* channels);
unsigned char NeAACDecSetConfiguration(NeAACDecHandle hpDecoder, NeAACDecConfigurationPtr config);
void NeAACDecClose(NeAACDecHandle hpDecoder);
NeAACDecConfigurationPtr NeAACDecGetCurrentConfiguration(NeAACDecHandle hpDecoder);
void* aac_frame_decode(NeAACDecStruct* hDecoder, NeAACDecFrameInfo* hInfo, unsigned char* buffer, uint32_t buffer_size, void** sample_buffer2, uint32_t sample_buffer_size);
void create_channel_config(NeAACDecStruct* hDecoder, NeAACDecFrameInfo* hInfo);
void ssr_filter_bank_end(fb_info* fb);
void passf2pos(const uint16_t ido, const uint16_t l1, const complex_t* cc, complex_t* ch, const complex_t* wa);
void passf2neg(const uint16_t ido, const uint16_t l1, const complex_t* cc, complex_t* ch, const complex_t* wa);
void passf3(const uint16_t ido, const uint16_t l1, const complex_t* cc, complex_t* ch, const complex_t* wa1, const complex_t* wa2, const int8_t isign);
void passf4pos(const uint16_t ido, const uint16_t l1, const complex_t* cc, complex_t* ch, const complex_t* wa1, const complex_t* wa2, const complex_t* wa3);
void passf4neg(const uint16_t ido, const uint16_t l1, const complex_t* cc, complex_t* ch, const complex_t* wa1, const complex_t* wa2, const complex_t* wa3);
void passf5(const uint16_t ido, const uint16_t l1, const complex_t* cc, complex_t* ch, const complex_t* wa1, const complex_t* wa2, const complex_t* wa3, const complex_t* wa4, const int8_t isign);
void cffti1(uint16_t n, complex_t* wa, uint16_t* ifac);
drc_info *drc_init(real_t cut, real_t boost);
void drc_end(drc_info *drc);
void drc_decode(drc_info *drc, real_t *spec);
fb_info* filter_bank_init(uint16_t frame_len);
void filter_bank_end(fb_info* fb);
void filter_bank_ltp(fb_info* fb, uint8_t window_sequence, uint8_t window_shape, uint8_t window_shape_prev, real_t* in_data, real_t* out_mdct, uint8_t object_type, uint16_t frame_len);
void ifilter_bank(fb_info* fb, uint8_t window_sequence, uint8_t window_shape, uint8_t window_shape_prev, real_t* freq_in, real_t* time_out, real_t* overlap, uint8_t object_type, uint16_t frame_len);
void ms_decode(ic_stream *ics, ic_stream *icsr, real_t *l_spec, real_t *r_spec, uint16_t frame_len);
void is_decode(ic_stream* ics, ic_stream* icsr, real_t* l_spec, real_t* r_spec, uint16_t frame_len);
int8_t is_intensity(ic_stream* ics, uint8_t group, uint8_t sfb);
uint8_t is_noise(ic_stream *ics, uint8_t group, uint8_t sfb);
real_t fp_sqrt(real_t value);
void pns_decode(ic_stream* ics_left, ic_stream* ics_right, real_t* spec_left, real_t* spec_right, uint16_t frame_len, uint8_t channel_pair, uint8_t object_type,
/* RNG states */ uint32_t* __r1, uint32_t* __r2);
int8_t invert_intensity(ic_stream* ics, uint8_t group, uint8_t sfb);
void* output_to_PCM(NeAACDecStruct* hDecoder, real_t** input, void* samplebuffer, uint8_t channels, uint16_t frame_len, uint8_t format);
uint8_t pulse_decode(ic_stream *ics, int16_t *spec_coef, uint16_t framelen);
void gen_rand_vector(real_t* spec, int16_t scale_factor, uint16_t size, uint8_t sub, uint32_t* __r1, uint32_t* __r2);
void huffman_sign_bits(bitfile *ld, int16_t *sp, uint8_t len);
uint8_t huffman_getescape(bitfile *ld, int16_t *sp);
uint8_t huffman_2step_quad(uint8_t cb, bitfile *ld, int16_t *sp);
uint8_t huffman_2step_quad_sign(uint8_t cb, bitfile *ld, int16_t *sp);
uint8_t huffman_2step_pair(uint8_t cb, bitfile *ld, int16_t *sp);
uint8_t huffman_2step_pair_sign(uint8_t cb, bitfile *ld, int16_t *sp);
uint8_t huffman_binary_quad(uint8_t cb, bitfile *ld, int16_t *sp);
uint8_t huffman_binary_quad_sign(uint8_t cb, bitfile *ld, int16_t *sp);
uint8_t huffman_binary_pair(uint8_t cb, bitfile *ld, int16_t *sp);
uint8_t huffman_binary_pair_sign(uint8_t cb, bitfile *ld, int16_t *sp);
int16_t huffman_codebook(uint8_t i);
void vcb11_check_LAV(uint8_t cb, int16_t *sp);
uint16_t drm_ps_data(drm_ps_info *ps, bitfile *ld);
drm_ps_info *drm_ps_init(void);
void drm_ps_free(drm_ps_info *ps);
uint8_t drm_ps_decode(drm_ps_info *ps, uint8_t guess, qmf_t X_left[38][64], qmf_t X_right[38][64]);
int8_t huffman_scale_factor(bitfile *ld);
uint8_t huffman_spectral_data(uint8_t cb, bitfile *ld, int16_t *sp);
int8_t huffman_spectral_data_2(uint8_t cb, bits_t *ld, int16_t *sp);
fb_info* ssr_filter_bank_init(uint16_t frame_len);
void ssr_filter_bank_end(fb_info* fb);
void ssr_ifilter_bank(fb_info* fb, uint8_t window_sequence, uint8_t window_shape, uint8_t window_shape_prev, real_t* freq_in, real_t* time_out, uint16_t frame_len);
int8_t AudioSpecificConfig2(uint8_t* pBuffer, uint32_t buffer_size, mp4AudioSpecificConfig* mp4ASC, program_config* pce, uint8_t short_form);
int8_t AudioSpecificConfigFromBitfile(bitfile* ld, mp4AudioSpecificConfig* mp4ASC, program_config* pce, uint32_t bsize, uint8_t short_form);
void pns_reset_pred_state(ic_stream* ics, pred_state* state);
void reset_all_predictors(pred_state* state, uint16_t frame_len);
void ic_prediction(ic_stream* ics, real_t* spec, pred_state* state, uint16_t frame_len, uint8_t sf_index);
uint8_t quant_to_spec(NeAACDecStruct* hDecoder, ic_stream* ics, int16_t* quant_data, real_t* spec_data, uint16_t frame_len);
uint8_t window_grouping_info(NeAACDecStruct* hDecoder, ic_stream* ics);
uint8_t reconstruct_channel_pair(NeAACDecStruct* hDecoder, ic_stream* ics1, ic_stream* ics2, element* cpe, int16_t* spec_data1, int16_t* spec_data2);
uint8_t reconstruct_single_channel(NeAACDecStruct* hDecoder, ic_stream* ics, element* sce, int16_t* spec_data);
void tns_decode_frame(ic_stream* ics, tns_info* tns, uint8_t sr_index, uint8_t object_type, real_t* spec, uint16_t frame_len);
void tns_encode_frame(ic_stream* ics, tns_info* tns, uint8_t sr_index, uint8_t object_type, real_t* spec, uint16_t frame_len);
uint8_t is_ltp_ot(uint8_t object_type);
void lt_prediction(ic_stream* ics, ltp_info* ltp, real_t* spec, int16_t* lt_pred_stat, fb_info* fb, uint8_t win_shape, uint8_t win_shape_prev, uint8_t sr_index, uint8_t object_type,
uint16_t frame_len);
void lt_update_state(int16_t* lt_pred_stat, real_t* time, real_t* overlap, uint16_t frame_len, uint8_t object_type);
void tns_decode_coef(uint8_t order, uint8_t coef_res_bits, uint8_t coef_compress, uint8_t* coef, real_t* a);
void tns_ar_filter(real_t* spectrum, uint16_t size, int8_t inc, real_t* lpc, uint8_t order);
void tns_ma_filter(real_t* spectrum, uint16_t size, int8_t inc, real_t* lpc, uint8_t order);
uint8_t faad_check_CRC(bitfile* ld, uint16_t len);
/* static function declarations */
void decode_sce_lfe(NeAACDecStruct* hDecoder, NeAACDecFrameInfo* hInfo, bitfile* ld, uint8_t id_syn_ele);
void decode_cpe(NeAACDecStruct* hDecoder, NeAACDecFrameInfo* hInfo, bitfile* ld, uint8_t id_syn_ele);
uint8_t single_lfe_channel_element(NeAACDecStruct* hDecoder, bitfile* ld, uint8_t channel, uint8_t* tag);
uint8_t channel_pair_element(NeAACDecStruct* hDecoder, bitfile* ld, uint8_t channel, uint8_t* tag);
#ifdef COUPLING_DEC
uint8_t coupling_channel_element(NeAACDecStruct* hDecoder, bitfile* ld);
#endif
uint16_t data_stream_element(NeAACDecStruct* hDecoder, bitfile* ld);
uint8_t program_config_element(program_config* pce, bitfile* ld);
uint8_t fill_element(NeAACDecStruct* hDecoder, bitfile* ld, drc_info* drc, uint8_t sbr_ele);
uint8_t individual_channel_stream(NeAACDecStruct* hDecoder, element* ele, bitfile* ld, ic_stream* ics, uint8_t scal_flag, int16_t* spec_data);
uint8_t ics_info(NeAACDecStruct* hDecoder, ic_stream* ics, bitfile* ld, uint8_t common_window);
uint8_t section_data(NeAACDecStruct* hDecoder, ic_stream* ics, bitfile* ld);
uint8_t scale_factor_data(NeAACDecStruct* hDecoder, ic_stream* ics, bitfile* ld);
#ifdef SSR_DEC
void gain_control_data(bitfile* ld, ic_stream* ics);
#endif
uint8_t spectral_data(NeAACDecStruct* hDecoder, ic_stream* ics, bitfile* ld, int16_t* spectral_data);
uint16_t extension_payload(bitfile* ld, drc_info* drc, uint16_t count);
uint8_t pulse_data(ic_stream* ics, pulse_info* pul, bitfile* ld);
void tns_data(ic_stream* ics, tns_info* tns, bitfile* ld);
#ifdef LTP_DEC
uint8_t ltp_data(NeAACDecStruct* hDecoder, ic_stream* ics, ltp_info* ltp, bitfile* ld);
#endif
uint8_t adts_fixed_header(adts_header* adts, bitfile* ld);
void adts_variable_header(adts_header* adts, bitfile* ld);
void adts_error_check(adts_header* adts, bitfile* ld);
uint8_t dynamic_range_info(bitfile* ld, drc_info* drc);
uint8_t excluded_channels(bitfile* ld, drc_info* drc);
uint8_t side_info(NeAACDecStruct* hDecoder, element* ele, bitfile* ld, ic_stream* ics, uint8_t scal_flag);
int8_t GASpecificConfig(bitfile* ld, mp4AudioSpecificConfig* mp4ASC, program_config* pce);
uint8_t adts_frame(adts_header* adts, bitfile* ld);
void get_adif_header(adif_header* adif, bitfile* ld);
void raw_data_block(NeAACDecStruct* hDecoder, NeAACDecFrameInfo* hInfo, bitfile* ld, program_config* pce, drc_info* drc);
uint8_t reordered_spectral_data(NeAACDecStruct* hDecoder, ic_stream* ics, bitfile* ld, int16_t* spectral_data);
#ifdef DRM
int8_t DRM_aac_scalable_main_header(NeAACDecStruct* hDecoder, ic_stream* ics1, ic_stream* ics2, bitfile* ld, uint8_t this_layer_stereo);
#endif
void dct4_kernel(real_t * in_real, real_t * in_imag, real_t * out_real, real_t * out_imag);
void DCT3_32_unscaled(real_t *y, real_t *x);
void DCT4_32(real_t *y, real_t *x);
void DST4_32(real_t *y, real_t *x);
void DCT2_32_unscaled(real_t *y, real_t *x);
void DCT4_16(real_t *y, real_t *x);
void DCT2_16_unscaled(real_t *y, real_t *x);
uint8_t rvlc_scale_factor_data(ic_stream *ics, bitfile *ld);
uint8_t rvlc_decode_scale_factors(ic_stream *ics, bitfile *ld);
uint8_t sbr_extension_data(bitfile* ld, sbr_info* sbr, uint16_t cnt, uint8_t resetFlag);
int8_t rvlc_huffman_sf(bitfile* ld_sf, bitfile* ld_esc, int8_t direction);
int8_t rvlc_huffman_esc(bitfile* ld_esc, int8_t direction);
uint8_t rvlc_decode_sf_forward(ic_stream* ics, bitfile* ld_sf, bitfile* ld_esc, uint8_t* intensity_used);
#ifdef DRM
void DRM_aac_scalable_main_element(NeAACDecStruct* hDecoder, NeAACDecFrameInfo* hInfo, bitfile* ld, program_config* pce, drc_info* drc);
#endif
uint32_t faad_latm_frame(latm_header *latm, bitfile *ld);
#ifdef SSR_DEC
void ssr_decode(ssr_info* ssr, fb_info* fb, uint8_t window_sequence, uint8_t window_shape, uint8_t window_shape_prev, real_t* freq_in, real_t* time_out, real_t* overlap,
real_t ipqf_buffer[SSR_BANDS][96 / 4], real_t* prev_fmd, uint16_t frame_len);
ssr_gain_control(ssr_info* ssr, real_t* data, real_t* output, real_t* overlap, real_t* prev_fmd, uint8_t band, uint8_t window_sequence, uint16_t frame_len);
ssr_gc_function(ssr_info* ssr, real_t* prev_fmd, real_t* gc_function, uint8_t window_sequence, uint16_t frame_len);
#endif
void extract_envelope_data(sbr_info *sbr, uint8_t ch);
void extract_noise_floor_data(sbr_info *sbr, uint8_t ch);
#ifndef FIXED_POINT
void envelope_noise_dequantisation(sbr_info *sbr, uint8_t ch);
void unmap_envelope_noise(sbr_info *sbr);
#endif
void ssr_ipqf(ssr_info* ssr, real_t* in_data, real_t* out_data, real_t buffer[SSR_BANDS][96 / 4], uint16_t frame_len, uint8_t bands);
mdct_info *faad_mdct_init(uint16_t N);
void faad_mdct_end(mdct_info *mdct);
void faad_imdct(mdct_info *mdct, real_t *X_in, real_t *X_out);
void faad_mdct(mdct_info *mdct, real_t *X_in, real_t *X_out);
#if (defined(PS_DEC) || defined(DRM_PS))
uint8_t sbrDecodeSingleFramePS(sbr_info* sbr, real_t* left_channel, real_t* right_channel, const uint8_t just_seeked, const uint8_t downSampledSBR);
#endif
void unmap_envelope_noise(sbr_info* sbr);
int16_t real_to_int16(real_t sig_in);
uint8_t sbr_save_prev_data(sbr_info* sbr, uint8_t ch);
void sbr_save_matrix(sbr_info* sbr, uint8_t ch);
fb_info *ssr_filter_bank_init(uint16_t frame_len);
void ssr_filter_bank_end(fb_info *fb);
void ssr_ifilter_bank(fb_info* fb, uint8_t window_sequence, uint8_t window_shape, uint8_t window_shape_prev, real_t* freq_in, real_t* time_out, uint16_t frame_len);
int32_t find_bands(uint8_t warp, uint8_t bands, uint8_t a0, uint8_t a1);
void sbr_header(bitfile* ld, sbr_info* sbr);
uint8_t calc_sbr_tables(sbr_info* sbr, uint8_t start_freq, uint8_t stop_freq, uint8_t samplerate_mode, uint8_t freq_scale, uint8_t alter_scale, uint8_t xover_band);
uint8_t sbr_data(bitfile* ld, sbr_info* sbr);
uint16_t sbr_extension(bitfile* ld, sbr_info* sbr, uint8_t bs_extension_id, uint16_t num_bits_left);
uint8_t sbr_single_channel_element(bitfile* ld, sbr_info* sbr);
uint8_t sbr_channel_pair_element(bitfile* ld, sbr_info* sbr);
uint8_t sbr_grid(bitfile* ld, sbr_info* sbr, uint8_t ch);
void sbr_dtdf(bitfile* ld, sbr_info* sbr, uint8_t ch);
void invf_mode(bitfile* ld, sbr_info* sbr, uint8_t ch);
void sinusoidal_coding(bitfile* ld, sbr_info* sbr, uint8_t ch);
uint8_t hf_adjustment(sbr_info *sbr, qmf_t Xsbr[MAX_NTSRHFG][64], real_t *deg, uint8_t ch);
uint8_t qmf_start_channel(uint8_t bs_start_freq, uint8_t bs_samplerate_mode, uint32_t sample_rate);
uint8_t qmf_stop_channel(uint8_t bs_stop_freq, uint32_t sample_rate, uint8_t k0);
uint8_t master_frequency_table_fs0(sbr_info* sbr, uint8_t k0, uint8_t k2, uint8_t bs_alter_scale);
uint8_t master_frequency_table(sbr_info* sbr, uint8_t k0, uint8_t k2, uint8_t bs_freq_scale, uint8_t bs_alter_scale);
uint8_t derived_frequency_table(sbr_info* sbr, uint8_t bs_xover_band, uint8_t k2);
void limiter_frequency_table(sbr_info* sbr);
#ifdef SBR_DEC
#ifdef SBR_LOW_POWER
void calc_prediction_coef_lp(sbr_info* sbr, qmf_t Xlow[MAX_NTSRHFG][64], complex_t* alpha_0, complex_t* alpha_1, real_t* rxx);
void calc_aliasing_degree(sbr_info* sbr, real_t* rxx, real_t* deg);
#else // SBR_LOW_POWER
void calc_prediction_coef(sbr_info* sbr, qmf_t Xlow[MAX_NTSRHFG][64], complex_t* alpha_0, complex_t* alpha_1, uint8_t k);
#endif // SBR_LOW_POWER
void calc_chirp_factors(sbr_info* sbr, uint8_t ch);
void patch_construction(sbr_info* sbr);
#endif // SBR_DEC
#ifdef SBR_DEC
uint8_t estimate_current_envelope(sbr_info* sbr, sbr_hfadj_info* adj, qmf_t Xsbr[MAX_NTSRHFG][64], uint8_t ch);
void calculate_gain(sbr_info* sbr, sbr_hfadj_info* adj, uint8_t ch);
#ifdef SBR_LOW_POWER
void calc_gain_groups(sbr_info* sbr, sbr_hfadj_info* adj, real_t* deg, uint8_t ch);
void aliasing_reduction(sbr_info* sbr, sbr_hfadj_info* adj, real_t* deg, uint8_t ch);
#endif // SBR_LOW_POWER
void hf_assembly(sbr_info* sbr, sbr_hfadj_info* adj, qmf_t Xsbr[MAX_NTSRHFG][64], uint8_t ch);
#endif // SBR_DEC
uint8_t get_S_mapped(sbr_info* sbr, uint8_t ch, uint8_t l, uint8_t current_band);
qmfa_info* qmfa_init(uint8_t channels);
void qmfa_end(qmfa_info* qmfa);
qmfs_info* qmfs_init(uint8_t channels);
void qmfs_end(qmfs_info* qmfs);
void sbr_qmf_analysis_32(sbr_info* sbr, qmfa_info* qmfa, const real_t* input, qmf_t X[MAX_NTSRHFG][64], uint8_t offset, uint8_t kx);
void sbr_qmf_synthesis_32(sbr_info* sbr, qmfs_info* qmfs, qmf_t X[MAX_NTSRHFG][64], real_t* output);
void sbr_qmf_synthesis_64(sbr_info* sbr, qmfs_info* qmfs, qmf_t X[MAX_NTSRHFG][64], real_t* output);
uint8_t envelope_time_border_vector(sbr_info *sbr, uint8_t ch);
void noise_floor_time_border_vector(sbr_info *sbr, uint8_t ch);
void hf_generation(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64], qmf_t Xhigh[MAX_NTSRHFG][64], real_t *deg, uint8_t ch);
void sbr_envelope(bitfile *ld, sbr_info *sbr, uint8_t ch);
void sbr_noise(bitfile *ld, sbr_info *sbr, uint8_t ch);
uint8_t middleBorder(sbr_info* sbr, uint8_t ch);
#ifdef SSR_DEC
static real_t **pp_q0, **pp_t0, **pp_t1;
void ssr_ipqf(ssr_info* ssr, real_t* in_data, real_t* out_data, real_t buffer[SSR_BANDS][96 / 4], uint16_t frame_len, uint8_t bands);
#endif

View File

@ -0,0 +1,645 @@
/*
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
** Any non-GPL usage of this software or parts of this software is strictly
** forbidden.
**
** The "appropriate copyright message" mentioned in section 2c of the GPLv2
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
**
** Commercial non-GPL licensing of this software is possible.
** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
**
** $Id: structs.h,v 1.49 2009/01/26 23:51:15 menno Exp $
**/
#pragma once
#include "neaacdec.h"
#define MAX_CHANNELS 64
#define MAX_SYNTAX_ELEMENTS 48
#define MAX_WINDOW_GROUPS 8
#define MAX_SFB 51
#define MAX_LTP_SFB 40
#define MAX_LTP_SFB_S 8
#define MAX_ASC_BYTES 64
/* used to save the prediction state */
typedef struct {
uint16_t n;
uint16_t ifac[15];
complex_t* work;
complex_t* tab;
} cfft_info;
typedef struct {
int16_t r[2];
int16_t COR[2];
int16_t VAR[2];
} pred_state;
typedef struct {
uint16_t N;
cfft_info* cfft;
complex_t* sincos;
int64_t cycles;
int64_t fft_cycles;
} mdct_info;
typedef struct {
const real_t* long_window[2];
const real_t* short_window[2];
const real_t* ld_window[2];
mdct_info* mdct256;
mdct_info* mdct1024;
mdct_info* mdct2048;
int64_t cycles;
} fb_info;
typedef struct {
uint8_t present;
uint8_t num_bands;
uint8_t pce_instance_tag;
uint8_t excluded_chns_present;
uint8_t band_top[17];
uint8_t prog_ref_level;
uint8_t dyn_rng_sgn[17];
uint8_t dyn_rng_ctl[17];
uint8_t exclude_mask[MAX_CHANNELS];
uint8_t additional_excluded_chns[MAX_CHANNELS];
real_t ctrl1;
real_t ctrl2;
} drc_info;
typedef struct {
uint8_t element_instance_tag;
uint8_t object_type;
uint8_t sf_index;
uint8_t num_front_channel_elements;
uint8_t num_side_channel_elements;
uint8_t num_back_channel_elements;
uint8_t num_lfe_channel_elements;
uint8_t num_assoc_data_elements;
uint8_t num_valid_cc_elements;
uint8_t mono_mixdown_present;
uint8_t mono_mixdown_element_number;
uint8_t stereo_mixdown_present;
uint8_t stereo_mixdown_element_number;
uint8_t matrix_mixdown_idx_present;
uint8_t pseudo_surround_enable;
uint8_t matrix_mixdown_idx;
uint8_t front_element_is_cpe[16];
uint8_t front_element_tag_select[16];
uint8_t side_element_is_cpe[16];
uint8_t side_element_tag_select[16];
uint8_t back_element_is_cpe[16];
uint8_t back_element_tag_select[16];
uint8_t lfe_element_tag_select[16];
uint8_t assoc_data_element_tag_select[16];
uint8_t cc_element_is_ind_sw[16];
uint8_t valid_cc_element_tag_select[16];
uint8_t channels;
uint8_t comment_field_bytes;
uint8_t comment_field_data[257];
uint8_t num_front_channels; /* extra added values */
uint8_t num_side_channels;
uint8_t num_back_channels;
uint8_t num_lfe_channels;
uint8_t sce_channel[16];
uint8_t cpe_channel[16];
} program_config;
typedef struct {
uint16_t syncword;
uint8_t id;
uint8_t layer;
uint8_t protection_absent;
uint8_t profile;
uint8_t sf_index;
uint8_t private_bit;
uint8_t channel_configuration;
uint8_t original;
uint8_t home;
uint8_t emphasis;
uint8_t copyright_identification_bit;
uint8_t copyright_identification_start;
uint16_t aac_frame_length;
uint16_t adts_buffer_fullness;
uint8_t no_raw_data_blocks_in_frame;
uint16_t crc_check;
uint8_t old_format;/* control param */
} adts_header;
typedef struct {
uint8_t copyright_id_present;
int8_t copyright_id[10];
uint8_t original_copy;
uint8_t home;
uint8_t bitstream_type;
uint32_t bitrate;
uint8_t num_program_config_elements;
uint32_t adif_buffer_fullness;
/* maximum of 16 PCEs */
program_config pce[16];
} adif_header;
typedef struct {
uint8_t last_band;
uint8_t data_present;
uint16_t lag;
uint8_t lag_update;
uint8_t coef;
uint8_t long_used[MAX_SFB];
uint8_t short_used[8];
uint8_t short_lag_present[8];
uint8_t short_lag[8];
} ltp_info;
typedef struct {
uint8_t limit;
uint8_t predictor_reset;
uint8_t predictor_reset_group_number;
uint8_t prediction_used[MAX_SFB];
} pred_info;
typedef struct {
uint8_t number_pulse;
uint8_t pulse_start_sfb;
uint8_t pulse_offset[4];
uint8_t pulse_amp[4];
} pulse_info;
typedef struct {
uint8_t n_filt[8];
uint8_t coef_res[8];
uint8_t length[8][4];
uint8_t order[8][4];
uint8_t direction[8][4];
uint8_t coef_compress[8][4];
uint8_t coef[8][4][32];
} tns_info;
typedef struct {
uint8_t max_band;
uint8_t adjust_num[4][8];
uint8_t alevcode[4][8][8];
uint8_t aloccode[4][8][8];
} ssr_info;
typedef struct {
uint8_t max_sfb;
uint8_t num_swb;
uint8_t num_window_groups;
uint8_t num_windows;
uint8_t window_sequence;
uint8_t window_group_length[8];
uint8_t window_shape;
uint8_t scale_factor_grouping;
uint16_t sect_sfb_offset[8][15 * 8];
uint16_t swb_offset[52];
uint16_t swb_offset_max;
uint8_t sect_cb[8][15 * 8];
uint16_t sect_start[8][15 * 8];
uint16_t sect_end[8][15 * 8];
uint8_t sfb_cb[8][8 * 15];
uint8_t num_sec[8]; /* number of sections in a group */
uint8_t global_gain;
int16_t scale_factors[8][51]; /* [0..255] */
uint8_t ms_mask_present;
uint8_t ms_used[MAX_WINDOW_GROUPS][MAX_SFB];
uint8_t noise_used;
uint8_t is_used;
uint8_t pulse_data_present;
uint8_t tns_data_present;
uint8_t gain_control_data_present;
uint8_t predictor_data_present;
pulse_info pul;
tns_info tns;
pred_info pred;
ltp_info ltp;
ltp_info ltp2;
ssr_info ssr;
uint16_t length_of_reordered_spectral_data; /* ER HCR data */
uint8_t length_of_longest_codeword;
uint8_t sf_concealment;/* ER RLVC data */
uint8_t rev_global_gain;
uint16_t length_of_rvlc_sf;
uint16_t dpcm_noise_nrg;
uint8_t sf_escapes_present;
uint8_t length_of_rvlc_escapes;
uint16_t dpcm_noise_last_position;
} ic_stream; /* individual channel stream */
typedef struct {
uint8_t channel;
int16_t paired_channel;
uint8_t element_instance_tag;
uint8_t common_window;
ic_stream ics1;
ic_stream ics2;
} element; /* syntax element (SCE, CPE, LFE) */
typedef struct {
int inited;
int version, versionA;
int framelen_type;
int useSameStreamMux;
int allStreamsSameTimeFraming;
int numSubFrames;
int numPrograms;
int numLayers;
int otherDataPresent;
uint32_t otherDataLenBits;
uint32_t frameLength;
uint8_t ASC[MAX_ASC_BYTES];
uint32_t ASCbits;
} latm_header;
typedef struct NeAACDecConfiguration
{
unsigned char defObjectType;
unsigned long defSampleRate;
unsigned char outputFormat;
unsigned char downMatrix;
unsigned char useOldADTSFormat;
unsigned char dontUpSampleImplicitSBR;
} NeAACDecConfiguration, *NeAACDecConfigurationPtr;
typedef struct
{
uint8_t drm_ps_data_available;
uint8_t bs_enable_sa;
uint8_t bs_enable_pan;
uint8_t bs_sa_dt_flag;
uint8_t bs_pan_dt_flag;
uint8_t g_last_had_sa;
uint8_t g_last_had_pan;
int8_t bs_sa_data[DRM_NUM_SA_BANDS];
int8_t bs_pan_data[DRM_NUM_PAN_BANDS];
int8_t g_sa_index[DRM_NUM_SA_BANDS];
int8_t g_pan_index[DRM_NUM_PAN_BANDS];
int8_t g_prev_sa_index[DRM_NUM_SA_BANDS];
int8_t g_prev_pan_index[DRM_NUM_PAN_BANDS];
int8_t sa_decode_error;
int8_t pan_decode_error;
int8_t g_last_good_sa_index[DRM_NUM_SA_BANDS];
int8_t g_last_good_pan_index[DRM_NUM_PAN_BANDS];
qmf_t SA[NUM_OF_SUBSAMPLES][MAX_SA_BAND];
complex_t d_buff[2][MAX_SA_BAND];
complex_t d2_buff[NUM_OF_LINKS][MAX_DELAY][MAX_SA_BAND];
uint8_t delay_buf_index_ser[NUM_OF_LINKS];
real_t prev_nrg[MAX_SA_BAND];
real_t prev_peakdiff[MAX_SA_BAND];
real_t peakdecay_fast[MAX_SA_BAND];
} drm_ps_info;
typedef struct
{
/* bitstream parameters */
uint8_t enable_iid;
uint8_t enable_icc;
uint8_t enable_ext;
uint8_t iid_mode;
uint8_t icc_mode;
uint8_t nr_iid_par;
uint8_t nr_ipdopd_par;
uint8_t nr_icc_par;
uint8_t frame_class;
uint8_t num_env;
uint8_t border_position[MAX_PS_ENVELOPES+1];
uint8_t iid_dt[MAX_PS_ENVELOPES];
uint8_t icc_dt[MAX_PS_ENVELOPES];
uint8_t enable_ipdopd;
uint8_t ipd_mode;
uint8_t ipd_dt[MAX_PS_ENVELOPES];
uint8_t opd_dt[MAX_PS_ENVELOPES];
/* indices */
int8_t iid_index_prev[34];
int8_t icc_index_prev[34];
int8_t ipd_index_prev[17];
int8_t opd_index_prev[17];
int8_t iid_index[MAX_PS_ENVELOPES][34];
int8_t icc_index[MAX_PS_ENVELOPES][34];
int8_t ipd_index[MAX_PS_ENVELOPES][17];
int8_t opd_index[MAX_PS_ENVELOPES][17];
int8_t ipd_index_1[17];
int8_t opd_index_1[17];
int8_t ipd_index_2[17];
int8_t opd_index_2[17];
/* ps data was correctly read */
uint8_t ps_data_available;
/* a header has been read */
uint8_t header_read;
/* hybrid filterbank parameters */
void *hyb;
uint8_t use34hybrid_bands;
uint8_t numTimeSlotsRate;
/**/
uint8_t num_groups;
uint8_t num_hybrid_groups;
uint8_t nr_par_bands;
uint8_t nr_allpass_bands;
uint8_t decay_cutoff;
uint8_t *group_border;
uint16_t *map_group2bk;
/* filter delay handling */
uint8_t saved_delay;
uint8_t delay_buf_index_ser[NO_ALLPASS_LINKS];
uint8_t num_sample_delay_ser[NO_ALLPASS_LINKS];
uint8_t delay_D[64];
uint8_t delay_buf_index_delay[64];
complex_t delay_Qmf[14][64]; /* 14 samples delay max, 64 QMF channels */
complex_t delay_SubQmf[2][32]; /* 2 samples delay max (SubQmf is always allpass filtered) */
complex_t delay_Qmf_ser[NO_ALLPASS_LINKS][5][64]; /* 5 samples delay max (table 8.34), 64 QMF channels */
complex_t delay_SubQmf_ser[NO_ALLPASS_LINKS][5][32]; /* 5 samples delay max (table 8.34) */
/* transients */
real_t alpha_decay;
real_t alpha_smooth;
real_t P_PeakDecayNrg[34];
real_t P_prev[34];
real_t P_SmoothPeakDecayDiffNrg_prev[34];
/* mixing and phase */
complex_t h11_prev[50];
complex_t h12_prev[50];
complex_t h21_prev[50];
complex_t h22_prev[50];
uint8_t phase_hist;
complex_t ipd_prev[20][2];
complex_t opd_prev[20][2];
} ps_info;
typedef struct {
real_t *x;
int16_t x_index;
uint8_t channels;
} qmfa_info;
typedef struct {
real_t *v;
int16_t v_index;
uint8_t channels;
} qmfs_info;
typedef struct{
uint32_t sample_rate;
uint32_t maxAACLine;
uint8_t rate;
uint8_t just_seeked;
uint8_t ret;
uint8_t amp_res[2];
uint8_t k0;
uint8_t kx;
uint8_t M;
uint8_t N_master;
uint8_t N_high;
uint8_t N_low;
uint8_t N_Q;
uint8_t N_L[4];
uint8_t n[2];
uint8_t f_master[64];
uint8_t f_table_res[2][64];
uint8_t f_table_noise[64];
uint8_t f_table_lim[4][64];
uint8_t f_group[5][64];
uint8_t N_G[5];
uint8_t table_map_k_to_g[64];
uint8_t abs_bord_lead[2];
uint8_t abs_bord_trail[2];
uint8_t n_rel_lead[2];
uint8_t n_rel_trail[2];
uint8_t L_E[2];
uint8_t L_E_prev[2];
uint8_t L_Q[2];
uint8_t t_E[2][MAX_L_E+1];
uint8_t t_Q[2][3];
uint8_t f[2][MAX_L_E+1];
uint8_t f_prev[2];
real_t *G_temp_prev[2][5];
real_t *Q_temp_prev[2][5];
int8_t GQ_ringbuf_index[2];
int16_t E[2][64][MAX_L_E];
int16_t E_prev[2][64];
real_t E_orig[2][64][MAX_L_E];
real_t E_curr[2][64][MAX_L_E];
int32_t Q[2][64][2];
real_t Q_div[2][64][2];
real_t Q_div2[2][64][2];
int32_t Q_prev[2][64];
int8_t l_A[2];
int8_t l_A_prev[2];
uint8_t bs_invf_mode[2][MAX_L_E];
uint8_t bs_invf_mode_prev[2][MAX_L_E];
real_t bwArray[2][64];
real_t bwArray_prev[2][64];
uint8_t noPatches;
uint8_t patchNoSubbands[64];
uint8_t patchStartSubband[64];
uint8_t bs_add_harmonic[2][64];
uint8_t bs_add_harmonic_prev[2][64];
uint16_t index_noise_prev[2];
uint8_t psi_is_prev[2];
uint8_t bs_start_freq_prev;
uint8_t bs_stop_freq_prev;
uint8_t bs_xover_band_prev;
uint8_t bs_freq_scale_prev;
uint8_t bs_alter_scale_prev;
uint8_t bs_noise_bands_prev;
int8_t prevEnvIsShort[2];
int8_t kx_prev;
uint8_t bsco;
uint8_t bsco_prev;
uint8_t M_prev;
uint16_t frame_len;
uint8_t Reset;
uint32_t frame;
uint32_t header_count;
uint8_t id_aac;
qmfa_info *qmfa[2];
qmfs_info *qmfs[2];
qmf_t Xsbr[2][MAX_NTSRHFG][64];
uint8_t Is_DRM_SBR;
drm_ps_info *drm_ps;
uint8_t numTimeSlotsRate;
uint8_t numTimeSlots;
uint8_t tHFGen;
uint8_t tHFAdj;
ps_info *ps;
uint8_t ps_used;
uint8_t psResetFlag;
/* to get it compiling */
/* we'll see during the coding of all the tools, whether
these are all used or not.
*/
uint8_t bs_header_flag;
uint8_t bs_crc_flag;
uint16_t bs_sbr_crc_bits;
uint8_t bs_protocol_version;
uint8_t bs_amp_res;
uint8_t bs_start_freq;
uint8_t bs_stop_freq;
uint8_t bs_xover_band;
uint8_t bs_freq_scale;
uint8_t bs_alter_scale;
uint8_t bs_noise_bands;
uint8_t bs_limiter_bands;
uint8_t bs_limiter_gains;
uint8_t bs_interpol_freq;
uint8_t bs_smoothing_mode;
uint8_t bs_samplerate_mode;
uint8_t bs_add_harmonic_flag[2];
uint8_t bs_add_harmonic_flag_prev[2];
uint8_t bs_extended_data;
uint8_t bs_extension_id;
uint8_t bs_extension_data;
uint8_t bs_coupling;
uint8_t bs_frame_class[2];
uint8_t bs_rel_bord[2][9];
uint8_t bs_rel_bord_0[2][9];
uint8_t bs_rel_bord_1[2][9];
uint8_t bs_pointer[2];
uint8_t bs_abs_bord_0[2];
uint8_t bs_abs_bord_1[2];
uint8_t bs_num_rel_0[2];
uint8_t bs_num_rel_1[2];
uint8_t bs_df_env[2][9];
uint8_t bs_df_noise[2][3];
} sbr_info;
typedef struct {
uint8_t adts_header_present;
uint8_t adif_header_present;
uint8_t latm_header_present;
uint8_t sf_index;
uint8_t object_type;
uint8_t channelConfiguration;
uint8_t aacSectionDataResilienceFlag;
uint8_t aacScalefactorDataResilienceFlag;
uint8_t aacSpectralDataResilienceFlag;
uint16_t frameLength;
uint8_t postSeekResetFlag;
uint32_t frame;
uint8_t downMatrix;
uint8_t upMatrix;
uint8_t first_syn_ele;
uint8_t has_lfe;
uint8_t fr_channels; /* number of channels in current frame */
uint8_t fr_ch_ele; /* number of elements in current frame */
uint8_t element_output_channels[MAX_SYNTAX_ELEMENTS]; /* element_output_channels: determines the number of channels the element will output */
uint8_t element_alloced[MAX_SYNTAX_ELEMENTS];/* element_alloced:determines whether the data needed for the element is allocated or not*/
uint8_t alloced_channels; /* alloced_channels: determines the number of channels where output data is allocated for*/
void* sample_buffer; /* output data buffer */
uint8_t window_shape_prev[MAX_CHANNELS];
uint16_t ltp_lag[MAX_CHANNELS];
fb_info* fb;
drc_info* drc;
real_t* time_out[MAX_CHANNELS];
real_t* fb_intermed[MAX_CHANNELS];
int8_t sbr_present_flag;
int8_t forceUpSampling;
int8_t downSampledSBR;
uint8_t sbr_alloced[MAX_SYNTAX_ELEMENTS]; /* determines whether SBR data is allocated for the gives element */
sbr_info* sbr[MAX_SYNTAX_ELEMENTS];
uint8_t ps_used[MAX_SYNTAX_ELEMENTS];
uint8_t ps_used_global;
real_t* ssr_overlap[MAX_CHANNELS];
real_t* prev_fmd[MAX_CHANNELS];
real_t ipqf_buffer[MAX_CHANNELS][4][96 / 4];
pred_state* pred_stat[MAX_CHANNELS];
int16_t* lt_pred_stat[MAX_CHANNELS];
uint8_t error_state;
uint32_t __r1; /* RNG states */
uint32_t __r2;
uint8_t pce_set;/* Program Config Element */
program_config pce;
uint8_t element_id[MAX_CHANNELS];
uint8_t internal_channel[MAX_CHANNELS];
NeAACDecConfiguration config; /* Configuration data */
int64_t cycles;
int64_t spectral_cycles;
int64_t output_cycles;
int64_t scalefac_cycles;
int64_t requant_cycles;
latm_header latm_config;
const unsigned char* cmes;
uint8_t isPS;
} NeAACDecStruct;
/* 1st step table */
typedef struct {
uint8_t offset;
uint8_t extra_bits;
} hcb;
/* 2nd step table with quadruple data */
typedef struct {
uint8_t bits;
int8_t x;
int8_t y;
} hcb_2_pair;
typedef struct {
uint8_t bits;
int8_t x;
int8_t y;
int8_t v;
int8_t w;
} hcb_2_quad;
/* binary search table */
typedef struct {
uint8_t is_leaf;
int8_t data[4];
} hcb_bin_quad;
typedef struct {
uint8_t is_leaf;
int8_t data[2];
} hcb_bin_pair;
typedef struct _bitfile {
/* bit input */
uint32_t bufa;
uint32_t bufb;
uint32_t bits_left;
uint32_t buffer_size; /* size of the buffer in bytes */
uint32_t bytes_left;
uint8_t error;
uint32_t* tail;
uint32_t* start;
const void* buffer;
} bitfile;
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
#ifdef ERROR_RESILIENCE
/* Modified bit reading functions for HCR */
#endif /*ERROR_RESILIENCE*/
typedef struct {
/* bit input */
uint32_t bufa;
uint32_t bufb;
int8_t len;
} bits_t;
typedef struct {
uint8_t cb;
uint8_t decoded;
uint16_t sp_offset;
bits_t bits;
} codeword_t;
typedef struct
{
int8_t index;
uint8_t len;
uint32_t cw;
} rvlc_huff_table;
// ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
#ifdef PS_DEC
/* type definitions */
typedef struct {
uint8_t frame_len;
uint8_t resolution20[3];
uint8_t resolution34[5];
qmf_t* work;
qmf_t** buffer;
qmf_t** temp;
} hyb_info;
#endif // PS_DEC
typedef struct {
real_t G_lim_boost[MAX_L_E][MAX_M];
real_t Q_M_lim_boost[MAX_L_E][MAX_M];
real_t S_M_boost[MAX_L_E][MAX_M];
} sbr_hfadj_info;
// ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
#ifdef SBR_DEC
typedef struct {
complex_t r01;
complex_t r02;
complex_t r11;
complex_t r12;
complex_t r22;
real_t det;
} acorr_coef;
#endif // SBR_DEC

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More