Skip to content

Commit

Permalink
All thats left is everything
Browse files Browse the repository at this point in the history
  • Loading branch information
baconpaul committed Jun 20, 2022
1 parent da28cf1 commit 05ce4af
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 41 deletions.
24 changes: 12 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
endif()

project(claudio-effect-x VERSION 0.9.0 LANGUAGES C CXX)
project(airwin-to-clap VERSION 0.9.0 LANGUAGES C CXX)


set(CMAKE_CXX_EXTENSIONS OFF)
Expand All @@ -33,15 +33,15 @@ if(NOT EXISTS "${CMAKE_BINARY_DIR}/individuals")
endif()

add_library(${PROJECT_NAME} MODULE
src/claudio.cpp
src/airwin-to-clap.cpp
)
target_include_directories(${PROJECT_NAME} PRIVATE include ${CMAKE_BINARY_DIR}/individuals)
target_link_libraries(${PROJECT_NAME} clap-core clap-helpers)
set_property(TARGET ${PROJECT_NAME} PROPERTY AIRWIN_INCLUDES "")
set_property(TARGET ${PROJECT_NAME} PROPERTY AIRWIN_COUNT 0)

function (addAirwin airwin)
set(awt claudio_${airwin})
set(awt aw2c_${airwin})
set(aw_src libs/airwindows/plugins/MacVST/${airwin}/source)
add_library(${awt} STATIC ${aw_src}/${airwin}.cpp ${aw_src}/${airwin}Proc.cpp)
target_include_directories(${awt} PRIVATE include)
Expand All @@ -53,8 +53,8 @@ function (addAirwin airwin)

set(CREATE_FN "${awt}CreateEffectInstance")
set(AIRWIN_NAME "${airwin}")
configure_file(src/individual_claudio.in.h individuals/${awt}.h)
configure_file(src/individual_claudio.in.cpp individuals/${awt}.cpp)
configure_file(src/individual_airwin.in.h individuals/${awt}.h)
configure_file(src/individual_airwin.in.cpp individuals/${awt}.cpp)

target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_BINARY_DIR}/individuals/${awt}.cpp)

Expand All @@ -79,33 +79,33 @@ addAirwin(DeBess)
get_target_property(AWC ${PROJECT_NAME} AIRWIN_COUNT)
message(STATUS "Generating ${AWC} plugins" )

set(sumfn "${CMAKE_BINARY_DIR}/individuals/claudio_configured.hxx")
set(sumfn "${CMAKE_BINARY_DIR}/individuals/aw2c_configured.hxx")
file(WRITE ${sumfn} "// machine generated. Include once\n")

get_target_property(AW ${PROJECT_NAME} AIRWIN_INCLUDES)
foreach(awt ${AW})
message(STATUS "Airwindow: ${awt}")
file(APPEND ${sumfn} "#include \"claudio_${awt}.h\"\n")
file(APPEND ${sumfn} "#include \"aw2c_${awt}.h\"\n")
endforeach()

file(APPEND ${sumfn} "uint32_t claudio_get_plugin_count(const clap_plugin_factory *f) { return ${AWC}; }\n")
file(APPEND ${sumfn} "const clap_plugin_descriptor *claudio_get_plugin_descriptor(const clap_plugin_factory *f, uint32_t w)\n")
file(APPEND ${sumfn} "uint32_t aw2c_get_plugin_count(const clap_plugin_factory *f) { return ${AWC}; }\n")
file(APPEND ${sumfn} "const clap_plugin_descriptor *aw2c_get_plugin_descriptor(const clap_plugin_factory *f, uint32_t w)\n")
file(APPEND ${sumfn} "{ switch(w) {\n")
set(CASEW 0)
foreach(awt ${AW})

file(APPEND ${sumfn} "case ${CASEW}:\n")
file(APPEND ${sumfn} " return &claudio_${awt}_desc;\n")
file(APPEND ${sumfn} " return &aw2c_${awt}_desc;\n")
file(APPEND ${sumfn} " break;\n")
math(EXPR CASEW "${CASEW} + 1")
endforeach()
file(APPEND ${sumfn} "} return nullptr; } \n")

file(APPEND ${sumfn} "std::pair<AudioEffect *, const clap_plugin_descriptor *> claudio_get_aeffInstance(audioMasterCallback c, const char* plugin_id)\n")
file(APPEND ${sumfn} "std::pair<AudioEffect *, const clap_plugin_descriptor *> aw2c_get_aeffInstance(audioMasterCallback c, const char* plugin_id)\n")
file(APPEND ${sumfn} "{")
set(CASEW 0)
foreach(awt ${AW})
file(APPEND ${sumfn} "if (strcmp(plugin_id, \"unofficial.com.airwindows.${awt}\") == 0) return { claudio_${awt}CreateEffectInstance(c), &claudio_${awt}_desc};\n")
file(APPEND ${sumfn} "if (strcmp(plugin_id, \"unofficial.com.airwindows.${awt}\") == 0) return { aw2c_${awt}CreateEffectInstance(c), &aw2c_${awt}_desc};\n")
endforeach()
file(APPEND ${sumfn} "return {nullptr, nullptr}; } \n")

Expand Down
6 changes: 6 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Unofficial Airwindows Support

ToDo

1. All of em
3. Push to github.
File renamed without changes.
59 changes: 47 additions & 12 deletions src/claudio.cpp → src/airwin-to-clap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@
#include "clap/helpers/host-proxy.hh"
#include "clap/helpers/host-proxy.hxx"

#include "claudio_configured.hxx"
#include "aw2c_configured.hxx"

#include <iostream>
#include <cassert>

struct ClaudioWrapper : public clap::helpers::Plugin<clap::helpers::MisbehaviourHandler::Terminate,
struct aw2cWrapper : public clap::helpers::Plugin<clap::helpers::MisbehaviourHandler::Terminate,
clap::helpers::CheckingLevel::Maximal>
{
AudioEffect *underlyer{nullptr};
ClaudioWrapper(const clap_host *host, const clap_plugin_descriptor *desc, AudioEffect *effect)
aw2cWrapper(const clap_host *host, const clap_plugin_descriptor *desc, AudioEffect *effect)
: clap::helpers::Plugin<clap::helpers::MisbehaviourHandler::Terminate,
clap::helpers::CheckingLevel::Maximal>(desc, host),
underlyer(effect)
{
assert(underlyer);
}
~ClaudioWrapper() = default;
~aw2cWrapper() = default;

bool activate(double sampleRate, uint32_t minFrameCount,
uint32_t maxFrameCount) noexcept override
Expand Down Expand Up @@ -146,25 +146,60 @@ struct ClaudioWrapper : public clap::helpers::Plugin<clap::helpers::Misbehaviour
assert (!nextEvent);
return CLAP_PROCESS_CONTINUE;
}

bool implementsState() const noexcept override { return true; }
bool stateSave(const clap_ostream *stream) noexcept override
{
uint8_t *data;
auto s = underlyer->getChunk((void**)&data, false);

auto c = data;
while (s > 0)
{
auto r = stream->write(stream, c, s);
if (r < 0)
return false;
s -= r;
c += r;
}
free(data);

return true;
}
bool stateLoad(const clap_istream *stream) noexcept override
{
char buffer[4096 * 16];
char *bp = &(buffer[0]);
int64_t rd;
int total = 0;
while ((rd = stream->read(stream, bp, 256)) > 0)
{
total += rd;
bp += rd;
if (total > 4096*16)
return false;
}

underlyer->setChunk(buffer, total, false);
return true;
}
};

static const clap_plugin *clap_create_plugin(const clap_plugin_factory *f, const clap_host *host,
const char *plugin_id)
{
auto [fx, desc] = claudio_get_aeffInstance(host, plugin_id);
std::cout << "FX = " << fx << " plugin_id = " << plugin_id << std::endl;

auto wr = new ClaudioWrapper(host, desc, fx);
auto [fx, desc] = aw2c_get_aeffInstance(host, plugin_id);
auto wr = new aw2cWrapper(host, desc, fx);
return wr->clapPlugin();
}

const CLAP_EXPORT struct clap_plugin_factory claudio_factory = {
claudio_get_plugin_count,
claudio_get_plugin_descriptor,
const CLAP_EXPORT struct clap_plugin_factory aw2c_factory = {
aw2c_get_plugin_count,
aw2c_get_plugin_descriptor,
clap_create_plugin,
};

static const void *get_factory(const char *factory_id) { return &claudio_factory; }
static const void *get_factory(const char *factory_id) { return &aw2c_factory; }

// clap_init and clap_deinit are required to be fast, but we have nothing we need to do here
bool clap_init(const char *p) { return true; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

// clang-format off
#include "audioeffectx.h"
#include "claudio_@[email protected]"
#include "aw2c_@[email protected]"

const char *@AIRWIN_NAME@_features[] = {CLAP_PLUGIN_FEATURE_AUDIO_EFFECT, nullptr};
clap_plugin_descriptor claudio_@AIRWIN_NAME@_desc = {
clap_plugin_descriptor aw2c_@AIRWIN_NAME@_desc = {
CLAP_VERSION,
"unofficial.com.airwindows.@AIRWIN_NAME@", // change this change the cmake generatortoo
"Airwindows @AIRWIN_NAME@ (Unofficial)",
Expand Down
15 changes: 15 additions & 0 deletions src/individual_airwin.in.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// Created by Paul Walker on 6/19/22.
//

// clang-format off
#ifndef AW2C_@AIRWIN_NAME@_X_INDIVIDUAL_AW2C_IN_H
#define AW2C_@AIRWIN_NAME@_X_INDIVIDUAL_AW2C_IN_H

#include "audioeffectx.h"
#include <clap/clap.h>

extern AudioEffect *@CREATE_FN@ (audioMasterCallback audioMaster);
extern clap_plugin_descriptor aw2c_@AIRWIN_NAME@_desc;

#endif
15 changes: 0 additions & 15 deletions src/individual_claudio.in.h

This file was deleted.

0 comments on commit 05ce4af

Please sign in to comment.