LoginSignup
1
3

More than 5 years have passed since last update.

Faust:soft clipperを作ってみた

Last updated at Posted at 2017-12-13

ハードクリップしないようにするエフェクトです。shaperとかsaturatorとかの方が通りがいいのかな?
DAWを新しくしたら前使ってたのが使えなくなったので、作ってみました。

declare name "SoftClipNoGui";

import("stdfaust.lib");

process = preGain : clipper : postGain  ;

preGain = preGainMono, preGainMono ; 
preGainMono = *( preSlider : ba.db2linear )  ;

clipper = clipperMono, clipperMono ;
clipperMono = ( clipSlider : ba.db2linear), _ : clip ; 
clip( a1, x ) = min( a0 , atan((a0 - a1) / a2 ) * a2 + a1 ) * a3
  with{
    a0 = abs(x);
    a2 = (1-a1) * 2 / ma.PI ;
    a3 = ma.signum(x) ;
  };

postGain = postGainMono, postGainMono ;
postGainMono = *( postSlider : ba.db2linear ) ;

preSlider = hslider("/v:Ctrl/1 pre[unit:dB]", 0, 0, 20, 1 ) ;
clipSlider = hslider("/v:Ctrl/2 clip", -1, -30, -1, 1 ) ;
postSlider = hslider("/v:Ctrl/3 post[unit:dB]", 0, -10, 10, 1 ) ;

clipが謎の数式になっていますが、y = x から y = 1 にうまく繋がる曲線はないかなあと試行錯誤した結果です。
y = x の途中から atan(x)を移動したものに乗り換えています。
スクリーンショット 2017-12-13 16.40.23.png
もっと賢い方法があるんでしょうが思いつきませんでした。

このatanのつぶれ具合がよくてよく使っています。
(ma.)tanhを使うと若干ハード寄りなつぶれ具合になります。

※ FaustLiveだとsignumがundefinedになって読み込んでくれない。謎。
online compilerとPlayGroundでは問題なし。なぜ?

1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3