Jump to page: 1 2 3
Thread overview
Help playing sounds using arsd.simpleaudio
Sep 28, 2019
Murilo
Sep 28, 2019
Adam D. Ruppe
Sep 28, 2019
Murilo
Sep 29, 2019
Murilo
Sep 29, 2019
Adam D. Ruppe
Sep 29, 2019
Murilo
Sep 29, 2019
Murilo
Sep 29, 2019
Adam D. Ruppe
Sep 29, 2019
Murilo
Sep 29, 2019
Adam D. Ruppe
Sep 29, 2019
Murilo
Sep 29, 2019
Adam D. Ruppe
Oct 19, 2019
Murilo
Oct 19, 2019
Adam D. Ruppe
Oct 19, 2019
Murilo
Oct 19, 2019
Adam D. Ruppe
Oct 19, 2019
Murilo
Oct 26, 2019
Murilo
Oct 30, 2019
Adam D. Ruppe
Nov 01, 2019
Murilo
Nov 01, 2019
johnsmith101
Sep 29, 2019
JN
Sep 29, 2019
Adam D. Ruppe
Sep 29, 2019
Murilo
September 28, 2019
Can anyone just please show me how to play a background sound(like those in games) using arsd.simpleaudio? I'd like something simple with a code snippet please.
September 28, 2019
On Saturday, 28 September 2019 at 03:21:38 UTC, Murilo wrote:
> Can anyone just please show me how to play a background sound(like those in games) using arsd.simpleaudio? I'd like something simple with a code snippet please.

it is really minimal be warned

but at the beginning of main() set it up with


	auto audio = new AudioPcmOutThread();
	audio.start();
	scope(exit) {
		audio.stop();
		audio.join();
	}


and then when you want it to make sounds, call its functions like

    audio.beep();

or

    audio.playOgg("my-file.ogg");

you can convert things like wav and mp3 into the ogg format with various tools of the internet.



that's about all it does.
September 28, 2019
On Saturday, 28 September 2019 at 14:03:53 UTC, Adam D. Ruppe wrote:
> On Saturday, 28 September 2019 at 03:21:38 UTC, Murilo wrote:
>> Can anyone just please show me how to play a background sound(like those in games) using arsd.simpleaudio? I'd like something simple with a code snippet please.
>
> it is really minimal be warned
>
> but at the beginning of main() set it up with
>
>
> 	auto audio = new AudioPcmOutThread();
> 	audio.start();
> 	scope(exit) {
> 		audio.stop();
> 		audio.join();
> 	}
>
>
> and then when you want it to make sounds, call its functions like
>
>     audio.beep();
>
> or
>
>     audio.playOgg("my-file.ogg");
>
> you can convert things like wav and mp3 into the ogg format with various tools of the internet.
>
>
>
> that's about all it does.

Thank you sooo much. Now it works. That is pretty much what I was looking for.
September 29, 2019
On Saturday, 28 September 2019 at 14:03:53 UTC, Adam D. Ruppe wrote:
> On Saturday, 28 September 2019 at 03:21:38 UTC, Murilo wrote:
>> Can anyone just please show me how to play a background sound(like those in games) using arsd.simpleaudio? I'd like something simple with a code snippet please.
>
> it is really minimal be warned
>
> but at the beginning of main() set it up with
>
>
> 	auto audio = new AudioPcmOutThread();
> 	audio.start();
> 	scope(exit) {
> 		audio.stop();
> 		audio.join();
> 	}
>
>
> and then when you want it to make sounds, call its functions like
>
>     audio.beep();
>
> or
>
>     audio.playOgg("my-file.ogg");
>
> you can convert things like wav and mp3 into the ogg format with various tools of the internet.
>
>
>
> that's about all it does.

Thanks. Now, I would like to know if I could just use it like this instead:

import arsd.simpleaudio;

void main()
{
    AudioPcmOutThread audio = new AudioPcmOutThread;
    audio.start;
    audio.playOgg("shock.ogg");
    audio.join;
    audio.stop;
}

September 29, 2019
On Saturday, 28 September 2019 at 03:21:38 UTC, Murilo wrote:
> Can anyone just please show me how to play a background sound(like those in games) using arsd.simpleaudio? I'd like something simple with a code snippet please.

I recommend SoLoud - bindings are available here http://code.dlang.org/packages/bindbc-soloud . It's more powerful than simpleaudio, supports multiple formats, 3D audio, etc.
September 29, 2019
On Sunday, 29 September 2019 at 09:25:59 UTC, JN wrote:
> It's more powerful than simpleaudio

heh. not hard to be better than my method list:

http://dpldocs.info/experimental-docs/arsd.simpleaudio.AudioPcmOutThread.html#members

beep
boop
blip
noise
playOgg

it is meant to be something more like an Atari 2600 than a modern movie theater :)
September 29, 2019
On Sunday, 29 September 2019 at 04:37:43 UTC, Murilo wrote:
> Thanks. Now, I would like to know if I could just use it like this instead:

What happens if an exception is thrown in the middle of your function? It shouldn't really matter (at least not with the newer versions) since it will automatically exit the audio thread when the main thread exits, but still there's definitely no benefit to writing it without the scope guard.
September 29, 2019
On Sunday, 29 September 2019 at 09:25:59 UTC, JN wrote:
> On Saturday, 28 September 2019 at 03:21:38 UTC, Murilo wrote:
>> Can anyone just please show me how to play a background sound(like those in games) using arsd.simpleaudio? I'd like something simple with a code snippet please.
>
> I recommend SoLoud - bindings are available here http://code.dlang.org/packages/bindbc-soloud . It's more powerful than simpleaudio, supports multiple formats, 3D audio, etc.

Thanks.
September 29, 2019
On Saturday, 28 September 2019 at 14:03:53 UTC, Adam D. Ruppe wrote:
> On Saturday, 28 September 2019 at 03:21:38 UTC, Murilo wrote:
>> Can anyone just please show me how to play a background sound(like those in games) using arsd.simpleaudio? I'd like something simple with a code snippet please.
>
> it is really minimal be warned
>
> but at the beginning of main() set it up with
>
>
> 	auto audio = new AudioPcmOutThread();
> 	audio.start();
> 	scope(exit) {
> 		audio.stop();
> 		audio.join();
> 	}
>
>
> and then when you want it to make sounds, call its functions like
>
>     audio.beep();
>
> or
>
>     audio.playOgg("my-file.ogg");
>
> you can convert things like wav and mp3 into the ogg format with various tools of the internet.
>
>
>
> that's about all it does.

Are you sure it is like this:
audio.stop();
audio.join();
and not like this:
audio.join();
audio.stop();
?
September 29, 2019
On Sunday, 29 September 2019 at 13:24:40 UTC, Adam D. Ruppe wrote:
> On Sunday, 29 September 2019 at 04:37:43 UTC, Murilo wrote:
>> Thanks. Now, I would like to know if I could just use it like this instead:
>
> What happens if an exception is thrown in the middle of your function? It shouldn't really matter (at least not with the newer versions) since it will automatically exit the audio thread when the main thread exits, but still there's definitely no benefit to writing it without the scope guard.

I'm very minimalistic, I hate unnecessary complexity, I believe that simple is better than complex so I always try to use the least syntax and lines of code when I'm making a program. That is why I don't like the scope guard. Could I simply add the lines `audio.stop(); audio.join();` to the very end of main()?
« First   ‹ Prev
1 2 3