On Wednesday, 5 July 2017 at 10:19:54 UTC, Sebastiaan Koppe wrote:
On Wednesday, 5 July 2017 at 09:43:05 UTC, Martin Tschierschke wrote:
On Wednesday, 5 July 2017 at 07:21:45 UTC, Sebastiaan Koppe wrote:
On Wednesday, 5 July 2017 at 05:34:37 UTC, FoxyBrown wrote:
On Tuesday, 4 July 2017 at 20:37:44 UTC, Sebastiaan Koppe wrote:
Portaudio is simple as well. And nice cross platform.

are there any bindings?

Sure, see http://code.dlang.org/packages/portaudio

Sorry, for that question but now, as I have several different options - all not 'overdocumented' - so what would be the shortest possible D program waiting for input and playing a sound from a file in parallel?

Something short like the single-file dub example...?

#!/usr/bin/env dub
/+ dub.sdl:
        name "hello"
+/
void main() {
        
 writef("Do you like the music?");
          char[] answer;
          answer = readln();
          writef("This was your Answer: ", answer);
        
}

This one plays a wav file. Couldn't get dub to do single-file on it. It kept giving linker errors. (Took example from https://github.com/v--/portaudio/blob/master/examples/pa_test.d)
[...]
 Lerror:
stderr.writefln("error %s", to!string(Pa_GetErrorText(err)));
    return 1;
}
Thank you!

Without the error handling it would be quite simple :-)
So, the following process starts the music in main, it is just to clarify the process for me: In main:

//1
PaStream* stream;
Sound input = decodeWAV("FILE.wav");
auto audio = Audio(input....);
Pa_Initialize();
Pa_OpenDefaultStream(&stream,...input...&callback,&audio);
//2
Pa_StartStream(stream);
//3
Pa_StopStream(stream);
Pa_CloseStream(stream);

For my purpose I will try to encapsulate it all in 3 additional own methods on top of it:
//1
 auto myinput = InitWav("File.wav");
//2
 PlaySound(myinput,volume=default, length=max_length);
//3
 StopSound(myinput);

With a new Struct myinput to handle input,audio and stream.

Thank you all for your help!


Reply via email to