2023/06/29

Slope Filter

Download Slope Filter (github.com)
Read Source Code (github.com)

Slope Filter is a filter to approximate arbitrary slope in decibel per octave (dB/oct). Perhaps useful to change the overall brightness of sound.

Internal is a cascade of high-shelf filters. Cutoff is set to `f_c * 2^n`, where n is index of cascade, and f_c is cutoff frequency. Slope Filter is using matched 1-pole high-shelf, but RBJ high-shelf also can be used with `Q=1/sqrt(2)`. In case of RBJ, it's possible to reduce the number of filters 1/2, 1/3, and so on, by changing cutoff interval to `f_c * 4^n`, `f_c * 6^n`, and so on. However, accuracy decreases as the number of filters decreases.

I also tried to turn this IIR cascade into linear phase using the method of "A New Reverse IIR Filtering Algorithm", but it didn't work. It's probably better to use bidirectional filtering to get impulse response, then convolve it.

Image is example gain response of -1 dB/oct.

-

Slope Filte をダウンロード (github.com)
ソースコードを読む (github.com)

Slope Filter は任意の dB/oct の傾きを近似するフィルタです。音の明るさを変更するときに使えるかもしれません。

中身は直列に接続したハイシェルフフィルタで、各段のカットオフ周波数を 1 倍, 2 倍, 4 倍, 8 倍, ... と設定しています。式にまとめると `f_c * 2^n` で n は直列接続されたフィルタのインデックス、 f_c はカットオフ周波数です。 Slope Filter では整合 1 次ハイシェルフを使っていますが RBJ のハイシェルフでも `Q=1/sqrt(2)` とすれば、ほぼ同じことができます。 RBJ のハイシェルフでは Q を調整しつつフィルタの数を 1/2, 1/3, ... と減らすこともできます。このときカットオフ周波数の間隔は `f_c * 4^n`, `f_c * 6^n`, ... となります。ただしフィルタの数が減っただけ近似の精度も落ちます。

この IIR フィルタを "A New Reverse IIR Filtering Algorithm" の手法を使って線形位相にしようと試みたのですが、うまく動きませんでした。おそらく、双方向フィルタリングを使用してインパルス応答を取得し、それを畳み込む方が良いでしょう。

画像は -1 dB/oct の傾きのあるゲイン応答の例です。

2023/06/27

MaybeCabinetIR

Try MaybeCabinetIR (github.io)
See list of other web synthesizers (github.io)

MaybeCabinetIR is impulse response (IR) generator which resembles guitar cabinets.

The sound is a bit too clean, but it works okay. When `Source -> LP Q` is high, strange delays are added to IR. Maybe this can be used for another reverb IR generator.

At start, I analyzed several cabinet IRs and came up with the recipe below:

  • Peaking at 100 to 200 Hz, around +20 dB. Broad Q.
  • Peaking at 1000 to 3000 Hz, +10 to +20 dB. Less broad Q.
  • (Optional) Negative peaking or notch at 500 to 1000 Hz. Narrow Q.

Character is mostly decided by the ratio between lower and higher peak.

IR is generated by following steps:

  1. Generate random noise.
  2. Apply low-pass bidirectionally.
  3. Apply inverse FFT.
  4. Rotate half to move peak into center
  5. Apply peaking filters bidirectionally.
  6. Transform 5 into minimum phase FIR.
  7. Apply highpass and lowpass to remove direct current and Nyquist frequency.
  8. Normalize amplitude.

The recipe is used at step 5. Bidirectional filtering is a technique to apply IIR filter as linear phase. It can only work on offline (or non real-time) processing as all the signal has to be known beforehand. Minimum phase algorithm is ported from `scipy.signal.minimum_phase`.

---

MaybeCabinetFIR を試す (github.io)
Web シンセサイザの一覧を見る (github.io)

MaybeCabinetIR はギターキャビネットに似せたインパルス応答 (IR) の Web シンセです。

クリーンすぎる感じもしますが、それなりに使えます。 `Source -> LP Q` の値が大きいとき変なディレイが現れます。また別のリバーブ IR 合成器へと応用できそうです。

制作にあたっては、いくつかキャビネット IR を分析して以下のレシピにたどり着きました。

  • ピーキング、 100 ~ 200 Hz, +20 dB 付近。広めの Q 。
  • ピーキング、 1000 ~ 3000 Hz, +10 ~ +20 dB。やや狭めた Q 。
  • (任意) 負のピーキングかノッチ、 500 ~ 1000 Hz。狭い Q 。

音のキャラクターは高低のピーキングのゲイン差で決まります。

IR は以下の手順で合成しています。

  1. ランダムなノイズを生成。
  2. 双方向にローパスを適用。
  3. 逆 FFT 。
  4. ピークを中央に動かすように半分回転。
  5. 双方向にピーキングを適用。
  6. 最小位相 (minimum phase) FIR に変換。
  7. ローパスとハイパスで直流とナイキスト周波数を除去。
  8. 振幅の正規化。

先のレシピはステップ 5 で適用されます。双方向フィルタリングは IIR フィルタを線形位相を保ったままかけるテクニックです。事前に信号がすべて分かっている必要があるのでオフライン (あるいは非リアルタイム) 処理でなければ使えません。最小位相に変換するアルゴリズムは `scipy.signal.minimum_phase` から移植しました。

2023/06/26

1 次ローパスのバイリニア変換

1 次ローパスのバイリニア変換を読む (github.io)

EasyOverdrive の適当にノイズを混ぜたピークホールドのエイリアシングの低減策として、ナイキスト周波数のゲインを 0 にした 1 次ローパスが使えるのではないかと思い調べました。

実装してからもう一度考え直したところ、後段のスムーシングに使っている 2 次ローパスがバイリニア変換してあるので特に意味がないことに気づきました。今回考えていた応用は分数ディレイのかかったインパルスを得ることなので、ラグランジュ補間か PolyBLIT 系のテクニックのほうがアンチエイリアシングに向いている気がします。

2023/06/25

EasyOverdrive


Source Code (github.com)

Download (github.com)

EasyOverdrive is an overdrive plugin stemmed from low quality limiter algorithm. JUCE framework is used.

---

ソースコード (github.com)

ダウンロード (github.com)

EasyOverdrive は質の悪いリミッターのアルゴリズムをもとにして作ったオーバードライブです。今回は JUCE を使いました。

2023/06/22

クロスオーバーフィルタの実装

クロスオーバーフィルタの実装を読む (github.io)

クロスオーバーフィルタの実装について調べたことをまとめました。

窓関数法による素朴な FIR 、 IIR の Linkwitz-Riley 、 FIR の Linkwitz-Riley の 3 つを実装しています。前 2 つはよく知られた手法ですが、 FIR の Linkwitz-Riley は Martin Vicanek さんによる "A New Reverse IIR Filtering Algorithm" で紹介されていた手法を実装しています。

画像は FIR の Linkwitz-Riley のインパルス応答です。

2023/06/16

アナログの周波数特性に一致する二次のデジタルフィルタの実装

アナログの周波数特性に一致する二次のデジタルフィルタの実装を読む (github.io)

Martin Vicanek さんによる "Matched Second Order Digital Filters" と "Matched One-Pole Digital Shelving Filters" で紹介されていた整合フィルタ (matched filter) を実装しました。

整合フィルタとはアナログの周波数特性にほぼ一致する離散フィルタのことです。主にバイリニア変換よりもアナログ特性をよく近似するフィルタを指しています。

画像は整合ピーキングフィルタ (matched peaking)  の周波数特性です。ナイキスト周波数 (10^0) でのゲインが 0 dB でないことが見て取れます。

2023/06/15

Biquad フィルタの比較

Biquad フィルタの比較を読む (github.io)

Biquad フィルタについて、 Web Audio などで使われている Audio EQ Cookbook に基づく実装と、 The Art of VA Filter Design という本で紹介されている topology-preserving transform (TPT) という離散化の手法に基づく実装を比較しました。

結論としては速くてコードも短い TPT フィルタを使えばよさそうです。

画像は Python 3 で計算した TPT フィルタの特性です。

2023/06/13

一次ローパスと一次オールパスからなるレゾナントフィルタ

一次ローパスと一次オールパスからなるレゾナントフィルタを読む (github.io)

TestBedSynth に組み込むために適当にでっち上げたフィルタのレゾナンスをチューニングしました。

伝達関数は得られたのですが Maxima で楽に解けなかったので、あきらめて数値計算で発散しないレゾナンスの最大値を求めました。いま改めて安定条件の式を見ると 4 つの場合分け (絶対値で 2 つ、二次方程式の解の公式で 2 つの場合分け) で解けそうな感じがします。

2023-06-13 追記: 伝達関数の安定条件の解から、より手軽なレゾナンスの最大値の計算式が得られました (qMax = c2 - c2*c1 + 1) 。

画像はでっち上げたフィルタのブロック線図です。

2023/06/10

Maboroshi

Maboroshi (illusion) is an album that features high emphasized tone cluster and repetitive rhythms. While checking the album, my ears started hurt because of the emphasized high.

Maboroshi is also my first track that is using a method to construct high emphasized tone cluster. The method starts from pretty fast arpeggio of high-pitched sound with release. The time scale of arpeggio is then shrinked, and the resulted tone cluster is repeated with 16th note cycle. Similar sound can be found in Grow Home, which is 3D action game. The sound is used to indicate the presence of crystals, and there's also a message in game that is like "this sound might be interesting for some, but it might be just a noise for others." When I started using this method, I was thinking about music that can only be made with computers. Then I got an inspiration that combining high frequency emphasis and unplayable fast phrases might be good. To emphasize high, there's already guitar amps. To play fast phrases, there's already player pianos. So the idea was mostly about combining the two to create something new. But in hindsight, the idea wasn't well executed. An previous album 旋回 was made from a realization that drums are harming the texture, years after practicing the method.

---

幻は反復的なリズムと高い音のトーンクラスターが目立つ曲を集めたアルバムです。高い音が始終隙間なく鳴り続けるので聴いていると耳が痛くなってきます。

アルバムのタイトルともなっている幻は、リリースのある高い音でとても速いアルペジオを組み、16分音符の周期で繰り返すことでトーンクラスターを作る、という手法を初めて使った古い曲です。 Grow Home というゲームのクリスタルの効果音でも同様の手法が使われていて、「面白い音に聞こえる人と、ただの騒音に感じる人に別れる」という趣旨のメッセージがゲーム中に登場します。この手法を見つけたときはコンピュータに全て演奏させる音楽でしかできないことは何か、ということを考えていました。そして閃いたのが音の高い部分を強調することと、人間には演奏不能な速いフレーズを使うことでした。音の高い部分を強調するだけならギターアンプ、演奏不能なフレーズだけであればプレイヤーピアノが既にあります。この二つを組み合わせると新しいのでは、ということだったのですが、今思えば適当な閃きでした。また、当時は手法の徹底が不十分でした。よくわからない閃きから数年後、ドラムによって質感が損なわれていること気づいて作ったのが、以前に公開したアルバム「旋回」です。

2023/06/05

Libre Music Challenge #18

Uhhyou Plugins are chosen for Libre Music Challenge #18.

View submissions (archive.org)

Libre Music Challenge is held by people using free software to make music. Below is a quote from official description.

This is a friendly contest where we make music with free (libre) software exclusively. Everyone is welcome to join, at any skill level. This is a place for learning and sharing knowledge, and an opportunity to explore creativity through limitation. But most importantly, we just hope it inspires you to make some music!

The challenge for this month is to make a track using only the Uhhyou set of plugins.

I made plugins as a convenient surplus to make some sound effects. So it was a surprise that all the submission went for tonal composition, and they are all well done!

I also got a report that GUI aren't working well on some Linux system. There are also related issues remain opened on GitHub (#35, #36). I haven't tested, but at least for Ardour, building both the host and the plugins might solve the problem, so to ensure that they both link to the same shared libraries on system. But it's also far from smooth experience.

---

Uhhyou Plugins が Libre Music Challenge #18 に選ばれました。

投稿を見る (archive.org)

Libre Music Challenge はフリーソフトウェアで音楽を作っている方々によって開かれています。以下は公式な説明の訳です。

これはフリー (自由) ソフトウェアのみで音楽を作るフレンドリーなコンテストです。誰でも、どのようなスキルであっても参加を歓迎します。ここは、学び、知識を共有し、制限の中で創造性を探求する機会となる場です。ただ、最も大事なことはあなたが音楽を作るきっかけになれば幸いだということです。

今月のチャレンジは Uhhyou のプラグインを使って曲を作ることです。

私のプラグインは効果音を入れるときに便利な脇役というくらいで作っていたので、投稿された曲がすべて普通の音楽になっていたのは驚きました。どれもよくまとまっています。

また、開催されている方から Linux でプラグインの GUI が動かなかったという報告をいただきました。 GitHub にも関連する未解決の issue がいくつかあります (#35, #36) 。未検証ですが、 Ardour についてはホストとプラグインの両方をソースコードからビルドすれば、どちらもシステムの共有ライブラリ (shared library, *.so) にリンクするはずなので動くようになるかと思います。