Hi,
I have been reading a number of posts about this, but I have not been able to figure it out.
I want to write hex to a midi file.
The hex code of the midi file looks like this:
4D 54 68 64 00 00 00 06 00 01 00 01 00 80 4D 54 72 6B 00 00 00 16 80 00 90 3C 60 81 00 3E 60 81 00 40 60 81 00 B0 7B 00 00 FF 2F 00
This is confirmed by opening an existing midi file with okteta.
So far I tried:
ofstream myfile;
myfile.open ("output.midi",ios::binary);
myfile << "4D 54 68 64 00 00 00 06 00 01 00 01 00 80 4D 54 72 6B";
myfile << "00 00 00 16 80 00 90 3C 60 81 00 3E 60 81 00 40 60 81 00 B0 7B 00 00 FF 2F 00";
myfile.close();
But this writes it as normal characters. Then I read that << adds formatting, so I should use write. I found this command;
write((char*)&i, sizeof i);
But that's just chinese to me.
How do I implement the write command correctly to write the hex stream. Or just how do write the hex stream.
Immensly gratefull!