2025/02/18

逆微分による歪みのアンチエイリアシング

逆微分による歪みのアンチエイリアシングを読む (github.io)

逆微分による歪みのアンチエイリアシング (antiderivative antialiasing, ADAA) について調べました。以下は参考にした論文です。

  1. Parker et. al. "Reducing the aliasing of nonlinear waveshaping using continuous-time convolution"
  2. Bilbao et. al. "Antiderivative antialiasing for memoryless nonlinearities
  3. La Pastina et. al. "Arbitrary-order IIR antiderivative antialiasing"

理論については Parker らの論文がとっつきやすいです。実装については Bilbao らの論文に基づいたものが多いようでした。

ADAA には以下の問題点があります。

  • 0 除算 (ill-condition) を避けるための分岐により計算量が一定しない。
  • 元となる関数によっては逆微分した式の計算が困難。

ADAA の次数が上がると上の問題点が以下のように化けます。

  • 0 除算を避けるための分岐先の最悪の場合の計算量が  O(2^n) のオーダーで増える。
  • 逆微分した式に見たこともないような数学特殊関数が現れ始める。複素解しか得られないこともある。

現実的には実装が簡単な 1 次の ADAA と 2 倍ほどのオーバーサンプリングの組み合わせで十分に思えます。

参考にした論文ではハードクリップや tanh といった歪みのみを対象にしていました。しかし単なるバイパスに同じ手法を適用すれば、離散系での計算式が非線形となる一風変わったフィルタが作れます。

画像は多項式によるソフトクリップ曲線の仕様です。逆微分した式はかなり煩雑です。

2024/12/30

FDN の結合

FDN の結合を読む (github.io)

2 つ以上のフィードバックディレイネットワーク (FDN) を結合する方法について調べました。今回は元となる小さいフィードバック行列を組み合わせて、より大きいフィードバック行列を構築するというアプローチをとっています。

FDN をフィードバック行列によって結合するときは、元となる小さいフィードバック行列の大きさはすべて等しくなければならないという制約があることがわかりました。また「0 を含む形」の結果も良くなかったので、このアプローチはリアルタイムでのドラムの合成には向いていない気がします。

画像は FDN の結合に使う係数を求める連立方程式です。 y と h_ij が変数、 I は単位行列、 n は元となるフィードバック行列の数です。

2024/12/28

MaybeCrash

Try MaybeCrash (github.io)
Source code (github.com)

MaybeCrash is a crash cymbal synthesizer using feedback delay network (FDN).

It sounds more like splash cymbal rather than a crash. Also, the gently struck sound is not good because the tuning is not quite right. To render the gently struck sound, set `Slicer -> nRegion` to 2 or more.

It is known that the sound of a crash cymbal can be approximated using von Karman equation (sound demo, paper). However, it is also known that the method is a bit too slow for real-time (another paper, mentioned in §1). There's also a method described by Dan Stowell, which is not based on physics but it runs on real-time and sounds good. The core insight of Dan Stowell's method is the tuning of input signal. It feeds low-passed white noise into a bunch of resonators. The magic is to change the cutoff of low-pass filter over time using an envelope. MaybeCrash is using a method similar to Dan Stowell's, however the difference is using FDN instead of resonators.

---

MaybeCrash を試す (github.io)
ソースコード (github.com)

MaybeCrash はフィードバックディレイネットワーク (FDN) を使ったクラッシュシンバルのシンセサイザです。

どちらかと言えばスプラッシュシンバルのような音が出ます。また、チューニングが足りていないので弱く叩いたときの音は苦手です。 `Slicer -> nRegion` を 2 以上にすると異なる強さで叩いた音を聞くことができます。

クラッシュシンバルの音は von Karman 方程式で近似できる (音のデモ, 論文) ことが知られています。しかし、リアルタイムで動かすことは難しい (論文, §1 で言及) ことも知られています。物理モデルではないですが、リアルタイムで動く手法としては Dan Stowell さんによるレゾネーターを使った方法があります。 Dan Stowell さんの手法の肝はレゾネーターに入力する信号のチューニングです。ローパスをかけたホワイトノイズなのですが、時間とともにローパスのカットオフを変えることで雰囲気を出しています。 MaybeCrash は Dan Stowell さんの手法と似たような仕組みですが、レゾネーターの代わりに FDN を使っている点が異なります。

2024/11/30

CoupledSnare

Try CoupledSnare (github.io)
Source code (github.com)

CoupledSnare is a modified version of RoughlySnare. It sounds quite nice.

In RoughlySnare, 2 feedback delay networks (FDNs) are serially connected. In CoupledSnare, 2 FDNs are combined into a single bigger network. 

To shrink the size of snare drum, try raising `Delay -> Frequency` to 600 Hz, and `Tone Shaping -> Lowpass` to 10000 Hz.

---

CoupledSnare を試す (github.io)
ソースコード (github.com)

CoupledSnare は RoughlySnare の改変版です。なかなかいい音が出ます。

RoughlySnare では 2 つのフィードバック・ディレイ・ネットワーク (FDN) を直列に接続していました。 CoupledSnare では 2 つの FDN を 1 つの大きな FDN に結合して相互にフィードバックがかかるようになっています。

`Delay -> Frequency` を 600 Hz 、 `Tone Shaping -> Lowpass` を 10000 Hz あたりに上げるとスネアドラムの径が小さくなったような音が出ます。

2024/11/07

"Uhhyou Plugins" on Discord / Discord の "Uhhyou Plugins" サーバー

"Uhhyou Plugins" server is now set up on Discord. It might be more convenient than email. Feel free to post anything about the plugins or related topics.

---

メール以外のコンタクト方法の要望があったので、 Discord 上に "Uhhyou Plugins" という名前のサーバーを用意しました。何かあればプラグインや関連する話題について、お気軽に投稿してください。

2024/10/24

SpectralPhaser

Download SpectralPhaser (github.io)
Source code (github.com)

SpectralPhaser is an effect that produces a phaser-like sound by applying a mask in the frequency domain. In addition to FFT, fast Walsh-Hadamard transform (FWHT) and Haar transform are available.

Discrete Fourier transform turns the input signal into a series of sine and cosine. Similarly, FWHT and Haar transform turn the signal into a series of square waves, which tend to sound rough to the human ear.

---

SpectralPhaser のダウンロードとマニュアル (github.io)
ソースコード (github.com)

SpectralPhaser は周波数領域でマスクをかけることでフェイザのような音が出るエフェクタです。 FFT に加えて、高速 Walsh-Hadamard 変換 (FWHT) 、 Haar 変換といった変換が使えます。 

FFT の計算している離散フーリエ変換は、入力信号を sin と cos の足し合わせに変換します。 FWHT と Haar 変換は sin, cos の代わりに矩形波の足し合わせに変換するので、人間の耳にはざらざらとした音になりがちです。

2024/10/16

RoughlySnare

Try RoughlySnare (github.io)
Source code (github.com)

RoughlySnare is a snare drum synthesizer based on mymembrane~ PureData patch by MikeMorenoDSP.

The drum membrane texture of mymembrane~ comes from a schroeder allpass placed on the feedback path of a comb filter. It's pretty fun to change the allpass parameters to add some expressions. Snare wire is a bandpassed noise following the amplitude of comb filter output, which is simple but sounds good.

RoughlySnare puts the cascade of (delay) -> (allpass) -> (snare wire) into a feedback delay network (FDN). There's also a second FDN to add tones. Delay times are set according to preferred modes of timpani.

---

RoughlySnare で遊ぶ (github.io)
ソースコードを見る (github.com)

RoughlySnare はスネアドラムのシンセサイザです。 MikeMorenoDSP さんの mymembrane~ という PureData のパッチを基にしています。

mymembrane~ はコムフィルタのフィードバック経路に Schroeder オールパスを置いて、ドラムの膜のような質感を出しています。オールパスに関するパラメータで音に表情をつけられるのが面白いです。スナッピーはコムフィルタの出力振幅にあわせてノイズを上げ下げしているだけなのですが、いい音がします。

RoughlySnare では、ディレイ -> オールパス -> スナッピーの接続を取り出して、フィードバックディレイネットワーク (FDN) に投げ込んでいます。また 2 つめの FDN によってトーンを追加できるようにしています。ディレイ時間の設定にはティンパニーの preferred modes を使っています。

2024/10/12

DoubleLoopCymbal

Download DoubleLoopCymbal (github.io)
Source Code (github.com)

DoubleLoopCymbal is a synthesizer that produces a sound somewhere between hi-hat and triangle. Metallic texture comes from 2 all-pass loops.

Block diagram is available on the manual page.

It is making some metallic noise, however it sounds synthetic when listening closer. Different tunings are tried, but I couldn't manage to add a better closing texture, and the crash texture which appears on a real cymbal when hit hard. It seems like closing of hi-hat can't be made from allpass loops. To stop sound, the feeds of allpasses should be moved to 0. However changing the feeds adds a texture similar to a phaser. On the crash texture, I found a better method described by henry bracey (link, description is on a comment). This method is not implement in this time since I wanted to make DoubleLoopCymbal lighter than ClangCymbal.

There are also a bug fix for GlitchSprinkler and a new parameter for GenericDrum. Both could be downloaded from the release page on GitHub.

---

DoubleLoopCymbal のダウンロードとマニュアル (github.io)
ソースコード (github.com)

DoubleLoopCymbal はハイハットとトライアングルの間のような音が出るシンセサイザです。オールパスループというディレイのつなぎ方を使って金属的な質感を出しています。

マニュアルに大まかなブロック線図を掲載しています。

金属音は出ていますが、よく聞くと胡散臭い音をしています。チューニングをいろいろと試したのですが、クローズの質感と、強く叩いたときのクラッシュシンバルのような質感は出せなかったです。クローズについてはオールパスループでは無理です。音を止めるにはフィードを下げなければなりませんが、そうするとフェイザをかけたような質感が現れてしまいます。クラッシュについては henry bracey さんによる良さそうな方法 (リンク、コメント欄に解説あり) を見つけたのですが ClangCymbal よりも軽くしたかったので今回は実装を見送りました。

また GlitchSprinkler のバグ修正と GenericDrum の機能追加も行いました。どちらもリリースページからダウンロードできます。

2024/08/29

適応ノッチフィルタの実装

適応ノッチフィルタの実装を読む (github.io)

適応ノッチフィルタの実装について調べました。適応ノッチフィルタはサイン波にノイズが加わった信号から、サイン波だけを消すときに使えます。ただしノイズの種類によってはうまく動かないこともあります。

今回調べた適応ノッチフィルタは内部で位相差のある 2 つの信号を作って振幅変調 (AM) をかけています。入力がサイン波であればカットオフ周波数の周りでの位相差によって AM 信号の直流成分の符号が変わります。この直流の符号の向きが入力のサイン波の周波数へと向かうようにする、というのが適応の仕組みです。直流成分の符号は位相差を φ とすると sgn(-cos(φ)) で計算できます。 sgn は符号関数です。

図は Ishibashi らによる “DSP Implementation of Adaptive Notch Filerts With Overflow Avoidance in Fixed-Point Arithmetic” で紹介されていた CPZ-ANF という名前の適応ノッチフィルタの、内部の 2 つの信号の位相差を示しています。 "Cutoff" の周りで位相差が -π/2 をまたぐので、位相差が -3π/2 を上回る範囲では適応がうまくいきます。位相差が -3π/2 を下回るような高い周波数では適応は失敗しがちです。

2024/08/26

より手軽な LFO のテンポシンク

より手軽な LFO のテンポシンクを読む (github.io)

以前の LFO のテンポシンクよりも手軽な方法を思いついたので試しました。 EMA フィルタによる同期と、蔵本モデルによる同期を紹介しています。以前の方法は状態遷移が煩雑でしたが、今回の方法は状態遷移が不要です。 DAW 上で動くプラグインの LFO であれば、同期先の周波数と位相がどちらも分かっているので EMA フィルタによる同期が適しています。

画像は逆走を防いだ EMA フィルタによる同期の例です。

2024/08/15

Integer Sample Tuning Table / 整数サンプル調律の表

Take a look at integer sample tuning table (github.io)

This is a tuning table used in GlitchSprinkler. They are named as `Discrete` tunings in GlitchSprinkler plugin. Web synth version is always using a tuning that `Min period` in the table parameter is 2 samples.

The errors of pitches are quite bad at higher frequencies, even around 1000 Hz.

---

整数サンプル調律の表を見る (github.io)

この調律は GlitchSprinkler で使われているものです。プラグイン版では Tuning の `Discrete` のいずれかを選べば対応する調律が使えます。 Web シンセ版は表の `Min period` を 2 サンプルに設定したときの調律に固定されています。

ピッチの誤差は高い周波数で悪くなり、 1000 Hz あたりでもかなりずれています。