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?

More than 3 years have passed since last update.

aplayでは、ボリューム調整できない罠

Posted at

そんなこと知ってるって?
いや、備忘録なんで許して。

例えば、wavを再生したいとき、コマンドはみなさんaplayを使うと思うんでよ。

aplay -D plughw:0 test.wav

こんな感じで使用しますよね?

で、再生できるとなるとこんなこと思ったりしませんか?

ボリューム調整の引数が見当たらないなー。

はっきりいうとaplayにはそんな機能見当たりません。 (私調べ)

マニュアルでも見当たらなかったから確かなはず、違ったら教えてください。

で結局どうするかというと、

amixerを使うにたどり着きました。

amixer -c0 sset Headphone 100% &&\
aplay -D plughw:0 test.wav

この「Headphone」という部分は、私のraspberry pi4bがこれじゃないとイヤイヤと聞かなかったものでこのように設定しております。
確認方法は、以下のコマンドでみてね。

amixer scontrols

で!

実際のところは、複数の音声を流すとかあるよね。
例えば、①の音声を流した後に、②の音声を再生したいとかとか。
この場合、①の音声が以上に音量が大きく録音されてたりすると、②との音量の格差に音が聞き取れないとかあるよね。
そういうときに、さっきのamixerを分けてコマンドするといい感じに調整できるというわけだ。

amixer -c0 sset Headphone 50% &&\
aplay -D plughw:0 test1.wav

amixer -c0 sset Headphone 100% &&\
aplay -D plughw:0 test2.wav

とまあ、それだけの話。

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?