
IT之家 11 月 23 日消息,MacBook 的触控板之所以能让用户感受到点击反馈,是因为玻璃面板下方的触觉马达会产生振动,模拟手指按压的感觉。而一款名为 nospeaker 的全新开源工具,竟然利用这套马达,让 MacBook 触控板直接发出了声音。
据IT之家了解,这款有趣的小工具由开发者科迪 · 科利尔(Cody Collier)开发,项目已在 GitHub 上开源,开发者账号为 os6。该工具通过命令行运行,能够利用触控板播放 macOS 系统语音,将文字转换成语音输出,还支持播放逐渐升高的音调。不过,它无法播放音乐、YouTube 视频或其他音频文件。
这款工具的关键在于触觉马达的振动速度。根据项目介绍,nospeaker 能够以每秒最高 4000 次的频率驱动马达,让玻璃面板快速振动,从而产生人耳可以听到的声音。
具体来说,工具首先调用 macOS 内置语音功能生成语音,然后每隔 10 毫秒分析一次音频,提取两个共振峰、响度和音高等信息,再通过马达将这些信息转换成两种音调进行播放。至于带有嘶嘶声的发音,则会被转换成短促的高频音调。
最终呈现的声音虽然带有明显的机器人腔调,但音量却出人意料地大。科利尔测量发现,这套方案在约 100 Hz 至 4 kHz 的频率范围内都能产生较强的声音,只是部分频段存在明显的输出盲区,其中约 1 kHz 附近的音质最为清晰。
在 MacBook 上进行的简单测试也表明,触控板发出的声音足以充当临时扬声器。开发者还建议用户将 Mac 静音,并把电脑放在桌面上使用,以减少额外噪声。
不过,这款工具并没有使用苹果公开提供的触觉反馈 API。苹果的公开 API 只提供三种固定的触觉反馈效果,因此 nospeaker 转而使用了私有的 MultitouchSupport 框架。这也意味着,未来 macOS 系统更新可能导致工具无法正常运行。
科利尔表示,工具不会让触觉马达的驱动强度超过正常工作时的最大值。
硬件方面,任何配备 Force Touch 触控板的 Mac 都应该能够运行这款工具,包括 2015 年及之后推出的 MacBook,以及 Magic Trackpad 2 和更新型号。系统要求为:苹果芯片 Mac 需要运行 macOS 12 或更高版本,英特尔 Mac 则需要 macOS 13 或更高版本。
目前,科利尔只在搭载 M5 Max 芯片的 MacBook Pro 上完成了测试。该项目采用 MIT 开源许可证,用户可以免费使用。
本文来源:https://www.ithome.com/1/030/905.htm
若有版权问题,请来信告知:13951431913#139.com 或在右方提交评论。

Apple MacBook trackpad can actually work as a speaker: open-source tool nospeaker produces sound using the haptic motor
IT Home, November 23: The reason a MacBook's trackpad lets users feel click feedback is that the haptic motor beneath the glass panel generates vibrations, simulating the feeling of a finger press. Now a brand-new open-source tool called nospeaker actually uses this motor to make the MacBook trackpad emit sound directly.
According to IT Home, this interesting little tool was developed by developer Cody Collier, the project has been open-sourced on GitHub, and the developer account is os6. The tool runs via the command line, can use the trackpad to play macOS system voices, convert text into speech output, and also supports playing gradually rising tones. However, it cannot play music, YouTube videos or other audio files.
The key to this tool lies in the vibration speed of the haptic motor. According to the project description, nospeaker can drive the motor at a frequency of up to 4,000 times per second, making the glass panel vibrate rapidly and thereby producing sound audible to the human ear.
Specifically, the tool first invokes macOS's built-in speech function to generate voice, then analyzes the audio every 10 milliseconds, extracting two formants, loudness and pitch information, and then converts this information into two tones via the motor for playback. As for pronunciations with a hissing sound, they are converted into short high-frequency tones.
Although the resulting sound has an obvious robotic tone, its volume is surprisingly loud. Collier measured that this solution can produce relatively strong sound across the frequency range of about 100 Hz to 4 kHz, though there are obvious output blind spots in some bands, with the sound quality clearest around 1 kHz.
Simple tests conducted on a MacBook also show that the sound emitted by the trackpad is sufficient to serve as a temporary speaker. The developer also recommends muting the Mac and placing the computer on a desk during use to reduce extra noise.
However, the tool does not use Apple's publicly provided haptic feedback API. Apple's public API offers only three fixed haptic feedback effects, so nospeaker instead uses the private MultitouchSupport framework. This also means future macOS updates may cause the tool to stop working properly.
Collier said the tool does not drive the haptic motor beyond its maximum strength during normal operation.
On the hardware side, any Mac equipped with a Force Touch trackpad should be able to run this tool, including MacBooks released in 2015 and later, as well as Magic Trackpad 2 and newer models. System requirements are: Apple silicon Macs need macOS 12 or later, while Intel Macs need macOS 13 or later.
So far, Collier has only completed testing on a MacBook Pro with the M5 Max chip. The project uses the MIT open-source license and is free for users.
本文来源:https://www.ithome.com/1/030/905.htm
若有版权问题,请来信告知:13951431913#139.com 或在右方提交评论。