Skip to content

Commit

Permalink
Clarify what the include files are
Browse files Browse the repository at this point in the history
and their provenance. (Which is: I wrote them all yesterday)
  • Loading branch information
baconpaul committed Jun 20, 2022
1 parent ba4f255 commit 9619334
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 81 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ function (addAirwin airwin)
add_library(${awt} STATIC ${aw_src}/${airwin}.cpp ${aw_src}/${airwin}Proc.cpp)
target_include_directories(${awt} PRIVATE include)
if (APPLE)
target_compile_options(${PROJECT_NAME} PRIVATE
-Werror -Wno-unused-value
target_compile_options(${awt} PRIVATE
-Wno-unused-value
-Wno-parentheses # these ones look like actual bugs tbh
)
endif()

Expand Down Expand Up @@ -79,7 +80,6 @@ foreach(awdir ${ALL_AIRWIN})
endforeach()



get_target_property(AWC ${PROJECT_NAME} AIRWIN_COUNT)
message(STATUS "Generating ${AWC} plugins" )

Expand Down
83 changes: 83 additions & 0 deletions include/airwin-to-clap.h
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
92 changes: 15 additions & 77 deletions include/audioeffectx.h
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
2 changes: 1 addition & 1 deletion src/individual_airwin.in.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const char *@AIRWIN_NAME@_features[] = {CLAP_PLUGIN_FEATURE_AUDIO_EFFECT, nullpt
clap_plugin_descriptor aw2c_@AIRWIN_NAME@_desc = {
CLAP_VERSION,
"unofficial.com.airwindows.@AIRWIN_NAME@", // change this change the cmake generatortoo
"Airwindows @AIRWIN_NAME@ (Unofficial)",
"AW @AIRWIN_NAME@ (Unofficial)",
"Unsupported",
"https://airwindows.com",
"",
Expand Down

0 comments on commit 9619334

Please sign in to comment.