如何将 /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
How to pipe /dev/urandom to linux sound output?
提问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/dsp
device 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 aplay
or something to "play" the data from /dev/random
though 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 上运行。