特定のパラメーターのみオートメーションを無効にすることは出来ますか?
具体的にはEQやエフェクトタイプを選択するコンボボックスを使用してますが、
このコンボボックスのみオートメーションを無効にしたいです。
特定のパラメーターのみオートメーションを無効にすることは出来ますか?
具体的にはEQやエフェクトタイプを選択するコンボボックスを使用してますが、
このコンボボックスのみオートメーションを無効にしたいです。
特定のパラメーターをオートメーション対象から除外することは可能です。
私が確認した方法は2通りあります。
1.AudioParameterXxxクラスを継承し、isAutomatable()関数をoverrideして関数の返り値としてfalseを返すように実装する。
AudioParameterFloatクラスやAudioParameterChoiceクラスの親クラスであるAudioProcessorParameterクラスには、isAutomatable()というメンバ関数が定義されています。JUCE: AudioProcessorParameter Class Reference
VSTホストは、各パラメータに対してisAutomatable()関数の返り値が true であるときにはオートメーション対象として取り扱い、返り値が false であるときにはオートメーション対象から除外するように動作します。
しかし、AudioParameterFloat::isAutomatable()関数の返り値は true を返すように実装されています。
そこで、次のように、AudioParameterXxxクラスを継承してisAutomatable()関数の実装をoverrideして変更することで、オートメーション対象から除外されるAudioParameterFloatを作ることができます。(※AudioParameterChoiceクラス他についても同様です)
class UnautomatableAudioParameterFloat: public AudioParameterFloat
{
public:
UnautomatableAudioParameterFloat(const String& parameterID,
const String& parameterName,
NormalisableRange<float> normalisableRange,
float defaultValue,
const String& parameterLabel = String(),
Category parameterCategory = AudioProcessorParameter::genericParameter,
std::function<String(float value, int maximumStringLength)> stringFromValue = nullptr,
std::function<float(const String& text)> valueFromString = nullptr)
: AudioParameterFloat(parameterID, parameterName, normalisableRange, defaultValue, parameterLabel, parameterCategory, stringFromValue, valueFromString)
{}
UnautomatableAudioParameterFloat(String parameterID,
String parameterName,
float minValue,
float maxValue,
float defaultValue)
: AudioParameterFloat(parameterID, parameterName, minValue, maxValue, defaultValue)
{}
virtual bool isAutomatable() const override { return false; };
};
2.AudioProcessorValueTreeState::Parameterクラスのコンストラクタで、9番目の引数に false を渡してパラメーターのインスタンスを生成する
AudioProcessorValueTreeState::ParameterクラスのコンストラクタにはisAutomatable()関数の返り値を設定するための引数が設けられています。
https://docs.juce.com/master/classAudioProcessorValueTreeState_1_1Parameter.html
これを利用することで、オートメーション対象から除外されるパラメーターのインスタンスを生成することができます。
auto unautomatable = std::make_unique<AudioProcessorValueTreeState::Parameter>(
"Unautomatable",
"Unautomatable",
"Unautomatable",
NormalisableRange<float>{0.0f, 1.0f, 0.01f},
0.5f,
nullptr,
nullptr,
false,
false); // 9番目の引数に false を渡す
ご丁寧にありがとうございます。
試してみましたが、現在のプロジェクトではRangedAudioParameterを使用しております。
RangedAudioParameterでは上記の方法でうまくいかないようでした。
RangedAudioParameterでもオートメーションを無効にできますでしょうか?
RangedAudioParameterクラスもAudioProcessorParameterクラスを継承したものなので、AudioParameterFloatクラスをオートメーション対象外にするのと同じく、『RangedAudioParameterクラスを継承した独自のクラスを定義して、isAutomatable()関数をoverrideして関数の返り値としてfalseを返すように実装』することで、同じことができると思うのですが…。
それでもうまくいかないのであれば、JBTA03さんのプロジェクトを見させていただかないと、私も原因が把握できないですね。