Hi! :-)
How can I have sound output in FB?
At Windows, I can use the BEEP command, but seems to be broken at Linux.
The wiki BEEP page drives you to an old post, mostly not usable today.
A forum search, reveals many articles, but most of them are Windows only and they're outdated too.
So my question is, does someone was successfully managed to have (just a simple) sound output on Linux recently (lets say, the last year)?
PS. a Shell command with a media player playing a sound file (eg. a ding wav) is maybe an option, but usually external commands are the last resort, because are much slower than internal ones.
TIA! :-)
A.
Sound output?
Re: Sound output?
Hi Achaean!
If you want to play simply BEEP through the speaker, then in the help there is an example of sound output through the port: http://www.freebasic.net/wiki/wikka.php?wakka=KeyPgOut
Run this example with ROOT in linux or with administrator privileges in Windows.
If you want to play WAV on Linux, then refer to the libraries: FMOD, BASS, SDL_MIXER .
A bit more complicated example is in the folder with the compiler playing with OPENAL.
If you want to play simply BEEP through the speaker, then in the help there is an example of sound output through the port: http://www.freebasic.net/wiki/wikka.php?wakka=KeyPgOut
Run this example with ROOT in linux or with administrator privileges in Windows.
If you want to play WAV on Linux, then refer to the libraries: FMOD, BASS, SDL_MIXER .
A bit more complicated example is in the folder with the compiler playing with OPENAL.
Re: Sound output?
THANKS Vanya!!! :-)
I'll look at it and I'll be back! :-)
Meanwhile I did some homework and to my astonishment, something messed with my Yakuake configuration, so thus the sound problem.
Maybe some update or a third-party tool installation? I'm not sure but I reconfigured it and now everything works flawlessly.
Now BEEP reproduces the default sound (who can be selected (if someone uses KDE, at Yakuake Settings or KDE Control Panel -> Notifications -> and choice from the drop down list (for KDE 4)).
PS. At the time of my personal homework I didn't know Vanya's answer, so consider this a workaround (although Vanya pointed out the straight forward solution). :-)
Just in case who someone wants more complicated sound, he can work from shell with paplay.
Eg. here's a small BAS:
paplay is from pulseaudio installation (which comes preinstalled on most systems).
"paplay -h" for help or "paplay --list-file-formats" for supported audio types.
Similar functionality on aplay and play commands (but you need to redirect console output to avoid onscreen garbage).
I'll look at it and I'll be back! :-)
Meanwhile I did some homework and to my astonishment, something messed with my Yakuake configuration, so thus the sound problem.
Maybe some update or a third-party tool installation? I'm not sure but I reconfigured it and now everything works flawlessly.
Now BEEP reproduces the default sound (who can be selected (if someone uses KDE, at Yakuake Settings or KDE Control Panel -> Notifications -> and choice from the drop down list (for KDE 4)).
PS. At the time of my personal homework I didn't know Vanya's answer, so consider this a workaround (although Vanya pointed out the straight forward solution). :-)
Just in case who someone wants more complicated sound, he can work from shell with paplay.
Eg. here's a small BAS:
Code: Select all
DIM AS STRING A
INPUT "Play sound?",A
IF A="Y" THEN SHELL "paplay /home/giorgos/ding.wav"
"paplay -h" for help or "paplay --list-file-formats" for supported audio types.
Similar functionality on aplay and play commands (but you need to redirect console output to avoid onscreen garbage).
Re: Sound output?
Those libraries VANYA mentioned are pretty heavy weight if you just want to play a .wav, since they do so much more than that.
For example plain SDL can load and play .wav files or play a PCM stream. SDL_mixer builds on top of SDL, adding support for various audio formats like ogg Vorbis and MIDI.
Pulseaudio and paplay aren't on 100% of distributions, while ALSA is pretty much supported by 100% of them. Not sure if aplay is always present, though. It seems like a decent solution to me.
For example plain SDL can load and play .wav files or play a PCM stream. SDL_mixer builds on top of SDL, adding support for various audio formats like ogg Vorbis and MIDI.
Pulseaudio and paplay aren't on 100% of distributions, while ALSA is pretty much supported by 100% of them. Not sure if aplay is always present, though. It seems like a decent solution to me.