假設目的是取出一個 wav file 的前 1024 bytes 的資料,將其轉換成 C Array,指令如下:
$ wget http://wav-sounds.com/wp-content/uploads/2017/09/Answer-02.wav
$ dd skip=70 iflag=skip_bytes if=Answer-02.wav bs=1K count=1 of=./1024bytes.bin
$ xxd -i 1024bytes.bin > test.hdd 的參數說明:
skip=70 iflag=skip_bytes:
略過 70 bytes。標準的 WAVE Header 應該是44bytes,但是此檔案多加了一些header,共有70bytes。bs=1K count=1 :
轉換後的資料如下:取出 1k 的資料,並且只做一次取出的動作
unsigned char __1024bytes_bin[] = { 0xff, 0xf3, 0x38, 0xc4, 0x00, 0x00, 0x00, 0x02, 0x5b, 0x20, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x28, 0xc4, 0x5f, 0x00, 0x00, 0x02, 0x5b, 0x20, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x38, 0xc4, 0x9a, 0x00, 0x00, 0x02, 0x5b, 0x20, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xa7, 0x5e, 0x58, 0x24, 0x03, 0x42, 0xc1, 0x5c, 0x00, 0x00, 0x21, 0x61, 0xb3, 0x33, 0x33, 0xfb, 0x12, 0x01, 0xb8, 0x8e, 0xfb, 0x0b, 0x1c, 0xd6, 0xef, 0x08, 0x43, 0x3c, 0xe7, 0x39, 0xb1, 0x96, 0xbc, 0xf6, 0x0a, 0x20, 0x15, 0xb7, 0x48, 0x10, 0x64, 0xd1, 0xff, 0xf3, 0x28, 0xc4, 0xf9, 0x0d, 0x40, 0x02, 0x5b, 0x20, 0x00, 0x00, 0x00, 0xcf, 0xcd, 0x74, 0x73, 0xd8, 0x42, 0x64, 0x8c, 0x5a, 0x3d, 0x20, 0x0a, 0x12, 0x44, 0x28, 0x08, 0x0a, 0x18, 0x5c, 0x56, 0x09, 0x93, 0x94, 0x00, 0x60, 0x6c, 0x9e, 0xa1, 0x97, 0x39, 0xc3, 0x27, 0x3a, 0x40, 0x28, 0x24, 0x5c, 0x10, 0x0c, 0x31, 0x68, 0xd1, 0xa3, 0x91, 0x00, 0x26, 0x1b, 0x6e, 0x0c, 0x65, 0xce, 0x70, 0xcb, 0x9e, 0xc1, 0x03, 0x0b, 0x8a, 0x09, 0xff, 0xf3, 0x38, 0xc4, 0xff, 0x17, 0xc0, 0x02, 0x5b, 0x20, 0x00, 0x00, 0x00, 0x18, 0xb9, 0xcf, 0xd2, 0x02, 0x76, 0xea, 0x10, 0x9a, 0x34, 0x74, 0x8d, 0x1b, 0x7b, 0x05, 0x10, 0x62, 0xe2, 0x82, 0x4c, 0x9c, 0xf6, 0xa1, 0x09, 0xed, 0x43, 0x2e, 0x73, 0x82, 0x34, 0x73, 0xa8, 0x43, 0x2d, 0x72, 0x46, 0x05, 0xf8, 0x00, 0x08, 0x30, 0xab, 0xee, 0x4a, 0x28, 0x52, 0x00, 0xc3, 0x68, 0x02, 0x0c, 0x12, 0x62, 0xa4, 0x1c, 0x20, 0x79, 0xf4, 0xca, 0x81, 0x03, 0x23, 0x30, 0x20, 0x98, 0x15, 0x27, 0x1b, 0x92, 0xd4, 0x59, 0xce, 0x0a, 0x08, 0x1a, 0x04, 0x80, 0xba, 0x39, 0xd6, 0x39, 0x49, 0x9d, 0x30, 0x4e, 0xc6, 0xf4, 0xc4, 0xac, 0xa2, 0x22, 0xc6, 0x10, 0x4c, 0x92, 0xff, 0xf3, 0x28, 0xc4, 0xff, 0x0e, 0xc0, 0x02, 0x5b, 0x20, 0x00, 0x00, 0x00, 0x62, 0xe3, 0x47, 0x62, 0x8b, 0xc3, 0x24, 0x9a, 0x4f, 0x2e, 0x0c, 0xa2, 0x29, 0x2e, 0xb4, 0xdd, 0x04, 0x25, 0x83, 0xdc, 0xa6, 0x43, 0x24, 0x0d, 0x0e, 0xa0, 0x7c, 0xc8, 0xb8, 0x77, 0xf8, 0x98, 0x17, 0x47, 0x99, 0x26, 0xe9, 0x8c, 0x39, 0x22, 0x5f, 0x1d, 0x83, 0xb0, 0x7f, 0x25, 0x90, 0xff, 0x99, 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, 0x38, 0xc4, 0x15, 0x10, 0xc1, 0x72, 0xe5, 0x5f, 0xc9, 0x28, 0x00, 0x31, 0x0c, 0x15, 0x83, 0x21, 0x43, 0x04, 0x67, 0x10, 0x6b, 0x23, 0x7f, 0xe4, 0xa2, 0x48, 0xe8, 0x53, 0xf3, 0x89, 0xb5, 0x64, 0x2c, 0xac, 0xa7, 0x31, 0x08, 0xcd, 0xe4, 0xfd, 0x46, 0x1c, 0x63, 0xff, 0xa9, 0xeb, 0x26, 0x43, 0xff, 0xff, 0xa4, 0x38, 0x0f, 0xb2, 0x04, 0x8a, 0x7f, 0x64, 0x00, 0x0a, 0x00, 0x2e, 0x80, 0xa3, 0xfa, 0xfe, 0x45, 0x5e, 0x80, 0x48, 0x44, 0x66, 0x5d, 0x64, 0x54, 0xfa, 0xd3, 0x96, 0xec, 0xe2, 0x8e, 0x16, 0x6d, 0x41, 0x3e, 0xaf, 0xf7, 0xfd, 0x3f, 0xad, 0x66, 0xe2, 0x01, 0x61, 0x18, 0x91, 0x0b, 0xf8, 0xda, 0xf2, 0xb9, 0xff, 0xc0, 0x20, 0x16, 0x37, 0xff, 0xf3, 0x28, 0xc4, 0x31, 0x17, 0x01, 0x8a, 0xe5, 0x96, 0x43, 0x0d, 0x0c, 0x73, 0x69, 0xf5 }; unsigned int __1024bytes_bin_len = 1024;
參考資料: