0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

mpvで音声ファイルをカラオケ化

Posted at

動機

  • 音声ファイルや音楽ファイルを再生するとき、ボーカルを減らしてカラオケ風にして、演奏メインで聴きたい。
  • 安全のため、ある程度メジャーなプレーヤ(オープンソース、いろんなOSで動く等)で実現したい。

解決策

オープンソースのmpvプレーヤを、jsでカスタマイズする。
定義または上書きしたキーを打つことで、循環的にボーカル低減レベルを切り替えることができる。

~/.config/mpv/scripts/my.js
var pow0 = 0;
mp.add_key_binding(")", "mlev", function() {
  pow0 = (pow0+1) % 7;
  mp.command("no-osd af add @mlev:lavfi=[stereotools=mlev=" + Math.pow(0.5,pow0) + "]");
  mp.commandv("show-text", "mlev 0.5^" + pow0);
});
命令 意味
mp.add_key_binding 処理にキーを割り当て。引数0は規定キー(shift-9(")"))。引数1は名前で~/.config/mpv/input.confでキー割当変更可能。引数2は処理。
no-osd オンスクリーンディスプレイを表示しない
af add オーディをフィルタを追加
@mlev 追加するフィルタ定義のローカル名。同じ名前の定義が既に追加済なら新しい値に入れ替える。
lavfi ffmpegの仮想入力デバイス名
stereotools ffmpegのステレオ関連のフィルタ
mlev=(数字) middle signalのレベル。0.015625 ~ 64。ボーカルはミドルに配置されていることが多いため、値を減らすと物理プラグを接触不良にしたようにボーカルの音量が小さくなる。
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?