简体   繁体   中英

Convert raw sound into binary header

I found out, that you can save header as binary file and there is no difference for compiler when someone include *h file with table represented as binary values inside.

I need to save raw sound data into table for further read on microcontroller. I know how to read it and then save as text, but it is to heavy for me, cause i'll hold this data in small flash.

So could anyone tell me how can I save it as "binary" header? I'm not sure how exactly should it look so any tip or explanation could be very helpful.

regards

Rafał Kopczyński

I suppose, you need to create compile-time generated array with your binary data. I'd suggest writing a simple help program, which would read binary data and write every int32_t there is as text, comma separated. Then you can copy all the output into your original program using something like int32_t data[] = { /*copy-paste here*/ } . Probably there's better way of doing it, but this works just fine. After the copying you can reinterpret_cast this array into anything you like.

PS There are no such things as binary headers. If(and surprisingly!) some compiler allows it, this is against standard.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM