-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
and their provenance. (Which is: I wrote them all yesterday)
- Loading branch information
Showing
4 changed files
with
102 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// | ||
// Created by Paul Walker on 6/20/22. | ||
// | ||
|
||
#ifndef AIRWIN_TO_CLAP_AIRWIN_TO_CLAP_H | ||
#define AIRWIN_TO_CLAP_AIRWIN_TO_CLAP_H | ||
|
||
// This file has the smallest possible API required to allow each of the Airwin | ||
// MacVST to compile without any external API. | ||
|
||
|
||
#include <cstdint> | ||
#include <cstring> | ||
#include <string> | ||
|
||
#include <cmath> | ||
|
||
struct clap_host; | ||
typedef const clap_host *audioMasterCallback; | ||
typedef int VstPlugCategory; | ||
typedef int32_t VstInt32; | ||
#define vst_strncpy strncpy | ||
|
||
static constexpr uint32_t kVstMaxProgNameLen = 32; | ||
static constexpr uint32_t kVstMaxParamStrLen = 64; | ||
static constexpr uint32_t kVstMaxProductStrLen = 64; | ||
static constexpr uint32_t kVstMaxVendorStrLen = 64; | ||
|
||
static constexpr uint32_t kPlugCategEffect = 1; | ||
|
||
|
||
inline void float2string(float f, char *c, uint32_t n) { | ||
strncpy(c, std::to_string(f).c_str(), n); | ||
} | ||
|
||
inline void dB2string(float value, char *t, uint32_t num) { | ||
if (value <= 0.00001) // -100 dB, show -inf from that point onwards | ||
vst_strncpy (t, "-inf", num); | ||
else | ||
float2string ((float)(20.0 * log10 (value)), t, num); | ||
} | ||
|
||
inline void int2string(int f, char *c, uint32_t n) { | ||
strncpy(c, std::to_string(f).c_str(), n); | ||
} | ||
|
||
struct AirwinToClapPortBaseClass { | ||
uint32_t numParams{0}; | ||
AirwinToClapPortBaseClass(audioMasterCallback audioMaster, uint32_t kNumPrograms, uint32_t kNumParameters) : numParams(kNumParameters){} | ||
|
||
virtual ~AirwinToClapPortBaseClass() = default; | ||
|
||
|
||
double sr{1}; | ||
|
||
void setSampleRate(double d) { sr = d; } | ||
double getSampleRate() { return sr; } | ||
|
||
int nin{0}, nout{0}; | ||
void setNumInputs(uint32_t kNumInputs) { nin = kNumInputs; } | ||
void setNumOutputs(uint32_t kNumOutputs) { nout = kNumOutputs; } | ||
void setUniqueID(uint32_t kUniqueId) {} | ||
|
||
bool canProcessReplacing() { return false; } | ||
bool canDoubleReplacing() { return false; } | ||
|
||
void programsAreChunks(bool b) {} | ||
virtual void processReplacing(float **inputs, float **outputs, VstInt32 sampleFrames) = 0; | ||
virtual void processDoubleReplacing(double **inputs, double **outputs, VstInt32 sampleFrames) = 0; | ||
|
||
virtual VstInt32 getChunk(void **data, bool isPreset) { return 0; }; | ||
|
||
virtual VstInt32 setChunk(void *data, VstInt32 byteSize, bool isPreset) { return 0; }; | ||
|
||
virtual float getParameter(VstInt32 index) { return 0.f; }; | ||
virtual void setParameter(VstInt32 index, float value) {}; | ||
virtual void getParameterLabel(VstInt32 index, char *text) {}; | ||
virtual void getParameterName(VstInt32 index, char *text) {}; | ||
virtual void getParameterDisplay(VstInt32 index, char *text) {}; | ||
virtual VstInt32 canDo(char *text) = 0; | ||
}; | ||
|
||
#endif // AIRWIN_TO_CLAP_AIRWIN_TO_CLAP_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,22 @@ | ||
// | ||
// Created by Paul Walker on 6/18/22. | ||
// | ||
|
||
/* | ||
* The AIRWIN code #includes a file called 'audioeffectx.h' which is often shipped with | ||
* another SDK and is not in the AIRWIN repo. | ||
* | ||
* We do not need that file nor its contents to port to CLAP, but we do need | ||
* something we can include which provides the base class interface the airwindows use. | ||
* And to avoid modifying the Airwindows code we want something with the same name so | ||
* #include actually works. | ||
* | ||
* So create this file, but then simply include a subsequent file with our base class and typedef | ||
* the audioeffectx classes to it. | ||
*/ | ||
#ifndef CLAUDIO_EFFECT_X_AUDIOEFFECTX_H | ||
#define CLAUDIO_EFFECT_X_AUDIOEFFECTX_H | ||
|
||
#include <cstdint> | ||
#include <cstring> | ||
#include <string> | ||
|
||
struct clap_host; | ||
typedef const clap_host *audioMasterCallback; | ||
typedef int VstPlugCategory; | ||
typedef int32_t VstInt32; | ||
#define vst_strncpy strncpy | ||
|
||
static constexpr uint32_t kVstMaxProgNameLen = 32; | ||
static constexpr uint32_t kVstMaxParamStrLen = 64; | ||
static constexpr uint32_t kVstMaxProductStrLen = 64; | ||
static constexpr uint32_t kVstMaxVendorStrLen = 64; | ||
|
||
static constexpr uint32_t kPlugCategEffect = 1; | ||
|
||
inline void float2string(float f, char *c, uint32_t n) { | ||
strncpy(c, std::to_string(f).c_str(), n); | ||
} | ||
|
||
inline void dB2string(float f, char *c, uint32_t n) { | ||
strncpy(c, std::to_string(f).c_str(), n); | ||
} | ||
|
||
inline void int2string(int f, char *c, uint32_t n) { | ||
strncpy(c, std::to_string(f).c_str(), n); | ||
} | ||
|
||
struct AudioEffect { | ||
uint32_t numParams{0}; | ||
AudioEffect(audioMasterCallback audioMaster, uint32_t kNumPrograms, uint32_t kNumParameters) : numParams(kNumParameters){} | ||
|
||
virtual ~AudioEffect() = default; | ||
|
||
|
||
double sr{1}; | ||
|
||
void setSampleRate(double d) { sr = d; } | ||
double getSampleRate() { return sr; } | ||
|
||
int nin{0}, nout{0}; | ||
void setNumInputs(uint32_t kNumInputs) { nin = kNumInputs; } | ||
void setNumOutputs(uint32_t kNumOutputs) { nout = kNumOutputs; } | ||
void setUniqueID(uint32_t kUniqueId) {} | ||
|
||
bool canProcessReplacing() { return false; } | ||
bool canDoubleReplacing() { return false; } | ||
|
||
void programsAreChunks(bool b) {} | ||
|
||
virtual bool getEffectName(char *name) = 0; // The plug-in name | ||
virtual VstPlugCategory getPlugCategory() = 0; // The general category for the plug-in | ||
virtual bool | ||
getProductString(char *text) = 0; // This is a unique plug-in string provided by Steinberg | ||
virtual bool getVendorString(char *text) = 0; // Vendor info | ||
virtual VstInt32 getVendorVersion() = 0; // Version number | ||
virtual void processReplacing(float **inputs, float **outputs, VstInt32 sampleFrames) = 0; | ||
|
||
virtual void processDoubleReplacing(double **inputs, double **outputs, VstInt32 sampleFrames) = 0; | ||
|
||
virtual VstInt32 getChunk(void **data, bool isPreset) { return 0; }; | ||
|
||
virtual VstInt32 setChunk(void *data, VstInt32 byteSize, bool isPreset) { return 0; }; | ||
|
||
virtual float getParameter(VstInt32 index) { return 0.f; }; // get the parameter value at the specified index | ||
virtual void setParameter(VstInt32 index, float value) {}; // set the parameter at index to value | ||
virtual void getParameterLabel(VstInt32 index, char *text) {}; // label for the parameter (eg dB) | ||
virtual void getParameterName(VstInt32 index, char *text) {}; // name of the parameter | ||
virtual void getParameterDisplay(VstInt32 index, char *text) {}; // text description of the current value | ||
virtual VstInt32 canDo(char *text) = 0; | ||
}; | ||
#include "airwin-to-clap.h" | ||
|
||
typedef AudioEffect AudioEffectX; | ||
typedef AirwinToClapPortBaseClass AudioEffect; | ||
typedef AirwinToClapPortBaseClass AudioEffectX; | ||
|
||
|
||
#endif //CLAUDIO_EFFECT_X_AUDIOEFFECTX_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters