Skip to content

Commit

Permalink
fix spk
Browse files Browse the repository at this point in the history
  • Loading branch information
Forairaaaaa committed Jan 4, 2024
1 parent 992d6c6 commit e3e960e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ size_t I2SAudioMicrophone::read(int16_t *buf, size_t len) {
// ESP_LOGI(TAG, "rec %d", BUFFER_SIZE);


// M5.Mic.record(buf, len, 16000);
// M5.Mic.record(buf, len >> 1, 16000);
M5.Mic.record(buf, 256, 16000);
// M5.Mic.record(buf, 512, 16000);
while (M5.Mic.isRecording());
Expand Down
13 changes: 7 additions & 6 deletions components/m5cores3_audio/speaker/i2s_audio_speaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ static const char *const TAG = "m5cores3.speaker";
void I2SAudioSpeaker::setup() {
// ESP_LOGCONFIG(TAG, "Setting up I2S Audio Speaker...");
ESP_LOGI(TAG, "setup");
auto cfg = M5.Speaker.config();
cfg.task_priority = 15;
M5.Speaker.config(cfg);
M5.Speaker.begin();
M5.Speaker.setVolume(200);

Expand All @@ -28,9 +31,9 @@ void I2SAudioSpeaker::setup() {

void I2SAudioSpeaker::start() { this->state_ = speaker::STATE_STARTING; }
void I2SAudioSpeaker::start_() {
if (!this->parent_->try_lock()) {
return; // Waiting for another i2s component to return lock
}
// if (!this->parent_->try_lock()) {
// return; // Waiting for another i2s component to return lock
// }
this->state_ = speaker::STATE_RUNNING;

// xTaskCreate(I2SAudioSpeaker::player_task, "speaker_task", 8192, (void *) this, 1, &this->player_task_handle_);
Expand Down Expand Up @@ -347,7 +350,7 @@ void I2SAudioSpeaker::watch_() {
this->state_ = speaker::STATE_STOPPED;
// vTaskDelete(this->player_task_handle_);
// this->player_task_handle_ = nullptr;
this->parent_->unlock();
// this->parent_->unlock();
// xQueueReset(this->buffer_queue_);
// ESP_LOGD(TAG, "Stopped I2S Audio Speaker");
}
Expand Down Expand Up @@ -425,8 +428,6 @@ size_t I2SAudioSpeaker::play(const uint8_t *data, size_t length) {


M5.Speaker.playRaw((int16_t*)data, length / 2, 16000);


return length;
}

Expand Down
4 changes: 2 additions & 2 deletions voice-assistant/m5stack-cores3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -270,15 +270,15 @@ microphone:
m5cores3_audio_id: m5cores3_audio_1
id: m5cores3_mic
adc_type: external
i2s_din_pin: 6
i2s_din_pin: 14
pdm: false

speaker:
- platform: m5cores3_audio
m5cores3_audio_id: m5cores3_audio_1
id: m5cores3_spk
dac_type: external
i2s_dout_pin: 7
i2s_dout_pin: 13
mode: mono


Expand Down

0 comments on commit e3e960e

Please sign in to comment.