digitalmars.D.learn - Help playing sounds using arsd.simpleaudio
- Murilo (3/3) Sep 27 2019 Can anyone just please show me how to play a background
- Adam D. Ruppe (16/19) Sep 28 2019 it is really minimal be warned
- Murilo (4/24) Sep 28 2019 Thank you sooo much. Now it works. That is pretty much what I was
- Murilo (13/33) Sep 28 2019 Thanks. Now, I would like to know if I could just use it like
- Adam D. Ruppe (6/8) Sep 29 2019 What happens if an exception is thrown in the middle of your
- Murilo (6/14) Sep 29 2019 I'm very minimalistic, I hate unnecessary complexity, I believe
- Murilo (9/29) Sep 29 2019 Are you sure it is like this:
- Adam D. Ruppe (3/4) Sep 29 2019 join waits for it to finish before returning. You need to stop
- Murilo (4/8) Sep 29 2019 Alright, thanks. So let me see if I get this straight, .stop()
- Adam D. Ruppe (8/9) Sep 29 2019 More specifically, stop tells the audio output to stop. It
- Murilo (4/13) Sep 29 2019 ahh, okay, thanks. Now, one last question, if stop() actually
- Adam D. Ruppe (4/7) Sep 29 2019 It does both. start is from the base class Thread, it starts it
- Murilo (16/23) Oct 18 2019 Thanks Adam. That worked on Windows, but now that I have switched
- Adam D. Ruppe (6/7) Oct 18 2019 Your system probably uses PulseAudio which I don't like, so I
- Murilo (3/10) Oct 18 2019 That unfortunately didn't work. I would be very grateful if you
- Adam D. Ruppe (1/1) Oct 19 2019 try it now with the new version of simpleaudio.d from git
- Murilo (4/5) Oct 19 2019 Ahhhhhh, now it works! Thank you so much man. I really appreciate
- Murilo (6/7) Oct 26 2019 Hi Adam, sorry to bother you, but I'm having a problem with
- Adam D. Ruppe (4/8) Oct 30 2019 That happens if you don't call .stop() and .join() in order at
- Murilo (13/21) Oct 31 2019 Thanks for the help.
- johnsmith101 (5/13) Nov 01 2019 hello,
- JN (4/7) Sep 29 2019 I recommend SoLoud - bindings are available here
- Adam D. Ruppe (10/11) Sep 29 2019 heh. not hard to be better than my method list:
- Murilo (2/10) Sep 29 2019 Thanks.
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.
Sep 27 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.
Sep 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:Thank you sooo much. Now it works. That is pretty much what I was looking for.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.
Sep 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: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; }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.
Sep 28 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.
Sep 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: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()?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.
Sep 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:Are you sure it is like this: audio.stop(); audio.join(); and not like this: audio.join(); audio.stop(); ?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.
Sep 29 2019
On Sunday, 29 September 2019 at 20:51:40 UTC, Murilo wrote:Are you sure it is like this:join waits for it to finish before returning. You need to stop before joining otherwise join may never return.
Sep 29 2019
On Sunday, 29 September 2019 at 20:57:09 UTC, Adam D. Ruppe wrote:On Sunday, 29 September 2019 at 20:51:40 UTC, Murilo wrote:Alright, thanks. So let me see if I get this straight, .stop() will stop the thread and then .join() will return. But what exactly does .join() return?Are you sure it is like this:join waits for it to finish before returning. You need to stop before joining otherwise join may never return.
Sep 29 2019
On Sunday, 29 September 2019 at 21:06:02 UTC, Murilo wrote:.stop() will stop the threadMore specifically, stop tells the audio output to stop. It finishes what it is doing and then exits. At this point, the thread terminates. join() waits for the thread to finish terminating (which it won't do if you don't tell it to stop *first*) and then cleans it up. join will return any exception/error it happened to throw while ending.
Sep 29 2019
On Sunday, 29 September 2019 at 22:52:02 UTC, Adam D. Ruppe wrote:On Sunday, 29 September 2019 at 21:06:02 UTC, Murilo wrote:ahh, okay, thanks. Now, one last question, if stop() actually makes the output, not the thread, stop, then start() makes the output, not the thread, begin?.stop() will stop the threadMore specifically, stop tells the audio output to stop. It finishes what it is doing and then exits. At this point, the thread terminates. join() waits for the thread to finish terminating (which it won't do if you don't tell it to stop *first*) and then cleans it up. join will return any exception/error it happened to throw while ending.
Sep 29 2019
On Sunday, 29 September 2019 at 23:48:35 UTC, Murilo wrote:Now, one last question, if stop() actually makes the output, not the thread, stop, then start() makes the output, not the thread, begin?It does both. start is from the base class Thread, it starts it which immediately opens the audio device and can feed stuff when it is necessary.
Sep 29 2019
but at the beginning of main() set it up with auto audio = new AudioPcmOutThread(); audio.start(); scope(exit) { audio.stop(); audio.join(); }Thanks Adam. That worked on Windows, but now that I have switched to Linux Mint it is throwing this: arsd.simpleaudio.AlsaException arsd/simpleaudio.d(1170): params init: Operation not permitted ---------------- ??:? arsd.simpleaudio.snd_pcm_t* arsd.simpleaudio.openAlsaPcm(arsd.simpleaudio.snd_pcm_stream_t) [0x55eab05a0f4a] ??:? ref arsd.simpleaudio.AudioOutput arsd.simpleaudio.AudioOutput.__ctor(int) [0x55eab059f7ec] ??:? void arsd.simpleaudio.AudioPcmOutThread.run() [0x55eab059f23d] ??:? void core.thread.Thread.run() [0x55eab05c10d1] ??:? thread_entryPoint [0x55eab05d809b] ??:? [0x7fb40e4ff6da] What should I do?
Oct 18 2019
On Saturday, 19 October 2019 at 01:48:57 UTC, Murilo wrote:init: Operation not permittedYour system probably uses PulseAudio which I don't like, so I don't support it in my code. It *might* work to run `pasuspender -- ./your_program_here` but I don't know. I can check more tomorrow.
Oct 18 2019
On Saturday, 19 October 2019 at 02:10:54 UTC, Adam D. Ruppe wrote:On Saturday, 19 October 2019 at 01:48:57 UTC, Murilo wrote:That unfortunately didn't work. I would be very grateful if you could find out a way around it and tell me.init: Operation not permittedYour system probably uses PulseAudio which I don't like, so I don't support it in my code. It *might* work to run `pasuspender -- ./your_program_here` but I don't know. I can check more tomorrow.
Oct 18 2019
try it now with the new version of simpleaudio.d from git
Oct 19 2019
On Saturday, 19 October 2019 at 13:08:49 UTC, Adam D. Ruppe wrote:try it now with the new version of simpleaudio.d from gitAhhhhhh, now it works! Thank you so much man. I really appreciate the work you do with your library, I have been using it for everything, I'm now training a neural network using your library.
Oct 19 2019
On Saturday, 19 October 2019 at 13:08:49 UTC, Adam D. Ruppe wrote:try it now with the new version of simpleaudio.d from gitHi Adam, sorry to bother you, but I'm having a problem with simpleaudio.d. This problem was happening on Windows too. When I play a sound the program never ends, the terminal continues to run the program and I have to end it manually. Any ideas what could be causing this? I am using it just as you had instructed.
Oct 26 2019
On Saturday, 26 October 2019 at 19:48:33 UTC, Murilo wrote:I play a sound the program never ends, the terminal continues to run the program and I have to end it manually. Any ideas what could be causing this? I am using it just as you had instructed.That happens if you don't call .stop() and .join() in order at the right time. Did you use the scope(exit) like I said?
Oct 30 2019
On Wednesday, 30 October 2019 at 19:11:00 UTC, Adam D. Ruppe wrote:On Saturday, 26 October 2019 at 19:48:33 UTC, Murilo wrote:Thanks for the help. I did use the scope. Here is my code: AudioPcmOutThread audio = new AudioPcmOutThread(); audio.start(); scope (exit) { audio.stop(); audio.join(); } audio.playOgg("bell.ogg"); The problem persists.I play a sound the program never ends, the terminal continues to run the program and I have to end it manually. Any ideas what could be causing this? I am using it just as you had instructed.That happens if you don't call .stop() and .join() in order at the right time. Did you use the scope(exit) like I said?
Oct 31 2019
On Wednesday, 30 October 2019 at 19:11:00 UTC, Adam D. Ruppe wrote:On Saturday, 26 October 2019 at 19:48:33 UTC, Murilo wrote:hello, Thank you so much for help, it helped me alot Thanks and regards.:)I play a sound the program never ends, the terminal continues to run the program and I have to end it manually. Any ideas what could be causing this? I am using it just as you had instructed.That happens if you don't call .stop() and .join() in order at the right time. Did you use the scope(exit) like I said?
Nov 01 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.
Sep 29 2019
On Sunday, 29 September 2019 at 09:25:59 UTC, JN wrote:It's more powerful than simpleaudioheh. 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 :)
Sep 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:Thanks.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.
Sep 29 2019