Navigation

    M5Stack Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. pickmonster
    P
    • Continue chat with pickmonster
    • Start new chat with pickmonster
    • Flag Profile
    • Profile
    • Following
    • Followers
    • Blocks
    • Topics
    • Posts
    • Best
    • Groups
    Save
    Saving

    pickmonster

    @pickmonster

    0
    Reputation
    3
    Posts
    92
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    pickmonster Follow

    Posts made by pickmonster

    • M5Core2 play wav audio failed by use M5.Speaker class

      Hardware: M5Core2
      Platform:Arduino

      Q:
      I have prepared a wave format file in the TF card and want to play it through the M5.Speaker class, but the audio cannot be played normally after configuring the Speaker

      // code
      void playSpeak(File* file) {
          auto config = M5.Speaker.config();
          config.pin_data_out = 2;
          config.pin_ws =  0;
          config.sample_rate = 16000;
          config.dma_buf_len = 1024;
          config.dma_buf_count = 2;
          // config.buzzer = true;
          config.i2s_port = I2S_NUM_0;
          M5.Speaker.config(config);
          M5.Speaker.begin();
          // M5.Speaker.tone(661, 1000);
          M5.Speaker.setAllChannelVolume(255);
          M5.Speaker.setVolume(64);
          M5.Speaker.setChannelVolume(0, 255);
          // bool status = M5.Speaker.tone(2000, 1000);
          uint8_t* dataBuf = (uint8_t*)malloc(file->size());
          file->read(dataBuf, file->size());
          Serial.printf("File Content: %d", file->size());
          bool status = M5.Speaker.playWav(dataBuf, file->size(), 1, 1, true);
          if (!status) {
              Serial.println("Failed to play");
          }
          free(dataBuf);
          file->close();
          M5.Speaker.end();
          i2s_driver_uninstall(I2S_NUM_0);
      }
      

      I have opened the source official test code in the Speaker class to print the WAV file information. The port print content is as follows:

      Speech Start
      File Content: 957804[ 14851][D][Speaker_Class.cpp:772] playWav(): [wav] RIFF           : RIFF
      [ 14851][D][Speaker_Class.cpp:773] playWav(): [wav] chunk_size     : 957796
      [ 14855][D][Speaker_Class.cpp:774] playWav(): [wav] WAVEfmt        : WAVEfmt 
      [ 14862][D][Speaker_Class.cpp:775] playWav(): [wav] fmt_chunk_size : 16
      [ 14868][D][Speaker_Class.cpp:776] playWav(): [wav] audiofmt       : 1
      [ 14874][D][Speaker_Class.cpp:777] playWav(): [wav] channel        : 1
      [ 14880][D][Speaker_Class.cpp:778] playWav(): [wav] sample_rate    : 16000
      [ 14887][D][Speaker_Class.cpp:779] playWav(): [wav] byte_per_sec   : 32000
      [ 14894][D][Speaker_Class.cpp:780] playWav(): [wav] block_size     : 2
      [ 14900][D][Speaker_Class.cpp:781] playWav(): [wav] bit_per_sample : 16
      Speech end
      

      To solve this problem, I tried the following:

      1. Test whether the hardware power amplifier is available. I tested the power amplifier through the official tone function to make sound normally.
      2. Read and learn I2S-related knowledge, and understand the basic principles
      3. Check the ESP32 I2S related instructions on the Internet

      But I didn't solve my problem, hope anyone can help me to find out where is the problem. Thank you so much!

      posted in Global Communities
      P
      pickmonster
    • 【M5Stack 提问】Ardunio框架使用M5.Speaker类播放wav音频文件问题

      硬件型号:M5Core2
      代码框架:Ardunio
      问题:
      我在TF卡中准备了一个wav格式的文件,想通过M5.Speaker类进行播放,但在配置Speaker后无法正常播放音频

      // 我的代码
      void playSpeak(File* file) {
          auto config = M5.Speaker.config();
          config.pin_data_out = 2;
          config.pin_ws =  0;
          config.sample_rate = 16000;
          config.dma_buf_len = 1024;
          config.dma_buf_count = 2;
          // config.buzzer = true;
          config.i2s_port = I2S_NUM_0;
          M5.Speaker.config(config);
          M5.Speaker.begin();
          // M5.Speaker.tone(661, 1000);
          M5.Speaker.setAllChannelVolume(255);
          M5.Speaker.setVolume(64);
          M5.Speaker.setChannelVolume(0, 255);
          // bool status = M5.Speaker.tone(2000, 1000);
          uint8_t* dataBuf = (uint8_t*)malloc(file->size());
          file->read(dataBuf, file->size());
          Serial.printf("File Content: %d", file->size());
          bool status = M5.Speaker.playWav(dataBuf, file->size(), 1, 1, true);
          if (!status) {
              Serial.println("Failed to play");
          }
          free(dataBuf);
          file->close();
          M5.Speaker.end();
          i2s_driver_uninstall(I2S_NUM_0);
      }
      

      我开放了Speaker类中源官方测试代码,用来打印wav文件信息,端口打印内容如下:

      Speech Start
      File Content: 957804[ 14851][D][Speaker_Class.cpp:772] playWav(): [wav] RIFF           : RIFF
      [ 14851][D][Speaker_Class.cpp:773] playWav(): [wav] chunk_size     : 957796
      [ 14855][D][Speaker_Class.cpp:774] playWav(): [wav] WAVEfmt        : WAVEfmt 
      [ 14862][D][Speaker_Class.cpp:775] playWav(): [wav] fmt_chunk_size : 16
      [ 14868][D][Speaker_Class.cpp:776] playWav(): [wav] audiofmt       : 1
      [ 14874][D][Speaker_Class.cpp:777] playWav(): [wav] channel        : 1
      [ 14880][D][Speaker_Class.cpp:778] playWav(): [wav] sample_rate    : 16000
      [ 14887][D][Speaker_Class.cpp:779] playWav(): [wav] byte_per_sec   : 32000
      [ 14894][D][Speaker_Class.cpp:780] playWav(): [wav] block_size     : 2
      [ 14900][D][Speaker_Class.cpp:781] playWav(): [wav] bit_per_sample : 16
      Speech end
      

      为解决该问题,我做了如下尝试:

      1. 测试硬件功放是否可用,我通过官方tone函数测试功放可以正常发出声音
      2. 阅读学习I2S相关知识,了解了基础原理
      3. 在网上查阅了ESP32 I2S相关使用指引

      但我并没有解决我的问题,希望有人可以帮我看看是哪里的问题?非常感谢!

      posted in 提问专区
      P
      pickmonster
    • M5StackCore2 Bluetouch have cache?

      Q1:
      I tried to create a ble-server, At the first time I set the service uuid a value, and the next time I set another uuid value, but there show also old value.
      Q2:
      I tried esp32 ble-server to blue-touch connect, but I found a question When I perform a Bluetooth connection, 3 services are created, but only one is available.

      Example Code Link:https://github.com/espressif/arduino-esp32/blob/master/libraries/BLE/examples/BLE_server/BLE_server.ino

      posted in Arduino
      P
      pickmonster