简体   繁体   中英

How to make the hardware beep sound in Mac OS X 10.6

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?

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:

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

say "beep"

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 Victoria Do your homework!

Use the following to explore voices:

say -v \?

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

这将遍历所有声音(适用于优胜美地):

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

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!)

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.

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).

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

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

printf "\a"

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

\a      Write a <bell> character.

If you need something, that sounds like "important"

you can use

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

:)

printf "\\a"也适用于终端,并会播放设置的警报声音。

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

这对我有用(mac os 10.14.6)

echo "\x07"  

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.

osascript -e 'tell application "System Events"发出哔哔声'

For more options, hear and pick

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM