1.1. Harmonic Motion in Acoustics#

Harmonic motion is a foundational concept in acoustics, describing repetitive oscillatory movements. This behavior underpins many physical phenomena, including sound waves and vibrations, making it essential for understanding architectural acoustics.

The mechanics of harmonic motion involve its mathematical description and practical applications in acoustics, particularly in analyzing repetitive oscillations and their impact on physical systems.

Mathematical Foundation of Harmonic Motion#

The motion of harmonic oscillators can be described as:

\[s(t) = s_\text{amp} \cos(\omega t + \phi)\]

where:

  • \(s_\text{amp}\) represents the amplitude, indicating the maximum displacement from equilibrium.

  • \(\omega = 2\pi f\) is the angular frequency.

  • \(f\) is the frequency of oscillation, measured in Hz.

  • \(\phi\) denotes the phase, determining the wave’s offset in time.

The relationship between frequency and period is given by:

\[f = \frac{1}{T}, \quad \omega = 2\pi f\]

Here, \(T\) is the period, the time for one complete oscillation. These equations describe simple harmonic motion, which is crucial for understanding wave phenomena in acoustics.

Interactive Demonstration#

Below is a Python code that provides an opportunity to experiment with amplitude, phase, and frequency, visualizing their effects on harmonic motion.

import micropip
await micropip.install("IPython")
import numpy as np
import ipywidgets as widgets
from ipywidgets import interact, fixed
import matplotlib.pyplot as plt
from IPython.display import Audio

play_sound = 1 # 1 to play sound, 0 otherwise
frequency = 200 # Frequency of the sine wave (Hz)
duration = 2 # Duration of the signal (in seconds)

@interact(
    s_amp=widgets.FloatSlider(min=1, max=5, step=0.1, continuous_update=True),
    phi=(0, np.pi),
    f=fixed(frequency),
    time=fixed(duration),
    ps=fixed(play_sound),
)
def sine_waves(
    s_amp,
    phi: float,
    f=frequency,
    time=duration,
    ps=play_sound,
):
    """
    Function to generate and plot sine waves with optional sound playback.

    Parameters:
    f : float
        Frequency of the sine wave (Hz).
    s_amp : float
        Amplitude of the sine wave.
    phi : float
        Phase shift of the sine wave (radians).
    time : float
        Duration of the signal (in seconds).
    ps : int
        Play sound flag (1 to play, 0 otherwise).
    """
    # Derived parameters
    omega = 2 * np.pi * f  # Angular frequency
    T = time / f  # Period
    dt = 1 / 48000  # Time step (sampling frequency = 48 kHz)
    t = np.arange(0, T + dt, dt)  # Time vector

    # Generate signals
    s = s_amp * np.cos(omega * t + phi)  # Signal with phase shift
    s2 = s_amp * np.cos(omega * t)  # Signal without phase shift

    # Plot the harmonic motion
    # plt.figure(figsize=(10, 6))
    plt.plot(t, s2, "k", label="Signal 1")
    plt.plot(t, s, "k--", label="Signal 2")
    plt.plot(t, s_amp / np.sqrt(2) * np.ones_like(t), "r", label="seff")
    plt.xlabel("t (s)", fontsize=20)
    plt.ylabel("s (-)", fontsize=20)
    plt.grid(True)
    plt.axis([t[0], t[-1], -s_amp - 2, s_amp + 2])
    plt.legend()
    plt.tight_layout()
    plt.box(True)
    plt.show()

    # Create a longer signal for sound playback
    s = s_amp * np.cos(omega * np.arange(0, 2 + dt, dt) + phi)

    # Play sound if ps == 1

    if ps == 1:
        audio_widget = Audio(s, rate=48000)
        display(audio_widget)

        print(" Play the sound.")