Re: Problems using rawWrite in an experiment with WAVs in D

2023-12-27 Thread Paul Backus via Digitalmars-d-learn
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

Re: Problems using rawWrite in an experiment with WAVs in D

2023-12-27 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
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*))[0 .. WaveHeader.sizeof]); ``` However I would recommend doing it field by

Problems using rawWrite in an experiment with WAVs in D

2023-12-27 Thread tososdk via Digitalmars-d-learn
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;

Re: Something similar to "inline"

2023-12-27 Thread Johan via Digitalmars-d-learn
On Wednesday, 27 December 2023 at 16:35:47 UTC, Paul Backus wrote: On Wednesday, 27 December 2023 at 15:57:14 UTC, tososdk wrote: Two things: Could you explain how "inline" works? Is there something similar in Dlang? I don't think the D forums is the best place to ask about how "inline"

Re: Something similar to "inline"

2023-12-27 Thread Paul Backus via Digitalmars-d-learn
On Wednesday, 27 December 2023 at 15:57:14 UTC, tososdk wrote: Two things: Could you explain how "inline" works? Is there something similar in Dlang? In C and C++, `inline` is a suggestion to the compiler that it should consider using [inline expansion][1] for calls to a particular function.

Re: Non-blocking keyboard input

2023-12-27 Thread Christian Köstlin via Digitalmars-d-learn
On Wednesday, 27 December 2023 at 14:41:05 UTC, Christian Köstlin wrote: One option (not tested) should be to close stdin so that readln then returns null or something on eof. Shutting down threads is always tricky. It would be great if there would be one or two (perhaps one synchronous, one

Re: Non-blocking keyboard input

2023-12-27 Thread Christian Köstlin via Digitalmars-d-learn
On Wednesday, 27 December 2023 at 05:07:04 UTC, Joe wrote: ??? Surely there there is a one liner library solution for this? I have a program that spawns a thread for debugging information and uses the keyboard input which allows me to display the

Re: Behaves different on my osx and linux machines

2023-12-27 Thread Christian Köstlin via Digitalmars-d-learn
On Wednesday, 27 December 2023 at 14:03:06 UTC, Kagamin wrote: Maybe you're not supposed to print text while reading? In parallel I have contacted schveiguy on discord and he found the culprid. But we do not have a solution yet. It probably will result in a bugreport at

Re: Behaves different on my osx and linux machines

2023-12-27 Thread Kagamin via Digitalmars-d-learn
Maybe you're not supposed to print text while reading?

Re: Behaves different on my osx and linux machines

2023-12-27 Thread Kagamin via Digitalmars-d-learn
Maybe write and read lock each other, try to use puts: ``` bool done = false; while (!done) { puts("1"); auto result = ["echo", "Hello World"].execute; if (result.status != 0) { writeln(2); throw new Exception("echo

Re: Non-blocking keyboard input

2023-12-27 Thread Adam D Ruppe via Digitalmars-d-learn
On Wednesday, 27 December 2023 at 05:07:04 UTC, Joe wrote: ??? Surely there there is a one liner library solution for this? It is not one line because it needs a bit of setup (and teardown, but the objects' destructors do that for you) but it is close:

Looking for some thoughtful review of my first D program

2023-12-27 Thread Thomas Teixeira via Digitalmars-d-learn
Hi, you all ! I've wanted to look at D for the last two years, being a C fanboy and not fond of C++. It seemed like a good alternative between some delightful extra new stuff and keeping C-like experience : performances and code style wise. I wrote my first CLI program this weekend and