Bienvenido a los foros de FT81x Manía. Te invitamos a regístrate totalmente gratis. Disfruta de tu experiencia con un grandes amigos y Staff.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Thread Contributor: raufjayHuman Voice audio from SD card

#1
0
Hello,
I am trying to play some human voice audio files already converted in 8 bit ulaw format. What I find in AN338 is very complex process to load the audio file from SDcard and play on FT811. 

I also tried the following code, I took out from James book and modified to work with GD2UB library. The noise.gd2 file is already copied on to SD card. The code compiles alright, but when I run the code, I see the message on LCD saying I need to copy *.gd2 file onto SD card. Whereas the noise.gd2 file is already on SD card root directory.

Any easier way to play the audio file on FT811 from the SD card?

NOTE: This I am trying out on STM32 bluepill board. On this board every thing is working, including FT811 built-in Audio, piano, organ etc.

Thanks,
# include <EEPROM.h>
# include <SPI.h>
# include <GD2UB.h>
# include "noisy_assets.h"
void setup()
{
 Serial.begin(115200);
GD.begin();
LOAD_ASSETS();
}
static void saydigit(byte n)
{
uint32_t base, len;
switch (n) {
case 0: base = DIGIT_0; len = DIGIT_0_LENGTH; break;
case 1: base = DIGIT_1; len = DIGIT_1_LENGTH; break;
case 2: base = DIGIT_2; len = DIGIT_2_LENGTH; break;
case 3: base = DIGIT_3; len = DIGIT_3_LENGTH; break;
case 4: base = DIGIT_4; len = DIGIT_4_LENGTH; break;
case 5: base = DIGIT_5; len = DIGIT_5_LENGTH; break;
case 6: base = DIGIT_6; len = DIGIT_6_LENGTH; break;
case 7: base = DIGIT_7; len = DIGIT_7_LENGTH; break;
case 8: base = DIGIT_8; len = DIGIT_8_LENGTH; break;
case 9: base = DIGIT_9; len = DIGIT_9_LENGTH; break;
}
GD.sample(base, len, 8000, ADPCM_SAMPLES);
}
void loop()
{
 byte d = GD.random(10);
 Serial.println(d);
 saydigit(d);
 //GD.random(10));
 delay(1000);
}
Reply
#2
1
Better response on post RE: Human Voice audio from SD cardHello I have tried for some time to convert mp3 files with the GD3Asset tool and work fine.

The version GD3Asset was one that I modify, but only from Linux, and of course you have to put code in the program and work. If you are not in a hurry I will try out my project and test it
Reply
#3
0
# include <GD2UB.h>


# define MUSICFILE "do.raw" //mesmeriz.ima"

static Streamer stream;
File archive;
SdFat SD(2);
const uint8_t SD_CS=PB12;


void setup()
{
GD.begin();
SD.begin(SD_CS, SD_SCK_MHZ(36));
archive = SD.open("do.raw");

GD.cmd_memwrite(0,21504);
GD.load("do.raw");
stream.begin(MUSICFILE);
}

void loop()
{
GD.cmd_gradient(0, 40, 0x282830,0, 272, 0x606040);
GD.cmd_text(240, 100, 31, OPT_CENTER, MUSICFILE);
uint16_t val, range;
stream.progress(val, range);
GD.cmd_slider(30, 160, 420, 8, 0, val, range);
GD.swap();
GD.finish();
stream.feed();
}
Hello,
I tried to modify the example for loading audio file from SD and playing it. But without success. I end up with mess. This code is loading but instead of voice I get just noise.

I need some help, in loading simple audio files, converted in 8bit ulaw format. And I want to play them on FT811. I have Audio output setup already working with built-in sounds. But I  need to play human voice.

I appreciate your help.

Thanks,

Rauf
Reply
#4
1
Better response on post RE: Human Voice audio from SD cardWell another approach to solve this, it is to get each voice file into correspond wav format. 

The next step consist in to convert each wav file into ima format, through the sox utility: SoX - Sound eXchange. The last version is: 14.4.2

This utility works through the cmd console on windows. I suggest to install the sox utility in the path C:\sox
Then copy the wav file in such path, open the console and get the path, like this example:

C:\sox>sox made.wav -c 1 made.ima

-c 1 specifies mono channel
Reply
#5
0
Thank you for your reply.
I would convert the wav file into ima mono format.
How to load the file from SD and play it with FT811. I found some examples, and tried to work with them. But one way or other fails.
Thanks

I now converted my audio files from wav to ima format using sox utility. each file is around 12k to 13k. I could not figure it out how to load the file from SD card and play it with FT811.
Need your advise.
Thanks,
Reply
#6
1
Better response on post RE: Human Voice audio from SD cardI been study the streamer instruction, we can to play a one sound ima file at time only when the sketch is uploading. For upload various sound files it's more better to use an asset file.

Taking up the first approach, this is the modification in order to load the asset file from SD reader:

#include <GD2UB.h>
#include "noisy_assets.h"  //Asset0

SdFat SD(3); const uint8_t SD_CS = PA15;   //STM32F746IG: external SD reader on SPI3, with SD_CS =PA15

char Asset0[] = "noisy.gd2"; File GAsset0;  String STRAsset0(Asset0);

void setup()
{
  GD.begin();
  SD.begin(SD_CS, SD_SCK_MHZ(36));
  GAsset0 = SD.open(STRAsset0);
  LOAD_ASSETS0();
}

static void saydigit(byte n)
{
  uint32_t base, len;
  switch (n) {
    case 0: base = DIGIT_0; len = DIGIT_0_LENGTH; break;
    case 1: base = DIGIT_1; len = DIGIT_1_LENGTH; break;
    case 2: base = DIGIT_2; len = DIGIT_2_LENGTH; break;
    case 3: base = DIGIT_3; len = DIGIT_3_LENGTH; break;
    case 4: base = DIGIT_4; len = DIGIT_4_LENGTH; break;
    case 5: base = DIGIT_5; len = DIGIT_5_LENGTH; break;
    case 6: base = DIGIT_6; len = DIGIT_6_LENGTH; break;
    case 7: base = DIGIT_7; len = DIGIT_7_LENGTH; break;
    case 8: base = DIGIT_8; len = DIGIT_8_LENGTH; break;
    case 9: base = DIGIT_9; len = DIGIT_9_LENGTH; break;
  }
  GD.sample(base, len, 8000, ADPCM_SAMPLES);
}

void loop()
{
  int n = GD.random(10);

  GD.Clear();
  GD.cmd_number(240, 136, 31, OPT_CENTER, n);
  GD.swap();

  saydigit(n);
  delay(1000);
}

Content of noisy.h


#define LOAD_ASSETS0()  GD.safeloadSdFat(GAsset0);
#define DIGIT_0 0UL
#define DIGIT_0_LENGTH 3272
#define DIGIT_0_FREQ 8000
#define DIGIT_1 3272UL
#define DIGIT_1_LENGTH 2576
#define DIGIT_1_FREQ 8000
#define DIGIT_2 5848UL
#define DIGIT_2_LENGTH 2320
#define DIGIT_2_FREQ 8000
#define DIGIT_3 8168UL
#define DIGIT_3_LENGTH 2392
#define DIGIT_3_FREQ 8000
#define DIGIT_4 10560UL
#define DIGIT_4_LENGTH 2608
#define DIGIT_4_FREQ 8000
#define DIGIT_5 13168UL
#define DIGIT_5_LENGTH 2664
#define DIGIT_5_FREQ 8000
#define DIGIT_6 15832UL
#define DIGIT_6_LENGTH 2728
#define DIGIT_6_FREQ 8000
#define DIGIT_7 18560UL
#define DIGIT_7_LENGTH 3192
#define DIGIT_7_FREQ 8000
#define DIGIT_8 21752UL
#define DIGIT_8_LENGTH 2104
#define DIGIT_8_FREQ 8000
#define DIGIT_9 23856UL
#define DIGIT_9_LENGTH 2960
#define DIGIT_9_FREQ 8000
#define ASSETS0_END 26816UL
Enjoy it the numbers!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)