← エンジン一覧に戻る ← Back to Engines Phase Vocoder & Phase Locking Engine | DS Soft
EN JP

フェーズボコーダ & 位相同期(Phase Locking)エンジン Phase Vocoder & Phase Locking Engine

「なぜピッチやテンポを変えても音質が濁らないのか?」高品質時間伸縮の設計思想 High-Quality Time Stretching & Pitch Shifting Artifact Elimination

概要と搭載アプリケーション Overview & Applications

フェーズボコーダ(Phase Vocoder)は、オーディオ信号の時間長(テンポ)と周波数(ピッチ)を互いに独立して変化させるDSPアルゴリズムです。
DS Softでは、従来の処理で発生しやすい「金属的なフランジャー音(Phasing Artifact)」、「ピッチの微小な不安定感・振幅リップル」、「超スロー再生時の波形荒れ」、「リサンプリング時の高域ノイズ」を抑えるため、位相ロックの精度向上、合成ホップ(hs)固定による振幅リップルの原理的根絶、アンチエイリアス付き高品質リサンプリングを組み込んだ、C++マルチスレッド対応エンジンを構築しました。

【自作に至った開発の経緯】
当初は既存のサードパーティ製オーディオライブラリ(SoundTouch等)を導入していましたが、ピッチシフトやタイムストレッチ時の音質の曇りや輪郭の劣化がどうしても拭えず、音響的クオリティに納得がいかないという課題に直面しました。
そこで、ライブラリ依存を脱却し、独自に「Phase Vocoder + Phase Locking(位相同期)」を一から設計・実装。さらにユーザーフィードバックをもとに再合成アーキテクチャの数学的見直しを重ね、原音のハリと透明感を極限まで保つエンジンへと進化させました。

The Phase Vocoder decouples pitch and tempo adjustments. DS Soft designed a high-performance C++ multi-threaded engine optimized for mobile devices, with refined phase locking, fixed synthesis hop (hs) OLA reconstruction to eliminate amplitude ripples, and anti-aliased high-quality resampling to suppress metallic phasing, pitch wobble, and high-frequency noise.

[Development Background]
Initially utilizing third-party libraries such as SoundTouch, we encountered audio dullness and detail degradation during pitch and tempo scaling. To overcome these quality limitations, we built a custom Phase Vocoder with Phase Locking from scratch, continuously refining its mathematical reconstruction architecture based on user feedback to preserve sound crispness and transparency.
採用アプリ:Adopted Apps:
Pitch Tempo Changer Video Speed & Pitch Changer Notewise AutoTuner Odd-Time Beat Converter

1. 方式の使い分けとピッチ・テンポの独立制御 ➔ 2パス処理アーキテクチャ 1. Method Selection & Independent Pitch/Tempo Control ➔ Two-Pass Architecture

💬 開発者のつぶやき: 「”音が酷い”というレビューを受けて一念発起、エンジンを自作してみよう」 💬 Dev's Note: "Motivated by user reviews pointing out sound degradation, I decided to build a custom audio engine from scratch."

ピッチやテンポを変える方法には、PSOLAやWSOLAなど、素材や用途に応じて有効な手法があります。本エンジンでは、25%のスロー再生から400%の高速再生までのような大きなテンポ変更にも対応しやすい、周波数領域ベースのPhase Vocoderを中核に採用しています。

【問題】 音声波形をそのまま伸縮させると、テンポの変更に伴ってピッチ(音程)まで一緒に上下してしまうため、テンポとピッチを個別にコントロールすることができない。

【対処(アプローチ)】 処理を明確に2ステップに分離する「2パス戦略(Stretch ➔ Resample)」を採用しました。

  • Pass 1(STFT タイムストレッチ): 短時間フーリエ変換(STFT)を用い、周波数ドメイン上で時間軸(テンポ)のみを正確に伸縮。
  • Pass 2(3次スプライン補間リサンプリング): 伸縮後の時間波形に対し、Catmull-Rom型の高精度3次スプライン補間(Cubic Interpolation)を適用して目的のピッチへ着地。
この分離アプローチにより、処理の数学的独立性と圧倒的なスピード、およびリアルタイムでの滑らかなパラメーター追従を実現しています。

PSOLA and WSOLA are effective options depending on the source material and use case. This engine centers on a frequency-domain Phase Vocoder, which is well suited to large tempo changes such as 25% slow playback through 400% fast playback.

[Problem] Directly stretching time waveforms inherently alters pitch alongside tempo, making independent control impossible.

[Solution] A clear 2-pass strategy (Stretch ➔ Resample): Pass 1 stretches the time axis via STFT in the frequency domain; Pass 2 applies high-precision Catmull-Rom cubic spline interpolation to reach target pitch cleanly.

2. 金属的フランジャーノイズの発生 ➔ ピーク検出型 Phase Locking(位相同期) 2. Metallic Phasing Artifacts ➔ Peak-Tracking Phase Locking

💬 開発者のつぶやき: 「え・・・・フェーズボコーダって音良いんじゃないの?」 💬 Dev's Note: "Wait... isn't a Phase Vocoder supposed to sound great...?"

【問題】 ナイーブな(単純な)フェーズボコーダでは、時間軸を引き伸ばした際に「隣り合う周波数ビン(Bin)どうしの位相関係がバラバラ」になり、波形が相互干渉することでコーラスがかかったようなキンキンした金属音(Phasing Artifact)や濁りが発生する。

【対処(アプローチ)】 ピーク追跡型のPhase Locked Bins(位相同期機構)を精度向上しました。主音・倍音成分の局所的ピークをサブビン精度で推定し、各周波数ビンを最も近いピークへ割り当てて位相回転を同期。さらに、微小なノイズ成分は不要にロックしないことで、波形の位相コヒーレンスを保ちながら、金属的な響きやシュワシュワした濁りを抑制します。

[Problem] Naive STFT time-stretching disrupts relative phase coherence between adjacent frequency bins, causing unnatural metallic phasing/flanging noise.

[Solution] Refined peak-tracking Phase Locking. The algorithm estimates local spectral peaks with sub-bin precision, assigns each bin to its nearest peak, and synchronizes phase rotation while leaving very low-level noise bins unlocked. This preserves phase coherence while reducing metallic and watery artifacts.

3. スロー再生時の波形荒れ & 残存ノイズの根本解決 ➔ 完全OLA再合成 3. Slow-Tempo Artifacts & Residual Phasing Elimination ➔ Perfect OLA

💬 開発者のつぶやき: 「なんか、トレモロ掛かってない?」 💬 Dev's Note: "Wait, why does this sound like a tremolo effect is turned on...?"

【問題】 25%のような極端なスロー再生では、分析フレーム間隔が開いて窓関数の重ね合わせ密度が疎になり、波形の荒れやブツ切りノイズ(トレモロ現象)が生じやすくなる。

【対処(アプローチ)】
  • 動的オーバーラップ(Dynamic Overlap Adjustment): テンポ減速量に応じて内部オーバーラップ倍率を動的に自動制御。どのような超スロー再生でも重ね合わせ密度を常に高く維持。
  • WOLA(Weighted Overlap-Add)再合成: 窓関数による加重Overlap-Addと正規化処理を適用し、フレーム境界の振幅リップルやブツ切り音を物理的に消去。

[Problem] At extreme slow-down rates such as 25%, wider analysis hop sizes can make overlap-add synthesis sparse, producing frame clicks and amplitude flutter (tremolo).

[Solution]
  • Dynamic Overlap Adjustment: Automatically scales internal overlap factors up during slow-tempo playback to ensure continuous window density.
  • WOLA Synthesis: Applies windowing and weight normalization to physically eliminate boundary amplitude clicks.
💬 ユーザーの声: 「なんか、まだトレモロ掛かってない?(金属的なノイズや、ピッチが不自然に歪む感じがある)」 💬 User's Feedback: "Wait, isn't there still a tremolo effect? (Subtle metallic harshness and pitch drift remain...)"

【問題】 なぜWOLA正規化を行っても金属音やピッチ歪みが残るのか?
従来の設計では、分析ホップ $h_a$ を固定して合成ホップを $h_s = \lfloor h_a \times \text{timeStretch} \rfloor$ と整数変換していました。しかし合成ホップ $h_s$ が窓長の厳密な約数(例: $\text{FRAME\_SIZE} / 4$)で均一でないと、合成窓を足し合わせる瞬間に周期的な振幅の波打ち(リップル)が生じます。この局所的なAM変調によって発生した変調サイドバンド(金属音の正体)は、後から全体振幅を重みで割っても波形の中に焼き付いて消えません。さらに整数サンプル移動による微小な丸め誤差が、持続音でのピッチ揺らぎや不自然な歪みを引き起こしていました。

【対処(アプローチ)】 合成ホップ($h_s$)固定 & 倍精度連続解析(完全OLA再合成)
  • 合成ホップ $h_s$ の完全固定 & 2の累乗アライン: 合成ストライド $h_s = \text{FRAME\_SIZE} / \text{internalOverlap}$ を処理全体で完全固定し、4や8など「2の累乗」にアライン。Sine窓の二乗和が理論的定数値(4倍重複なら正確に2.0)を常に満たし、振幅リップルと変調サイドバンドが原理的に完全消滅します。
  • 分析ホップの倍精度連続トラバース & サブサンプル線形補間: 分析側の移動量を倍精度浮動小数点 $h_a = h_s / \text{timeStretch}$ として連続計算し、小数部(frac)による線形補間(v0 * (1 - frac) + v1 * frac)で切り出すことで、位相理論値と波形を1サンプル未満で完全一致させピッチの歪み・揺らぎを根絶。
  • 動的オーバーラップとの統合: スロー再生時にはオーバーラップ数を $4 \to 8 \to 16$ と2の累乗で動的に自動引き上げ、超スロー再生でも完全な定数和と窓密度を同時に保証。

[Problem] Why did metallic artifacts and pitch distortion remain despite WOLA?
Even with WOLA normalization, if the synthesis hop $h_s = \lfloor h_a \times \text{timeStretch} \rfloor$ is not a strict uniform divisor of the frame size, overlapping windows create periodic amplitude ripples. The spurious amplitude modulation (AM) generates modulation sidebands (the source of metallic noise) baked into the audio that cannot be removed by amplitude scaling. Furthermore, stepping in integer samples caused fractional timing jitter, producing noticeable pitch wobble and distortion on sustained notes.

[Solution] Fixed Synthesis Hop ($h_s$) & Double-Precision Continuous Analysis
  • Fixed Synthesis Hop ($h_s$) & Power-of-Two Alignment: Holding $h_s = \text{FRAME\_SIZE} / \text{internalOverlap}$ constant aligned to powers of two (4, 8, 16) guarantees the theoretical constant sum of squared Sine windows (precisely 2.0 at 4x overlap), eradicating amplitude ripples and sidebands at the physical level.
  • Continuous Double-Precision Analysis & Sub-Sample Linear Interpolation: Evaluating analysis positions continuously via double precision $h_a = h_s / \text{timeStretch}$ with sub-sample linear interpolation (v0 * (1 - frac) + v1 * frac) locks calculated phase advances to the waveform, eliminating pitch drift and timing jitter entirely.
  • Integration with Dynamic Overlap: Scales overlap factors ($4 \to 8 \to 16$) in powers of two during slow playback, ensuring both dense coverage and perfect constant overlap-add (COLA).

4. リサンプリング時の高域ノイズ ➔ アンチエイリアス付き高品質リサンプリング 4. High-Frequency Resampling Noise ➔ Anti-Aliased High-Quality Resampling

💬 開発者のつぶやき: 「ユーザー様からいただいた参考音源を聞き衝撃。え、こんな滑らかでシルキーにピッチ変えられるの?」 💬 Dev's Note: "Listening to a reference audio sample sent by a user, I was stunned: 'Wait, pitch can actually be shifted this smoothly and silkily?!'"

【問題】 ピッチ変更後のリサンプリングでは、処理条件によって不要な高域成分が折り返し、ザラつきや高音域のノイズとして聞こえることがある。

【対処(アプローチ)】 高品質モードでは、アンチエイリアスフィルタを内包したKaiser窓付きsincリサンプリングを採用しました。不要な高域成分を抑えながら補間することで、高音域のザラつきや折り返し由来のノイズを低減し、滑らかで明瞭な再生を目指します。

[Problem] During resampling after pitch adjustment, unwanted high-frequency content can fold back into the audible range, creating graininess and high-frequency noise.

[Solution] High-quality mode uses Kaiser-windowed sinc resampling with integrated anti-alias filtering. By suppressing unnecessary high-frequency content during interpolation, it reduces graininess and alias-related noise for smoother, clearer playback.

5. モバイルでの高計算負荷 ➔ C++マルチスレッド並列処理(Lock-Free) 5. Heavy Mobile Compute Load ➔ C++ Multi-Thread Parallel Processing

💬 開発者のつぶやき: 「さすがに1曲の変換に1分以上は長すぎるよな・・・」 💬 Dev's Note: "Converting one song taking over a minute is definitely too long..."

【問題】 長尺ファイルやステレオ音声を高精度なFFT/STFTフレーム分解・合成処理する際、重い複素数演算によってモバイル端末のCPU負荷が高まり、ファイル変換やリアルタイムプレビューに時間を要する。

【対処(アプローチ)】 C++のマルチスレッド機能を活用し、L/Rステレオ各チャンネルのSTFT処理を完全独立スレッドで並列実行するアーキテクチャを設計しました。
各スレッドが専用の演算リソースと状態バッファを個別保持することで、スレッド間のロック競合をゼロ(Lock-Free)にし、CPUのマルチコア性能を100%引き出す爆速処理を実現しています。

[Problem] High-resolution STFT/FFT frame processing over stereo channels incurs significant CPU load on mobile hardware.

[Solution] Multi-threaded execution via C++. Stereo channels process in parallel with isolated thread-local state buffers, eliminating lock contention and utilizing 100% multi-core capacity.

6. 技術の応用展開 ➔ 部分的なピッチ・時間伸縮が切り拓く新体験 6. Architectural Expansion ➔ Localized Pitch & Time Modulation

💬 ユーザーの声: 「Melodyneみたいに、特定の音だけ音程変えられるアプリ作れない?」
💬 開発者のつぶやき: 「ピンポイントに時間軸を伸縮できるなら……これ、拍ごとに伸縮させて変拍子変換とかいけるんじゃね?」
💬 User's Voice: "Can you build an app like Melodyne that edits specific notes on mobile?"
💬 Dev's Note: "Wait, if we can stretch localized time segments arbitrarily... couldn't we transform regular meters into odd time signatures or custom grooves on the fly?!"

フェーズボコーダの本質的な強みは、楽曲全体を一律にストレッチ・ピッチ変更するだけに留まりません。「時間軸上の特定区間」「特定の音符」だけをピンポイントに切り出し、局所的にパラメーターを動的コントロールできる柔軟性にあります。
DS Softではこの特性に着目し、「ピッチ領域」と「テンポ(時間)領域」のそれぞれにおいて、従来の常識を覆すユニークな応用アプリへと展開しました。

● ピッチ領域の応用 ➔ Notewise AutoTuner(メロディ補正・スケール再構築)

オーディオ波形から音符(ノート)単位のピッチ軌跡を検出し、ピンポイントで音程を操作。

  • 単一ノートの補正: ボーカルや管楽器メロディの「特定の1音だけ」をピッチシフトし、調外音や音程のズレを綺麗にリファイン。
  • スケール・調性のダイナミック変換: メロディ内の特定の構成音を半音単位で上下させることで、「短調(マイナー)の楽曲を長調(メジャー)にトランスフォーム」したり、教会旋法(ドリアン、フリジアン等)や民族音階へ楽曲のムードそのものを再構築。
● テンポ(時間)領域の応用 ➔ Odd-Time Beat Converter(変拍子化・グルーヴ変形)

曲全体を均一に速く/遅くするのではなく、自動ビート解析と連動して「リズムの特定の拍だけをミリ秒単位で個別に伸縮・削除」。

  • 変拍子へのトランスフォーム: 4/4拍子の楽曲から特定の拍を伸縮・挿入することで、自然な音質を保ったまま「5/4拍子や7/8拍子のプログレ楽曲」へと再構築。
  • グルーヴの自由自在なコントロール: イーブンな8ビートや16ビートの裏拍を局所的にタイムストレッチし、シャッフルやスウィング、バルカン風の複雑なポリリズムへとグルーヴ感を自在に変形。

The true strength of the Phase Vocoder extends far beyond uniform tempo or pitch shifts across an entire track. Its mathematical elegance allows for pinpoint, localized dynamic modulation applied to specific time intervals or individual notes.
DS Soft leveraged this unique characteristic to pioneer unconventional applications across both the pitch and time domains.

● Pitch Domain ➔ Notewise AutoTuner (Melody Tuning & Scale Re-Harmonization)

Tracks note-level pitch trajectories from audio waveforms and applies localized surgical frequency shifts.

  • Individual Note Correction: Pinpoint adjustment for single out-of-tune notes in vocal or melodic instrument recordings.
  • Dynamic Scale Transformation: Shifting specific notes in a melody allows converting minor-key songs to major keys, or morphing melodies into Dorian, Phrygian, or exotic modal scales.
● Time Domain ➔ Odd-Time Beat Converter (Odd-Meter Conversion & Groove Morphing)

Rather than uniformly changing song tempo, it pairs automatic beat analysis with millisecond-precision localized stretching or deletion of specific beats.

  • Odd-Meter Transformation: Stretches or alters designated beats in standard 4/4 songs to reconstruct them cleanly into 5/4 or 7/8 progressive rock rhythms.
  • Groove Control & Morphing: Localized time-stretching of off-beats transforms even 8th/16th note rhythms into swung, shuffled, or complex Balkan polyrhythms on the fly.

7. プロダクト設計における割り切り ➔ あえて使わない選択(Media3の採用) 7. Architectural Trade-offs ➔ Leveraging Android Media3

💬 開発者のつぶやき: 「全部マシマシだと却って使いづらい?」 💬 Dev's Note: "Piling on every heavy feature actually makes it harder to use...?"

DS Softでは、すべてのアプリで自作フェーズボコーダを盲目的に採用するのではなく、「アプリが追求する体験の軸」によってエンジンを柔軟に切り替えています。

Pitch Tempo Changer Flash での割り切り選択
「Pitch Tempo Changer Flash」のコンセプトは「とにかく動作が軽い爆速レスポンス」です。
STFT演算の負荷を伴うフェーズボコーダをあえて搭載せず、Androidシステムと最も深く密着して超高速に動作する「Android Media3(ExoPlayer / Sonic系)のピッチ・スピード機能」を全面的に採用しました。
極限の高速起動・即時スライド反応・システム負荷ゼロを最優先するための、技術的アプローチの明確な使い分け(割り切り)を行っています。

We do not blindly force custom Phase Vocoder engines into every application. Architectural choices are matched strictly to the user experience goals of each product:

Pitch Tempo Changer Flash Case Study
For "Pitch Tempo Changer Flash," instantaneous responsiveness and minimal CPU footprint are paramount. Rather than running CPU-heavy custom Phase Vocoder loops, we leveraged Android's native Media3 pitch/speed API for system-integrated, ultra-fast performance.

おわりに:実際の音でお試しください Conclusion: Experience the Sound

これらの理論や仕組みが実際に音としてどのような効果をもたらしているか、ぜひご自身の耳でお試しください。
その上で、もしご意見やご感想をいただけましたら、それが今後の開発の原動力になります。

Experience how these algorithms and design ideas actually shape the sound in our applications.
If you have any feedback or thoughts, we would love to hear from you—it directly fuels our ongoing development!

搭載アプリ(Pitch Tempo Changer)を見る » View App (Pitch Tempo Changer) »