“Audio-visual” is a cliché in visual coding and is still popular. By taking a sound source or input and analyzing the data, you can create various visual (and other) representations, ranging from practical visualizations to more expressive pieces. On this page, we will take a look at the fundamental structure of sound and examples of how to transform it into visuals.

「オーディオ・ビジュアル」は、コードでビジュアルを作る界隈では使い古されていながらも、今も人気のトピックです。音源、または音の入力を取り込み、データを分析することで、実用的なものからより表現豊かな作品まで、さまざまな視覚表現(およびその他の表現)を作り出せます。このページでは、音の基本的な構造とそれをビジュアルに変換する方法を見ていきます。

<aside> 💡 We will use the Web Audio API to play sound and get data for visualization. For more details about the Web Audio API, refer to this MDN page. You could also use p5.sound, which is a wrapper for the Web Audio API. 音の再生と可視化のためのデータ取得にWeb Audio APIを使用します。Web Audio APIの詳細については、MDNのページを参照してください。Web Audio APIをラップしたp5.soundを使うこともできます。

</aside>

Characteristics of sound waves

音波の特性

Sound is a wave. It starts from an object, anything from a guitar string, vocal cords, a propeller, to an popping balloon. When an object vibrates, has repetitive motion, or causes some impact, it causes the particles of the medium around it to vibrate, transferring the vibrations from one particle to the next. In air, these vibrations manifest as fluctuating air pressure; in water and solids, the particles oscillate back and forth.

音はです。この波はギターの弦、声帯、プロペラ、または破裂する風船など、あらゆる物体から始まります。物体が振動したり、ある動きを繰り返したり、衝撃を発生させると、その周りの媒体の粒子が振動し、振動は次の粒子へと伝わっていきます。空気中では、これらの振動は気圧の変動として現れます。水や固体では、粒子は前後に振動します。

When a sound wave reaches our ears, it causes our eardrums to vibrate. These vibrations are then translated into electrical signals in the inner ear, which the brain interprets as sound. It is fascinating, as we will see, the sound wave is just a messy up-down of the pressure level. But, we can hear different pitches and harmonies, and distinguish between various instruments, human voices, and different kinds of noise.

耳に音波が届くと、鼓膜が振動します。その振動は内耳で電気信号に変換され、脳はそれを音として解釈します。音波は雑然とした圧力レベルの上下動ですが、人がそこから異なる音の高さや調和、さらには様々な楽器や人の声、さまざまな種類の雑音を聞き分けられるのは驚異的なことです。

The characteristics of sound waves, such as frequency and amplitude, determine how we perceive different sounds. The frequency of a wave, measured in hertz (Hz), determines the pitch of the sound: higher frequencies produce higher-pitched sounds, and lower frequencies result in lower-pitched sounds. Meanwhile, the amplitude, or the height of the wave, determines the volume; larger amplitudes make louder sounds.

周波数と振幅などの音波の特性によって人がどのように異なる音を知覚するかが決まります。ヘルツ(Hz)で測られる波の周波数は、音の高さを決めます。周波数が高いほど音が高くなり、周波数が低いほど低音になります。一方で、振幅または波の高さは音量に関わり、振幅が大きいほど、より大きな音になります。

Screen Shot 2022-10-01 at 11.20.56 AM.png

In this picture, the maximum height of the wave, $a$ in the figure, is the amplitude, and the length of $b$ is the wavelength. Or if the horizontal axis of the is time, $b$ is the period, which is the time it takes for each oscillation. Frequency is the number of oscillations per second, which is one second divided by the period, $f = 1 /T$, where $T$ represents the period.

図の$a$、波の最大の振れ幅が振幅(amplitude)、$b$の長さが波長(wavelength)です。横軸が時間であれば$b$は1回の振動にかかる時間、周期(period)になります。1秒間の振動の回数が周波数(frequency)で、周期をTとすると、これは1秒を周期で割ったもの $f = 1 / T$ になります。

Sound wave as digital data

デジタルデータとしての音波