2
2

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.

【python】wavファイルの読み書きにはこれを使え【wavio】

Posted at

最近にわかに増えてきたハイレゾ対応wavファイル。これは24bitのビットレートであり、pythonで扱うには大変めんどくさい。そんな問題を解決してくれるモジュールが「wavio」だ。

導入

pip install wavio

wavファイルの読み込み

wavread.py
import wavio

wav = wavio.read(filename)

fs = wav.rate # サンプリング周波数[Hz]
samplewidth = wav.sampwidth # サンプル幅[Byte]
bit = wav.sampwidth * 8 # 量子化ビット数[bit]
data = wav.data # 波形データ
ch = len(wav.data[0, :]) # チャンネル数

wavファイルの書き出し

wavwrite.py
wavio.write("filename.wav", data, fs, sampwidth = samplewidth)

終わりに

実際に裏で動いているのはpythonの標準モジュールwaveなんだけど、まあ、こういうのがあると便利ですよね

2
2
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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?