如何将 /dev/urandom 通过管道传输到 linux 声音输出?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6465624/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 04:42:54  来源:igfitidea点击:

How to pipe /dev/urandom to linux sound output?

linuxalsapulseaudio

提问by c2h2

This doesn't seem to work at all:

这似乎根本不起作用:

cat /dev/urandom > /dev/dsp    #from wikipedia.org

Is it because of pulseaudio? or I need to do some settings?

是不是因为pulseaudio?或者我需要做一些设置?

采纳答案by TomH

I'm not sure there is a simple device you can just send the bytes to these days - the /dev/dspdevice is an old OSS thing and probably won't exist on a modern ALSA based system where the sound card is controlled by the devices in /dev/snd.

我不确定是否有一个简单的设备,您可以将字节发送到这些天 - 该/dev/dsp设备是旧的 OSS 东西,可能不会存在于基于 ALSA 的现代系统中,其中声卡由/dev/snd.

You're probably better off using aplayor something to "play" the data from /dev/randomthough you will probably need to give it a load of switches to tell it what format to assume the data is in. To make it play as if it were WAV data you want something like:

你可能最好使用aplay或其他东西来“播放”数据,/dev/random尽管你可能需要给它一个开关负载来告诉它假设数据是什么格式。让它像 WAV 数据一样播放你想要这样的东西:

aplay -c 2 -f S16_LE -r 44100 /dev/random

回答by Mihai

cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 10 | sed 1000000000q |aplay

cat /dev/urandom | tr -dc '0-9' | fold -w 10 | sed 1000000000q |aplay

cat /dev/urandom | tr -dc '0-9' | fold -w 10 | sed 1000000000q |aplay



cat /dev/urandom | tr -dc '&*(&(^)' | fold -w 10 | sed 1000000000q |aplay

cat /dev/urandom | tr -dc '&*(&(^)' | fold -w 10 | sed 1000000000q |aplay

cat /dev/urandom | tr -dc '~`!@#$%^&*()' | fold -w 1 | sed 1000000000q |aplay

cat /dev/urandom | tr -dc "0-9a-z" |aplay

cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 |aplay -r 192000

回答by RedEyed

pacat /dev/urandom Works on ubuntu without any additional installation.

pacat /dev/urandom 无需任何额外安装即可在 ubuntu 上运行。