On Wednesday, 27 December 2023 at 20:20:23 UTC, tososdk wrote:
I was recreating some code from C++ to D:
[...]
But since I am somewhat new to these topics and even more so to
Dlang, I don't understand very well. The problem occurs in the
creation of the .wav, regarding rawWrite, I'm not really
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
I was recreating some code from C++ to D:
```
import std.stdio;
import std.file;
import std.string;
import std.math;
struct WavHeader {
char[4] riff;
int flength;
char[4] wave;
char[4] fmt;
int chunk_size;
short format_tag;
short num_chans;
int sample_rate;
int