Re: cat sound.wav > /dev/dsp Not Working

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Bill,

Thanks again for your response and for giving me an explanation of what the problem is.  

What I am trying to do is create an alarm that gets repeated and has varying delays of silence in between the alarm that gets played (there will also be several different alarm sounds of differing durations).  This is for an embedded application with no X.  I have successfully achieved this using the ALSA API and file descriptors to play back sounds etc.  There are a number of problems however:- firstly usb speakers being disconnected while sound is being played causes ALSA API to crash for some reason (Logitech V10 usb speakers) with my code (using the ALSA API- how can I prevent this?) .  Secondly I have to run this code on a second lot of hardware (my code written with ALSA API works on one set of hardware but causes a clicking noise on the other- (note:- the usb device being used is the same in both cases)). Third problem is the thread that plays sound using the ALSA API is too tightly coupled to what the rest of the application is doing and when long sounds are played the application slows down (this is obviously an architecture issue with my code).  

Alot of these problems can be avoided if I don't try to re-invent the wheel.  What I am looking at using is Qt/Embedded QSound (using sockets to stream sound to socket server).  On linux this uses /dev/dsp and can only play wav files.  It is my thinking that if I can get the application to play sounds through /dev/dsp (OSS emulation) then there is a very good chance that I can use QSound to solve all the above problems.  There are other ways to achieve the same outcome such as Phonon/GStreamer/Alsa as well as Jack audio connection kit and ALSA (both seem like a lot of work- any other ideas would be welcome).  The beauty of QSound is that it gives a seamless way to play alarm sounds on Windows and different hardware running linux.

I've sent this information to the mailing list before including my code but its been too much information and therefore I haven't got any responses (probably also it depends on how you phrase your questions!). This is why I've attempted to break the problem down.

Apologies for the long-winded email. Really appreciate your comments and any suggestions you have to make. (btw. the wav file is not empty).

Cheers,

Geoff Crowther



-----Original Message-----
From: Bill Unruh [mailto:unruh@xxxxxxxxxxxxxx] 
Sent: Tuesday, 22 December 2009 9:37 AM
To: Geoffrey Crowther
Cc: Sergei Steshenko; alsa-user@xxxxxxxxxxxxxxxxxxxxx
Subject: RE:  cat sound.wav > /dev/dsp Not Working

On Mon, 21 Dec 2009, Geoffrey Crowther wrote:

> Sergei, Bill,
>
> Thankyou for your response to my query.  After I sent this email I tried the same thing with Logitech V10 USB speakers rather than the C-Media USB headphones.  The same wav file gets played successfully (same machine, same kernel) doing cat sound.wav > /dev/dsp.  Your second point though about number of bits/endianess etc could be an issue.  The sound I am hearing could be white noise but its not continuous and it sounds like a brief clicking noise. Will try and change the number of bits, endianess etc to see if I can get some better results.  Any further comments would be most welcome.

The issue is that when you pipe the stream to /dev/dsp, /dev/dsp is set up for
a certain number of channels, bits per second, etc. If you are lucky and it is
two channel, 16bit, 44100 bps, and the header on the wave file is a multiple
of 4 bytes long, and the endianness is right, then the wave file will create
sound. But this is NOT the way to test if anything works. You should either
hear music, or white noise. A brief click suggests that the header is being
sent ( ie some 10 or so bytes) which produces 1/10000 sec of noise, but
nothing else. Ie your wave file is empty.

Now, why do you want to play through oss? alsa will play .wav files fine
(aplay nameoffile.wav).

If you told us what you wanted to do rather than what your think is the
solution to your problem, perhaps we could be more helpful.

Whatever it is you NEVER want to play a wav file by doing cat
file.wav>/dev/dsp.



>
> Cheers,
>
> Geoff Crowther
>
> -----Original Message-----
> From: Sergei Steshenko [mailto:steshenko_sergei@xxxxxxx]
> Sent: Tuesday, 22 December 2009 6:28 AM
> To: Geoffrey Crowther
> Cc: alsa-user@xxxxxxxxxxxxxxxxxxxxx
> Subject: Re:  cat sound.wav > /dev/dsp Not Working
>
> On Sun, 20 Dec 2009 20:50:28 -0800
> Geoffrey Crowther <gcrowther@xxxxxxxxxx> wrote:
>
>> Hello,
>>
>> Want to use OSS emulation through /dev/dsp for playing wav files.  As a simple test to start with I attempt the following:-
>>
>> cat sound.wav > /dev/dsp
>>
> [snip]
>
> WAV file is not a PCM stream, so even after you're done fixing AOSS problems
> this won't work as expected.
>
> Use 'sox' or 'ecasound' to convert your WAV file to proper (number of bits,
> endianness, etc.) PCM stream which is written to stdout and pipe it into
> /dev/dsp.
>
> Regards,
>  Sergei.
>

-- 
William G. Unruh   |  Canadian Institute for|     Tel: +1(604)822-3273
Physics&Astronomy  |     Advanced Research  |     Fax: +1(604)822-5324
UBC, Vancouver,BC  |   Program in Cosmology |     unruh@xxxxxxxxxxxxxx
Canada V6T 1Z1     |      and Gravity       |  www.theory.physics.ubc.ca/

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Alsa-user mailing list
Alsa-user@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/alsa-user

[Index of Archives]     [ALSA Devel]     [Linux Audio Users]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]

  Powered by Linux