Arduino AudioKit HAL
AudioKitHAL.h
1 /**
2  * @file AudioKit.h
3  * @author Phil Schatzmann
4  * @brief Arduino API for AudioKit
5  * @version 0.1
6  * @date 2021-12-12
7  *
8  * @copyright Copyright (c) 2021
9  *
10  */
11 #pragma once
12 #include "AudioKitSettings.h"
13 
14 // include drivers
15 #include "audio_hal/driver/es7148/es7148.h"
16 #include "audio_hal/driver/es7210/es7210.h"
17 #include "audio_hal/driver/es7243/es7243.h"
18 #include "audio_hal/driver/es8311/es8311.h"
19 #include "audio_hal/driver/es8374/es8374.h"
20 #include "audio_hal/driver/es8388/es8388.h"
21 #include "audio_hal/driver/tas5805m/tas5805m.h"
22 #include "audio_hal/audiokit_board.h"
23 #include "audio_hal/audiokit_logger.h"
24 #include "SPI.h"
25 
26 #ifdef ESP32
27 #include "esp_a2dp_api.h"
28 #include "audio_hal/audio_system.h"
29 #include "audio_hal/audio_version.h"
30 #include "driver/i2s.h"
31 #include "audio_hal/audio_type_def.h"
32 
33 #endif
34 
35 // Support for old IDF versions
36 #if ESP_IDF_VERSION_MAJOR < 4 && !defined(I2S_COMM_FORMAT_STAND_I2S)
37 #define I2S_COMM_FORMAT_STAND_I2S \
38  (I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB)
39 #define I2S_COMM_FORMAT_STAND_MSB \
40  (I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_LSB)
41 #define I2S_COMM_FORMAT_STAND_PCM_LONG \
42  (I2S_COMM_FORMAT_PCM | I2S_COMM_FORMAT_PCM_LONG)
43 #define I2S_COMM_FORMAT_STAND_PCM_SHORT \
44  (I2S_COMM_FORMAT_PCM | I2S_COMM_FORMAT_PCM_SHORT)
45 typedef int eps32_i2s_audio_sample_rate_type;
46 #else
47 typedef uint32_t eps32_i2s_audio_sample_rate_type;
48 #endif
49 
50 class AudioKit;
51 class AudioKit* selfAudioKit = nullptr;
52 
53 /**
54  * @brief Configuation for AudioKit
55  *
56  */
58  i2s_port_t i2s_num = (i2s_port_t)0;
59  gpio_num_t mclk_gpio = (gpio_num_t)0;
60  bool sd_active = false;
61 
62  audio_hal_adc_input_t adc_input = AUDIOKIT_DEFAULT_INPUT; /*!< set adc channel with audio_hal_adc_input_t*/
63  audio_hal_dac_output_t dac_output =AUDIOKIT_DEFAULT_OUTPUT; /*!< set dac channel */
64  audio_hal_codec_mode_t codec_mode; /*!< select codec mode: adc, dac or both */
65  audio_hal_iface_mode_t master_slave_mode = AUDIOKIT_DEFAULT_MASTER_SLAVE; /*!< audio codec chip mode */
66  audio_hal_iface_format_t fmt = AUDIOKIT_DEFAULT_I2S_FMT; /*!< I2S interface format */
67  audio_hal_iface_samples_t sample_rate = AUDIOKIT_DEFAULT_RATE; /*!< I2S interface samples per second */
68  audio_hal_iface_bits_t bits_per_sample = AUDIOKIT_DEFAULT_BITSIZE; /*!< i2s interface number of bits per sample */
69 
70  /// Returns true if the CODEC is the master
71  bool isMaster() { return master_slave_mode == AUDIO_HAL_MODE_MASTER; }
72 
73  /// provides the bits per sample
74  int bitsPerSample() {
75  switch (bits_per_sample) {
76  case AUDIO_HAL_BIT_LENGTH_16BITS:
77  return 16;
78  case AUDIO_HAL_BIT_LENGTH_24BITS:
79  return 24;
80  case AUDIO_HAL_BIT_LENGTH_32BITS:
81  return 32;
82  }
83  // KIT_LOGE("bits_per_sample not supported: %d", bits_per_sample);
84  return 0;
85  }
86 
87  /// Provides the sample rate in samples per second
88  uint32_t sampleRate() {
89  switch (sample_rate) {
90  case AUDIO_HAL_08K_SAMPLES: /*!< set to 8k samples per second */
91  return 8000;
92  case AUDIO_HAL_11K_SAMPLES: /*!< set to 11.025k samples per second */
93  return 11000;
94  case AUDIO_HAL_16K_SAMPLES: /*!< set to 16k samples in per second */
95  return 16000;
96  case AUDIO_HAL_22K_SAMPLES: /*!< set to 22.050k samples per second */
97  return 22000;
98  case AUDIO_HAL_24K_SAMPLES: /*!< set to 24k samples in per second */
99  return 24000;
100  case AUDIO_HAL_32K_SAMPLES: /*!< set to 32k samples in per second */
101  return 32000;
102  case AUDIO_HAL_44K_SAMPLES: /*!< set to 44.1k samples per second */
103  return 44000;
104  case AUDIO_HAL_48K_SAMPLES: /*!< set to 48k samples per second */
105  return 48000;
106  }
107  // KIT_LOGE("sample rate not supported: %d", sample_rate);
108  return 0;
109  }
110 
111 #ifdef ESP32
112  /// Provides the ESP32 i2s_config_t to configure I2S
113  i2s_config_t i2sConfig() {
114  // use just the oposite of the CODEC setting
115  const i2s_config_t i2s_config = {
116  .mode = i2sMode(),
117  .sample_rate = sampleRate(),
118  .bits_per_sample = (i2s_bits_per_sample_t)bitsPerSample(),
119  .channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
120  .communication_format = (i2s_comm_format_t)i2sFormat(),
121  .intr_alloc_flags = ESP_INTR_FLAG_LEVEL2 | ESP_INTR_FLAG_IRAM,
122  .dma_buf_count = 3,
123  .dma_buf_len = 320,
124  .use_apll = true,
125  .tx_desc_auto_clear = true,
126  // #if ESP_IDF_VERSION_MAJOR >= 4
127  // .fixed_mclk = 2000000,
128  // #endif
129  };
130  return i2s_config;
131  }
132 
133  /// Provides the ESP32 i2s_pin_config_t to configure the pins for I2S
134  i2s_pin_config_t i2sPins() {
135  i2s_pin_config_t result;
136  get_i2s_pins(i2s_num, &result);
137  #if ESP_IDF_VERSION_MAJOR >= 4
138  result.mck_io_num = I2S_PIN_NO_CHANGE; //mclk_gpio;
139  #endif
140  return result;
141  }
142 
143  protected:
144  i2s_comm_format_t i2sFormat(){
145  i2s_comm_format_t its_com_fmt = (i2s_comm_format_t) I2S_COMM_FORMAT_STAND_I2S;
146  if (fmt==AUDIO_HAL_I2S_LEFT){
147  its_com_fmt = (i2s_comm_format_t) I2S_COMM_FORMAT_STAND_MSB;
148  } else if(fmt==AUDIO_HAL_I2S_RIGHT){
149  its_com_fmt = (i2s_comm_format_t) I2S_COMM_FORMAT_STAND_MSB;
150  } else if(fmt==AUDIO_HAL_I2S_DSP){
151  its_com_fmt = (i2s_comm_format_t )I2S_COMM_FORMAT_STAND_PCM_SHORT;
152  }
153  return its_com_fmt;
154  }
155 
156  i2s_mode_t i2sMode() {
157  int mode = isMaster() ? I2S_MODE_SLAVE : I2S_MODE_MASTER;
158  // using ESP32 dac/adc
159  if (fmt == AUDIO_HAL_I2S_DSP){
160  if (codec_mode == AUDIO_HAL_CODEC_MODE_DECODE) {
161  mode = mode | I2S_MODE_TX | I2S_MODE_DAC_BUILT_IN;
162  } else if (codec_mode == AUDIO_HAL_CODEC_MODE_ENCODE) {
163  mode = mode | I2S_MODE_RX | I2S_MODE_ADC_BUILT_IN;
164  } else if (codec_mode == AUDIO_HAL_CODEC_MODE_BOTH) {
165  mode = mode | I2S_MODE_RX | I2S_MODE_TX | I2S_MODE_ADC_BUILT_IN | I2S_MODE_DAC_BUILT_IN;
166  }
167  } else {
168  // I2S
169  if (codec_mode == AUDIO_HAL_CODEC_MODE_DECODE) {
170  mode = mode | I2S_MODE_TX;
171  } else if (codec_mode == AUDIO_HAL_CODEC_MODE_ENCODE) {
172  mode = mode | I2S_MODE_RX;
173  } else if (codec_mode == AUDIO_HAL_CODEC_MODE_BOTH) {
174  mode = mode | I2S_MODE_RX | I2S_MODE_TX;
175  }
176  }
177  return (i2s_mode_t) mode;
178  }
179 
180 #endif
181 };
182 
183 /**
184  * @brief Do we read or write audio data - or both
185  *
186  */
187 enum AudioKitInOut {AudioOutput, AudioInput, AudioInputOutput };
188 
189 /**
190  * @brief AudioKit API using the audio_hal
191  *
192  */
193 
194 class AudioKit {
195 
196  public:
197  AudioKit() {
198  // setup SPI for SD drives
199  selfAudioKit = this;
200  setupSPI();
201  }
202 
203  /// Provides the default configuration for input or output
204  AudioKitConfig defaultConfig(AudioKitInOut inout=AudioInputOutput) {
205  AudioKitConfig result;
206  switch(inout){
207  case AudioOutput:
208  result.codec_mode = AUDIO_HAL_CODEC_MODE_DECODE; // dac
209  case AudioInput:
210  result.codec_mode = AUDIO_HAL_CODEC_MODE_ENCODE; // adc
211  default:
212  result.codec_mode = AUDIO_HAL_CODEC_MODE_BOTH;
213  }
214  return result;
215  }
216 
217  /// Starts the codec
218  bool begin(AudioKitConfig cnfg) {
219  KIT_LOGI(LOG_METHOD);
220  cfg = cnfg;
221  KIT_LOGI("Selected board: %d", AUDIOKIT_BOARD);
222 
223  // setup headphone if necessary
225 
226  audio_hal_conf.adc_input = cfg.adc_input;
227  audio_hal_conf.dac_output = cfg.dac_output;
228  audio_hal_conf.codec_mode = cfg.codec_mode;
229  audio_hal_conf.i2s_iface.mode = cfg.master_slave_mode;
230  audio_hal_conf.i2s_iface.fmt = cfg.fmt;
231  audio_hal_conf.i2s_iface.samples = cfg.sample_rate;
232  audio_hal_conf.i2s_iface.bits = cfg.bits_per_sample;
233 
234  // init HAL
235  if (hal_handle == 0) {
236  hal_handle = audio_hal_init(&audio_hal_conf, &AUDIO_DRIVER);
237  if (hal_handle == 0) {
238  KIT_LOGE("audio_hal_init");
239  return false;
240  }
241  }
242 
243 
244 #ifdef ESP32
245 
246  // setup i2s driver - with no queue
247  i2s_config_t i2s_config = cfg.i2sConfig();
248  if (i2s_driver_install(cfg.i2s_num, &i2s_config, 0, NULL) != ESP_OK) {
249  KIT_LOGE("i2s_driver_install");
250  return false;
251  }
252 
253  // define i2s pins
254  i2s_pin_config_t pin_config = cfg.i2sPins();
255  KIT_LOGI("i2s_set_pin");
256  if (i2s_set_pin(cfg.i2s_num, &pin_config) != ESP_OK) {
257  KIT_LOGE("i2s_set_pin");
258  return false;
259  }
260 
261 //#if ESP_IDF_VERSION_MAJOR < 4
262  if (i2s_mclk_gpio_select(cfg.i2s_num, cfg.mclk_gpio) != ESP_OK) {
263  KIT_LOGE("i2s_mclk_gpio_select");
264  return false;
265  }
266 //#endif
267 
268 #endif
269 
270  // call start
271  if (!setActive(true)) {
272  KIT_LOGE("setActive");
273  return false;
274  }
275 
276  return true;
277  }
278 
279  /// Stops the CODEC
280  bool end() {
281  KIT_LOGI(LOG_METHOD);
282 
283 #ifdef ESP32
284  // uninstall i2s driver
285  i2s_driver_uninstall(cfg.i2s_num);
286 #endif
287  // stop codec driver
288  audio_hal_ctrl_codec(hal_handle, cfg.codec_mode, AUDIO_HAL_CTRL_STOP);
289  // deinit
290  audio_hal_deinit(hal_handle);
291  return true;
292  }
293 
294  /// Provides the actual configuration
295  AudioKitConfig config() { return cfg; }
296 
297  /// Sets the codec active / inactive
298  bool setActive(bool active) {
299  return audio_hal_ctrl_codec( hal_handle, cfg.codec_mode, active ? AUDIO_HAL_CTRL_START : AUDIO_HAL_CTRL_STOP) == ESP_OK;
300  }
301 
302  /// Mutes the output
303  bool setMute(bool mute) {
304  return audio_hal_set_mute(hal_handle, mute) == ESP_OK;
305  }
306 
307  /// Defines the Volume
308  bool setVolume(int vol) {
309  return (vol > 0) ? audio_hal_set_volume(hal_handle, vol) == ESP_OK : false;
310  }
311 
312  /// Determines the volume
313  int volume() {
314  int volume;
315  if (audio_hal_get_volume(hal_handle, &volume) != ESP_OK) {
316  volume = -1;
317  }
318  return volume;
319  }
320 
321 #ifdef ESP32
322 
323  /// Writes the audio data via i2s to the DAC
324  size_t write(const void *src, size_t size,
325  TickType_t ticks_to_wait = portMAX_DELAY) {
326  KIT_LOGD("write: %zu", size);
327  size_t bytes_written = 0;
328  if (i2s_write(cfg.i2s_num, src, size, &bytes_written, ticks_to_wait) !=
329  ESP_OK) {
330  KIT_LOGE("i2s_write");
331  }
332  return bytes_written;
333  }
334 
335  /// Reads the audio data via i2s from the ADC
336  size_t read(void *dest, size_t size,
337  TickType_t ticks_to_wait = portMAX_DELAY) {
338  KIT_LOGD("read: %zu", size);
339  size_t bytes_read = 0;
340  if (i2s_read(cfg.i2s_num, dest, size, &bytes_read, ticks_to_wait) !=
341  ESP_OK) {
342  KIT_LOGE("i2s_read");
343  }
344  return bytes_read;
345  }
346 
347 #endif
348 
349  /**
350  * @brief Get the gpio number for auxin detection
351  *
352  * @return -1 non-existent
353  * Others gpio number
354  */
355  int8_t pinAuxin() { return get_auxin_detect_gpio(); }
356 
357  /**
358  * @brief Get the gpio number for headphone detection
359  *
360  * @return -1 non-existent
361  * Others gpio number
362  */
363  int8_t pinHeadphoneDetect() { return get_headphone_detect_gpio(); }
364 
365  /**
366  * @brief Get the gpio number for PA enable
367  *
368  * @return -1 non-existent
369  * Others gpio number
370  */
371  int8_t pinPaEnable() { return get_pa_enable_gpio(); }
372 
373  /**
374  * @brief Get the gpio number for adc detection
375  *
376  * @return -1 non-existent
377  * Others gpio number
378  */
379  int8_t pinAdcDetect() { return get_adc_detect_gpio(); }
380 
381  /**
382  * @brief Get the mclk gpio number of es7243
383  *
384  * @return -1 non-existent
385  * Others gpio number
386  */
387  int8_t pinEs7243Mclk() { return get_es7243_mclk_gpio(); }
388 
389  /**
390  * @brief Get the record-button id for adc-button
391  *
392  * @return -1 non-existent
393  * Others button id
394  */
395  int8_t pinInputRec() { return get_input_rec_id(); }
396 
397  /**
398  * @brief Get the number for mode-button
399  *
400  * @return -1 non-existent
401  * Others number
402  */
403  int8_t pinInputMode() { return get_input_mode_id(); }
404 
405  /**
406  * @brief Get number for set function
407  *
408  * @return -1 non-existent
409  * Others number
410  */
411  int8_t pinInputSet() { return get_input_set_id(); };
412 
413  /**
414  * @brief Get number for play function
415  *
416  * @return -1 non-existent
417  * Others number
418  */
419  int8_t pinInputPlay() { return get_input_play_id(); }
420 
421  /**
422  * @brief number for volume up function
423  *
424  * @return -1 non-existent
425  * Others number
426  */
427  int8_t pinVolumeUp() { return get_input_volup_id(); }
428 
429  /**
430  * @brief Get number for volume down function
431  *
432  * @return -1 non-existent
433  * Others number
434  */
435  int8_t pinVolumeDown() { return get_input_voldown_id(); }
436 
437  /**
438  * @brief Get green led gpio number
439  *
440  * @return -1 non-existent
441  * Others gpio number
442  */
443  int8_t pinResetCodec() { return get_reset_codec_gpio(); }
444 
445  /**
446  * @brief Get DSP reset gpio number
447  *
448  * @return -1 non-existent
449  * Others gpio number
450  */
451  int8_t pinResetBoard() { return get_reset_board_gpio(); }
452 
453  /**
454  * @brief Get DSP reset gpio number
455  *
456  * @return -1 non-existent
457  * Others gpio number
458  */
459  int8_t pinGreenLed() { return get_green_led_gpio(); }
460 
461  /**
462  * @brief Get green led gpio number
463  *
464  * @return -1 non-existent
465  * Others gpio number
466  */
467  int8_t pinBlueLed() { return get_blue_led_gpio(); }
468 
469  /**
470  * @brief SPI CS Pin for SD Drive
471  *
472  * @return int8_t
473  */
474  int8_t pinSpiCs() {
475  return spi_cs_pin;
476  }
477 
478  /**
479  * @brief Activates/deactivates the speaker amplifier output
480  * This is working only if the driver is supporting the functionality
481  * @param active
482  */
483  void setSpeakerActive(bool active) {
484  int paPin = get_pa_enable_gpio();
485  if (paPin>0){
486  digitalWrite(paPin, active);
487  } else {
488  KIT_LOGW("setSpeakerActive not supported");
489  }
490  }
491 
492  /**
493  * @brief Switch off the PA if the headphone in plugged in
494  * and switch it on again if the headphone is unplugged
495  *
496  */
497  static void actionHeadphoneDetection() {
498  if (selfAudioKit->headphonePin>0){
499 
500  // detect changes
501  bool isConnected = selfAudioKit->headphoneStatus();
502  if (selfAudioKit->headphoneIsConnected != isConnected) {
503  KIT_LOGD("actionHeadphoneDetection -> %s", isConnected ? "inserted" : "removed");
504  selfAudioKit->speakerChangeTimeout = millis()+600;
505  selfAudioKit->headphoneIsConnected = isConnected;
506  }
507 
508  // update when changes have stabilized
509  if (millis()>selfAudioKit->speakerChangeTimeout){
510  // update if things have stabilized
511  bool isConnected = selfAudioKit->headphoneStatus();
512  bool powerActive = !isConnected;
513  KIT_LOGW("Headphone jack has been %s", isConnected ? "inserted" : "removed");
514  selfAudioKit->setSpeakerActive(powerActive);
515  selfAudioKit->speakerChangeTimeout = millis()+1000*60*50*30; // 30 days
516  }
517  }
518  yield();
519  }
520 
521 
522  /**
523  * @brief Returns true if the headphone was detected
524  *
525  * @return true
526  * @return false
527  */
529  return headphonePin>0 ? !digitalRead(headphonePin) : false;
530  }
531 
532  protected:
533  AudioKitConfig cfg;
534  audio_hal_codec_config_t audio_hal_conf;
535  audio_hal_handle_t hal_handle = 0;
536  audio_hal_codec_i2s_iface_t iface;
537  int8_t spi_cs_pin;
538  bool headphoneIsConnected = false;
539  unsigned long speakerChangeTimeout = 0;
540  int8_t headphonePin = -1;
541 
542  /**
543  * @brief Setup the headphone detection
544  */
546  int8_t paPin = pinPaEnable();
547  if (paPin>0){
548  headphonePin = pinHeadphoneDetect();
549  if (headphonePin>0){
550  pinMode(headphonePin, INPUT_PULLUP);
551  pinMode(paPin, OUTPUT);
552  KIT_LOGI("headphone detection is active");
553  } else {
554  KIT_LOGI("headphone detection not supported");
555  }
556  } else {
557  KIT_LOGI("headphone detection: PA not supported");
558  }
559  }
560 
561  /**
562  * @brief Setup the SPI so that we can access the SD Drive
563  */
564  void setupSPI() {
565  KIT_LOGD(LOG_METHOD);
566 // I assume this is valid for all AudioKits!
567 #if AUDIOKIT_SETUP_SD==1
568  if (cfg.sd_active){
569  spi_cs_pin = PIN_AUDIO_KIT_SD_CARD_CS;
570  pinMode(spi_cs_pin, OUTPUT);
571  digitalWrite(spi_cs_pin, HIGH);
572 
573  SPI.begin(PIN_AUDIO_KIT_SD_CARD_CLK, PIN_AUDIO_KIT_SD_CARD_MISO, PIN_AUDIO_KIT_SD_CARD_MOSI, PIN_AUDIO_KIT_SD_CARD_CS);
574  KIT_LOGW("setupSPI for SD");
575  }
576 #else
577  #warning "SPI initialization for the SD drive not supported - you might need to take care of this yourself"
578 #endif
579  }
580 
581 
582 
583 };
AUDIOKIT_BOARD selects a specic board: 1) lyrat_v4_3 2) lyrat_v4_2 3) lyrat_mini_v1_1 4) esp32_s2_kal...
AudioKit API using the audio_hal.
Definition: AudioKitHAL.h:194
int8_t pinHeadphoneDetect()
Get the gpio number for headphone detection.
Definition: AudioKitHAL.h:363
int8_t pinGreenLed()
Get DSP reset gpio number.
Definition: AudioKitHAL.h:459
bool headphoneStatus()
Returns true if the headphone was detected.
Definition: AudioKitHAL.h:528
int8_t pinAdcDetect()
Get the gpio number for adc detection.
Definition: AudioKitHAL.h:379
int8_t pinVolumeUp()
number for volume up function
Definition: AudioKitHAL.h:427
int8_t pinSpiCs()
SPI CS Pin for SD Drive.
Definition: AudioKitHAL.h:474
int8_t pinPaEnable()
Get the gpio number for PA enable.
Definition: AudioKitHAL.h:371
int8_t pinInputRec()
Get the record-button id for adc-button.
Definition: AudioKitHAL.h:395
bool setActive(bool active)
Sets the codec active / inactive.
Definition: AudioKitHAL.h:298
int8_t pinInputMode()
Get the number for mode-button.
Definition: AudioKitHAL.h:403
int8_t pinEs7243Mclk()
Get the mclk gpio number of es7243.
Definition: AudioKitHAL.h:387
static void actionHeadphoneDetection()
Switch off the PA if the headphone in plugged in and switch it on again if the headphone is unplugged...
Definition: AudioKitHAL.h:497
int volume()
Determines the volume.
Definition: AudioKitHAL.h:313
int8_t pinAuxin()
Get the gpio number for auxin detection.
Definition: AudioKitHAL.h:355
void setupSPI()
Setup the SPI so that we can access the SD Drive.
Definition: AudioKitHAL.h:564
bool begin(AudioKitConfig cnfg)
Starts the codec.
Definition: AudioKitHAL.h:218
bool setMute(bool mute)
Mutes the output.
Definition: AudioKitHAL.h:303
int8_t pinVolumeDown()
Get number for volume down function.
Definition: AudioKitHAL.h:435
bool end()
Stops the CODEC.
Definition: AudioKitHAL.h:280
int8_t pinResetBoard()
Get DSP reset gpio number.
Definition: AudioKitHAL.h:451
void setupHeadphoneDetection()
Setup the headphone detection.
Definition: AudioKitHAL.h:545
bool setVolume(int vol)
Defines the Volume.
Definition: AudioKitHAL.h:308
int8_t pinResetCodec()
Get green led gpio number.
Definition: AudioKitHAL.h:443
int8_t pinInputSet()
Get number for set function.
Definition: AudioKitHAL.h:411
AudioKitConfig defaultConfig(AudioKitInOut inout=AudioInputOutput)
Provides the default configuration for input or output.
Definition: AudioKitHAL.h:204
int8_t pinBlueLed()
Get green led gpio number.
Definition: AudioKitHAL.h:467
int8_t pinInputPlay()
Get number for play function.
Definition: AudioKitHAL.h:419
AudioKitConfig config()
Provides the actual configuration.
Definition: AudioKitHAL.h:295
void setSpeakerActive(bool active)
Activates/deactivates the speaker amplifier output This is working only if the driver is supporting t...
Definition: AudioKitHAL.h:483
Configuation for AudioKit.
Definition: AudioKitHAL.h:57
audio_hal_iface_bits_t bits_per_sample
Definition: AudioKitHAL.h:68
uint32_t sampleRate()
Provides the sample rate in samples per second.
Definition: AudioKitHAL.h:88
int bitsPerSample()
provides the bits per sample
Definition: AudioKitHAL.h:74
audio_hal_dac_output_t dac_output
Definition: AudioKitHAL.h:63
bool isMaster()
Returns true if the CODEC is the master.
Definition: AudioKitHAL.h:71
audio_hal_adc_input_t adc_input
Definition: AudioKitHAL.h:62
audio_hal_iface_format_t fmt
Definition: AudioKitHAL.h:66
audio_hal_iface_mode_t master_slave_mode
Definition: AudioKitHAL.h:65
audio_hal_iface_samples_t sample_rate
Definition: AudioKitHAL.h:67
audio_hal_codec_mode_t codec_mode
Definition: AudioKitHAL.h:64