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

ピアノの音

Posted at

🎹 ピアノの音:数式によるモデル化


🔹 ① 音の基本モデル:調和振動子(1本の弦)

弦の変位 $y(t)$ は以下のように表せます:

$$
y(t) = A \cdot e^{-r t} \cdot \sin(2\pi f t + \phi)
$$

  • $A$:初期振幅(打弦強さ)
  • $r$:減衰係数(弦の抵抗、共鳴体へのエネルギー散逸)
  • $f$:基本周波数(音の高さ、例:A4 = 440Hz)
  • $\phi$:初期位相

🔹 ② 複数モードの重ね合わせ(倍音成分)

ピアノ弦は「1本でも複数モードで振動」します:

$$
y(t) = \sum_{n=1}^{N} A_n \cdot e^{-r_n t} \cdot \sin(2\pi n f_0 t + \phi_n)
$$

  • $f_0$:基本周波数(鍵盤で決まる)
  • $n$:モード番号(倍音数)
  • $A_n, r_n, \phi_n$:各モードに対する振幅・減衰・位相

🔹 ③ 共鳴体(響板)との結合 → 音圧波形 $p(t)$

共鳴板で増幅された空気振動は:

$$
p(t) = K \cdot \frac{d^2 y(t)}{dt^2}
$$

  • $p(t)$:音圧(マイクや耳に届く音の物理量)
  • $K$:共鳴板の音響効率(弦から空気への結合係数)

🔹 ④ デジタル信号としてのピアノ音(PCM形式)

$$
x[n] = \sum_{n=1}^{N} A_n \cdot e^{-r_n n T_s} \cdot \sin(2\pi n f_0 n T_s + \phi_n)
$$

  • $T_s$:サンプリング周期(例:44.1kHz)
  • $x[n]$:デジタル化された音(WAVファイルなど)

✅ 応用例:A4(440Hz)ピアノ音の近似モデル

# Program Name: piano_harmonics_sim.py
# Creation Date: 20250710
# Overview: Generate a piano-like sound by summing damped sine waves (harmonics)
# Usage: Run in a Python environment with sounddevice or IPython.display for playback

import numpy as np
import scipy.io.wavfile as wav
import matplotlib.pyplot as plt
import os
import IPython.display as ipd

# --- Parameters / パラメータ設定 ---
fs = 44100               # Sampling rate [Hz]
duration = 1.0           # Duration [s]
t = np.linspace(0, duration, int(fs * duration), endpoint=False)

f0 = 440.0               # Fundamental frequency [Hz] (A4)
N = 5                    # Number of harmonics
A_n = [1, 0.6, 0.3, 0.15, 0.05]  # Amplitude per harmonic
r_n = [3, 5, 7, 9, 12]           # Damping factor per harmonic
phi_n = [0, 0.3, 0.6, 1.0, 1.5]  # Phase per harmonic [rad]

# --- Signal synthesis / 信号生成 ---
y = np.zeros_like(t)
for n in range(N):
    y += A_n[n] * np.exp(-r_n[n] * t) * np.sin(2 * np.pi * (n + 1) * f0 * t + phi_n[n])

# Normalize and convert to int16
y /= np.max(np.abs(y))
y_int16 = np.int16(y * 32767)

# --- Save to WAV file ---
output_path = "piano_sound.wav"
wav.write(output_path, fs, y_int16)

# --- Plot waveform ---
plt.figure(figsize=(10, 3))
plt.plot(t[:2000], y[:2000])
plt.title("Piano-like Sound Waveform (First 2000 samples)")
plt.xlabel("Time [s]")
plt.ylabel("Amplitude")
plt.grid(True)
plt.tight_layout()
plt.show()

# --- Playback ---
ipd.Audio(output_path)


🎼 結論:ピアノの音の式まとめ

$$
\boxed{
p(t) = K \cdot \frac{d^2}{dt^2} \left[ \sum_{n=1}^{N} A_n e^{-r_n t} \sin(2\pi n f_0 t + \phi_n) \right]
}
$$

これは「打弦 → 弦振動 → 響板共鳴 → 空気圧変動 → 聴覚」という物理連鎖の定式化です。


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