如何在 Mac OS X 10.6 中发出硬件蜂鸣声

发布于 2024-09-07 04:39:16 字数 255 浏览 2 评论 0原文

我只是希望 Mac OS X 10.6 能像 open suse 和其他发行版中那样发出硬件蜂鸣声。我尝试了以下方法

终端 ->蜂鸣= -bash:蜂鸣:找不到命令

终端->说 beep = 语音发出蜂鸣声(不是硬件蜂鸣声,但很棒;))

applescript -> beep = Macintosh 铃声(我想要硬件蜂鸣声!)

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

I just want that Mac OS X 10.6 does a hardware beep sound like in open suse and other distributions. I tried following approaches

Terminal -> beep = -bash: beep: command not found

Terminal -> say beep = voice speaks out beep (Not a Hardware beep but awesome ;) )

applescript -> beep = Macintosh bell (I want a Hardware beep!)

Does anybody know how to make the Hardware beep in bin/bash or applescript?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(17

柏拉图鍀咏恒 2024-09-14 04:39:17

打印 \a 对我来说并不总是有效(MBA,10.7.4)。我用这个代替:

say "beep"

Printing \a did not always work for me (MBA, 10.7.4). I use this instead:

say "beep"
狼性发作 2024-09-14 04:39:17

事实上,以下内容是有效且有些旋律的:

say -v Bells "dong dong dong"

[更新] 不幸的是,Bells 不再包含在最新的 OS X 中。尝试:

say -v Daniel Do your homework!

使用以下内容来探索声音:

say -v \?

Indeed, the following is effective and somewhat melodic:

say -v Bells "dong dong dong"

[Update] Unfortunately Bells is no longer included in latest OS X. Try:

say -v Daniel Do your homework!

Use the following to explore voices:

say -v \?
暗喜 2024-09-14 04:39:17

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

write echo ^G in the bash. to create the ^G press ctrl+v and then ctrl+g.

一城柳絮吹成雪 2024-09-14 04:39:17

使用 afplay 播放任意警报声音

我很惊讶没有人提到 afplay:这是播放任意声音文件的命令行程序。它自从 OS X 最初发布以来就已经存在了(如果你还记得的话,还有 NeXTSTEP)。

例如,您可以从命令行运行它或将其放入脚本中:

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

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

(如果您能找到 Teletype 33 型电铃的录音,可加分!)

Play an arbitrary alert sound with afplay

I'm surprised nobody has mentioned afplay: that's the command line program that plays arbitrary sound files. It's been around since the original releases of OS X (and NeXTSTEP, if your memory is that long).

For example, you can run this from the command line or put it in a script:

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

You're not limited to system sounds; one advantage of using afplay is that you can choose your own sound file as an alert. For example, you could download one of these sound files and pick your favorite.

(Extra points if you can find a recording of an Teletype Model 33 bell!)

仅此而已 2024-09-14 04:39:17

这将循环播放所有声音(适用于优胜美地):

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

This will loop through all the voices (works on Yosemite):

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
清风夜微凉 2024-09-14 04:39:17

macOS 中没有“硬件蜂鸣声”。

您正在考虑的功能是非常古老的(20 世纪 90 年代之前)IBM PC 兼容硬件的产物。在大多数计算机配备声卡之前,大多数机器都有一个小型扬声器或压电蜂鸣器连接到定时器芯片的通道之一。这可用于生成简单的音调或蜂鸣声。即使在许多计算机集成了声卡之后,在相当长的一段时间内,计算机将此输出路由到单独的内部扬声器仍然很常见。最近,许多计算机,尤其是笔记本电脑,已将此功能集成到板载声卡中。

(如果您对 PC 扬声器界面如何工作的技术细节感到好奇,这里有更多详细信息。)

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

There is no "hardware beep" in 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.

(If you're curious about the technical details of how the PC speaker interface worked, there are more details here.)

This hardware has never existed in Apple computers. The only audio output available is through the sound card, and the only system beep in macOS is the user's alert sound.

一百个冬季 2024-09-14 04:39:17

在终端中输入:

echo -e "\a"

-e 参数告诉 echo 处理转义字符。由于 \n 是换行符,\a 是铃声字符(与 Ctrl+G 相同)。

In the terminal type :

echo -e "\a"

The -e parameter tells echo to process escaped characters. As the \n is the new line character, the \a is the bell one (the same as Ctrl+G).

百变从容 2024-09-14 04:39:17

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

使用 OSA(开放脚本架构)技术告诉 AppleScript 执行命令 beep

Under OS X terminals, execute command: osascript -e 'beep'

Using OSA (Open Script Architecture) technology to tell AppleScript to execute command beep.

沧笙踏歌 2024-09-14 04:39:17
printf "\a"

如果您查看 man printf,它会为您提供转义字符列表,包括 \a

\a      Write a <bell> character.
printf "\a"

If you look at man printf, it gives you a list of escaped characters, including \a:

\a      Write a <bell> character.
箜明 2024-09-14 04:39:17

如果您需要某些东西,听起来像“重要”,

您可以使用

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

while true; do; tput bel && sleep 0.33; done

If you need something, that sounds like "important"

you can use

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

or

while true; do; tput bel && sleep 0.33; done

????

裸钻 2024-09-14 04:39:17

printf "\a" 也可以在终端中工作并播放设置的警报声音。

printf "\a" also works in a terminal and will play the set alert sound.

这对我有用(mac os 10.14.6)

echo "\x07"  

This works for me (mac os 10.14.6)

echo "\x07"  
财迷小姐 2024-09-14 04:39:17

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

on MacOS X, the "sound warning" option (Terminal/Preferences) has to be activated to get a sound.

但可醉心 2024-09-14 04:39:17

osascript -e '告诉应用程序“系统事件”发出蜂鸣声'

osascript -e 'tell application "System Events" to beep'

记忆里有你的影子 2024-09-14 04:39:17

如果您安装了 Xcode,您可以发出蜂鸣声/响铃。我还没有想到我可以让 printf "\a" 字符在 C 中工作。

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

我相信,这是一种方法,但仅限于程序运行时。

If you've got Xcode installed you can make a beep/bell. I haven't figured that I can make the printf "\a" character work in C.

There's one way to make the tone work as the program runs, start Xcode, drop down menu under Xcode, Preferences, Behaviours, check the first box "Play sound", choose from the list or add a sound.

That's one way to do it, but only as the program runs, I believe.

沧桑㈠ 2024-09-14 04:39:17

如需更多选择,请聆听并选择

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

For more options, hear and pick

ls /System/Library/Sounds/*.* | awk '{print $1}' | while read sound; do printf "afplay $sound\n"; afplay $sound; sleep 0.5; done
ls /System/Library/PrivateFrameworks/ScreenReader.framework/Versions/A/Resources/Sounds/*.* | awk '{print $1}' | while read sound; do printf "afplay $sound\n"; afplay $sound; sleep 0.5; done
又爬满兰若 2024-09-14 04:39:16

tput bel 适用于大多数 shell。

在 OS X 中,如果在终端不在前台时执行该命令(以及任何其他使铃声响起的命令),也会为您带来徽章:

tput bel works in most shells.

In OS X, this (and any other command that makes the bell go off) also gets you a badge if the command is executed when Terminal was not in the foreground:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文