让我们使用 PC 键盘在终端演奏钢琴
创始人
2024-03-01 21:34:48
0

厌倦了工作?那么来吧,让我们弹弹钢琴!是的,你没有看错,根本不需要真的钢琴。我们可以用 PC 键盘在命令行下就能弹钢琴。向你们介绍一下 piano-rs —— 这是一款用 Rust 语言编写的,可以让你用 PC 键盘在终端弹钢琴的简单工具。它自由开源,基于 MIT 协议。你可以在任何支持 Rust 的操作系统中使用它。

piano-rs:使用 PC 键盘在终端弹钢琴

安装

确保系统已经安装了 Rust 编程语言。若还未安装,运行下面命令来安装它。

curl https://sh.rustup.rs -sSf | sh

(LCTT 译注:这种直接通过 curl 执行远程 shell 脚本是一种非常危险和不成熟的做法。)

安装程序会问你是否默认安装还是自定义安装还是取消安装。我希望默认安装,因此输入 1 (数字一)。

info: downloading installer

Welcome to Rust!

This will download and install the official compiler for the Rust programming
language, and its package manager, Cargo.

It will add the cargo, rustc, rustup and other commands to Cargo's bin
directory, located at:

/home/sk/.cargo/bin

This path will then be added to your PATH environment variable by modifying the
profile files located at:

/home/sk/.profile
/home/sk/.bash_profile

You can uninstall at any time with rustup self uninstall and these changes will
be reverted.

Current installation options:

default host triple: x86_64-unknown-linux-gnu
 default toolchain: stable
 modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
1

info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
223.6 KiB / 223.6 KiB (100 %) 215.1 KiB/s ETA: 0 s
info: latest update on 2017-10-12, rust version 1.21.0 (3b72af97e 2017-10-09)
info: downloading component 'rustc'
 38.5 MiB / 38.5 MiB (100 %) 459.3 KiB/s ETA: 0 s
info: downloading component 'rust-std'
 56.7 MiB / 56.7 MiB (100 %) 220.6 KiB/s ETA: 0 s
info: downloading component 'cargo'
 3.7 MiB / 3.7 MiB (100 %) 173.5 KiB/s ETA: 0 s
info: downloading component 'rust-docs'
 4.1 MiB / 4.1 MiB (100 %) 224.0 KiB/s ETA: 0 s
info: installing component 'rustc'
info: installing component 'rust-std'
info: installing component 'cargo'
info: installing component 'rust-docs'
info: default toolchain set to 'stable'

stable installed - rustc 1.21.0 (3b72af97e 2017-10-09)

Rust is installed now. Great!

To get started you need Cargo's bin directory ($HOME/.cargo/bin) in your PATH
environment variable. Next time you log in this will be done automatically.

To configure your current shell run source $HOME/.cargo/env

登出然后重启系统来将 cargo 的 bin 目录纳入 PATH 变量中。

校验 Rust 是否正确安装:

$ rustc --version
rustc 1.21.0 (3b72af97e 2017-10-09)

太棒了!Rust 成功安装了。是时候构建 piano-rs 应用了。

使用下面命令克隆 Piano-rs 仓库:

git clone https://github.com/ritiek/piano-rs

上面命令会在当前工作目录创建一个名为 piano-rs 的目录并下载所有内容到其中。进入该目录:

cd piano-rs

最后,运行下面命令来构建 Piano-rs:

cargo build --release

编译过程要花上一阵子。

用法

编译完成后,在 piano-rs 目录中运行下面命令:

./target/release/piano-rs

这就是我们在终端上的钢琴键盘了!可以开始弹指一些音符了。按下按键可以弹奏相应音符。使用 左/右 方向键可以在弹奏时调整音频。而,使用 上/下 方向键可以在弹奏时调整音长。

Piano-rs 使用与 multiplayerpiano.com 一样的音符和按键。另外,你可以使用这些音符来学习弹指各种流行歌曲。

要查看帮助。输入:

$ ./target/release/piano-rs -h

piano-rs 0.1.0
Ritiek Malhotra 
Play piano in the terminal using PC keyboard.

USAGE:
 piano-rs [OPTIONS]

FLAGS:
 -h, --help Prints help information
 -V, --version Prints version information

OPTIONS:
 -c, --color  Color of block to generate when a note is played (Default: "red")
 -d, --duration  Duration to play each note for, where 0 means till the end of note (Default: 0)
 -s, --sequence  Frequency sequence from 0 to 5 to begin with (Default: 2)

我必须承认这是个超级酷的项目。对于那些买不起钢琴的人,很推荐使用这款应用。

祝你周末愉快!!

此致敬礼!


via: https://www.ostechnix.com/let-us-play-piano-terminal-using-pc-keyboard/

作者:SK 译者:lujun9972 校对:wxy

本文由 LCTT 原创编译,Linux中国 荣誉推出

相关内容

告别空谈AI:荣耀三叶草战...
在人工智能浪潮席卷全球的当下,科技企业纷纷踏上 AI 发展之路。荣...
2025-07-07 20:44:07
7.4商业观察:端侧AI芯...
投资信息太多太杂,不知道什么是重点?「华彬金融观察」公众号,深度研...
2025-07-04 06:42:10
AI投资从叙事博弈走向产业...
□徐兵 上半年,AI行情上演了一场典型的资本“冷热交替”。一季度,...
2025-07-03 08:11:36
金正恩观看朝鲜在俄作战士兵...
当地时间6月29日,朝鲜最高领导人金正恩会见访朝的俄罗斯文化部长奥...
2025-07-01 12:42:22
速递|谷歌“终端智能体”的...
图片来源:谷歌 谷歌正在推出一款新型 AI Agent工具,旨在...
2025-06-27 13:12:21
短短一年,是什么让移动AI...
2024年,是AI入端元年,大模型和agent被接入到各类移动终端...
2025-06-20 12:14:34

热门资讯

Helix:高级 Linux ... 说到 基于终端的文本编辑器,通常 Vim、Emacs 和 Nano 受到了关注。这并不意味着没有其他...
使用 KRAWL 扫描 Kub... 用 KRAWL 脚本来识别 Kubernetes Pod 和容器中的错误。当你使用 Kubernet...
JStock:Linux 上不... 如果你在股票市场做投资,那么你可能非常清楚投资组合管理计划有多重要。管理投资组合的目标是依据你能承受...
通过 SaltStack 管理... 我在搜索Puppet的替代品时,偶然间碰到了Salt。我喜欢puppet,但是我又爱上Salt了:)...
Epic 游戏商店现在可在 S... 现在可以在 Steam Deck 上运行 Epic 游戏商店了,几乎无懈可击! 但是,它是非官方的。...
《Apex 英雄》正式可在 S... 《Apex 英雄》现已通过 Steam Deck 验证,这使其成为支持 Linux 的顶级多人游戏之...
如何在 Github 上创建一... 学习如何复刻一个仓库,进行更改,并要求维护人员审查并合并它。你知道如何使用 git 了,你有一个 G...
2024 开年,LLUG 和你... Hi,Linuxer,2024 新年伊始,不知道你是否已经准备好迎接新的一年~ 2024 年,Lin...
什么是 KDE Connect... 什么是 KDE Connect?它的主要特性是什么?它应该如何安装?本文提供了基本的使用指南。科技日...
Opera 浏览器内置的 VP... 昨天我们报道过 Opera 浏览器内置了 VPN 服务,用户打开它可以防止他们的在线活动被窥视。不过...