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