summaryrefslogtreecommitdiff
path: root/shared-bindings
diff options
context:
space:
mode:
authorHierophect <hierophect@gmail.com>2020-01-08 17:11:50 -0500
committerHierophect <hierophect@gmail.com>2020-01-08 17:11:50 -0500
commitb74e78d2c049388f5cb17bf27cbef16379241f3d (patch)
tree2a7c1ce73d4e5287cbaf0a3f53ff326c351970c5 /shared-bindings
parentb778aee21d7facb8ced147086a2bc5225a319d80 (diff)
parenta10cd8580c3227f64cc0b0a7762f37732e31b91b (diff)
Merge remote-tracking branch 'upstream/master' into stm32-cpython-compat
Diffstat (limited to 'shared-bindings')
-rw-r--r--shared-bindings/_bleio/PacketBuffer.c201
-rw-r--r--shared-bindings/_bleio/PacketBuffer.h43
-rw-r--r--shared-bindings/_bleio/__init__.c5
-rw-r--r--shared-bindings/audiomp3/MP3Decoder.c (renamed from shared-bindings/audiomp3/MP3File.c)65
-rw-r--r--shared-bindings/audiomp3/MP3Decoder.h (renamed from shared-bindings/audiomp3/MP3File.h)4
-rw-r--r--shared-bindings/audiomp3/__init__.c6
6 files changed, 311 insertions, 13 deletions
diff --git a/shared-bindings/_bleio/PacketBuffer.c b/shared-bindings/_bleio/PacketBuffer.c
new file mode 100644
index 000000000..f9f171870
--- /dev/null
+++ b/shared-bindings/_bleio/PacketBuffer.c
@@ -0,0 +1,201 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", 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
+ * AUTHORS OR COPYRIGHT HOLDERS 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 "py/mperrno.h"
+#include "py/ioctl.h"
+#include "py/objproperty.h"
+#include "py/runtime.h"
+#include "py/stream.h"
+
+#include "shared-bindings/_bleio/__init__.h"
+#include "shared-bindings/_bleio/PacketBuffer.h"
+#include "shared-bindings/_bleio/UUID.h"
+#include "shared-bindings/util.h"
+
+//| .. currentmodule:: _bleio
+//|
+//| :class:`PacketBuffer` -- Packet-oriented characteristic usage.
+//| =====================================================================
+//|
+//| Accumulates a Characteristic's incoming packets in a FIFO buffer and facilitates packet aware
+//| outgoing writes. A packet's size is either the characteristic length or the maximum transmission
+//| unit (MTU), whichever is smaller. The MTU can change so check `packet_size` before creating a
+//| buffer to store data.
+//|
+//| When we're the server, we ignore all connections besides the first to subscribe to
+//| notifications.
+//|
+//| .. class:: PacketBuffer(characteristic, *, buffer_size)
+//|
+//| Monitor the given Characteristic. Each time a new value is written to the Characteristic
+//| add the newly-written bytes to a FIFO buffer.
+//|
+//| :param Characteristic characteristic: The Characteristic to monitor.
+//| It may be a local Characteristic provided by a Peripheral Service, or a remote Characteristic
+//| in a remote Service that a Central has connected to.
+//| :param int buffer_size: Size of ring buffer (in packets of the Characteristic's maximum
+//| length) that stores incoming packets coming from the peer.
+//|
+STATIC mp_obj_t bleio_packet_buffer_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
+ enum { ARG_characteristic, ARG_buffer_size };
+ static const mp_arg_t allowed_args[] = {
+ { MP_QSTR_characteristic, MP_ARG_REQUIRED | MP_ARG_OBJ },
+ { MP_QSTR_buffer_size, MP_ARG_KW_ONLY | MP_ARG_REQUIRED | MP_ARG_INT },
+ };
+
+ mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
+ mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
+
+ const mp_obj_t characteristic = args[ARG_characteristic].u_obj;
+
+ const int buffer_size = args[ARG_buffer_size].u_int;
+ if (buffer_size < 1) {
+ mp_raise_ValueError_varg(translate("%q must be >= 1"), MP_QSTR_buffer_size);
+ }
+
+ if (!MP_OBJ_IS_TYPE(characteristic, &bleio_characteristic_type)) {
+ mp_raise_TypeError(translate("Expected a Characteristic"));
+ }
+
+ bleio_packet_buffer_obj_t *self = m_new_obj(bleio_packet_buffer_obj_t);
+ self->base.type = &bleio_packet_buffer_type;
+
+ common_hal_bleio_packet_buffer_construct(self, MP_OBJ_TO_PTR(characteristic), buffer_size);
+
+ return MP_OBJ_FROM_PTR(self);
+}
+
+STATIC void check_for_deinit(bleio_packet_buffer_obj_t *self) {
+ if (common_hal_bleio_packet_buffer_deinited(self)) {
+ raise_deinited_error();
+ }
+}
+
+//| .. method:: readinto(buf)
+//|
+//| Reads a single BLE packet into the ``buf``. Raises an exception if the next packet is longer
+//| than the given buffer. Use `packet_size` to read the maximum length of a single packet.
+//|
+//| :return: number of bytes read and stored into ``buf``
+//| :rtype: int
+//|
+STATIC mp_obj_t bleio_packet_buffer_readinto(mp_obj_t self_in, mp_obj_t buffer_obj) {
+ bleio_packet_buffer_obj_t *self = MP_OBJ_TO_PTR(self_in);
+ check_for_deinit(self);
+
+ mp_buffer_info_t bufinfo;
+ mp_get_buffer_raise(buffer_obj, &bufinfo, MP_BUFFER_WRITE);
+
+ return MP_OBJ_NEW_SMALL_INT(common_hal_bleio_packet_buffer_readinto(self, bufinfo.buf, bufinfo.len));
+}
+STATIC MP_DEFINE_CONST_FUN_OBJ_2(bleio_packet_buffer_readinto_obj, bleio_packet_buffer_readinto);
+
+//| .. method:: write(data, *, header=None)
+//|
+//| Writes all bytes from data into the same outgoing packet. The bytes from header are included
+//| before data when the pending packet is currently empty.
+//|
+//| This does not block until the data is sent. It only blocks until the data is pending.
+//|
+// TODO: Add a kwarg `merge=False` to dictate whether subsequent writes are merged into a pending
+// one.
+STATIC mp_obj_t bleio_packet_buffer_write(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
+ enum { ARG_data, ARG_header };
+ static const mp_arg_t allowed_args[] = {
+ { MP_QSTR_data, MP_ARG_REQUIRED | MP_ARG_OBJ },
+ { MP_QSTR_header, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL}},
+ };
+
+ mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
+ mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
+
+ bleio_packet_buffer_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
+ check_for_deinit(self);
+
+ mp_buffer_info_t data_bufinfo;
+ mp_get_buffer_raise(args[ARG_data].u_obj, &data_bufinfo, MP_BUFFER_READ);
+
+ mp_buffer_info_t header_bufinfo;
+ header_bufinfo.len = 0;
+ if (args[ARG_header].u_obj != MP_OBJ_NULL) {
+ mp_get_buffer_raise(args[ARG_header].u_obj, &header_bufinfo, MP_BUFFER_READ);
+ }
+
+ common_hal_bleio_packet_buffer_write(self, data_bufinfo.buf, data_bufinfo.len,
+ header_bufinfo.buf, header_bufinfo.len);
+ return mp_const_none;
+}
+STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_packet_buffer_write_obj, 1, bleio_packet_buffer_write);
+
+//| .. method:: deinit()
+//|
+//| Disable permanently.
+//|
+STATIC mp_obj_t bleio_packet_buffer_deinit(mp_obj_t self_in) {
+ bleio_packet_buffer_obj_t *self = MP_OBJ_TO_PTR(self_in);
+ common_hal_bleio_packet_buffer_deinit(self);
+ return mp_const_none;
+}
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_packet_buffer_deinit_obj, bleio_packet_buffer_deinit);
+
+//| .. attribute:: packet_size
+//|
+//| Maximum size of each packet in bytes. This is the minimum of the Characterstic length and
+//| the negotiated Maximum Transfer Unit (MTU).
+//|
+STATIC mp_obj_t bleio_packet_buffer_get_packet_size(mp_obj_t self_in) {
+ bleio_packet_buffer_obj_t *self = MP_OBJ_TO_PTR(self_in);
+
+ return mp_obj_new_bool(common_hal_bleio_packet_buffer_get_packet_size(self));
+}
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_packet_buffer_get_packet_size_obj, bleio_packet_buffer_get_packet_size);
+
+const mp_obj_property_t bleio_packet_buffer_packet_size_obj = {
+ .base.type = &mp_type_property,
+ .proxy = { (mp_obj_t)&bleio_packet_buffer_get_packet_size_obj,
+ (mp_obj_t)&mp_const_none_obj,
+ (mp_obj_t)&mp_const_none_obj },
+};
+
+STATIC const mp_rom_map_elem_t bleio_packet_buffer_locals_dict_table[] = {
+ { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&bleio_packet_buffer_deinit_obj) },
+
+ // Standard stream methods.
+ { MP_OBJ_NEW_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&bleio_packet_buffer_readinto_obj) },
+ { MP_OBJ_NEW_QSTR(MP_QSTR_write), MP_ROM_PTR(&bleio_packet_buffer_write_obj) },
+
+ { MP_OBJ_NEW_QSTR(MP_QSTR_packet_size), MP_ROM_PTR(&bleio_packet_buffer_packet_size_obj) },
+};
+
+STATIC MP_DEFINE_CONST_DICT(bleio_packet_buffer_locals_dict, bleio_packet_buffer_locals_dict_table);
+
+
+const mp_obj_type_t bleio_packet_buffer_type = {
+ { &mp_type_type },
+ .name = MP_QSTR_PacketBuffer,
+ .make_new = bleio_packet_buffer_make_new,
+ .locals_dict = (mp_obj_dict_t*)&bleio_packet_buffer_locals_dict
+};
diff --git a/shared-bindings/_bleio/PacketBuffer.h b/shared-bindings/_bleio/PacketBuffer.h
new file mode 100644
index 000000000..990a2f8bb
--- /dev/null
+++ b/shared-bindings/_bleio/PacketBuffer.h
@@ -0,0 +1,43 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", 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
+ * AUTHORS OR COPYRIGHT HOLDERS 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.
+ */
+
+#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_PACKETBUFFER_H
+#define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_PACKETBUFFER_H
+
+#include "common-hal/_bleio/PacketBuffer.h"
+
+extern const mp_obj_type_t bleio_packet_buffer_type;
+
+extern void common_hal_bleio_packet_buffer_construct(
+ bleio_packet_buffer_obj_t *self, bleio_characteristic_obj_t *characteristic,
+ size_t buffer_size);
+void common_hal_bleio_packet_buffer_write(bleio_packet_buffer_obj_t *self, uint8_t *data, size_t len, uint8_t* header, size_t header_len);
+int common_hal_bleio_packet_buffer_readinto(bleio_packet_buffer_obj_t *self, uint8_t *data, size_t len);
+uint16_t common_hal_bleio_packet_buffer_get_packet_size(bleio_packet_buffer_obj_t *self);
+bool common_hal_bleio_packet_buffer_deinited(bleio_packet_buffer_obj_t *self);
+void common_hal_bleio_packet_buffer_deinit(bleio_packet_buffer_obj_t *self);
+
+#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_PACKETBUFFER_H
diff --git a/shared-bindings/_bleio/__init__.c b/shared-bindings/_bleio/__init__.c
index ba2454da4..5d26862a6 100644
--- a/shared-bindings/_bleio/__init__.c
+++ b/shared-bindings/_bleio/__init__.c
@@ -35,6 +35,7 @@
#include "shared-bindings/_bleio/CharacteristicBuffer.h"
#include "shared-bindings/_bleio/Connection.h"
#include "shared-bindings/_bleio/Descriptor.h"
+#include "shared-bindings/_bleio/PacketBuffer.h"
#include "shared-bindings/_bleio/ScanEntry.h"
#include "shared-bindings/_bleio/ScanResults.h"
#include "shared-bindings/_bleio/Service.h"
@@ -69,6 +70,7 @@
//| CharacteristicBuffer
//| Connection
//| Descriptor
+//| PacketBuffer
//| ScanEntry
//| ScanResults
//| Service
@@ -140,8 +142,9 @@ STATIC const mp_rom_map_elem_t bleio_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_Characteristic), MP_ROM_PTR(&bleio_characteristic_type) },
{ MP_ROM_QSTR(MP_QSTR_CharacteristicBuffer), MP_ROM_PTR(&bleio_characteristic_buffer_type) },
{ MP_ROM_QSTR(MP_QSTR_Descriptor), MP_ROM_PTR(&bleio_descriptor_type) },
+ { MP_ROM_QSTR(MP_QSTR_PacketBuffer), MP_ROM_PTR(&bleio_packet_buffer_type) },
{ MP_ROM_QSTR(MP_QSTR_ScanEntry), MP_ROM_PTR(&bleio_scanentry_type) },
- { MP_ROM_QSTR(MP_QSTR_ScanResults), MP_ROM_PTR(&bleio_scanresults_type) },
+ { MP_ROM_QSTR(MP_QSTR_ScanResults), MP_ROM_PTR(&bleio_scanresults_type) },
{ MP_ROM_QSTR(MP_QSTR_Service), MP_ROM_PTR(&bleio_service_type) },
{ MP_ROM_QSTR(MP_QSTR_UUID), MP_ROM_PTR(&bleio_uuid_type) },
diff --git a/shared-bindings/audiomp3/MP3File.c b/shared-bindings/audiomp3/MP3Decoder.c
index f518bae4b..224042212 100644
--- a/shared-bindings/audiomp3/MP3File.c
+++ b/shared-bindings/audiomp3/MP3Decoder.c
@@ -30,18 +30,16 @@
#include "lib/utils/context_manager_helpers.h"
#include "py/objproperty.h"
#include "py/runtime.h"
-#include "shared-bindings/audiomp3/MP3File.h"
+#include "shared-bindings/audiomp3/MP3Decoder.h"
#include "shared-bindings/util.h"
#include "supervisor/shared/translate.h"
//| .. currentmodule:: audiomp3
//|
-//| :class:`MP3` -- Load a mp3 file for audio playback
-//| ========================================================
+//| :class:`MP3Decoder` -- Load a mp3 file for audio playback
+//| =========================================================
//|
-//| A .mp3 file prepped for audio playback. Only mono and stereo files are supported. Samples must
-//| be 8 bit unsigned or 16 bit signed. If a buffer is provided, it will be used instead of allocating
-//| an internal buffer.
+//| An object that decodes MP3 files for playback on an audio device.
//|
//| .. class:: MP3(file[, buffer])
//|
@@ -63,7 +61,7 @@
//| speaker_enable.switch_to_output(value=True)
//|
//| data = open("cplay-16bit-16khz-64kbps.mp3", "rb")
-//| mp3 = audiomp3.MP3File(data)
+//| mp3 = audiomp3.MP3Decoder(data)
//| a = audioio.AudioOut(board.A0)
//|
//| print("playing")
@@ -129,6 +127,37 @@ STATIC mp_obj_t audiomp3_mp3file_obj___exit__(size_t n_args, const mp_obj_t *arg
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiomp3_mp3file___exit___obj, 4, 4, audiomp3_mp3file_obj___exit__);
+//| .. attribute:: file
+//|
+//| File to play back.
+//|
+STATIC mp_obj_t audiomp3_mp3file_obj_get_file(mp_obj_t self_in) {
+ audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in);
+ check_for_deinit(self);
+ return self->file;
+}
+MP_DEFINE_CONST_FUN_OBJ_1(audiomp3_mp3file_get_file_obj, audiomp3_mp3file_obj_get_file);
+
+STATIC mp_obj_t audiomp3_mp3file_obj_set_file(mp_obj_t self_in, mp_obj_t file) {
+ audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in);
+ check_for_deinit(self);
+ if (!MP_OBJ_IS_TYPE(file, &mp_type_fileio)) {
+ mp_raise_TypeError(translate("file must be a file opened in byte mode"));
+ }
+ common_hal_audiomp3_mp3file_set_file(self, file);
+ return mp_const_none;
+}
+MP_DEFINE_CONST_FUN_OBJ_2(audiomp3_mp3file_set_file_obj, audiomp3_mp3file_obj_set_file);
+
+const mp_obj_property_t audiomp3_mp3file_file_obj = {
+ .base.type = &mp_type_property,
+ .proxy = {(mp_obj_t)&audiomp3_mp3file_get_file_obj,
+ (mp_obj_t)&audiomp3_mp3file_set_file_obj,
+ (mp_obj_t)&mp_const_none_obj},
+};
+
+
+
//| .. attribute:: sample_rate
//|
//| 32 bit value that dictates how quickly samples are loaded into the DAC
@@ -193,6 +222,24 @@ const mp_obj_property_t audiomp3_mp3file_channel_count_obj = {
(mp_obj_t)&mp_const_none_obj},
};
+//| .. attribute:: rms_level
+//|
+//| The RMS audio level of a recently played moment of audio. (read only)
+//|
+STATIC mp_obj_t audiomp3_mp3file_obj_get_rms_level(mp_obj_t self_in) {
+ audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in);
+ check_for_deinit(self);
+ return mp_obj_new_float(common_hal_audiomp3_mp3file_get_rms_level(self));
+}
+MP_DEFINE_CONST_FUN_OBJ_1(audiomp3_mp3file_get_rms_level_obj, audiomp3_mp3file_obj_get_rms_level);
+
+const mp_obj_property_t audiomp3_mp3file_rms_level_obj = {
+ .base.type = &mp_type_property,
+ .proxy = {(mp_obj_t)&audiomp3_mp3file_get_rms_level_obj,
+ (mp_obj_t)&mp_const_none_obj,
+ (mp_obj_t)&mp_const_none_obj},
+};
+
STATIC const mp_rom_map_elem_t audiomp3_mp3file_locals_dict_table[] = {
// Methods
@@ -201,9 +248,11 @@ STATIC const mp_rom_map_elem_t audiomp3_mp3file_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&audiomp3_mp3file___exit___obj) },
// Properties
+ { MP_ROM_QSTR(MP_QSTR_file), MP_ROM_PTR(&audiomp3_mp3file_file_obj) },
{ MP_ROM_QSTR(MP_QSTR_sample_rate), MP_ROM_PTR(&audiomp3_mp3file_sample_rate_obj) },
{ MP_ROM_QSTR(MP_QSTR_bits_per_sample), MP_ROM_PTR(&audiomp3_mp3file_bits_per_sample_obj) },
{ MP_ROM_QSTR(MP_QSTR_channel_count), MP_ROM_PTR(&audiomp3_mp3file_channel_count_obj) },
+ { MP_ROM_QSTR(MP_QSTR_rms_level), MP_ROM_PTR(&audiomp3_mp3file_rms_level_obj) },
};
STATIC MP_DEFINE_CONST_DICT(audiomp3_mp3file_locals_dict, audiomp3_mp3file_locals_dict_table);
@@ -219,7 +268,7 @@ STATIC const audiosample_p_t audiomp3_mp3file_proto = {
const mp_obj_type_t audiomp3_mp3file_type = {
{ &mp_type_type },
- .name = MP_QSTR_MP3File,
+ .name = MP_QSTR_MP3Decoder,
.make_new = audiomp3_mp3file_make_new,
.locals_dict = (mp_obj_dict_t*)&audiomp3_mp3file_locals_dict,
.protocol = &audiomp3_mp3file_proto,
diff --git a/shared-bindings/audiomp3/MP3File.h b/shared-bindings/audiomp3/MP3Decoder.h
index adc13ea2c..36d525e93 100644
--- a/shared-bindings/audiomp3/MP3File.h
+++ b/shared-bindings/audiomp3/MP3Decoder.h
@@ -31,18 +31,20 @@
#include "py/obj.h"
#include "extmod/vfs_fat.h"
-#include "shared-module/audiomp3/MP3File.h"
+#include "shared-module/audiomp3/MP3Decoder.h"
extern const mp_obj_type_t audiomp3_mp3file_type;
void common_hal_audiomp3_mp3file_construct(audiomp3_mp3file_obj_t* self,
pyb_file_obj_t* file, uint8_t *buffer, size_t buffer_size);
+void common_hal_audiomp3_mp3file_set_file(audiomp3_mp3file_obj_t* self, pyb_file_obj_t* file);
void common_hal_audiomp3_mp3file_deinit(audiomp3_mp3file_obj_t* self);
bool common_hal_audiomp3_mp3file_deinited(audiomp3_mp3file_obj_t* self);
uint32_t common_hal_audiomp3_mp3file_get_sample_rate(audiomp3_mp3file_obj_t* self);
void common_hal_audiomp3_mp3file_set_sample_rate(audiomp3_mp3file_obj_t* self, uint32_t sample_rate);
uint8_t common_hal_audiomp3_mp3file_get_bits_per_sample(audiomp3_mp3file_obj_t* self);
uint8_t common_hal_audiomp3_mp3file_get_channel_count(audiomp3_mp3file_obj_t* self);
+float common_hal_audiomp3_mp3file_get_rms_level(audiomp3_mp3file_obj_t* self);
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOIO_MP3FILE_H
diff --git a/shared-bindings/audiomp3/__init__.c b/shared-bindings/audiomp3/__init__.c
index 06f852ff1..fb2187669 100644
--- a/shared-bindings/audiomp3/__init__.c
+++ b/shared-bindings/audiomp3/__init__.c
@@ -29,7 +29,7 @@
#include "py/obj.h"
#include "py/runtime.h"
-#include "shared-bindings/audiomp3/MP3File.h"
+#include "shared-bindings/audiomp3/MP3Decoder.h"
//| :mod:`audiomp3` --- Support for MP3-compressed audio files
//| ==========================================================
@@ -44,12 +44,12 @@
//| .. toctree::
//| :maxdepth: 3
//|
-//| MP3File
+//| MP3Decoder
//|
STATIC const mp_rom_map_elem_t audiomp3_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_audiomp3) },
- { MP_ROM_QSTR(MP_QSTR_MP3File), MP_ROM_PTR(&audiomp3_mp3file_type) },
+ { MP_ROM_QSTR(MP_QSTR_MP3Decoder), MP_ROM_PTR(&audiomp3_mp3file_type) },
};
STATIC MP_DEFINE_CONST_DICT(audiomp3_module_globals, audiomp3_module_globals_table);