diff --git a/_analog_audio_8h_source.html b/_analog_audio_8h_source.html index fa48794918..fb98956b09 100644 --- a/_analog_audio_8h_source.html +++ b/_analog_audio_8h_source.html @@ -122,51 +122,46 @@
66  analog.end();
67  }
68 
-
69  // /// Overides the sample rate and uses the max value which is around ~13MHz. Call this methd after begin();
-
70  // void setMaxSampleRate() {
-
71  // analog.setMaxSampleRate();
-
72  // }
-
73 
-
74  AnalogConfig &config() {
-
75  return adc_config;
-
76  }
-
77 
-
79  size_t write(const uint8_t *src, size_t size_bytes) override {
-
80  TRACED();
-
81  return analog.write(src, size_bytes);
-
82  }
-
83 
-
84  size_t readBytes(uint8_t *dest, size_t size_bytes) override {
-
85  return analog.readBytes(dest, size_bytes);
-
86  }
-
87 
-
88  int available() override {
-
89  return analog.available();
-
90  }
-
91 
-
92  int availableForWrite() override {
-
93  return analog.availableForWrite();
+
69  AnalogConfig &config() {
+
70  return adc_config;
+
71  }
+
72 
+
74  size_t write(const uint8_t *src, size_t size_bytes) override {
+
75  TRACED();
+
76  return analog.write(src, size_bytes);
+
77  }
+
78 
+
79  size_t readBytes(uint8_t *dest, size_t size_bytes) override {
+
80  return analog.readBytes(dest, size_bytes);
+
81  }
+
82 
+
83  int available() override {
+
84  return analog.available();
+
85  }
+
86 
+
87  int availableForWrite() override {
+
88  return analog.availableForWrite();
+
89  }
+
90 
+
92  AnalogDriver* driver() {
+
93  return &analog;
94  }
95 
-
97  AnalogDriver* driver() {
-
98  return &analog;
-
99  }
+
96 protected:
+
97  AnalogDriver analog;
+
98  AnalogConfig adc_config;
+
99 };
100 
-
101 protected:
-
102  AnalogDriver analog;
-
103  AnalogConfig adc_config;
-
104 };
-
105 
-
106 }
-
107 
-
108 #endif
+
101 }
+
102 
+
103 #endif
audio_tools::AnalogAudioStream
ESP32: A very fast ADC and DAC using the ESP32 I2S interface. For all other architectures we support ...
Definition: AnalogAudio.h:20
-
audio_tools::AnalogAudioStream::write
size_t write(const uint8_t *src, size_t size_bytes) override
ESP32 only: writes the data to the I2S interface.
Definition: AnalogAudio.h:79
+
audio_tools::AnalogAudioStream::write
size_t write(const uint8_t *src, size_t size_bytes) override
ESP32 only: writes the data to the I2S interface.
Definition: AnalogAudio.h:74
audio_tools::AnalogAudioStream::begin
bool begin(AnalogConfig cfg)
starts the DAC
Definition: AnalogAudio.h:58
audio_tools::AnalogAudioStream::end
void end() override
stops the I2S and unistalls the analog
Definition: AnalogAudio.h:64
audio_tools::AnalogAudioStream::setAudioInfo
virtual void setAudioInfo(AudioInfo info)
updates the sample rate dynamically
Definition: AnalogAudio.h:38
audio_tools::AnalogAudioStream::AnalogAudioStream
AnalogAudioStream()=default
Default constructor.
-
audio_tools::AnalogAudioStream::driver
AnalogDriver * driver()
Provides access to the driver.
Definition: AnalogAudio.h:97
+
audio_tools::AnalogAudioStream::driver
AnalogDriver * driver()
Provides access to the driver.
Definition: AnalogAudio.h:92
audio_tools::AnalogAudioStream::~AnalogAudioStream
virtual ~AnalogAudioStream()
Destructor.
Definition: AnalogAudio.h:26
audio_tools::AnalogAudioStream::defaultConfig
AnalogConfig defaultConfig(RxTxMode mode=TX_MODE)
Provides the default configuration.
Definition: AnalogAudio.h:31
audio_tools::AnalogAudioStream::begin
bool begin() override
Reopen with last config.
Definition: AnalogAudio.h:53
diff --git a/_audio_kit_8h_source.html b/_audio_kit_8h_source.html index 10bc5b50a8..56bc0fc8da 100644 --- a/_audio_kit_8h_source.html +++ b/_audio_kit_8h_source.html @@ -85,7 +85,7 @@
14 class AudioKitStream;
15 AudioKitStream *pt_AudioKitStream = nullptr;
16 
-
23 class AudioKitStreamConfig : public I2SConfig {
+
23 class AudioKitStreamConfig : public I2SConfig {
24 
25 friend class AudioKitStream;
26 
@@ -136,14 +136,14 @@
72 
74  void setupI2SPins(RxTxMode rxtx_mode) {
75  TRACED();
-
76  this->rx_tx_mode = rxtx_mode;
+
76  this->rx_tx_mode = rxtx_mode;
77  i2s_pin_config_t i2s_pins;
78  board.setup(pins);
79  board.get_i2s_pins((i2s_port_t)port_no, &i2s_pins);
80  pin_mck = i2s_pins.mck_io_num;
81  pin_bck = i2s_pins.bck_io_num;
82  pin_ws = i2s_pins.ws_io_num;
-
83  if (rx_tx_mode == RX_MODE){
+
83  if (rx_tx_mode == RX_MODE){
84  pin_data = i2s_pins.data_in_num;
85  pin_data_rx = I2S_PIN_NO_CHANGE;
86  } else {
@@ -223,7 +223,7 @@
164  }
165 
167  audio_hal_codec_mode_t toCodecMode() {
-
168  switch (rx_tx_mode) {
+
168  switch (rx_tx_mode) {
169  case TX_MODE:
170  LOGD("-> %s","AUDIO_HAL_CODEC_MODE_DECODE");
171  return AUDIO_HAL_CODEC_MODE_DECODE;
@@ -244,7 +244,7 @@
194  AudioKitStreamConfig defaultConfig(RxTxMode mode = RXTX_MODE) {
195  TRACED();
196  AudioKitStreamConfig result{mode};
-
197  result.rx_tx_mode = mode;
+
197  result.rx_tx_mode = mode;
198  return result;
199  }
200 
@@ -289,7 +289,7 @@
241  }
242 
244  int available() {
-
245  return cfg.rx_tx_mode == TX_MODE ? 0 : DEFAULT_BUFFER_SIZE;
+
245  return cfg.rx_tx_mode == TX_MODE ? 0 : DEFAULT_BUFFER_SIZE;
246  }
247 
248  size_t write(const uint8_t *data, size_t length) override {
@@ -578,8 +578,8 @@
audio_tools::AudioKitStream::readBytes
size_t readBytes(uint8_t *data, size_t length) override
Reads the audio data.
Definition: AudioKit.h:253
audio_tools::AudioKitStream::pinAuxin
int8_t pinAuxin()
Get the gpio number for auxin detection.
Definition: AudioKit.h:455
audio_tools::AudioStream
Base class for all Audio Streams. It support the boolean operator to test if the object is ready with...
Definition: AudioStreams.h:47
-
audio_tools::I2SConfig
configuration for all common i2s settings
Definition: I2SConfig.h:52
-
audio_tools::I2SConfig::rx_tx_mode
RxTxMode rx_tx_mode
public settings
Definition: I2SConfig.h:94
+
audio_tools::I2SConfigESP32
configuration for USE_ALT_PIN_SUPPORT i2s
Definition: I2SConfigESP32.h:31
+
audio_tools::I2SConfigESP32::rx_tx_mode
RxTxMode rx_tx_mode
public settings
Definition: I2SConfigESP32.h:67
audio_tools::I2SStream
We support the Stream interface for the I2S access. In addition we allow a separate mute pin which mi...
Definition: I2SStream.h:32
audio_tools::I2SStream::readBytes
virtual size_t readBytes(uint8_t *data, size_t length) override
Reads the audio data.
Definition: I2SStream.h:98
audio_tools::I2SStream::write
virtual size_t write(const uint8_t *buffer, size_t size)
Writes the audio data to I2S.
Definition: I2SStream.h:92
diff --git a/_audio_s_p_d_i_f_8h_source.html b/_audio_s_p_d_i_f_8h_source.html index 4aa8774e8e..b36f4fe3cd 100644 --- a/_audio_s_p_d_i_f_8h_source.html +++ b/_audio_s_p_d_i_f_8h_source.html @@ -199,7 +199,7 @@
160  int bclk = sample_rate * I2S_BITS_PER_SAMPLE * I2S_CHANNELS;
161  int mclk = (I2S_BUG_MAGIC / bclk) * bclk; // use mclk for avoiding I2S bug
162 
-
163  I2SConfig i2s_cfg;
+
163  I2SConfig i2s_cfg;
164  i2s_cfg.sample_rate = sample_rate;
165  i2s_cfg.channels = cfg.channels;
166  i2s_cfg.i2s_format = I2S_STD_FORMAT;
@@ -209,105 +209,107 @@
170  i2s_cfg.pin_data = cfg.pin_data;
171 #ifdef ESP32
172  i2s_cfg.use_apll = true;
-
173  i2s_cfg.fixed_mclk = mclk;
-
174 #endif
-
175  i2sOn = i2s.begin(i2s_cfg);
-
176  return i2sOn;
-
177  }
-
178 
-
179  void end() {
-
180  TRACED();
-
181  i2s.end();
-
182  i2sOn = false;
-
183  }
-
184 
-
186  void setAudioInfo(AudioInfo info) {
-
187  TRACED();
-
188  if (info.bits_per_sample != 16) {
-
189  LOGE("Unsupported bits per sample: %d - must be 16!",
-
190  info.bits_per_sample);
-
191  }
-
192  if (cfg.bits_per_sample != info.bits_per_sample
-
193  || cfg.channels != info.channels
-
194  || cfg.sample_rate != info.sample_rate
-
195  || !i2sOn) {
-
196  cfg.bits_per_sample = info.bits_per_sample;
-
197  cfg.channels = info.channels;
-
198  cfg.sample_rate = info.sample_rate;
-
199  begin(cfg);
-
200  }
-
201  }
-
202 
-
204  SPDIFConfig defaultConfig() {
-
205  SPDIFConfig c;
-
206  return c;
-
207  }
-
208 
-
210  size_t write(const uint8_t *src, size_t size) {
-
211  if (!i2sOn) return 0;
-
212  const uint8_t *p = src;
-
213  size_t result = 0;
-
214 
-
215  while (p < (uint8_t *)src + size) {
-
216  // convert PCM 16bit data to BMC 32bit pulse pattern
-
217  if (cfg.channels == 2) {
-
218  *(spdif_ptr + 1) =
-
219  (uint32_t)(((bmc_tab[*p] << 16) ^ bmc_tab[*(p + 1)]) << 1) >> 1;
-
220  p += 2;
-
221  } else {
-
222  // must be one channels -> use the same value for both
-
223  *(spdif_ptr + 1) =
-
224  (uint32_t)(((bmc_tab[*p] << 16) ^ bmc_tab[*(p)]) << 1) >> 1;
-
225  p++;
-
226  }
-
227  result += 2;
-
228  spdif_ptr += 2; // advance to next audio data
-
229 
-
230  if (spdif_ptr >= &spdif_buf[SPDIF_BUF_ARRAY_SIZE]) {
-
231  // set block start preamble
-
232  ((uint8_t *)spdif_buf)[SYNC_OFFSET] ^= SYNC_FLIP;
-
233 
-
234  i2s.write((uint8_t *)spdif_buf, sizeof(spdif_buf));
-
235  spdif_ptr = spdif_buf;
-
236  }
-
237  }
-
238 
-
239  return result;
-
240  }
-
241 
-
242  protected:
-
243  bool i2sOn = false;
-
244  SPDIFConfig cfg;
-
245  I2SStream i2s;
-
246 
-
247  // initialize S/PDIF buffer
-
248  void spdif_buf_init(void) {
-
249  TRACED();
-
250  size_t i;
-
251  uint32_t bmc_mw = BMC_W;
-
252 
-
253  for (i = 0; i < (size_t)SPDIF_BUF_ARRAY_SIZE; i += 2) {
-
254  spdif_buf[i] = bmc_mw ^= BMC_MW_DIF;
-
255  }
-
256  }
-
257 };
-
258 
-
259 using SPDIFStream = SPDIFOutput;
+
173 # if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0 , 0)
+
174  i2s_cfg.fixed_mclk = mclk;
+
175 # endif
+
176 #endif
+
177  i2sOn = i2s.begin(i2s_cfg);
+
178  return i2sOn;
+
179  }
+
180 
+
181  void end() {
+
182  TRACED();
+
183  i2s.end();
+
184  i2sOn = false;
+
185  }
+
186 
+
188  void setAudioInfo(AudioInfo info) {
+
189  TRACED();
+
190  if (info.bits_per_sample != 16) {
+
191  LOGE("Unsupported bits per sample: %d - must be 16!",
+
192  info.bits_per_sample);
+
193  }
+
194  if (cfg.bits_per_sample != info.bits_per_sample
+
195  || cfg.channels != info.channels
+
196  || cfg.sample_rate != info.sample_rate
+
197  || !i2sOn) {
+
198  cfg.bits_per_sample = info.bits_per_sample;
+
199  cfg.channels = info.channels;
+
200  cfg.sample_rate = info.sample_rate;
+
201  begin(cfg);
+
202  }
+
203  }
+
204 
+
206  SPDIFConfig defaultConfig() {
+
207  SPDIFConfig c;
+
208  return c;
+
209  }
+
210 
+
212  size_t write(const uint8_t *src, size_t size) {
+
213  if (!i2sOn) return 0;
+
214  const uint8_t *p = src;
+
215  size_t result = 0;
+
216 
+
217  while (p < (uint8_t *)src + size) {
+
218  // convert PCM 16bit data to BMC 32bit pulse pattern
+
219  if (cfg.channels == 2) {
+
220  *(spdif_ptr + 1) =
+
221  (uint32_t)(((bmc_tab[*p] << 16) ^ bmc_tab[*(p + 1)]) << 1) >> 1;
+
222  p += 2;
+
223  } else {
+
224  // must be one channels -> use the same value for both
+
225  *(spdif_ptr + 1) =
+
226  (uint32_t)(((bmc_tab[*p] << 16) ^ bmc_tab[*(p)]) << 1) >> 1;
+
227  p++;
+
228  }
+
229  result += 2;
+
230  spdif_ptr += 2; // advance to next audio data
+
231 
+
232  if (spdif_ptr >= &spdif_buf[SPDIF_BUF_ARRAY_SIZE]) {
+
233  // set block start preamble
+
234  ((uint8_t *)spdif_buf)[SYNC_OFFSET] ^= SYNC_FLIP;
+
235 
+
236  i2s.write((uint8_t *)spdif_buf, sizeof(spdif_buf));
+
237  spdif_ptr = spdif_buf;
+
238  }
+
239  }
+
240 
+
241  return result;
+
242  }
+
243 
+
244  protected:
+
245  bool i2sOn = false;
+
246  SPDIFConfig cfg;
+
247  I2SStream i2s;
+
248 
+
249  // initialize S/PDIF buffer
+
250  void spdif_buf_init(void) {
+
251  TRACED();
+
252  size_t i;
+
253  uint32_t bmc_mw = BMC_W;
+
254 
+
255  for (i = 0; i < (size_t)SPDIF_BUF_ARRAY_SIZE; i += 2) {
+
256  spdif_buf[i] = bmc_mw ^= BMC_MW_DIF;
+
257  }
+
258  }
+
259 };
260 
-
261 } // namespace audio_tools
+
261 using SPDIFStream = SPDIFOutput;
+
262 
+
263 } // namespace audio_tools
audio_tools::AudioStream
Base class for all Audio Streams. It support the boolean operator to test if the object is ready with...
Definition: AudioStreams.h:47
-
audio_tools::I2SConfig
configuration for all common i2s settings
Definition: I2SConfig.h:52
+
audio_tools::I2SConfigESP32
configuration for USE_ALT_PIN_SUPPORT i2s
Definition: I2SConfigESP32.h:31
audio_tools::I2SStream
We support the Stream interface for the I2S access. In addition we allow a separate mute pin which mi...
Definition: I2SStream.h:32
audio_tools::I2SStream::write
virtual size_t write(const uint8_t *buffer, size_t size)
Writes the audio data to I2S.
Definition: I2SStream.h:92
audio_tools::I2SStream::end
void end()
Stops the I2S interface.
Definition: I2SStream.h:67
audio_tools::SPDIFOutput
Output as 16 bit stereo SPDIF on the I2S data output pin.
Definition: AudioSPDIF.h:120
-
audio_tools::SPDIFOutput::defaultConfig
SPDIFConfig defaultConfig()
Provides the default configuration.
Definition: AudioSPDIF.h:204
+
audio_tools::SPDIFOutput::defaultConfig
SPDIFConfig defaultConfig()
Provides the default configuration.
Definition: AudioSPDIF.h:206
audio_tools::SPDIFOutput::~SPDIFOutput
virtual ~SPDIFOutput()
destructor
Definition: AudioSPDIF.h:126
-
audio_tools::SPDIFOutput::setAudioInfo
void setAudioInfo(AudioInfo info)
Change the audio parameters.
Definition: AudioSPDIF.h:186
+
audio_tools::SPDIFOutput::setAudioInfo
void setAudioInfo(AudioInfo info)
Change the audio parameters.
Definition: AudioSPDIF.h:188
audio_tools::SPDIFOutput::begin
bool begin()
Starting with default settings.
Definition: AudioSPDIF.h:129
audio_tools::SPDIFOutput::SPDIFOutput
SPDIFOutput()=default
default constructor
audio_tools::SPDIFOutput::begin
bool begin(SPDIFConfig config)
Start with the provided parameters.
Definition: AudioSPDIF.h:132
-
audio_tools::SPDIFOutput::write
size_t write(const uint8_t *src, size_t size)
Writes the audio data as SPDIF to the defined output pin.
Definition: AudioSPDIF.h:210
+
audio_tools::SPDIFOutput::write
size_t write(const uint8_t *src, size_t size)
Writes the audio data as SPDIF to the defined output pin.
Definition: AudioSPDIF.h:212
audio_tools
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition: AnalogAudio.h:10
audio_tools::AudioInfo
Basic Audio information which drives e.g. I2S.
Definition: AudioTypes.h:48
audio_tools::AudioInfo::channels
int channels
Number of channels: 2=stereo, 1=mono.
Definition: AudioTypes.h:106
diff --git a/_audio_streams_8h_source.html b/_audio_streams_8h_source.html index b20864f9ac..3839982474 100644 --- a/_audio_streams_8h_source.html +++ b/_audio_streams_8h_source.html @@ -1979,7 +1979,7 @@
audio_tools::MemoryType
MemoryType
Memory types.
Definition: AudioTypes.h:31
audio_tools::RxTxMode
RxTxMode
Audio Source (TX_MODE) or Audio Sink (RX_MODE). RXTX_MODE is Source and Sink at the same time!
Definition: AudioTypes.h:24
audio_tools
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition: AnalogAudio.h:10
-
audio_tools::readSamples
size_t readSamples(Stream *p_stream, T *data, int samples)
guaranteed to return the requested data
Definition: AudioTypes.h:312
+
audio_tools::readSamples
size_t readSamples(Stream *p_stream, T *data, int samples)
guaranteed to return the requested data
Definition: AudioTypes.h:331
audio_tools::delay
void delay(uint64_t ms)
Waits for the indicated milliseconds.
Definition: Millis.h:10
audio_tools::millis
uint64_t millis()
Returns the milliseconds since the start.
Definition: Millis.h:17
audio_tools::AudioInfo
Basic Audio information which drives e.g. I2S.
Definition: AudioTypes.h:48
diff --git a/_audio_types_8h_source.html b/_audio_types_8h_source.html index 38494909a4..6d18c8d302 100644 --- a/_audio_types_8h_source.html +++ b/_audio_types_8h_source.html @@ -307,74 +307,90 @@
291 
292 };
293 
-
295 template<typename T>
-
296 T readSample(Stream* p_stream){
-
297  T result=0;
-
298  uint8_t *p_result = (uint8_t*) &result;
-
299  int open = sizeof(T);
-
300  int total = 0;
-
301  // copy missing data
-
302  while (open>0){
-
303  int read = p_stream->readBytes(p_result+total, open);
-
304  open -= read;
-
305  total += read;
-
306  }
-
307  return result;
-
308 }
-
309 
-
311 template<typename T>
-
312 size_t readSamples(Stream* p_stream, T* data, int samples){
-
313  uint8_t *p_result = (uint8_t*) data;
-
314  int open = samples*sizeof(T);
-
315  int total = 0;
-
316  // copy missing data
-
317  while (open>0){
-
318  int read = p_stream->readBytes(p_result+total, open);
-
319  open -= read;
-
320  total += read;
-
321  }
-
322  // convert bytes to samples
-
323  return samples / sizeof(T);
-
324 }
-
325 
-
327 template<typename T>
-
328 size_t writeSamples(Print* p_out, T* data, int samples, int maxSamples=512){
-
329  uint8_t *p_result = (uint8_t*) data;
-
330  int open = samples*sizeof(T);
-
331  int total = 0;
-
332  // copy missing data
-
333  while (open>0){
-
334  int to_write = min(open, static_cast<int>(maxSamples*sizeof(T)));
-
335  int written = p_out->write(p_result+total, to_write );
-
336  open -= written;
-
337  total += written;
-
338  }
-
339  // convert bytes to samples
-
340  return total / sizeof(T);
-
341 }
-
342 
-
343 
-
351 inline float mapFloat(float x, float in_min, float in_max, float out_min, float out_max) {
-
352  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
-
353 }
-
354 
-
356 static const char* mime_pcm = "audio/pcm";
-
357 
-
358 
-
359 #ifndef IS_DESKTOP
-
361 inline void waitFor(HardwareSerial &out){
-
362  while(!out);
-
363 }
-
364 #endif
-
365 
-
367 inline void waitFor(bool &flag){
-
368  while(!flag);
-
369 }
-
370 
-
372 using Pins = Vector<int>;
+
294 #if defined(USE_I2S)
+
295 
+
299 enum I2SFormat {
+
300  I2S_STD_FORMAT,
+
301  I2S_LSB_FORMAT,
+
302  I2S_MSB_FORMAT,
+
303  I2S_PHILIPS_FORMAT,
+
304  I2S_RIGHT_JUSTIFIED_FORMAT,
+
305  I2S_LEFT_JUSTIFIED_FORMAT,
+
306  I2S_PCM,
+
307 };
+
308 
+
309 INLINE_VAR const char* i2s_formats[] = {"I2S_STD_FORMAT","I2S_LSB_FORMAT","I2S_MSB_FORMAT","I2S_PHILIPS_FORMAT","I2S_RIGHT_JUSTIFIED_FORMAT","I2S_LEFT_JUSTIFIED_FORMAT","I2S_PCM"};
+
310 
+
311 #endif
+
312 
+
314 template<typename T>
+
315 T readSample(Stream* p_stream){
+
316  T result=0;
+
317  uint8_t *p_result = (uint8_t*) &result;
+
318  int open = sizeof(T);
+
319  int total = 0;
+
320  // copy missing data
+
321  while (open>0){
+
322  int read = p_stream->readBytes(p_result+total, open);
+
323  open -= read;
+
324  total += read;
+
325  }
+
326  return result;
+
327 }
+
328 
+
330 template<typename T>
+
331 size_t readSamples(Stream* p_stream, T* data, int samples){
+
332  uint8_t *p_result = (uint8_t*) data;
+
333  int open = samples*sizeof(T);
+
334  int total = 0;
+
335  // copy missing data
+
336  while (open>0){
+
337  int read = p_stream->readBytes(p_result+total, open);
+
338  open -= read;
+
339  total += read;
+
340  }
+
341  // convert bytes to samples
+
342  return samples / sizeof(T);
+
343 }
+
344 
+
346 template<typename T>
+
347 size_t writeSamples(Print* p_out, T* data, int samples, int maxSamples=512){
+
348  uint8_t *p_result = (uint8_t*) data;
+
349  int open = samples*sizeof(T);
+
350  int total = 0;
+
351  // copy missing data
+
352  while (open>0){
+
353  int to_write = min(open, static_cast<int>(maxSamples*sizeof(T)));
+
354  int written = p_out->write(p_result+total, to_write );
+
355  open -= written;
+
356  total += written;
+
357  }
+
358  // convert bytes to samples
+
359  return total / sizeof(T);
+
360 }
+
361 
+
362 
+
370 inline float mapFloat(float x, float in_min, float in_max, float out_min, float out_max) {
+
371  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
+
372 }
373 
-
374 
-
375 }
+
375 static const char* mime_pcm = "audio/pcm";
+
376 
+
377 
+
378 #ifndef IS_DESKTOP
+
380 inline void waitFor(HardwareSerial &out){
+
381  while(!out);
+
382 }
+
383 #endif
+
384 
+
386 inline void waitFor(bool &flag){
+
387  while(!flag);
+
388 }
+
389 
+
391 using Pins = Vector<int>;
+
392 
+
393 
+
394 }
audio_tools::AudioInfoSource
Supports the subscription to audio change notifications.
Definition: AudioTypes.h:135
audio_tools::AudioInfoSupport
Supports changes to the sampling rate, bits and channels.
Definition: AudioTypes.h:116
audio_tools::AudioTime
Tools for calculating timer values.
Definition: AudioTypes.h:174
@@ -395,17 +411,18 @@
audio_tools::int24_4bytes_t::scale16
int16_t scale16() const
provides value between -32767 and 32767
Definition: Int24_4bytes_t.h:110
audio_tools::int24_4bytes_t::scaleFloat
float scaleFloat() const
provides value between -1.0 and 1.0
Definition: Int24_4bytes_t.h:120
audio_tools::MemoryType
MemoryType
Memory types.
Definition: AudioTypes.h:31
-
audio_tools::waitFor
void waitFor(bool &flag)
wait for flag to be active
Definition: AudioTypes.h:367
+
audio_tools::waitFor
void waitFor(bool &flag)
wait for flag to be active
Definition: AudioTypes.h:386
audio_tools::RxTxMode
RxTxMode
Audio Source (TX_MODE) or Audio Sink (RX_MODE). RXTX_MODE is Source and Sink at the same time!
Definition: AudioTypes.h:24
audio_tools::TimeUnit
TimeUnit
Time Units.
Definition: AudioTypes.h:41
audio_tools
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition: AnalogAudio.h:10
-
audio_tools::readSamples
size_t readSamples(Stream *p_stream, T *data, int samples)
guaranteed to return the requested data
Definition: AudioTypes.h:312
-
audio_tools::mapFloat
float mapFloat(float x, float in_min, float in_max, float out_min, float out_max)
Similar to Arduino map function but using floats.
Definition: AudioTypes.h:351
-
audio_tools::mime_pcm
static const char * mime_pcm
Mime type for PCM.
Definition: AudioTypes.h:356
-
audio_tools::readSample
T readSample(Stream *p_stream)
guaranteed to return the requested data
Definition: AudioTypes.h:296
+
audio_tools::readSamples
size_t readSamples(Stream *p_stream, T *data, int samples)
guaranteed to return the requested data
Definition: AudioTypes.h:331
+
audio_tools::mapFloat
float mapFloat(float x, float in_min, float in_max, float out_min, float out_max)
Similar to Arduino map function but using floats.
Definition: AudioTypes.h:370
+
audio_tools::mime_pcm
static const char * mime_pcm
Mime type for PCM.
Definition: AudioTypes.h:375
+
audio_tools::readSample
T readSample(Stream *p_stream)
guaranteed to return the requested data
Definition: AudioTypes.h:315
audio_tools::millis
uint64_t millis()
Returns the milliseconds since the start.
Definition: Millis.h:17
+
audio_tools::I2SFormat
I2SFormat
I2S Formats.
Definition: AudioTypes.h:299
audio_tools::RxTxModeNames
INLINE_VAR const char * RxTxModeNames[]
Text string (description) for RxTxMode.
Definition: AudioTypes.h:36
-
audio_tools::writeSamples
size_t writeSamples(Print *p_out, T *data, int samples, int maxSamples=512)
guaranteed to return the requested data
Definition: AudioTypes.h:328
+
audio_tools::writeSamples
size_t writeSamples(Print *p_out, T *data, int samples, int maxSamples=512)
guaranteed to return the requested data
Definition: AudioTypes.h:347
audio_tools::AudioInfo
Basic Audio information which drives e.g. I2S.
Definition: AudioTypes.h:48
audio_tools::AudioInfo::copyFrom
void copyFrom(AudioInfo info)
Same as set.
Definition: AudioTypes.h:83
audio_tools::AudioInfo::channels
int channels
Number of channels: 2=stereo, 1=mono.
Definition: AudioTypes.h:106
diff --git a/_codec_float_8h_source.html b/_codec_float_8h_source.html index 0d73e26084..c8ef0dffe8 100644 --- a/_codec_float_8h_source.html +++ b/_codec_float_8h_source.html @@ -231,7 +231,7 @@
audio_tools::EncoderFloat::setAudioInfo
virtual void setAudioInfo(AudioInfo from) override
We actually do nothing with this.
Definition: CodecFloat.h:135
audio_tools::Print
Definition: NoArduino.h:58
audio_tools
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition: AnalogAudio.h:10
-
audio_tools::mime_pcm
static const char * mime_pcm
Mime type for PCM.
Definition: AudioTypes.h:356
+
audio_tools::mime_pcm
static const char * mime_pcm
Mime type for PCM.
Definition: AudioTypes.h:375
audio_tools::AudioInfo
Basic Audio information which drives e.g. I2S.
Definition: AudioTypes.h:48
diff --git a/_container_ogg_8h_source.html b/_container_ogg_8h_source.html index 29381a333c..96e7e5d599 100644 --- a/_container_ogg_8h_source.html +++ b/_container_ogg_8h_source.html @@ -480,7 +480,7 @@
audio_tools::Print
Definition: NoArduino.h:58
audio_tools::RingBuffer::availableForWrite
virtual int availableForWrite()
provides the number of entries that are available to write
Definition: Buffers.h:358
audio_tools
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition: AnalogAudio.h:10
-
audio_tools::mime_pcm
static const char * mime_pcm
Mime type for PCM.
Definition: AudioTypes.h:356
+
audio_tools::mime_pcm
static const char * mime_pcm
Mime type for PCM.
Definition: AudioTypes.h:375
audio_tools::AudioInfo
Basic Audio information which drives e.g. I2S.
Definition: AudioTypes.h:48
audio_tools::AudioInfo::channels
int channels
Number of channels: 2=stereo, 1=mono.
Definition: AudioTypes.h:106
audio_tools::AudioInfo::bits_per_sample
int bits_per_sample
Number of bits per sample (int16_t = 16 bits)
Definition: AudioTypes.h:108
diff --git a/_f_f_t_display_8h_source.html b/_f_f_t_display_8h_source.html index 4767a43e4e..386a71d025 100644 --- a/_f_f_t_display_8h_source.html +++ b/_f_f_t_display_8h_source.html @@ -154,7 +154,7 @@
audio_tools::FFTDisplay::getMagnitude
float getMagnitude(int x)
Definition: FFTDisplay.h:45
audio_tools::Vector< float >
audio_tools
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition: AnalogAudio.h:10
-
audio_tools::mapFloat
float mapFloat(float x, float in_min, float in_max, float out_min, float out_max)
Similar to Arduino map function but using floats.
Definition: AudioTypes.h:351
+
audio_tools::mapFloat
float mapFloat(float x, float in_min, float in_max, float out_min, float out_max)
Similar to Arduino map function but using floats.
Definition: AudioTypes.h:370
audio_tools::AudioFFTConfig
Configuration for AudioFFT. If there are more then 1 channel the channel_used is defining which chann...
Definition: AudioFFT.h:43
audio_tools::AudioFFTConfig::callback
void(* callback)(AudioFFTBase &fft)
Callback method which is called after we got a new result.
Definition: AudioFFT.h:50
diff --git a/_i2_s_config_8h_source.html b/_i2_s_config_8h_source.html index 71a1aa2086..412ea698f4 100644 --- a/_i2_s_config_8h_source.html +++ b/_i2_s_config_8h_source.html @@ -73,170 +73,23 @@
2 #include "AudioConfig.h"
3 #ifdef USE_I2S
4 
-
5 #ifndef PIN_I2S_MCK
-
6 # define PIN_I2S_MCK -1
-
7 #endif
-
8 
-
9 #if defined(ESP32) && ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0 , 0)
-
10 # include "driver/i2s.h"
-
11 #endif
-
12 
-
13 #if defined(STM32) || defined(ARDUINO_ARCH_RP2040) || defined(USE_NANO33BLE)
-
14 # define I2S_BUFFER_SIZE_ONLY
-
15 #endif
-
16 
-
17 namespace audio_tools {
-
18 
+
5 
+
6 namespace audio_tools {
+
7 
+
8 }
+
9 
+
10 #if defined(ESP32)
+
11 # if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0 , 0)
+
12 # include "I2SConfigESP32.h"
+
13 # else
+
14 # include "I2SConfigESP32V1.h"
+
15 # endif
+
16 #else
+
17 # include "I2SConfigStd.h"
+
18 #endif
19 
-
23 enum I2SFormat {
-
24  I2S_STD_FORMAT,
-
25  I2S_LSB_FORMAT,
-
26  I2S_MSB_FORMAT,
-
27  I2S_PHILIPS_FORMAT,
-
28  I2S_RIGHT_JUSTIFIED_FORMAT,
-
29  I2S_LEFT_JUSTIFIED_FORMAT,
-
30  I2S_PCM,
-
31 };
-
32 
-
36 enum I2SSignalType {
-
37  Digital,
-
38  Analog,
-
39  PDM,
-
40  TDM
-
41 };
-
42 
-
43 INLINE_VAR const char* i2s_formats[] = {"I2S_STD_FORMAT","I2S_LSB_FORMAT","I2S_MSB_FORMAT","I2S_PHILIPS_FORMAT","I2S_RIGHT_JUSTIFIED_FORMAT","I2S_LEFT_JUSTIFIED_FORMAT","I2S_PCM"};
-
44 INLINE_VAR const char* i2s_signal_types[] = {"Digital","Analog","PDM","TDM"};
-
45 
-
46 
-
52 class I2SConfig : public AudioInfo {
-
53  public:
-
54 
-
55  I2SConfig() {
-
56  channels = DEFAULT_CHANNELS;
-
57  sample_rate = DEFAULT_SAMPLE_RATE;
-
58  bits_per_sample = DEFAULT_BITS_PER_SAMPLE;
-
59  }
-
60 
-
62  I2SConfig(const I2SConfig &cfg) = default;
-
63 
-
65  I2SConfig(RxTxMode mode) {
-
66  channels = DEFAULT_CHANNELS;
-
67  sample_rate = DEFAULT_SAMPLE_RATE;
-
68  bits_per_sample = DEFAULT_BITS_PER_SAMPLE;
-
69  rx_tx_mode = mode;
-
70  switch(mode){
-
71  case RX_MODE:
-
72  pin_data = PIN_I2S_DATA_IN;
-
73  #ifdef ESP32
-
74  auto_clear = false;
-
75  #endif
-
76  break;
-
77  case TX_MODE:
-
78  pin_data = PIN_I2S_DATA_OUT;
-
79  #ifdef ESP32
-
80  auto_clear = I2S_AUTO_CLEAR;
-
81  #endif
-
82  break;
-
83  default:
-
84  #ifdef ESP32
-
85  auto_clear = I2S_AUTO_CLEAR;
-
86  #endif
-
87  pin_data = PIN_I2S_DATA_OUT;
-
88  pin_data_rx = PIN_I2S_DATA_IN;
-
89  break;
-
90  }
-
91  }
-
92 
-
94  RxTxMode rx_tx_mode = TX_MODE;
-
95  bool is_master = true;
-
96  int port_no = 0; // processor dependent port
-
97  int pin_ws = PIN_I2S_WS;
-
98  int pin_bck = PIN_I2S_BCK;
-
99  int pin_data; // rx or tx pin dependent on mode: tx pin for RXTX_MODE
-
100  int pin_data_rx; // rx pin for RXTX_MODE
-
101  int pin_mck = PIN_I2S_MCK;
-
102  I2SFormat i2s_format = I2S_STD_FORMAT;
-
103 
-
104 #if defined(I2S_BUFFER_SIZE_ONLY)
-
105  int buffer_count = I2S_BUFFER_COUNT;
-
106  int buffer_size = I2S_BUFFER_SIZE;
-
107 #elif defined(ESP32)
-
108 #if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0 , 0)
-
109  int channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT;
-
110 #endif
-
111  int buffer_count = I2S_BUFFER_COUNT;
-
112  int buffer_size = I2S_BUFFER_SIZE;
-
113  I2SSignalType signal_type = Digital; // e.g. the ESP32 supports analog input or output or PDM picrophones
-
114  bool auto_clear = I2S_AUTO_CLEAR;
-
115  bool use_apll = I2S_USE_APLL;
-
116  uint32_t fixed_mclk = 0;
-
117 #endif
-
118 
-
119 #if defined(USE_ALT_PIN_SUPPORT)
-
120  bool is_arduino_pin_numbers = true;
-
121 #endif
-
122 
-
123 
-
124  void logInfo(const char* source=nullptr) {
-
125  AudioInfo::logInfo(source);
-
126  LOGI("rx/tx mode: %s", RxTxModeNames[rx_tx_mode]);
-
127  LOGI("port_no: %d", port_no);
-
128  LOGI("is_master: %s", is_master ? "Master":"Slave");
-
129  LOGI("sample rate: %d", sample_rate);
-
130  LOGI("bits per sample: %d", bits_per_sample);
-
131  LOGI("number of channels: %d", channels);
-
132 #ifdef ESP32
-
133  LOGI("signal_type: %s", i2s_signal_types[signal_type]);
-
134  if (signal_type==Digital){
-
135  LOGI("i2s_format: %s", i2s_formats[i2s_format]);
-
136  }
-
137  LOGI("auto_clear: %s",auto_clear? "true" : "false");
-
138  if (use_apll) {
-
139  LOGI("use_apll: %s", use_apll ? "true" : "false");
-
140  }
-
141  if (fixed_mclk){
-
142  LOGI("fixed_mclk: %d", (int) fixed_mclk);
-
143  }
-
144  LOGI("buffer_count:%d",buffer_count);
-
145  LOGI("buffer_size:%d",buffer_size);
-
146 
-
147 #endif
-
148 #if defined(I2S_BUFFER_SIZE_ONLY)
-
149  LOGI("buffer_count:%d",buffer_count);
-
150  LOGI("buffer_size:%d",buffer_size);
-
151 #endif
-
152  if (pin_mck!=-1)
-
153  LOGI("pin_mck: %d", pin_mck);
-
154  if (pin_bck!=-1)
-
155  LOGI("pin_bck: %d", pin_bck);
-
156  if (pin_ws!=-1)
-
157  LOGI("pin_ws: %d", pin_ws);
-
158  if (pin_data!=-1)
-
159  LOGI("pin_data: %d", pin_data);
-
160  if (pin_data_rx!=-1 && rx_tx_mode==RXTX_MODE){
-
161  LOGI("pin_data_rx: %d", pin_data_rx);
-
162  }
-
163  }
-
164 
-
165 };
-
166 
-
167 }
-
168 
-
169 #endif
-
audio_tools::I2SConfig
configuration for all common i2s settings
Definition: I2SConfig.h:52
-
audio_tools::I2SConfig::I2SConfig
I2SConfig(const I2SConfig &cfg)=default
Default Copy Constructor.
-
audio_tools::I2SConfig::rx_tx_mode
RxTxMode rx_tx_mode
public settings
Definition: I2SConfig.h:94
-
audio_tools::I2SConfig::I2SConfig
I2SConfig(RxTxMode mode)
Constructor.
Definition: I2SConfig.h:65
-
audio_tools::RxTxMode
RxTxMode
Audio Source (TX_MODE) or Audio Sink (RX_MODE). RXTX_MODE is Source and Sink at the same time!
Definition: AudioTypes.h:24
+
20 #endif
audio_tools
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition: AnalogAudio.h:10
-
audio_tools::I2SSignalType
I2SSignalType
I2S Signal Types: Digital, Analog, PDM.
Definition: I2SConfig.h:36
-
audio_tools::I2SFormat
I2SFormat
I2S Formats.
Definition: I2SConfig.h:23
-
audio_tools::RxTxModeNames
INLINE_VAR const char * RxTxModeNames[]
Text string (description) for RxTxMode.
Definition: AudioTypes.h:36
-
audio_tools::AudioInfo
Basic Audio information which drives e.g. I2S.
Definition: AudioTypes.h:48
-
audio_tools::AudioInfo::channels
int channels
Number of channels: 2=stereo, 1=mono.
Definition: AudioTypes.h:106
-
audio_tools::AudioInfo::bits_per_sample
int bits_per_sample
Number of bits per sample (int16_t = 16 bits)
Definition: AudioTypes.h:108
-
audio_tools::AudioInfo::sample_rate
int sample_rate
Sample Rate: e.g 44100.
Definition: AudioTypes.h:104