Convert audio and image file to C array,Audacity,how to use bin2c

To convert audio and image file into C array we need two tools

  1. Audacity
  2. bin2c

Audacity

you can download this tool from here–>

Is Audacity is free?

Yes! It is a free tool to record audio and can playback the recorded audio, it has features to edit audio, noise cancellation  

Audacity record computer audio?

Yes! It records laptop or computer audio with the help of built-in microphone which we have in our laptop

Record audio in Audacity and convert audio file to raw file

  1. open  Audacity tool
  2. press the red button to start recording audio
  3. after recording the audio stop the recording
  4. click on file option–> Export Audio
  5. your file name.raw –>save as: other uncompressed files –>Header: Raw(header-less) –> Encoding: unsigned 8-bit Pcm–>Save–>ok
  6. view the recorded audio in the document folder –> Audacity

watch video here—>

bin2c

bin2c is a tool which will convert the raw audio file and image file into C Array

you can download this tool from here–>

how to use bin2c

  1. download bin2c and extract zip files
  2. copy and paste bin2c application on Desktop
  3. win+r and type CMD to open the command terminal
  4. type the command cd Desktop
  5. then type command bin2c
  6. copy and paste the raw file of Audacity on Desktop
  7. then type the command bin2c  -o sample.h sample.raw
  8. C array file will be formed on the Desktop

watch video here—>

convert image to C array

the process to convert image is same as audio just need to change the file name

type the command bin2c   -o sample.h sample.jpg

Example of c array generated by bin2c

const long int imx_raw_size = 14048;
const unsigned char imx_raw[14048] = {
    0x7F, 0x7F, 0x7F, 0x7F, 0x80, 0x80, 0x80, 0x80, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F,
    0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x80, 0x80, 0x7F, 0x7F,
    0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
    0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x80,
    0x80, 0x80, 0x80, 0x80, 0x7F, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x7F, 0x7F, 0x7F, 0x7F,
    0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F,
    0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x80, 0x80, 0x7F, 0x80, 0x80, 0x80, 0x80, 0x80,
    0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
    0x80, 0x80, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F,
    0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x80, 0x80, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x80, 0x80,
    0x7F, 0x7F, 0x7F, 0x7F, 0x80, 0x80,
    
};

Mohammed Anees

Hey there, welcome to aneescraftsmanship I am Mohammed Anees an independent developer/blogger. I like to share and discuss the craft with others plus the things which I have learned because I believe that through discussion and sharing a new world opens up

1 Comment

Leave a Reply

Your email address will not be published.