Skip to content

Commit

Permalink
Better PDM for ESP32
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcombriat committed Jan 26, 2025
1 parent 26d9d58 commit 14952b5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion internal/MozziGuts_impl_ESP32.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ namespace MozziPrivate {
inline bool esp32_tryWriteSample() {
size_t bytes_written;
//i2s_write(i2s_num, &_esp32_prev_sample, ESP_SAMPLE_SIZE, &bytes_written, 0);
#if MOZZI_IS(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_I2S_DAC) || MOZZI_IS(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_PDM_VIA_I2S)
#if MOZZI_IS(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_I2S_DAC)
i2s_channel_write(tx_handle,_esp32_prev_sample, 2*sizeof(_esp32_prev_sample[0]), &bytes_written, 0);
#elif MOZZI_IS(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_PDM_VIA_I2S)
i2s_channel_write(tx_handle,_esp32_prev_sample, MOZZI_PDM_RESOLUTION*sizeof(_esp32_prev_sample[0]), &bytes_written, 0);
/* #elif MOZZI_IS(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_INTERNAL_DAC)
dac_continuous_write(dac_handle, _esp32_prev_sample, ESP_SAMPLE_SIZE, &bytes_written, 0);
*/
Expand Down
2 changes: 1 addition & 1 deletion internal/config_checks_esp32.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ MOZZI_CHECK_SUPPORTED(MOZZI_AUDIO_INPUT, MOZZI_AUDIO_INPUT_NONE)
#if MOZZI_IS(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_PDM_VIA_I2S)
# define MOZZI_I2S_FORMAT MOZZI_I2S_FORMAT_LSBJ // pdm codes are for LSBJ format
# if !defined(MOZZI_PDM_RESOLUTION)
# define MOZZI_PDM_RESOLUTION 2 // we send two 16 bits values
# define MOZZI_PDM_RESOLUTION 8
# endif
#else
# define MOZZI_PDM_RESOLUTION 1 // unconditionally, no other value allowed
Expand Down

0 comments on commit 14952b5

Please sign in to comment.