Problems using rawWrite in an experiment with WAVs in D
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Wed Dec 27 21:20:32 UTC 2023
Because WaveHeader has no pointers in it, only raw memory, assuming it
is all in the cpu endianesss and with ``align(1)`` you can slice that
block of stack memory and write from that.
```d
file.rawWrite((cast(ubyte*)&wahv)[0 .. WaveHeader.sizeof]);
```
However I would recommend doing it field by field.
A lot more work, but allows you to handle endianness issues and remove
alignment concerns. Also changing of field sizes if required.
Same principles as the code above.
More information about the Digitalmars-d-learn
mailing list