我只是希望Mac OS X 10.6能像开放suse和其他发行版一样发出硬件哔哔声。我尝试了以下方法

Terminal -> beep = -bash: beep:命令不存在

终端->说哔哔=声音说哔哔(不是硬件的哔哔但很棒;))

applescript -> beep =麦金塔铃声(我想要一个硬件beep!)

有人知道如何在bin/bash或applescript中使硬件发出哔哔声吗?


在bash中写入echo ^G。要创建^G,按ctrl+v,然后按ctrl+ G。


Tput bel工作在大多数贝壳。

在OS X中,如果命令在终端不在前台时执行,这个(以及任何其他让铃声响起的命令)也会给你一个徽章:


终端类型:

echo -e "\a"

e参数告诉echo处理转义字符。由于\n是新的行字符,\a是钟形字符(与Ctrl+G相同)。


printf "\a"

如果你看man printf,它会给你一个转义字符列表,包括\a:

\a      Write a <bell> character.

打印\a并不总是为我工作(MBA, 10.7.4)。我用这个代替:

say "beep"

如果你安装了XCODE,你可以发出哔哔声。我还没有发现我可以让打印“\a”字符在C中工作。

有一种方法可以让声音在程序运行时工作,启动XCODE,在XCODE下拉菜单,首选项,行为,选中第一个框播放声音,从列表中选择或添加一个声音。

这是一种方法,但我认为只有在程序运行时才能做到。


在MacOS X上,必须激活“声音警告”选项(终端/首选项)才能发出声音。


确实,下面这段很有效果,也很有旋律:

say -v Bells "dong dong dong"

[更新]不幸的是bell不再包含在最新的OS x中。

say -v Victoria Do your homework!

使用以下方法探索声音:

say -v \?

Printf“\a”也适用于终端,并将播放设置的警报声音。


这将循环所有的声音(在约塞米蒂工作):

say -v '?' | awk '{print $1}' | while read voice; do printf "using $voice...\n"; say -v $voice "hello, this is me using the $voice voice"; sleep 1; done

告诉应用程序“系统事件”哔哔声


在OS X终端下,执行命令:osascript -e 'beep'

使用OSA (Open Script Architecture)技术告诉AppleScript执行命令哔哔声。


如果你需要什么,听起来就像“important”

你可以使用

tput bel && sleep 0.33s && tput bel && sleep 0.33s && tput bel && sleep 0.33s && tput bel && sleep 0.33s && tput bel && sleep 0.33s && tput bel && sleep 0.33s && tput bel && sleep 0.33s && tput bel && sleep 0.33s && tput bel && sleep 0.33s && tput bel && sleep 0.33s

:)


macOS中没有“硬件哔哔声”。

The functionality you're thinking of is an artifact of very old (pre-1990s) IBM PC-compatible hardware. Before most computers had sound cards, most machines had a small speaker or piezo buzzer connected to one of the channels of a timer chip. This could be used to generate simple tones or beeps. Even after many computers integrated sound cards, it remained common for quite some time for computers to route this output to a separate internal speaker. More recently, many computers, especially laptops, have integrated this functionality into the onboard sound card.

(如果你对PC扬声器接口工作原理的技术细节感到好奇,这里有更多细节。)

这种硬件在苹果电脑中从未存在过。唯一可用的音频输出是通过声卡,macOS中唯一的系统哔哔声是用户的警报声。


播放任意警报声音与afplay

我很惊讶没有人提到afplay:这是一个播放任意声音文件的命令行程序。它从最初的OS X版本(还有NeXTSTEP,如果你的记忆够长的话)就已经存在了。

例如,你可以在命令行或者脚本中运行:

$ afplay /System/Library/Sounds/Ping.aiff

你不局限于系统声音;使用afplay的一个优点是,您可以选择自己的声音文件作为警报。例如,你可以下载其中一个声音文件并选择你最喜欢的。

(如果你能找到33型电传铃的录音就会加分!)


这适用于我(mac os 10.14.6)

echo "\x07"  

要了解更多选项,请听并选择

ls /System/Library/Sounds/ | awk '{print $1}' | while read sound; do printf "using $sound...\n"; afplay /System/Library/Sounds/$voice; sleep 0.5; done

ls /System/Library/PrivateFrameworks/ScreenReader.framework/Versions/A/Resources/Sounds/ | awk '{print $1}' | while read sound; do printf "using $voice...\n"; afplay /System/Library/PrivateFrameworks/ScreenReader.framework/Versions/A/Resources/Sounds/$sound; sleep 0.5; done