adafruit-circuitpython-ogg 1.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,189 @@
1
+ Metadata-Version: 2.4
2
+ Name: adafruit-circuitpython-ogg
3
+ Version: 1.0.1
4
+ Summary: Ogg Vorbis decoder and player for CircuitPython, with prebuilt C and turbo (viper) kernels
5
+ Author-email: Adafruit Industries <circuitpython@adafruit.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/adafruit/Adafruit_CircuitPython_OGG
8
+ Keywords: adafruit,blinka,circuitpython,micropython,ogg,vorbis,audio,decoder,music,player
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Topic :: Software Development :: Libraries
11
+ Classifier: Topic :: Software Development :: Embedded Systems
12
+ Classifier: Topic :: System :: Hardware
13
+ Classifier: Programming Language :: Python :: 3
14
+ Description-Content-Type: text/x-rst
15
+ License-File: LICENSE
16
+ Requires-Dist: Adafruit-Blinka
17
+ Provides-Extra: optional
18
+ Dynamic: license-file
19
+
20
+ Introduction
21
+ ============
22
+
23
+
24
+ .. image:: https://readthedocs.org/projects/adafruit-circuitpython-ogg/badge/?version=latest
25
+ :target: https://docs.circuitpython.org/projects/ogg/en/latest/
26
+ :alt: Documentation Status
27
+
28
+
29
+ .. image:: https://raw.githubusercontent.com/adafruit/Adafruit_CircuitPython_Bundle/main/badges/adafruit_discord.svg
30
+ :target: https://adafru.it/discord
31
+ :alt: Discord
32
+
33
+
34
+ .. image:: https://github.com/adafruit/Adafruit_CircuitPython_OGG/workflows/Build%20CI/badge.svg
35
+ :target: https://github.com/adafruit/Adafruit_CircuitPython_OGG/actions
36
+ :alt: Build Status
37
+
38
+
39
+ .. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
40
+ :target: https://github.com/astral-sh/ruff
41
+ :alt: Code Style: Ruff
42
+
43
+ Play Ogg Vorbis files on CircuitPython. ``OggDecoder`` decodes Ogg Vorbis audio to 16-bit PCM,
44
+ and ``OggPlayer`` streams it to an ``I2SOut``, ``PWMAudioOut`` or ``AudioOut`` while your code
45
+ keeps running. On an RP2350 it plays 44.1 kHz stereo files at the stock 150 MHz with about a
46
+ quarter of the CPU.
47
+
48
+ The decoder is written from the Xiph.Org Vorbis I specification. No third-party decoder code is
49
+ included. The audio decode runs in a prebuilt kernel for each chip architecture, in fixed
50
+ point, and stays within a few LSB of ffmpeg's floating point decode.
51
+
52
+
53
+ Dependencies
54
+ =============
55
+ This library depends on:
56
+
57
+ * `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_ 11 or later, on a board
58
+ that can load native ``.mpy`` files (``microcontroller.cpu.architecture`` is not ``None``)
59
+
60
+ The decoding loops are a precompiled kernel, one file per architecture. Arm and Xtensa (ESP32)
61
+ chips use a C build of the kernel, ``ogg_native``; RISC-V chips use a turbo (``@micropython.viper``) build,
62
+ ``ogg_kernel``. Both have the same functions and give the same output to within an LSB.
63
+
64
+ ================= ========================= ======================================
65
+ Architecture Kernel Boards
66
+ ================= ========================= ======================================
67
+ ``armv6m`` ``ogg_native`` (C) RP2040
68
+ ``armv7emsp`` ``ogg_native`` (C) SAMD51 (M4), nRF52840, RP2350, STM32F4
69
+ ``xtensawin`` ``ogg_native`` (C) ESP32, ESP32-S2, ESP32-S3
70
+ ``rv32imc`` ``ogg_kernel`` (turbo) ESP32-C3, C5, C6
71
+ ================= ========================= ======================================
72
+
73
+ ``ogg_kernel`` is also built for the Arm and Xtensa architectures, as a fallback. Without a
74
+ kernel the decoder falls back to plain Python, which is correct but far slower than real time
75
+ for music. Playback has been tested on the RP2350 and the ESP32-S3.
76
+
77
+ Please ensure all dependencies are available on the CircuitPython filesystem.
78
+ This is easily achieved by downloading
79
+ `the Adafruit library and driver bundle <https://circuitpython.org/libraries>`_
80
+ or individual libraries can be installed using
81
+ `circup <https://github.com/adafruit/circup>`_.
82
+
83
+ Installing to a Connected CircuitPython Device with Circup
84
+ ==========================================================
85
+
86
+ Make sure that you have ``circup`` installed in your Python environment.
87
+ Install it with the following command if necessary:
88
+
89
+ .. code-block:: shell
90
+
91
+ pip3 install circup
92
+
93
+ With ``circup`` installed and your CircuitPython device connected use the
94
+ following command to install:
95
+
96
+ .. code-block:: shell
97
+
98
+ circup install adafruit_ogg
99
+
100
+ Or the following command to update an existing version:
101
+
102
+ .. code-block:: shell
103
+
104
+ circup update
105
+
106
+ Usage Example
107
+ =============
108
+
109
+ .. code-block:: python
110
+
111
+ import adafruit_ogg
112
+ from adafruit_fruitjam.peripherals import Peripherals
113
+
114
+ decoder = adafruit_ogg.OggDecoder("song.ogg")
115
+ fruit_jam = Peripherals(audio_output="headphone", sample_rate=decoder.sample_rate)
116
+
117
+ player = adafruit_ogg.OggPlayer(fruit_jam.audio)
118
+ player.play(decoder)
119
+ while player.playing:
120
+ player.update() # decode the next piece; call this often while playing
121
+
122
+ ``decoder.comments`` holds the file's tags (``TITLE``, ``ARTIST`` and so on), and
123
+ ``decoder.open(path)`` switches to another file, reusing the buffers.
124
+
125
+ Speed and memory
126
+ ================
127
+
128
+ Measured on an Adafruit Fruit Jam (RP2350B) at 150 MHz. Load is decode time divided by audio
129
+ time; under 100% keeps up.
130
+
131
+ ========================= ====== =================
132
+ Format Load Opening a file
133
+ ========================= ====== =================
134
+ 44.1 kHz stereo 24% 0.5 s
135
+ 22.05 kHz mono 8% 0.5 s
136
+ 11.025 kHz mono 5% 0.3 s
137
+ ========================= ====== =================
138
+
139
+ - The decoder needs about 100 KB (11 kHz mono) to 175 KB (48 kHz stereo), most of it codebook
140
+ tables, which depend on the file.
141
+ - Keep the decoder in internal SRAM. On the RP2350, with its buffers in PSRAM it decodes about
142
+ four times slower (93% load at 44.1 kHz stereo). Create it first in ``code.py``, before other
143
+ large allocations such as ``Peripherals``, and reuse it with ``decoder.open()``.
144
+ - ``OggPlayer`` decodes straight into the half of its buffer that the audio DMA has already
145
+ copied, so it does not work with ``audiomixer``, which reads the buffer in place.
146
+ - Opening a file parses its codebooks, which takes a fraction of a second. Let the player
147
+ finish or stop it before opening the next file.
148
+
149
+ Building the kernels
150
+ ====================
151
+
152
+ ``src/ogg_turbo.py`` is the turbo kernel (``@micropython.viper`` functions) and
153
+ ``src/native/ogg_native.c`` the same functions in C. ``src/Makefile`` compiles the turbo kernel
154
+ with ``mpy-cross -march`` for each architecture into ``adafruit_ogg/ogg_kernel.<arch>.mpy``;
155
+ ``src/native/Makefile`` builds the C kernel with the CircuitPython native module tools
156
+ (``py/dynruntime.mk``, needs ``arm-none-eabi-gcc``, ``xtensa-esp32-elf-gcc`` from the
157
+ ESP-IDF tools, and ``pyelftools``) into
158
+ ``adafruit_ogg/ogg_native.<arch>.mpy``:
159
+
160
+ .. code-block:: shell
161
+
162
+ make -C src MPY_CROSS=path/to/circuitpython/mpy-cross/build/mpy-cross
163
+ make -C src/native MPY_DIR=path/to/circuitpython all-arches
164
+
165
+ Use the CircuitPython version the files will run on.
166
+
167
+ Testing
168
+ =======
169
+
170
+ ``tools/make_test_media.py`` downloads public domain and CC0 recordings from Wikimedia Commons
171
+ and makes smaller versions (it needs ``ffmpeg`` and the ``soundfile`` package).
172
+ ``tests/test_decoder.py`` decodes them with the kernel, run under CPython by a model that fails
173
+ on any 32-bit overflow, and with the plain Python decoder, and compares both with ffmpeg.
174
+ ``tests/test_codebook.py`` and ``tests/test_ogg_reader.py`` need no media.
175
+ ``tools/kernel_check.py`` compares the C and turbo kernels on a board and times them.
176
+
177
+ Documentation
178
+ =============
179
+ API documentation for this library can be found on `Read the Docs <https://docs.circuitpython.org/projects/ogg/en/latest/>`_.
180
+
181
+ For information on building library documentation, please check out
182
+ `this guide <https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/sharing-our-docs-on-readthedocs#sphinx-5-1>`_.
183
+
184
+ Contributing
185
+ ============
186
+
187
+ Contributions are welcome! Please read our `Code of Conduct
188
+ <https://github.com/adafruit/Adafruit_CircuitPython_OGG/blob/HEAD/CODE_OF_CONDUCT.md>`_
189
+ before contributing to help this project stay welcoming.
@@ -0,0 +1,21 @@
1
+ adafruit_circuitpython_ogg-1.0.1.dist-info/licenses/LICENSE,sha256=bQxQlJZdQnI0BAF8SlSIVnkOuhemp1xqC5_RPHvHKIo,1102
2
+ adafruit_ogg/__init__.py,sha256=3RV4EwbaNXautCxwSpryOTBhmHXQ4Nv_WIwx4P28n2w,61733
3
+ adafruit_ogg/_float.py,sha256=WB3uPedrRpldWd90ayFmP7SmkxiGDeCBl_s8sAXZT4g,9241
4
+ adafruit_ogg/ogg_kernel.armv6m.mpy,sha256=pkZPqUIxA8Ke4OwncK9eQpmAQ--BuuACuHHoC-7N6ds,18391
5
+ adafruit_ogg/ogg_kernel.armv6m.mpy.license,sha256=x0CNJztITfJuEPiEy7vRw-7YoXKz7ozBkRLjFbm995Q,114
6
+ adafruit_ogg/ogg_kernel.armv7emsp.mpy,sha256=wx-JcD7VHjm_H_1tQMK4HAoUkWKg0MtxpMkjd388jkE,16431
7
+ adafruit_ogg/ogg_kernel.armv7emsp.mpy.license,sha256=x0CNJztITfJuEPiEy7vRw-7YoXKz7ozBkRLjFbm995Q,114
8
+ adafruit_ogg/ogg_kernel.rv32imc.mpy,sha256=Y08Er6hIR0rpp8rb9wUKfPzrBfH_oAeFeW-HzhRTJSY,19530
9
+ adafruit_ogg/ogg_kernel.rv32imc.mpy.license,sha256=x0CNJztITfJuEPiEy7vRw-7YoXKz7ozBkRLjFbm995Q,114
10
+ adafruit_ogg/ogg_kernel.xtensawin.mpy,sha256=MrdP6Z58K98Q2rtuvxKaQ9tvfNF4BDoja2TxE8JXs2Y,20402
11
+ adafruit_ogg/ogg_kernel.xtensawin.mpy.license,sha256=x0CNJztITfJuEPiEy7vRw-7YoXKz7ozBkRLjFbm995Q,114
12
+ adafruit_ogg/ogg_native.armv6m.mpy,sha256=ZEHqLndm31IKxvrLjQX_9i-oZHt6cjY1Ji0GdQ2ncZA,7301
13
+ adafruit_ogg/ogg_native.armv6m.mpy.license,sha256=x0CNJztITfJuEPiEy7vRw-7YoXKz7ozBkRLjFbm995Q,114
14
+ adafruit_ogg/ogg_native.armv7emsp.mpy,sha256=aZSGKZuSRHnaKmx_usiLowQINdzxAZLn9oNy06isEcg,6093
15
+ adafruit_ogg/ogg_native.armv7emsp.mpy.license,sha256=x0CNJztITfJuEPiEy7vRw-7YoXKz7ozBkRLjFbm995Q,114
16
+ adafruit_ogg/ogg_native.xtensawin.mpy,sha256=qXcT5rYMzz1j98TFYSBFUPT5Sy9pQ1zhUBEshE7bWeI,6324
17
+ adafruit_ogg/ogg_native.xtensawin.mpy.license,sha256=x0CNJztITfJuEPiEy7vRw-7YoXKz7ozBkRLjFbm995Q,114
18
+ adafruit_circuitpython_ogg-1.0.1.dist-info/METADATA,sha256=wet5d70qWNF5rhYJiGBqCKArAnMO9TSDje0VWwfrmKE,8116
19
+ adafruit_circuitpython_ogg-1.0.1.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
20
+ adafruit_circuitpython_ogg-1.0.1.dist-info/top_level.txt,sha256=JOb9Ul3eFAa7fD4PyUu3k9Lk4quewh6KaByq44V_Bhc,13
21
+ adafruit_circuitpython_ogg-1.0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Mikey Sklar for Adafruit Industries
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ adafruit_ogg