On Monday, 27 September 2021 at 13:45:19 UTC, Paul wrote:
Vitaliy,
Thanks for your assistance. I was looking at your
serialization package. Is your example correct?
struct MyStruct {
ubyte mybyte1;
@NoCereal uint nocereal1; //won't be serialised
@Bits!4 ubyte nibble;
Vitaliy,
Thanks for your assistance. I was looking at your serialization
package. Is your example correct?
struct MyStruct {
ubyte mybyte1;
@NoCereal uint nocereal1; //won't be serialised
@Bits!4 ubyte nibble;
@Bits!1 ubyte bit;
@Bits!3 ubyte bits3;
On Sunday, 26 September 2021 at 15:09:38 UTC, Paul wrote:
Is there way to write the myStruct data to the file in a single
statement...or two?
Thanks for any assistance.
Header[1] header;
void readFileHeader( ref File f )
{
f.rawRead( header );
}
S
Finished product...
~15k samples x 2 sin() waves/composite wave x 16 DTMF tones = 16
DTMF wave files in ~40ms!
I love D.
What's with the 4 bytes of zero?
I miss-counted. All is well!
Thanks Ali / Steven
Hmm...well this is what I did and sort of got what I wanted; it
did compile and write data!
auto myStruct = new mystruct[1];
File f = File("myFile.wav", "wb");
f.rawWrite(myStruct); //this is 44 bytes
f.rawWrite(shortWaveArray);
What I got in the file was this:
-my 44 byte myStruct data + (4
On 9/26/21 11:09 AM, Paul wrote:
I'm building a binary file. I can write my 'short[] myArray' directly
to the file using: File f = File( "myFile.wav", "wb" );
f.rawWrite(myArray); It doesn't write any array formatting stuff (i.e.
'[ , , ]'); it just moves the data into myFile like I want.
I
Correcting my sloppy code. :)
On 9/26/21 8:53 AM, Ali Çehreli wrote:
>// We need an array Ses (length of 1 in this case)
>auto ses = new S[1];
Allocating a dynamic array there is egregious pessimization. The
following works the same but this time the static array of a single S
will be
rawRead and rawWrite work with slices (arrays) of things. You need to
use an array of your struct even if there is a single item. Here is an
example:
import std.stdio;
import std.file;
struct S {
int i;
double d;
}
void readFrom(string name) {
// We need an array Ses (length of 1 in thi