Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a way to play a WAV through /dev/console? (without being root)

The same way the shell command

/dev/urandom > /dev/console

produces a random sound

cat music.wav > /dev/console

does not work.

I can use /dev/dsp but the sound does not come from the internal PC speaker.

share|improve this question
    
It's sounding like you might want to play a sound file located on one system remotely on another system, is this the case? –  ultrasawblade Mar 28 '12 at 1:19

1 Answer 1

TL; DR

No, it's not possible. Use aplay or mplayer.

Why not?

There are two problems with your idea. The first is that writing to /dev/console results in the written characters showing up in the system console, which is commonly used for showing error notifications to the user (I believe), and not for playing sounds. If you somehow got sound from writing to it, I would guess it is due to the 1/256 chance of every character being , which should make a short beep.

The second problem is that a .wav is not a raw, unambiguous audio stream, even if it is less complex and (generally) not compressed like many other formats. In fact (iirc) there can never be such a thing as a raw, unambiguous audio stream. You will always (at the very least) need a header specifying sample resolution and rate in order to do anything useful with the data. I would be very surprised if it was decided that one of the responsibilities of the Linux kernel was to decode various audio formats. It is typically a thing best done by a program in userspace.

Digression:

The Windows 9x line (at least part of it) did image decoding in the kernel for icons. That turned out to be a less-than-stellar idea, and caused many, many bluescreens.

Proposed solution

If you wanted to play your wav from the command line, there are a range of programs that will decode the file for you and communicate it to the kernel, generally using the ALSA interface. I suggest aplay, which is available on most systems and is rather simplistic, or mplayer which is also widely distributed, but with far larger complexity. If your system supports sound, chances are at least one of those are installed.

share|improve this answer
    
Actually, .wav does support compression. It just isn't used often. –  Ignacio Vazquez-Abrams Mar 27 '12 at 22:15
    
Yes, yes it does. My point being, it is not to audio as utf-8 plain files are to text. –  Eroen Mar 27 '12 at 22:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.