長春Linux運維培訓(xùn)哪家好?千鋒教你在Linux下彈鋼琴
厭倦了工作?那么來吧,讓我們彈彈鋼琴!是的,你沒有看錯,根本不需要真的鋼琴。千鋒Linux培訓(xùn)班的老師可以教你用 PC 鍵盤在命令行下就能彈鋼琴。向你們介紹一下 piano-rs —— 這是一款用 Rust 語言編寫的,可以讓你用 PC 鍵盤在終端彈鋼琴的簡單工具。它自由開源,基于 MIT 協(xié) 議。你可以在任何支持 Rust 的操作系統(tǒng)中使用它。
piano-rs:使用 PC 鍵盤在終端彈鋼琴
安裝
確保系統(tǒng)已經(jīng)安裝了 Rust 編程語言。若還未安裝,運行下面命令來安裝它。
curl https://sh.rustup.rs -sSf | sh
(LCTT 譯注:這種直接用 curl 執(zhí)行遠(yuǎn)程 shell 腳本是一種非常危險和不成熟的做法。)
安裝程序會問你是否默認(rèn)安裝還是自定義安裝還是取消安裝。我希望默認(rèn)安裝,因此輸入 1 (數(shù)字一)。
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
登出然后重啟系統(tǒng)來將 cargo 的 bin 目錄納入 PATH 變量中。
校驗 Rust 是否正確安裝:
$ rustc --version
rustc 1.21.0 (3b72af97e 2017-10-09)
太棒了!Rust 成功安裝了。是時候構(gòu)建 piano-rs 應(yīng)用了。
使用下面命令克隆 Piano-rs 倉庫:
git clone https://github.com/ritiek/piano-rs
上面命令會在當(dāng)前工作目錄創(chuàng)建一個名為 piano-rs 的目錄并下載所有內(nèi)容到其中。進(jìn)入該目錄:
cd piano-rs
末了,運行下面命令來構(gòu)建 Piano-rs:
cargo build --release
編譯過程要花上一陣子。
用法
編譯完成后,在 piano-rs 目錄中運行下面命令:
./target/release/piano-rs
這就是我們在終端上的鋼琴鍵盤了!可以開始彈指一些音符了。按下按鍵可以彈奏相應(yīng)音符。使用 左/右 方向鍵可以在彈奏時調(diào)整音頻。而,使用 上/下 方向鍵以在彈奏時調(diào)整音長。
Piano-rs 使用與 multiplayerpiano.com 一樣的音符和按鍵。另外,你可以使用這些音符來學(xué)習(xí)彈指各種流行歌曲。
要查看幫助。輸入:
$ ./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)
我必須承認(rèn)這是個超級酷的項目。對于那些買不起鋼琴的人,很推薦使用這款應(yīng)用。
千鋒哈爾濱校區(qū):http://hrb.mobiletrain.org/
培訓(xùn)咨詢專線:17710405956 咨 詢 QQ : 1660794050
哈爾濱校址:哈爾濱市松北區(qū)創(chuàng)新一路699號 科技創(chuàng)新城19號樓B座五樓
長春Linux運維培訓(xùn)哪家好?千鋒教你在Linux下彈鋼琴