summaryrefslogtreecommitdiff
path: root/shared-bindings
diff options
context:
space:
mode:
authorJeff Epler <jepler@gmail.com>2019-07-24 20:57:32 -0500
committerJeff Epler <jepler@gmail.com>2019-07-25 06:44:26 -0500
commit6b44e40ee8dba415213468afe14f7202b42ec429 (patch)
tree95145620819766182bbf8810884f024d5521d7c5 /shared-bindings
parentf39a6f40fdf3dfcd54ff3142255155f76da18016 (diff)
audiocore: Factor from audioio
When nrf pwm audio is introduced, it will be called `audiopwmio`. To enable code sharing with the existing (dac-based) `audioio`, factor the sample and mixer types to `audiocore`. INCOMPATIBLE CHANGE: Now, `Mixer`, `RawSample` and `WaveFile` must be imported from `audiocore`, not `audioio`.
Diffstat (limited to 'shared-bindings')
-rw-r--r--shared-bindings/audiocore/Mixer.c (renamed from shared-bindings/audioio/Mixer.c)4
-rw-r--r--shared-bindings/audiocore/Mixer.h (renamed from shared-bindings/audioio/Mixer.h)4
-rw-r--r--shared-bindings/audiocore/RawSample.c (renamed from shared-bindings/audioio/RawSample.c)2
-rw-r--r--shared-bindings/audiocore/RawSample.h (renamed from shared-bindings/audioio/RawSample.h)3
-rw-r--r--shared-bindings/audiocore/WaveFile.c (renamed from shared-bindings/audioio/WaveFile.c)2
-rw-r--r--shared-bindings/audiocore/WaveFile.h (renamed from shared-bindings/audioio/WaveFile.h)5
-rw-r--r--shared-bindings/audiocore/__init__.c69
-rw-r--r--shared-bindings/audiocore/__init__.h34
-rw-r--r--shared-bindings/audioio/AudioOut.c2
-rw-r--r--shared-bindings/audioio/AudioOut.h2
-rw-r--r--shared-bindings/audioio/__init__.c17
-rw-r--r--shared-bindings/index.rst1
12 files changed, 124 insertions, 21 deletions
diff --git a/shared-bindings/audioio/Mixer.c b/shared-bindings/audiocore/Mixer.c
index dce4b3955..b2f0a3fda 100644
--- a/shared-bindings/audioio/Mixer.c
+++ b/shared-bindings/audiocore/Mixer.c
@@ -23,7 +23,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
-#include "shared-bindings/audioio/Mixer.h"
+#include "shared-bindings/audiocore/Mixer.h"
#include <stdint.h>
@@ -32,7 +32,7 @@
#include "py/objproperty.h"
#include "py/runtime.h"
#include "shared-bindings/microcontroller/Pin.h"
-#include "shared-bindings/audioio/RawSample.h"
+#include "shared-bindings/audiocore/RawSample.h"
#include "shared-bindings/util.h"
#include "supervisor/shared/translate.h"
diff --git a/shared-bindings/audioio/Mixer.h b/shared-bindings/audiocore/Mixer.h
index 832072b8f..ef12f9a70 100644
--- a/shared-bindings/audioio/Mixer.h
+++ b/shared-bindings/audiocore/Mixer.h
@@ -28,8 +28,8 @@
#define MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOIO_MIXER_H
#include "common-hal/microcontroller/Pin.h"
-#include "shared-module/audioio/Mixer.h"
-#include "shared-bindings/audioio/RawSample.h"
+#include "shared-module/audiocore/Mixer.h"
+#include "shared-bindings/audiocore/RawSample.h"
extern const mp_obj_type_t audioio_mixer_type;
diff --git a/shared-bindings/audioio/RawSample.c b/shared-bindings/audiocore/RawSample.c
index 62998f580..912b48bfb 100644
--- a/shared-bindings/audioio/RawSample.c
+++ b/shared-bindings/audiocore/RawSample.c
@@ -31,8 +31,8 @@
#include "py/objproperty.h"
#include "py/runtime.h"
#include "shared-bindings/microcontroller/Pin.h"
-#include "shared-bindings/audioio/AudioOut.h"
#include "shared-bindings/util.h"
+#include "shared-bindings/audiocore/RawSample.h"
#include "supervisor/shared/translate.h"
//| .. currentmodule:: audioio
diff --git a/shared-bindings/audioio/RawSample.h b/shared-bindings/audiocore/RawSample.h
index 0d764b77c..b02778cad 100644
--- a/shared-bindings/audioio/RawSample.h
+++ b/shared-bindings/audiocore/RawSample.h
@@ -27,9 +27,8 @@
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOIO_RAWSAMPLE_H
#define MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOIO_RAWSAMPLE_H
-#include "common-hal/audioio/AudioOut.h"
#include "common-hal/microcontroller/Pin.h"
-#include "shared-module/audioio/RawSample.h"
+#include "shared-module/audiocore/RawSample.h"
extern const mp_obj_type_t audioio_rawsample_type;
diff --git a/shared-bindings/audioio/WaveFile.c b/shared-bindings/audiocore/WaveFile.c
index 242c915d3..4c1993b7c 100644
--- a/shared-bindings/audioio/WaveFile.c
+++ b/shared-bindings/audiocore/WaveFile.c
@@ -29,7 +29,7 @@
#include "lib/utils/context_manager_helpers.h"
#include "py/objproperty.h"
#include "py/runtime.h"
-#include "shared-bindings/audioio/WaveFile.h"
+#include "shared-bindings/audiocore/WaveFile.h"
#include "shared-bindings/util.h"
#include "supervisor/shared/translate.h"
diff --git a/shared-bindings/audioio/WaveFile.h b/shared-bindings/audiocore/WaveFile.h
index 62a4200dc..d2572318b 100644
--- a/shared-bindings/audioio/WaveFile.h
+++ b/shared-bindings/audiocore/WaveFile.h
@@ -27,10 +27,11 @@
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOIO_WAVEFILE_H
#define MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOIO_WAVEFILE_H
-#include "common-hal/audioio/AudioOut.h"
-#include "common-hal/microcontroller/Pin.h"
+#include "py/obj.h"
#include "extmod/vfs_fat.h"
+#include "shared-module/audiocore/WaveFile.h"
+
extern const mp_obj_type_t audioio_wavefile_type;
void common_hal_audioio_wavefile_construct(audioio_wavefile_obj_t* self,
diff --git a/shared-bindings/audiocore/__init__.c b/shared-bindings/audiocore/__init__.c
new file mode 100644
index 000000000..c64759d4f
--- /dev/null
+++ b/shared-bindings/audiocore/__init__.c
@@ -0,0 +1,69 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2017 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 <stdint.h>
+
+#include "py/obj.h"
+#include "py/runtime.h"
+
+#include "shared-bindings/microcontroller/Pin.h"
+#include "shared-bindings/audiocore/__init__.h"
+#include "shared-bindings/audiocore/Mixer.h"
+#include "shared-bindings/audiocore/RawSample.h"
+#include "shared-bindings/audiocore/WaveFile.h"
+
+//| :mod:`audiocore` --- Support for audio samples and mixer
+//| ========================================================
+//|
+//| .. module:: audiocore
+//| :synopsis: Support for audio samples and mixer
+//| :platform: SAMD21
+//|
+//| The `audiocore` module contains core classes for audio IO
+//|
+//| Libraries
+//|
+//| .. toctree::
+//| :maxdepth: 3
+//|
+//| Mixer
+//| RawSample
+//| WaveFile
+//|
+
+STATIC const mp_rom_map_elem_t audiocore_module_globals_table[] = {
+ { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_audiocore) },
+ { MP_ROM_QSTR(MP_QSTR_Mixer), MP_ROM_PTR(&audioio_mixer_type) },
+ { MP_ROM_QSTR(MP_QSTR_RawSample), MP_ROM_PTR(&audioio_rawsample_type) },
+ { MP_ROM_QSTR(MP_QSTR_WaveFile), MP_ROM_PTR(&audioio_wavefile_type) },
+};
+
+STATIC MP_DEFINE_CONST_DICT(audiocore_module_globals, audiocore_module_globals_table);
+
+const mp_obj_module_t audiocore_module = {
+ .base = { &mp_type_module },
+ .globals = (mp_obj_dict_t*)&audiocore_module_globals,
+};
diff --git a/shared-bindings/audiocore/__init__.h b/shared-bindings/audiocore/__init__.h
new file mode 100644
index 000000000..02437cd13
--- /dev/null
+++ b/shared-bindings/audiocore/__init__.h
@@ -0,0 +1,34 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2017 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_AUDIOCORE___INIT___H
+#define MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOCORE___INIT___H
+
+#include "py/obj.h"
+
+// Nothing now.
+
+#endif // MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOCORE___INIT___H
diff --git a/shared-bindings/audioio/AudioOut.c b/shared-bindings/audioio/AudioOut.c
index 571dcdaca..79df66f7d 100644
--- a/shared-bindings/audioio/AudioOut.c
+++ b/shared-bindings/audioio/AudioOut.c
@@ -32,7 +32,7 @@
#include "py/runtime.h"
#include "shared-bindings/microcontroller/Pin.h"
#include "shared-bindings/audioio/AudioOut.h"
-#include "shared-bindings/audioio/RawSample.h"
+#include "shared-bindings/audiocore/RawSample.h"
#include "shared-bindings/util.h"
#include "supervisor/shared/translate.h"
diff --git a/shared-bindings/audioio/AudioOut.h b/shared-bindings/audioio/AudioOut.h
index d09a5c9ca..1076ac5cc 100644
--- a/shared-bindings/audioio/AudioOut.h
+++ b/shared-bindings/audioio/AudioOut.h
@@ -29,7 +29,7 @@
#include "common-hal/audioio/AudioOut.h"
#include "common-hal/microcontroller/Pin.h"
-#include "shared-bindings/audioio/RawSample.h"
+#include "shared-bindings/audiocore/RawSample.h"
extern const mp_obj_type_t audioio_audioout_type;
diff --git a/shared-bindings/audioio/__init__.c b/shared-bindings/audioio/__init__.c
index 4786b6425..837b66255 100644
--- a/shared-bindings/audioio/__init__.c
+++ b/shared-bindings/audioio/__init__.c
@@ -32,9 +32,11 @@
#include "shared-bindings/microcontroller/Pin.h"
#include "shared-bindings/audioio/__init__.h"
#include "shared-bindings/audioio/AudioOut.h"
-#include "shared-bindings/audioio/Mixer.h"
-#include "shared-bindings/audioio/RawSample.h"
-#include "shared-bindings/audioio/WaveFile.h"
+#include "shared-bindings/audiocore/__init__.h"
+#include "shared-bindings/audioio/AudioOut.h"
+#include "shared-bindings/audiocore/Mixer.h"
+#include "shared-bindings/audiocore/RawSample.h"
+#include "shared-bindings/audiocore/WaveFile.h"
//| :mod:`audioio` --- Support for audio input and output
//| ======================================================
@@ -51,22 +53,19 @@
//| :maxdepth: 3
//|
//| AudioOut
-//| Mixer
-//| RawSample
-//| WaveFile
//|
//| All classes change hardware state and should be deinitialized when they
//| are no longer needed if the program continues after use. To do so, either
//| call :py:meth:`!deinit` or use a context manager. See
//| :ref:`lifetime-and-contextmanagers` for more info.
//|
+//| Since CircuitPython 5, `Mixer`, `RawSample` and `WaveFile` are moved
+//| to :mod:`audiocore`.
+//|
STATIC const mp_rom_map_elem_t audioio_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_audioio) },
{ MP_ROM_QSTR(MP_QSTR_AudioOut), MP_ROM_PTR(&audioio_audioout_type) },
- { MP_ROM_QSTR(MP_QSTR_Mixer), MP_ROM_PTR(&audioio_mixer_type) },
- { MP_ROM_QSTR(MP_QSTR_RawSample), MP_ROM_PTR(&audioio_rawsample_type) },
- { MP_ROM_QSTR(MP_QSTR_WaveFile), MP_ROM_PTR(&audioio_wavefile_type) },
};
STATIC MP_DEFINE_CONST_DICT(audioio_module_globals, audioio_module_globals_table);
diff --git a/shared-bindings/index.rst b/shared-bindings/index.rst
index 8f9bbbb31..b7690d292 100644
--- a/shared-bindings/index.rst
+++ b/shared-bindings/index.rst
@@ -36,6 +36,7 @@ Module Supported Ports
`analogio` **All Supported**
`audiobusio` **SAMD/SAMD Express**
`audioio` **SAMD Express**
+`audiocore` **All with audioio**
`binascii` **ESP8266**
`bitbangio` **SAMD Express, ESP8266**
`board` **All Supported**