Mozzi  version v2.0
sound synthesis library for Arduino
config_checks_esp32.h
1 /*
2  * config_checks_esp32.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_ESP32_H
13 #define CONFIG_CHECK_ESP32_H
14 
80 #if not IS_ESP32()
81 #error This header should be included for ESP32 architecture, only
82 #endif
83 
84 #include "disable_2pinmode_on_github_workflow.h"
85 #if !defined(MOZZI_AUDIO_MODE)
86 #define MOZZI_AUDIO_MODE MOZZI_OUTPUT_INTERNAL_DAC
87 #endif
88 MOZZI_CHECK_SUPPORTED(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_EXTERNAL_TIMED, MOZZI_OUTPUT_EXTERNAL_CUSTOM, MOZZI_OUTPUT_PDM_VIA_I2S, MOZZI_OUTPUT_I2S_DAC, MOZZI_OUTPUT_INTERNAL_DAC)
89 
90 #if !defined(MOZZI_AUDIO_RATE)
91 #define MOZZI_AUDIO_RATE 32768
92 #endif
93 
94 #if defined(MOZZI_PWM_RATE)
95 #error Configuration of MOZZI_PWM_RATE is not currently supported on this platform (always same as MOZZI_AUDIO_RATE)
96 #endif
97 
98 #if !defined(MOZZI_ANALOG_READ)
99 # define MOZZI_ANALOG_READ MOZZI_ANALOG_READ_NONE
100 #endif
101 
102 MOZZI_CHECK_SUPPORTED(MOZZI_ANALOG_READ, MOZZI_ANALOG_READ_NONE)
103 MOZZI_CHECK_SUPPORTED(MOZZI_AUDIO_INPUT, MOZZI_AUDIO_INPUT_NONE)
104 
105 #if MOZZI_IS(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_I2S_DAC, MOZZI_OUTPUT_PDM_VIA_I2S)
106 # if !defined(MOZZI_I2S_PIN_BCK)
107 # define MOZZI_I2S_PIN_BCK 26
108 # endif
109 # if !defined(MOZZI_I2S_PIN_WS)
110 # define MOZZI_I2S_PIN_WS 25
111 # endif
112 # if !defined(MOZZI_I2S_PIN_DATA)
113 # define MOZZI_I2S_PIN_DATA 33
114 # endif
115 #endif
116 
117 #if MOZZI_IS(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_INTERNAL_DAC, MOZZI_OUTPUT_I2S_DAC, MOZZI_OUTPUT_PDM_VIA_I2S)
118 # include <driver/i2s.h>
119 # if !defined(MOZZI_IS2_PORT)
120 # define MOZZI_I2S_PORT I2S_NUM_0
121 # endif
122 #endif
123 
124 #if !defined(MOZZI_AUDIO_BITS)
125 # if MOZZI_IS(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_INTERNAL_DAC)
126 # define MOZZI_AUDIO_BITS 8
127 # else
128 # define MOZZI_AUDIO_BITS 16
129 # endif
130 #endif
131 
132 #if MOZZI_IS(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_PDM_VIA_I2S)
133 # if !defined(MOZZI_PDM_RESOLUTION)
134 # define MOZZI_PDM_RESOLUTION 8
135 # endif
136 #else
137 # define MOZZI_PDM_RESOLUTION 1 // unconditionally, no other value allowed
138 #endif
139 
140 // All modes besides timed external bypass the output buffer!
141 #if !MOZZI_IS(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_EXTERNAL_TIMED)
142 # define BYPASS_MOZZI_OUTPUT_BUFFER true
143 #endif
144 
145 #define MOZZI__INTERNAL_ANALOG_READ_RESOLUTION 12
146 
147 #endif // #ifndef CONFIG_CHECK_ESP32_H
#define MOZZI_AUDIO_INPUT
Whether to enable built in audio input feature.
#define MOZZI_AUDIO_MODE
Configure how Mozzi outputs generated sounds.
#define MOZZI_ANALOG_READ
Whether to compile in support for non-blocking analog reads.