Thread overview | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
September 28, 2019 Help playing sounds using arsd.simpleaudio | ||||
---|---|---|---|---|
| ||||
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 Re: Help playing sounds using arsd.simpleaudio | ||||
---|---|---|---|---|
| ||||
Posted in reply to Murilo | 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 Re: Help playing sounds using arsd.simpleaudio | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | 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 Re: Help playing sounds using arsd.simpleaudio | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | 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 Re: Help playing sounds using arsd.simpleaudio | ||||
---|---|---|---|---|
| ||||
Posted in reply to Murilo | 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 Re: Help playing sounds using arsd.simpleaudio | ||||
---|---|---|---|---|
| ||||
Posted in reply to JN | 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 Re: Help playing sounds using arsd.simpleaudio | ||||
---|---|---|---|---|
| ||||
Posted in reply to Murilo | 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 Re: Help playing sounds using arsd.simpleaudio | ||||
---|---|---|---|---|
| ||||
Posted in reply to JN | 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 Re: Help playing sounds using arsd.simpleaudio | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | 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 Re: Help playing sounds using arsd.simpleaudio | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | 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()?
|
Copyright © 1999-2021 by the D Language Foundation