Mozzi  version v2.0
sound synthesis library for Arduino
config_checks_esp8266.h
1 /*
2  * config_checks_esp8266.h
3  *
4  * This file is part of Mozzi.
5  *
6  * Copyright 2023-2024 Thomas Friedrichsmeier and the Mozzi Team
7  *
8  * Mozzi is licensed under the GNU Lesser General Public Licence (LGPL) Version 2.1 or later.
9  *
10 */
11 
12 #ifndef CONFIG_CHECK_ESP8266_H
13 #define CONFIG_CHECK_ESP8266_H
14 
72 #if not IS_ESP8266()
73 #error This header should be included for ESP architecture, only
74 #endif
75 
76 #include "disable_2pinmode_on_github_workflow.h"
77 #if !defined(MOZZI_AUDIO_MODE)
78 #define MOZZI_AUDIO_MODE MOZZI_OUTPUT_PDM_VIA_SERIAL
79 #endif
80 MOZZI_CHECK_SUPPORTED(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_EXTERNAL_TIMED, MOZZI_OUTPUT_EXTERNAL_CUSTOM, MOZZI_OUTPUT_PDM_VIA_I2S, MOZZI_OUTPUT_PDM_VIA_SERIAL, MOZZI_OUTPUT_I2S_DAC)
81 
82 #if !defined(MOZZI_AUDIO_RATE)
83 #define MOZZI_AUDIO_RATE 32768
84 #endif
85 
86 #if !defined(MOZZI_AUDIO_BITS)
87 # define MOZZI_AUDIO_BITS 16
88 #endif
89 
90 #if !defined(MOZZI_ANALOG_READ)
91 # define MOZZI_ANALOG_READ MOZZI_ANALOG_READ_NONE
92 #endif
93 
94 MOZZI_CHECK_SUPPORTED(MOZZI_ANALOG_READ, MOZZI_ANALOG_READ_NONE)
95 MOZZI_CHECK_SUPPORTED(MOZZI_AUDIO_INPUT, MOZZI_AUDIO_INPUT_NONE)
96 
97 #if MOZZI_IS(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_PDM_VIA_I2S, MOZZI_OUTPUT_PDM_VIA_SERIAL)
98 # if !defined(PDM_RESOLUTION)
99 # define MOZZI_PDM_RESOLUTION 2
100 # endif
101 # include "disable_stereo_on_github_workflow.h"
102 MOZZI_CHECK_SUPPORTED(MOZZI_AUDIO_CHANNELS, 1)
103 MOZZI_CHECK_SUPPORTED(MOZZI_AUDIO_BITS, 16)
104 #elif MOZZI_IS(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_I2S_DAC)
105 # define MOZZI_PDM_RESOLUTION 1 // DO NOT CHANGE THIS VALUE! Not actually PDM coded, but this define is useful to keep code simple.
106 MOZZI_CHECK_SUPPORTED(MOZZI_AUDIO_BITS, 16)
107 #endif
108 
109 #define PDM_RESOLUTION 2 // 1 corresponds to 32 PDM clocks per sample, 2 corresponds to 64 PDM clocks, etc. (and at some level you're going hit the hardware limits)
110 
111 #if MOZZI_IS(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_PDM_VIA_I2S, MOZZI_OUTPUT_I2S_DAC)
112 // NOTE: On ESP / output via I2S, we simply use the I2S buffer as the output
113 // buffer, which saves RAM, but also simplifies things a lot
114 // esp. since i2s output already has output rate control -> no need for a
115 // separate output timer
116 #define BYPASS_MOZZI_OUTPUT_BUFFER true
117 #endif
118 
119 #define MOZZI__INTERNAL_ANALOG_READ_RESOLUTION 10
120 
121 #endif // #ifndef CONFIG_CHECK_ESP8266_H
#define MOZZI_AUDIO_INPUT
Whether to enable built in audio input feature.
#define MOZZI_AUDIO_BITS
Output resolution of audio samples.
#define MOZZI_AUDIO_CHANNELS
This sets allows to change from a single/mono audio output channel to stereo output.
#define MOZZI_AUDIO_MODE
Configure how Mozzi outputs generated sounds.
#define MOZZI_ANALOG_READ
Whether to compile in support for non-blocking analog reads.