Apps and experimental tools / Sound × Mathematics

November 18, 2026Feature overview & user guide

Harmonic Synth 24

An experiment in 24-partial synthesis, recorded sound, frequency ratios, and two kinds of piano roll.

How this app came about

Hello, I'm Reiji.

I often use mathematical formulas and programs to make sounds and explore the relationships between them.

I wondered if I could take part of what I usually do, narrow down the functions a little, and turn it into a web app with a user interface so I wouldn't have to keep typing in formulas by hand. I tried making one, found it surprisingly fun, and decided to share it.

At first, I implemented two functions:

  • A mixer for creating timbres by choosing the waveform and volume of each of up to 24 harmonic components.
  • A piano roll that uses that timbre as its sound source and lets you enter frequency ratios directly, so you can play music using combinations of pitches that cannot be expressed in 12-tone equal temperament alone, including just-intonation intervals with various prime limits.

Note: A prime limit specifies the largest prime number permitted in the numerator and denominator of a just-intonation frequency ratio. For example, 5-limit uses the prime factors 2, 3, and 5; 7-limit also permits 7; and 11-limit also permits 11.

After that, I added a familiar 12-tone equal-tempered piano roll and a sampling function so that sounds recorded with a microphone could be used as sound sources too. That means you can even play a tune using a fart sound.

I also thought it would be interesting to see directly how the formulas change when I adjust the sound settings in the UI, so I added a live equation display.

Then I added a Custom Waveform Editor, so I could define the waveform of each of the 24 components by entering a formula or drawing it directly. The app can also approximate a waveform I draw with a Fourier series and display the resulting equation.

As I kept implementing ideas whenever they came to me, the app ended up with more functions than I had expected.

That has made the screen a little crowded, and there is still room to improve the UI. I plan to keep updating the app little by little.

If you're interested, please give it a try.

24 adjustable partialsRatio & 12-TET piano rollsMicrophone / audio samplingLive equationsCustom waveform editor
Cropped screenshot of the ratio piano roll, note events and playback settings

A workbench for experiments

Hear a timbre, change its components, enter notes, and listen again.

Different tuning systems can be tried with the same general sequence-editing workflow. The visual displays help connect audible changes with settings and formulas, without presenting them as calibrated acoustic measurements.

Screenshots show the English-language interface of a development version. On-screen labels may differ slightly as the application is updated.

01 / MAIN FUNCTIONS

What the application can do

01 — SOUND SOURCE

Build a timbre from 24 harmonic components

Each component can be adjusted independently. Choose a waveform, change its level, or mute it; the synthesized sound and its mathematical description respond to the settings.

  • Components 1–24, based on integer multiples of the reference frequency
  • Sine, triangle, square, sawtooth, and Custom waveforms
  • Volume, mute controls, timbre presets, and JSON export/import
Cropped screenshot of the 24-partial mixer with waveform selectors, level sliders and mute buttons
Fig. 1 — Twenty-four individually adjustable partials.
02 — SOUND SOURCE

Use recorded audio instead of synthesis

Record a single note with a microphone or import an audio file. Set the pitch of the source recording, then use the recorded timbre for piano-roll playback. Pitch transposition is performed by changing playback speed.

Recordings can be saved separately as WAV files. Audio recordings are not embedded in the song JSON.

Cropped sampler controls, including recording, audio file import, source frequency and waveform preview
Fig. 2 — Microphone recording and audio file import.
03 — COMPOSITION

Two independent piano rolls

Ratio mode lets each pitch row use a freely entered positive ratio such as 3/2 or 23/16. The actual frequency is obtained by multiplying the reference frequency by that ratio, without rounding to 12-TET.

12-TET mode offers a conventional chromatic piano roll from C2 to B6, with an adjustable A4 reference. The two modes keep separate note data.

The included starting scores are Reiji’s versions of “God Save the King”: 14 bars in 3/4, with 163 note events in each mode.

Ratio mode with note rectangles on a beat grid and pitch ratios at left
Fig. 3 — Piano-roll notes are positioned horizontally by beat and vertically by pitch row.
04 — OBSERVATION

Watch the waveform, levels, and live equation

The waveform panel provides a model of the synthesized tone while idle, and an audio-path waveform view during playback. The harmonic-level display shows the configured levels of the 24 components; it is not an FFT measurement of the speakers.

The equation panel updates when synthesis parameters or the selected/playback pitch changes. With sampled audio, it displays a playback-rate relationship instead of pretending that the recording was made by the 24-partial mixer.

Synthesized waveform graph beside a harmonic-level bar chart
Fig. 4 — The two graphical views.
Live harmonic equation and expanded numerical sum for the currently selected sound
Fig. 5 — Live equations, sounding-note frequencies, and playback controls.
05 — WAVEFORM EDITING

Edit individual waveforms with equations or freehand drawing

Each of the 24 mixer components can use a Custom waveform. Select Custom and click Edit to open the modal editor. Within one cycle (0–2π), enter a supported equation or draw directly on the graph. The result can be previewed and applied to that component.

For a hand-drawn waveform, the app samples one cycle at 256 points and produces an approximation using a 24th-order Fourier series. It removes the DC component and normalizes the peak amplitude. The resulting equation and coefficients can be inspected, and the Custom waveform settings are included in JSON export and import.

Scope and limits: freehand-to-equation conversion is an approximation, not exact reconstruction. The equation parser accepts only a limited set of mathematical and LaTeX-like expressions. A Custom waveform can itself contain higher harmonics, so 24 mixer components do not impose a 24th-harmonic cutoff. The displayed graph and coefficients describe the synthesis model, not a measurement of speaker output.

Actual mixer screenshot showing Custom selected for Harmonic 1 with an Edit button
Fig. 6 — Choose Custom and use Edit to reopen the waveform editor.
Actual Custom Waveform Editor screenshot showing formula input, conversion controls, waveform graph and Fourier approximation
Fig. 7 — Formula input, hand-drawn waveforms, and Fourier-series approximation in the modal editor.

02 / INSTRUCTIONS

User guide

01

Open the page and choose the playback source

Open the application in a modern browser. Under Piano-roll sound source, choose the 24-partial mixer or sampled audio. The master-volume control at the top applies to playback. Start with a low volume.

02

If using synthesis: design the sound

Choose a timbre preset or open the 24-partial mixer. Adjust each component’s waveform and volume, and use Mute to compare contributions. Click Preview sound to hear the result. To customize a component, select Custom and click Edit to open its waveform editor; use the equation controls or draw on the graph, then apply the result. The waveform, levels, and live equation reflect the selected settings.

03

If using a sample: record or import a sound

Use Record microphone, then Stop recording, or click Load audio file. Enter the recorded note’s actual frequency in the sample reference-frequency field. Select the sampled-audio source before playback; use Preview recording to check it.

Microphone recording generally requires HTTPS or localhost and browser permission. The recording limit in this version is ten seconds. A pitched, sustained single note is the simplest material to test.
04

Choose ratio or 12-TET mode

Use the two tabs above the score. In ratio mode, enter ratios on the left of the pitch rows, and set the reference frequency at the top (initially C = 261.625565 Hz). In 12-TET mode, choose pitches on the chromatic keyboard and use the A4 setting (initially 440 Hz).

The two scores are separate: changing modes does not convert an existing ratio score into a 12-TET score.

05

Enter and edit notes

Click an empty position on a row to add a note. Drag a note to change its starting position; drag its right edge to change its duration. An empty interval acts as a rest. Select a note to edit start, duration, and note volume precisely in the inspector. Choose the grid resolution, including triplets, and adjust tempo, meter, bar count, zoom, and horizontal scroll.

Ratio piano-roll toolbar showing mode tabs, time signature, tempo, grid and transport controls
Fig. 8 — Mode selector and note-entry settings.
06

Play and inspect the result

Click Play sequence to hear the active score and Stop to end playback. When stopped, selecting a note shows its pitch equation. During playback, the panel shows the frequencies of all sounding notes and a combined equation for the polyphonic mix. Open Show per-note expansions to inspect each voice: its partial-by-partial expansion with the 24-partial mixer, or its playback-rate transposition relationship with the sampler. These are mathematical models of audio generation, not measurements of speaker output.

07

Clear, restore, save, and reopen

Clear all notes removes note events in the currently active piano-roll mode after a confirmation. Restore Reiji’s original song returns that mode to its included starting data. Use Save song (JSON) and Load saved song for both scores together, or the separate mixer/timbre JSON controls to keep settings.

Save sampled audio as WAV separately: the JSON records its settings, not the audio waveform.

Piano-roll note inspector and JSON song/mixing import and export controls
Fig. 9 — Editing details and JSON file controls.
08

Change the interface language

The application opens in Japanese by default. Use the 日本語 / English buttons in its header to switch languages. This does not change the notes or tuning data.

03 / MATHEMATICAL MODEL

What the equations represent

The numbers below describe how the application defines a target pitch or a synthesized waveform. They are useful for examining the relationship between user input and generated sound, rather than as measurements of the listening environment.

Frequency-ratio piano roll

f = fref × r

The reference frequency multiplied by the user-entered ratio r.

12-tone equal temperament

f = fA4 × 2(m − 69)/12

m is the MIDI note number; 69 is the MIDI note number assigned to A4 (normally 440 Hz), so m − 69 gives the semitone distance from A4. fA4 is the A4 reference frequency.

24-partial synthesis model

u(t) = ∑n=1…24 an Wn(2πnf0t)

t is time (seconds); n is the component number (1–24); an is its amplitude coefficient; Wn is the chosen waveform function; and f0 is the reference frequency (Hz) for the sounding pitch. Nonsinusoidal waveforms can introduce additional higher-frequency content.

Sample transposition

playback rate = ftarget / fsample

ftarget is the target frequency (Hz) of the note specified in the piano roll. fsample is the reference frequency (Hz) of the recorded or loaded sample. Their ratio sets the playback-speed multiplier: for example, 440 / 220 = 2 plays the sample twice as fast and one octave higher.

Custom waveform: Fourier approximation

w(θ) ≈ ∑k=1…24 [ak cos(kθ) + bk sin(kθ)]

θ runs from 0 to 2π over one cycle; k is the order of each Fourier component; ak and bk are the estimated cosine and sine coefficients. Hand-drawn waveforms are approximated through order 24 after DC removal and peak normalization.

04 / DATA & LIMITATIONS

Notes on use and interpretation

  • Visualization versus measurement: The harmonic bars display mixer settings; the equation describes the synthesis configuration. Neither is a calibrated loudspeaker or room measurement. The audio waveform shown during playback comes from the browser audio path, not a microphone measurement of the external speaker.
  • Twenty-four components: The mixer controls 24 nominal partials. Triangle, square, and sawtooth choices can generate higher-order spectral components beyond those nominal frequencies.
  • Custom waveform data: Fourier coefficients are included in the applicable JSON exports and imports. Older application versions without Custom support cannot read JSON containing these waveforms.
  • Save formats: The song JSON stores both piano-roll scores and relevant settings. WAV recordings must be saved and transferred separately; mixing information and timbre settings can also be exchanged as JSON.
  • Pitch choices: Ratio mode uses the entered ratio directly. The application does not automatically determine which ratio is musically preferable in a given harmonic context.
  • Browser and device differences: Audio behavior can vary with browser, hardware, and speaker system. This project is an interactive experiment rather than a physically verified sound-output standard.
ApplicationHarmonic Synth 24 — Ratio / 12-TET Piano Roll
TechnologyBrowser application / Web Audio API / AI-assisted coding
Input systemsFrequency-ratio piano roll; 12-tone equal-tempered piano roll
Sound sources24-partial synthesized sound; microphone or imported audio sample
Demo score“God Save the King” — Reiji’s entered ratio and 12-TET scores
Application URLreiji-lab.org/tools/harmonic-synth-24/

Experimental ideas and musical input: Reiji. Documentation and implementation were prepared with family support and AI-assisted development. The descriptions refer to the version documented in November 2026.

Usage

Harmonic Synth 24 is free to use for experimentation, learning, and research. Feel free to share the URL.

Contact:

アプリ・実験用ツール / 音 × 数学

2026年11月18日機能紹介・操作マニュアル

Harmonic Synth 24

24個の倍音成分の合成、サンプリング、音程比と12平均律の2種類のピアノロールを組み合わせた実験用アプリ。

制作の経緯

こんにちは、れいじです。

普段は数式やプログラムを使って音を鳴らし、音の関係性を探ったりしています。

普段やっていることの一部を、もう少し機能を限定して、数式をポチポチ打ち込まなくても操作できるUIを備えたWebアプリにできないかなと思い付いて作ってみたところ、案外面白かったので公開することにしました。

最初に実装したのは、次の2つの機能です。

  • 最大24個の倍音成分について、それぞれ波形や音量を設定してミキシングし、音色を作る機能
  • その音色を音源として使い、周波数比を直接入力することで、さまざまなlimitの純正律音程をはじめ、12平均律だけでは表現できない音の組み合わせで曲を演奏できるピアノロール

※ limit(素数限界)とは、純正律の音程比を構成する素数の上限を表すものです。例えば5-limitでは2・3・5、7-limitでは2・3・5・7を使用し、11-limitではさらに11を使用できます。

その後、普段なじみのある一般的な12平均律のピアノロールも追加したり、マイクで録音した音を音源として利用できるサンプリング機能を追加したりしました。これなら、おならの音でも曲を演奏できます。

また、UIで音の設定を変えたときに、数式がどのように変化するのかを直接確認できたら面白いと思い、数式をリアルタイムに表示する機能も追加しました。

さらに、24個の成分それぞれの波形を、数式を入力したりグラフに直接描いたりして編集できるカスタム波形エディターも追加しました。手描きした波形からフーリエ級数の近似式を作って表示することもできます。

思い付いた機能を次々に実装していたら、予想以上に多機能になってしまいました。

その分、画面が少しごちゃごちゃしてしまい、UIなどにはまだ改善の余地があります。今後も少しずつバージョンアップしていこうと思っています。

興味があれば、ぜひ使ってみてください。

24成分の倍音ミキサー音程比・12平均律録音・サンプリングリアルタイム数式カスタム波形編集
音程比のピアノロール画面。音符や演奏設定が表示されている

音を試すための作業台

音を作る。設定を変える。音符を入力する。もう一度聴く。

同じ編集操作で異なる音律や音色を試すことができます。各種表示は、耳で聴いた変化と設定値・計算式を結びつけるためのもので、校正された音響測定結果ではありません。

掲載画像は開発中バージョンの英語表示を使用しています。アプリの更新により表示が一部異なる場合があります。

01 / MAIN FUNCTIONS

主な機能

01 — 音源

24個の倍音成分から音色を作る

24個の各成分について、波形・音量・ミュートを個別に設定できます。設定の変更は合成音と数式表示に反映されます。

  • 基準周波数の整数倍に対応する第1〜24成分
  • 正弦波・三角波・矩形波・ノコギリ波・Custom波形の選択
  • 音量・ミュート・音色プリセット・JSONでの保存と読み込み
24倍音ミキサー。各成分の波形、音量、ミュートを選択できる
図1 — 24個の成分を個別に編集できるミキサー。
02 — 音源

録音した音を音源として使う

PCマイクで単音を録音するか、音声ファイルを読み込むことができます。録音元の周波数を設定すると、その音色をピアノロールの演奏に使用できます。音程の移調は再生速度の変更によって行います。

録音素材はWAV形式で別途保存できます。曲のJSONに音声そのものは含まれません。

マイク録音、音声ファイルの読み込み、基準周波数、波形プレビューの操作画面
図2 — マイク録音・音声ファイル読み込み。
03 — 曲の入力

独立した2種類のピアノロール

音程比モードでは、各音程行に 3/2 や 23/16 などの正の周波数比を入力できます。基準周波数との乗算で音高を決め、12平均律には丸めません。

12平均律モードでは、C2〜B6の半音階を使い、A4の基準周波数を変更できます。2種類の演奏データは別々に保持されます。

初期データには、禮司が入力した英国国歌「God Save the King」の両モード版が入っています。各14小節・3/4拍子・163音符です。

左側に周波数比、右側に音符を配置するピアノロール
図3 — 横軸は発音位置、縦軸は音程行。
04 — 観察

合成波形・倍音レベル・数式を確認する

停止時には計算上の合成波形、演奏時にはブラウザ内の音声経路から取得した波形を表示します。倍音レベルの棒グラフは24成分の設定値を表しており、スピーカーの実測FFT結果ではありません。

数式パネルでは音色の設定や選択中・演奏中の音高に応じて表示内容が更新されます。サンプラーを使う場合は、24倍音の合成式ではなく再生速度による移調関係を示します。

合成波形と倍音レベルのグラフ
図4 — 波形と倍音レベルの表示。
現在の音色と音高に連動する数式パネル
図5 — リアルタイム数式、発音中の音程・周波数、再生操作。
05 — 波形編集

数式と手描きで、成分ごとの波形を編集する

24個のミキサー成分それぞれに「Custom」波形を設定できます。波形を「Custom」に切り替えて「編集」を押すと、モーダル型のエディターが開きます。1周期(0〜2π)の波形を、対応する数式の入力またはグラフへの直接描画で編集し、試聴・適用できます。

手描き波形は1周期を256点で取り扱い、24次までのフーリエ級数で近似します。直流成分を除去し、ピーク振幅を正規化します。近似式や係数を確認でき、Custom波形の設定はJSONで保存・復元できます。

仕様上の注意:手描きから数式への変換は近似であり、元の曲線と完全には一致しません。数式入力は一部の演算・LaTeX風表記に限定されます。また、各Custom波形自体が高次倍音を含むため、「24成分」は第24倍音までの帯域制限を意味しません。表示される波形や係数は合成モデルに基づくもので、スピーカー出力の実測値ではありません。

第1倍音の波形をCustomに選択し、Editボタンが表示されている実際のミキサー画面
図6 — Customを選び、編集ボタンから再編集できます。
数式入力、変換ボタン、波形グラフ、フーリエ近似の表示があるCustom Waveform Editorの実際の画面
図7 — モーダル内での数式入力・手描き編集・フーリエ級数による近似。

02 / INSTRUCTIONS

操作マニュアル

01

アプリを開いて音源を選ぶ

ブラウザでアプリを開き、「ピアノロールの音源」から「24倍音ミキサー」または「録音した音(サンプラー)」を選びます。画面上部のマスター音量は演奏全体に作用します。最初は小さめの音量で試してください。

02

合成音を使う場合:音色を調整する

プリセットを選ぶか、「24倍音ミキサー」を開いて、各成分の波形と音量を設定します。「ミュート」で個別の成分を止めることもできます。「音色を試聴」を押して結果を聴き、波形や数式の変化を確かめます。成分ごとの波形を編集する場合は「Custom」を選んで「編集」を押し、数式または手描きで波形を作ってから適用します。

03

サンプルを使う場合:録音または読み込む

「マイク録音」→「録音終了」、または「音声ファイルを読み込む」で素材を登録します。「録音した音の基準周波数」に実際の音高をHzで入力し、音源をサンプラーに切り替えます。「録音音を試聴」で確認できます。

マイク機能には、通常HTTPSまたはlocalhostの環境とマイク利用の許可が必要です。録音は最大10秒です。まずは単音をできるだけ安定して鳴らすと試しやすくなります。
04

ピアノロールの方式を選ぶ

譜面上の切替ボタンから選びます。音程比モードは左側の比率を編集し、画面上部の基準周波数(初期値 C = 261.625565 Hz)を設定します。12平均律モードは半音階の鍵盤を使い、A4(初期値 440 Hz)を基準にします。

両モードのデータは独立しています。モードを切り替えても、入力済みの音符が自動的にもう一方の音律へ変換されるわけではありません。

05

音符を入力・編集する

空白をクリックすると音符を追加できます。音符をドラッグすると開始位置、右端をドラッグすると長さを変更できます。何も置かない区間は休符です。音符を選択すれば、下の「音符の詳細」で開始位置・長さ・音量を数値で指定できます。3連符を含むグリッドの単位やテンポ、拍子、小節数、横軸の拡大率も設定できます。

ピアノロールの方式、テンポ、拍子、グリッド、再生ボタンなど
図8 — ピアノロールの基本操作部。
06

演奏して確認する

「自動演奏」で現在のピアノロールを再生し、「停止」で演奏を止めます。停止時は、選択した音符の音高に応じた数式を確認できます。演奏中は、発音しているすべての音の周波数と、それらを重ね合わせた合成式を表示します。「各音の内訳・展開式を表示」を開くと、音ごとの式も確認できます。24倍音ミキサーでは倍音成分の展開式、サンプラーでは再生速度による移調関係が表示されます。これらは音声生成の数理モデルであり、スピーカー出力の実測結果ではありません。

07

一括削除・復元・保存・読み込み

「曲の音符を一括削除」は、確認後に現在のモードの音符だけを削除します。「禮司の初期データに戻す」でそのモードの初期曲を復元できます。「曲を保存(JSON)」では両モードの演奏データをまとめて保存でき、「保存した曲を読み込む」で再開できます。ミキシング設定や音色設定は別のJSONとして保存できます。

録音した音そのものはJSONに含まれないため、WAVも別に保存してください。

音符の詳細欄、曲のJSON保存・読み込み、ミキシング情報のファイル操作
図9 — 音符の詳細とファイル操作。
08

日本語・英語を切り替える

アプリは日本語を初期表示にしています。画面右上の「日本語 / English」から切り替えられます。言語を変更しても曲や音律の設定は変わりません。

03 / MATHEMATICAL MODEL

表示される数式について

以下はアプリ内部で音の高さや合成波形をどのように定義しているかを示した式です。設定値と生成音の関係を理解するためのもので、スピーカーから出た音の実測式ではありません。

音程比モード

f = fref × r

基準周波数に入力比率 r を掛けて音高を求めます。

12平均律モード

f = fA4 × 2(m − 69)/12

m はMIDIノート番号、69は基準音A4に対応するMIDIノート番号です。m − 69 はA4からの半音数を表し、fA4 はA4の基準周波数(通常440 Hz)です。

24成分の合成音

u(t) = ∑n=1…24 an Wn(2πnf0t)

t は時間(秒)、n は成分番号(1〜24)、an は各成分の振幅係数、Wn は選択した波形関数、f0 は発音する音の基準周波数(Hz)です。正弦波以外の波形では、さらに高次の周波数成分が生じ得ます。

サンプル音の移調

再生速度 = ftarget / fsample

ftarget はピアノロールで指定した演奏したい音の周波数(Hz)、fsample は録音・読み込みしたサンプル音の基準周波数(Hz)です。この比で再生速度を変更します。例えば、440 / 220 = 2 なら2倍速で再生され、1オクターブ高い音になります。

Custom波形のフーリエ近似

w(θ) ≈ ∑k=1…24 [ak cos(kθ) + bk sin(kθ)]

θ は1周期の角度(0〜2π)、k はフーリエ成分の次数、ak と bk はそれぞれ余弦・正弦の近似係数です。手描き波形は直流成分除去・ピーク正規化のうえ、24次までで近似します。

04 / DATA & LIMITATIONS

保存データと注意事項

  • 表示と実測の違い:倍音レベルはミキサーで指定した成分の設定値、数式は合成条件を表すモデルです。いずれもスピーカーや室内音響の校正済み測定結果ではありません。再生中の波形もブラウザ内部の音声経路を示すもので、外部スピーカー音をマイク測定したものではありません。
  • 24成分とは:ミキサーが制御する基本の成分数です。三角波・矩形波・ノコギリ波などは、そこから追加の高次周波数成分を生む場合があります。
  • Custom波形の保存:フーリエ係数は対応するJSONの保存・読み込みに含まれます。Custom波形に対応しない旧バージョンでは、その情報を含むJSONを読み込めません。
  • 保存形式:曲JSONには両モードの譜面と関連設定を格納しますが、録音音声は含みません。サンプル音はWAVで別途保存してください。ミキシングと音色も別のJSONで入出力できます。
  • 音律の選択:音程比は入力された値をそのまま用います。どの比率が曲の和声に適するかをアプリが自動判定するものではありません。
  • 動作環境:ブラウザ・音声デバイス・スピーカーによって聴こえ方や動作は異なります。厳密な音響測定器ではなく実験用アプリとして使用してください。
アプリ名Harmonic Synth 24 — Ratio / 12-TET Piano Roll
実装ブラウザアプリ / Web Audio API / AIによるコーディング支援
音程入力任意の周波数比 / 12平均律
音源24成分の合成音 / マイク録音・音声ファイル
初期演奏曲英国国歌「God Save the King」— 禮司の入力データ
アプリURLreiji-lab.org/tools/harmonic-synth-24/

実験上の発想・演奏データ:禮司。資料整理および実装は家族の支援とAIによるコーディング支援を利用しています。本記事は2026年11月時点の仕様を対象にしています。

利用について / Usage

Harmonic Synth 24は、音響・音律の実験や学習に自由にご利用いただけます。URLの共有も歓迎します。

お問い合わせ / Contact: