Go Down

Topic: Please help! How turn wav to binary data!!! (Read 586 times) previous topic - next topic

wgq6959424

Jul 14, 2018, 08:05 am Last Edit: Jul 17, 2018, 05:47 am by wgq6959424
we kown that Arduino system don't like c language have  file system

so,i use  Sd card save my .wav file.

but  SD.h  libraries  didn't have a like c language :

f.open("music.wav","rb")   // open a stream file use in binary system
f.open("music.wav","r")  just r,w ...No rb wb


and like  fread()   etc  fread("music.wav")   // reads data from the file stream


Please help me :  open a wav file  turn it to binary data.

thanks

pert

DON'T CROSS POST!!!!!!!!!!!!!!!!!!!!
http://forum.arduino.cc/index.php?topic=558023
I HAVE REPORTED THIS THREAD TO THE MODERATORS

TolpuddleSartre

All files contain binary data - there is no need to convert anything.


wgq6959424

but, some websites need to turn wav into binary transmission and identify them.
so,i need kown how turn wav bytes by bytes to binary data

thanks a lot

Paul_KD7HB

but, some websites need to turn wav into binary transmission and identify them.
so,i need kown how turn wav bytes by bytes to binary data

thanks a lot
To stop all the confusion, please give an example of a byte from a wave file and how you think that would be in binary.

Paul

MorganS

WAV is a very specific form of compression that works well for audio data. A small WAV file holds many megabytes of audio.

The Arduino memory is just a few kilobytes. It cannot hold even 1 second of uncompressed audio. What do you want to do with that tiny piece of data?
"The problem is in the code you didn't post."

wgq6959424

WAV is a very specific form of compression that works well for audio data. A small WAV file holds many megabytes of audio.

The Arduino memory is just a few kilobytes. It cannot hold even 1 second of uncompressed audio. What do you want to do with that tiny piece of data?
thank you for  MorganS reply

 I have a project about speech recognition using Arduino.The idea is to convert the wav file(The file size is about 8K) to Base64 to facilitate server identification.

The current progress is to turn wav into binary

slippyr4

WAV is a very specific form of compression that works well for audio data. A small WAV file holds many megabytes of audio.
That's not true at all. WAV is a container format and can contain audio data in a variety of different codecs. However, most commonly, WAV is used to store uncompressed linear PCM data.

MorganS

Hmmm italic code

That will read bytes from the file. But they are meaningless without decompression.
"The problem is in the code you didn't post."

PaulS

Quote
I'm not sure if I read all the information contained in the entire wav file.
Why don't you? You know (or could, the library knows) the size of the file. You know how many bytes you read from the file. The numbers match and you've read all the data, or they don't, and you haven't.
The art of getting good answers lies in asking good questions.

pksato

#11
Jul 16, 2018, 04:32 pm Last Edit: Jul 16, 2018, 06:35 pm by pksato
Hi wgq6959424, and others,
A long time ago (1990) I managed to play wav files using a PC printer port and DAC/ADC. On the dark age on information. I get some information about .wav on magazines ans other pre internet information media.
The microsoft wave file have a 44 bytes of header, one of these bytes store the bit sample size, 8bit, 16 bits, etc.
I starting my study of Arduino, I dion't know all functions of API/ABI.
If wav file always have same format, just ignore first 44bytes and read rest of data according of know bit sample size.

PaulS

Quote
If wav file always have same format, just ignore first 44bytes and read data according of bit sample size.
If you ignore the first 44 bytes, you won't know the bit sample size, so reading the rest of the data "according of bit sample size" isn't going to work too well.
The art of getting good answers lies in asking good questions.

wgq6959424

Hi wgq6959424, and others,
A long time ago (1990) I managed to play wav files using a PC printer port and DAC/ADC. On the dark age on information. I get some information about .wav on magazines ans other pre internet information media.
The microsoft wave file have a 44 bytes of header, one of these bytes store the bit sample size, 8bit, 16 bits, etc.
I starting my study of Arduino, I dion't know all functions of API/ABI.
If wav file always have same format, just ignore first 44bytes and read data according of bit sample size.

Now it's my dark moment   (*>﹏<*)

Paul_KD7HB

Thanks Paul 
ok. the example wav file at :  http://speech-doc.gz.bcebos.com/rest-api-asr/public_audio/16k.wav


The current idea is to open the wav file and then read each byte.


File myFile = SD.open("16k.wav");

byte buffer[256];

uint16_t  bufLen=myFile.read(buffer,256);
       
      for (uint16_t i=0;i<bufLen;i++){
         
            Serial.print(buffer,HEX);

          }

        myFile.close();


I'm not sure if I read all the information contained in the entire wav file.



Ok, was what you read "binary"? By now you surely realize every byte on every file is "binary".

Paul

Go Up