I found this code,
ofstream myfile;
myfile.open ("output.midi",ios::binary);
char buffer[44] = {0x4D,0x54,0x68,0x64,0x00,0x00,0x00,0x06,0x00,0x01,0x00,0x01,0x00,0x80,0x4D,0x54,0x72,0x6B,0x00,0x00,0x00,0x16,0x80,0x00,0x90,0x3C,0x60,0x81,0x00,0x3E,0x60,0x81,0x00,0x40,0x60,0x81,0x00,0xB0,0x7B,0x00,0x00,0xFF,0x2F,0x00};
myfile.write(buffer,44);
How do I go about understanding this, I can see that the first 2 bytes = MZ a PE header signature, what about the other hex values though, how can one just write hex to a file though, I guess these hex values are from a hex dump or is there a way to manually predict what hex values(apart from the header) to write.
I am trying to understand file formats, bmp, jpeg, exe, wav etc - in this case midi.
You can create a bmp from pure code for example, you need to know the header file format and then just create an buffer array of pixel values and use fopen() fwrite().
How about understanding other file formats such as EXE, I take it EXE is unique in the sense that it's compiled of functions/variables and not just a file of pixel, or sound values?