PDA

View Full Version : generating beep sound in Qt under linux platform



babusunlux
3rd July 2006, 09:26
Hai,

I know in window when a '\a' is printed it alerts sound is generated. But Same character is used in Qt with linux why does not it generates beep sound... so can anybody help me how do i proceed in Qt Since i need to generate the alarm when the value reaches less the some value. Basically i want to know how to generate the bell sound in Qt. Including printf("\a\a\a\a"); in Qt code doesn't work. Help please.................

high_flyer
3rd July 2006, 11:53
Sound access is a platform depended operation.
That is why under linux you don't get the beep with \a.
From reading QSound (Qt3 as I see you use Qt3) you can see that the trolls are offering a platform independent way to play wav files.
If you want to access the PC speaker (not through soud card) then I think you will have to write platform dependent code.
If you want it to compile and work under more than one OS you will need to use #ifdef for conditional compilation.

babusunlux
3rd July 2006, 13:05
Hai

ok fine.. But I can run .wav files in qt to generate sound from speaker. If it is how do i proceed. If it is using QSound.. But i have not worked much on it.. Please help me and i will be very greatful to you...


Thanks

high_flyer
3rd July 2006, 13:52
Playing wavs on the speaker is not trivial.
It is much easier if you just use #ifdef sections with platform dependent code.

jacek
3rd July 2006, 16:52
But I can run .wav files in qt to generate sound from speaker. If it is how do i proceed. If it is using QSound.. But i have not worked much on it..
If you just want to play a .wav file in Qt3/X11 you have to compile Qt with NAS support. See QSound docs (http://doc.trolltech.com/3.3/qsound.html) for more information.

Mad Max
4th July 2006, 07:13
Try to use this method:
void QApplication::beep ()

high_flyer
4th July 2006, 09:58
Playing wavs on the speaker is not trivial.
Wel,playing wavs on the speaker is not trivial, but a beep is (so it seems) :-)

babusunlux
5th July 2006, 08:52
Hai..

My QTapplication is something like this...
It scans value from a device where a two limits will be already set. If the scanned value reaches those values i need to generate a sound from speaker to alert the user.....
I tried a lot of ways to play .wav file but it was not working. But when i check using Sound Card Detection it works fine....
So how do i proceed with this....
I had tired the beep() also in my application but it didn't work... I found that NAS has to be installed... So i installed it and it has been asked to rebuild the Qt application means reconfigure the qt application... Since i am using Fedora Core 4 i am not finding the ./configure file to run under any Qt folder... So can anyboby help me how do i proceed... or any idea to overcome this problem..

With Regards
Babu.K

Brandybuck
6th July 2006, 01:44
I had tired the beep() also in my application but it didn't work... I found that NAS has to be installed... So i installed it and it has been asked to rebuild the Qt application means reconfigure the qt application... Since i am using Fedora Core 4 i am not finding the ./configure file to run under any Qt folder... So can anyboby help me how do i proceed... or any idea to overcome this problem.
You may need to remove the prepackaged Qt and build your own.

babusunlux
6th July 2006, 14:13
Hai...
Thanks for your support so much..
Since i am working on Fedora Core 4. and i have installed the NAS and finding difficult in rebuilding the Qt. Since Qt software i am using is with the OS.. So i am not finding a way to reconfigure.... I thought let me try a sample program with beep()..

I tried just giving ---- QApplication :: beep(); ---- But still I didn't hear any beep sound from my computer. Can anybody help me in this regard..

With Regards,
Babu.K

Mad Max
7th July 2006, 07:38
Check a list of modules of your system (lsmod | grep pcspkr). Is there pcspkr module? If it is not present then install it (modprobe pcspkr).