diff --git a/.gitignore b/.gitignore index 3d68d95..9f80449 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ build build_win include -seq2wav_test* +clef_test* *.dll *.a *.so diff --git a/LICENSE.md b/LICENSE.md index 14f50e9..167150d 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,4 @@ -seq2wav is copyright (c) 2020 Adam Higerd +libclef is copyright (c) 2020-2024 Adam Higerd Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/Makefile b/Makefile index 418c0d2..fe23419 100644 --- a/Makefile +++ b/Makefile @@ -1,22 +1,24 @@ +first: test + include config.mak -test: seq2wav_test$(EXE) +test: clef_test$(EXE) -debug: seq2wav_test_d$(EXE) +debug: clef_test_d$(EXE) -static: $(BUILDPATH)/libseq2wav.a +static: $(BUILDPATH)/libclef.a $(BUILDPATH)/Makefile.d: $(wildcard src/*.cpp src/*/*.cpp src/*.h src/*/*.h) Makefile src/Makefile $(MAKE) -C src ../$(BUILDPATH)/Makefile.d -seq2wav_test$(EXE) seq2wav_test_d$(EXE): src/Makefile $(BUILDPATH)/Makefile.d +clef_test$(EXE) clef_test_d$(EXE): src/Makefile $(BUILDPATH)/Makefile.d $(MAKE) -C src ../$@ -$(BUILDPATH)/libseq2wav.a $(BUILDPATH)/libseq2wav_d.a: src/Makefile $(BUILDPATH)/Makefile.d $(INCLUDES) +$(BUILDPATH)/libclef.a $(BUILDPATH)/libclef_d.a: src/Makefile $(BUILDPATH)/Makefile.d $(INCLUDES) $(MAKE) -C src ../$@ clean: FORCE -rm -f $(BUILDPATH)/*.o $(BUILDPATH)/*.d $(BUILDPATH)/*/*.o $(BUILDPATH)/Makefile.d - -rm -f seq2wav_test$(EXE) seq2wav_test_d$(EXE) $(BUILDPATH)/libseq2wav.a $(BUILDPATH)/libseq2wav_d.a + -rm -f clef_test$(EXE) clef_test_d$(EXE) $(BUILDPATH)/libclef.a $(BUILDPATH)/libclef_d.a FORCE: diff --git a/README.md b/README.md index 9ed5307..cf082d4 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ -seq2wav +libclef ======= -seq2wav is a generic library for building decoders and media player plugins for sequenced audio formats. +libclef is a generic library for building decoders and media player plugins for sequenced audio formats. +It was formerly known as "seq2wav". Currently, there is support for the following targets: @@ -13,20 +14,20 @@ Currently, there is support for the following targets: Building -------- -seq2wav is meant to be statically linked as a component in another project. See the "Template +libclef is meant to be statically linked as a component in another project. See the "Template project" section below for more information. -On POSIX systems or when building under MinGW, seq2wav itself has no dependencies beyond a -C++17-compliant compiler and GNU Make. To build seq2wav using Microsoft Visual Studio, ATL support +On POSIX systems or when building under MinGW, libclef itself has no dependencies beyond a +C++17-compliant compiler and GNU Make. To build libclef using Microsoft Visual Studio, ATL support and the Visual Studio command-line tools must be installed. To build an Audacious plugin, the Audacious development headers must be present. These may be found in -the `audacious-dev` package on Debian-based distros.) The seq2wav build system uses `pkg-config` to +the `audacious-dev` package on Debian-based distros.) The libclef build system uses `pkg-config` to locate the required files. Audacious plugins cannot currently be built using Microsoft Visual C++. To build a Foobar2000 plugin, the [Foobar2000 SDK](https://www.foobar2000.org/SDK) is required. -seq2wav has been tested with the 2020-07-28 version of the Foobar2000 SDK. The SDK should be -extracted into the `plugins/` folder of the project that uses seq2wav. +libclef has been tested with the 2020-07-28 version of the Foobar2000 SDK. The SDK should be +extracted into the `plugins/` folder of the project that uses libclef. No additional dependencies are required for building a Winamp plugin. @@ -34,22 +35,22 @@ Build scripts are included for cross-compiling Windows binaries on Linux using M to run the Visual Studio command-line tools. (Installing the Visual Studio command-line tools on Linux is left as an exercise to the reader.) -Further information for building seq2wav-based tools and plugins can be found in the [template -project documentation](template/README.md). If built standalone, seq2wav produces a very basic +Further information for building libclef-based tools and plugins can be found in the [template +project documentation](template/README.md). If built standalone, libclef produces a very basic command-line test program that creates a file named `sample.wav`. The test program does not support building with Microsoft Visual C++. Template project ---------------- -A template project for creating tools or plugins based on seq2wav may be found in the `template/` -folder. Copy all of the files in `template/` to a new folder and place the seq2wav source tree -in a `seq2wav/` folder inside it. (If using `git`, you may use -`git submodule add https://bitbucket.org/ahigerd/seq2wav` to clone seq2wav into the appropriate +A template project for creating tools or plugins based on libclef may be found in the `template/` +folder. Copy all of the files in `template/` to a new folder and place the libclef source tree +in a `libclef/` folder inside it. (If using `git`, you may use +`git submodule add https://github.com/ahigerd/libclef` to clone libclef into the appropriate location and track it as a submodule.) Modify `config.mak` in the new project to set `PLUGIN_NAME` appropriately, and change the filenames in `buildvs.cmd` to refer to the same plugin name instead of `template`. Additionally, fill in -`plugins/s2wplugin.cpp` with the necessary metadata and code for the player plugins. +`plugins/clefplugin.cpp` with the necessary metadata and code for the player plugins. Avoid nesting subdirectories more than one level inside `src/`, as the build scripts will not find source files in any deeper levels. @@ -58,8 +59,8 @@ Further information can be found in the [template project documentation](templat License ------- -seq2wav is copyright (c) 2020-2023 Adam Higerd and distributed -under the terms of the [MIT license](LICENSE.md). +libclef is copyright (c) 2020-2023 Adam Higerd and distributed under the terms of the +[MIT license](LICENSE.md). [CLAP](https://cleveraudio.org/) is an open-source audio plugin format. The [CLAP SDK](https://github.com/free-audio/clap) is copyright (c) 2021 Alexander BIQUE diff --git a/config.mak b/config.mak index f9ff156..878774e 100644 --- a/config.mak +++ b/config.mak @@ -1,5 +1,5 @@ # Note: Don't use -march=native for code intended for distribution. -msse2 is probably good. -CXXFLAGS := -fPIC -std=gnu++17 -Wno-multichar -I../src -I../seq2wav/src -msse2 -I. -Isrc/ $(PLUGIN_CXXFLAGS) +CXXFLAGS := -fPIC -std=gnu++17 -Wno-multichar -I../src -I../libclef/src -msse2 -I. -Isrc/ $(PLUGIN_CXXFLAGS) QMAKE = qmake DLL := so @@ -45,9 +45,9 @@ CXXFLAGS_D := $(CXXFLAGS) -Og -ffast-math -gstabs else CXXFLAGS_D := $(CXXFLAGS) -Og -ffast-math -ggdb3 endif -LDFLAGS := $(LDFLAGS) -L../seq2wav/$(BUILDPATH) -L../$(BUILDPATH) $(PLUGIN_LDFLAGS) -LDFLAGS_R := $(LDFLAGS) -lseq2wav -LDFLAGS_D := $(LDFLAGS) -lseq2wav_d +LDFLAGS := $(LDFLAGS) -L../libclef/$(BUILDPATH) -L../$(BUILDPATH) $(PLUGIN_LDFLAGS) +LDFLAGS_R := $(LDFLAGS) -lclef +LDFLAGS_D := $(LDFLAGS) -lclef_d validate: FORCE ifeq ($(PLUGIN_NAME),sample) @@ -55,7 +55,7 @@ ifeq ($(PLUGIN_NAME),sample) @exit 1 endif -seq2wav/$(BUILDPATH)/libseq2wav.a seq2wav/$(BUILDPATH)/libseq2wav_d.a: validate +libclef/$(BUILDPATH)/libclef.a libclef/$(BUILDPATH)/libclef_d.a: validate define validate_xspec = ifeq ($(XSPEC),) diff --git a/gui/gui.pri b/gui/gui.pri index cea071e..dcc31a5 100644 --- a/gui/gui.pri +++ b/gui/gui.pri @@ -1,5 +1,5 @@ -isEmpty(S2W_LDFLAGS) { - error("S2W_LDFLAGS must be set") +isEmpty(CLEF_LDFLAGS) { + error("CLEF_LDFLAGS must be set") } isEmpty(BUILDPATH) { @@ -11,8 +11,8 @@ isEmpty(PLUGIN_NAME) { } PROJPATH = $$absolute_path($$BUILDPATH/..) -S2WPATH = $$absolute_path($$BUILDPATH/../seq2wav) -S2WBUILDPATH = $$absolute_path($$S2WPATH/$$relative_path($$BUILDPATH,$$PROJPATH)) +CLEF_PATH = $$absolute_path($$BUILDPATH/../libclef) +CLEF_BUILDPATH = $$absolute_path($$CLEF_PATH/$$relative_path($$BUILDPATH,$$PROJPATH)) TEMPLATE = app @@ -24,7 +24,7 @@ isEmpty(BUILD_DEBUG) { CONFIG -= debug debug_and_release CONFIG += release LIBS += -L$$BUILDPATH -l$$PLUGIN_NAME - PRE_TARGETDEPS += $$BUILDPATH/lib$${PLUGIN_NAME}.a $$S2WBUILDPATH/libseq2wav.a + PRE_TARGETDEPS += $$BUILDPATH/lib$${PLUGIN_NAME}.a $$CLEF_BUILDPATH/libclef.a } else { TARGET = ../$${PLUGIN_NAME}_gui_d OBJECTS_DIR = $$BUILDPATH/gui_d @@ -33,18 +33,18 @@ isEmpty(BUILD_DEBUG) { CONFIG -= release debug_and_release CONFIG += debug LIBS += -L$$BUILDPATH -l$${PLUGIN_NAME}_d - PRE_TARGETDEPS += $$BUILDPATH/lib$${PLUGIN_NAME}_d.a $$S2WBUILDPATH/libseq2wav_d.a + PRE_TARGETDEPS += $$BUILDPATH/lib$${PLUGIN_NAME}_d.a $$CLEF_BUILDPATH/libclef_d.a } QT = core gui widgets multimedia CONFIG += c++17 QMAKE_CXXFLAGS += -std=c++17 -Wno-multichar DEFINES -= QT_DEPRECATED_WARNINGS DEFINES += QT_NO_DEPRECATED_WARNINGS -INCLUDEPATH += $$S2WPATH/src $$S2WPATH/gui $$PROJPATH/src -LIBS += $$S2W_LDFLAGS +INCLUDEPATH += $$CLEF_PATH/src $$CLEF_PATH/gui $$PROJPATH/src +LIBS += $$CLEF_LDFLAGS -S2W_CLASSES = mainwindow tagview playercontrols vumeter -for (CLS,S2W_CLASSES) { - exists($$S2WPATH/gui/$${CLS}.h):HEADERS += $$S2WPATH/gui/$${CLS}.h - exists($$S2WPATH/gui/$${CLS}.cpp):SOURCES += $$S2WPATH/gui/$${CLS}.cpp +CLEF_CLASSES = mainwindow tagview playercontrols vumeter +for (CLS,CLEF_CLASSES) { + exists($$CLEF_PATH/gui/$${CLS}.h):HEADERS += $$CLEF_PATH/gui/$${CLS}.h + exists($$CLEF_PATH/gui/$${CLS}.cpp):SOURCES += $$CLEF_PATH/gui/$${CLS}.cpp } diff --git a/gui/guiutils.h b/gui/guiutils.h index e05b1e2..f70bfc3 100644 --- a/gui/guiutils.h +++ b/gui/guiutils.h @@ -1,5 +1,5 @@ -#ifndef S2W_GUIUTILS_H -#define S2W_GUIUTILS_H +#ifndef CLEF_GUIUTILS_H +#define CLEF_GUIUTILS_H #include diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 8560cdd..1b5bb21 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -13,7 +13,7 @@ #include #include -MainWindow::MainWindow(S2WPluginBase* plugin) +MainWindow::MainWindow(ClefPluginBase* plugin) : QMainWindow(nullptr), m_plugin(plugin), ctx(nullptr), controls(nullptr), m_autoPlay(false) { setWindowTitle(QString::fromStdString(plugin->pluginName())); diff --git a/gui/mainwindow.h b/gui/mainwindow.h index e6f2a5d..55e8211 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -1,10 +1,10 @@ -#ifndef S2W_MAINWINDOW_H -#define S2W_MAINWINDOW_H +#ifndef CLEF_MAINWINDOW_H +#define CLEF_MAINWINDOW_H #include #include #include -class S2WPluginBase; +class ClefPluginBase; class SynthContext; class TagView; class PlayerControls; @@ -13,7 +13,7 @@ class MainWindow : public QMainWindow { Q_OBJECT public: - MainWindow(S2WPluginBase* plugin); + MainWindow(ClefPluginBase* plugin); void openFile(const QString& path, bool autoPlay = false); @@ -44,7 +44,7 @@ private slots: void openFile(const QString& path, bool doAcquire, bool autoPlay); protected: - S2WPluginBase* m_plugin; + ClefPluginBase* m_plugin; SynthContext* ctx; PlayerControls* controls; diff --git a/gui/playercontrols.h b/gui/playercontrols.h index 44e35e2..cd4dff0 100644 --- a/gui/playercontrols.h +++ b/gui/playercontrols.h @@ -1,5 +1,5 @@ -#ifndef S2W_PLAYERCONTROLS_H -#define S2W_PLAYERCONTROLS_H +#ifndef CLEF_PLAYERCONTROLS_H +#define CLEF_PLAYERCONTROLS_H #include #include diff --git a/gui/tagview.cpp b/gui/tagview.cpp index a9045bd..7093a14 100644 --- a/gui/tagview.cpp +++ b/gui/tagview.cpp @@ -16,7 +16,7 @@ TagView::TagView(QWidget* parent) clearTags(); } -void TagView::loadTags(S2WPluginBase* plugin, const QString& filename, const std::string& stdFilename, const std::string& stdPath) +void TagView::loadTags(ClefPluginBase* plugin, const QString& filename, const std::string& stdFilename, const std::string& stdPath) { clearTags(); setTitle(filename); diff --git a/gui/tagview.h b/gui/tagview.h index 9f43c08..e7cce0e 100644 --- a/gui/tagview.h +++ b/gui/tagview.h @@ -1,11 +1,11 @@ -#ifndef S2W_TAGVIEW_H -#define S2W_TAGVIEW_H +#ifndef CLEF_TAGVIEW_H +#define CLEF_TAGVIEW_H #include #include #include #include "tagmap.h" -class S2WPluginBase; +class ClefPluginBase; class QLabel; class QFormLayout; class QComboBox; @@ -19,7 +19,7 @@ Q_OBJECT QString autoSubsong() const; public slots: - void loadTags(S2WPluginBase* plugin, const QString& filename, const std::string& stdFilename, const std::string& stdPath); + void loadTags(ClefPluginBase* plugin, const QString& filename, const std::string& stdFilename, const std::string& stdPath); void clearTags(); signals: diff --git a/gui/vumeter.h b/gui/vumeter.h index 0b44b28..5d8ceca 100644 --- a/gui/vumeter.h +++ b/gui/vumeter.h @@ -1,5 +1,5 @@ -#ifndef S2W_VUMETER_H -#define S2W_VUMETER_H +#ifndef CLEF_VUMETER_H +#define CLEF_VUMETER_H #include #include diff --git a/src/Makefile b/src/Makefile index ad1ea5c..8436fd4 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,22 +1,22 @@ include ../config.mak -CXXFLAGS := $(patsubst -I../seq2wav/src,-I../src,$(CXXFLAGS)) -CXXFLAGS_R := $(patsubst -I../seq2wav/src,-I../src,$(CXXFLAGS_R)) -CXXFLAGS_D := $(patsubst -I../seq2wav/src,-I../src,$(CXXFLAGS_D)) +CXXFLAGS := $(patsubst -I../libclef/src,-I../src,$(CXXFLAGS)) +CXXFLAGS_R := $(patsubst -I../libclef/src,-I../src,$(CXXFLAGS_R)) +CXXFLAGS_D := $(patsubst -I../libclef/src,-I../src,$(CXXFLAGS_D)) SOURCES = $(filter-out main.cpp, $(wildcard *.cpp */*.cpp)) -../seq2wav_test$(EXE): ../$(BUILDPATH)/main.o ../$(BUILDPATH)/libseq2wav.a +../clef_test$(EXE): ../$(BUILDPATH)/main.o ../$(BUILDPATH)/libclef.a $(CXX) -o $@ $^ -../seq2wav_test_d$(EXE): ../$(BUILDPATH)/main_d.o ../$(BUILDPATH)/libseq2wav_d.$(DLL) +../clef_test_d$(EXE): ../$(BUILDPATH)/main_d.o ../$(BUILDPATH)/libclef_d.$(DLL) $(CXX) -o $@ $^ -../$(BUILDPATH)/libseq2wav.a: $(patsubst %.cpp, ../$(BUILDPATH)/%.o, $(SOURCES)) | ../$(BUILDPATH)/Makefile.d +../$(BUILDPATH)/libclef.a: $(patsubst %.cpp, ../$(BUILDPATH)/%.o, $(SOURCES)) | ../$(BUILDPATH)/Makefile.d rm -f $@ gcc-ar -rc $@ $^ -../$(BUILDPATH)/libseq2wav_d.a: $(patsubst %.cpp, ../$(BUILDPATH)/%_d.o, $(SOURCES)) | ../$(BUILDPATH)/Makefile.d +../$(BUILDPATH)/libclef_d.a: $(patsubst %.cpp, ../$(BUILDPATH)/%_d.o, $(SOURCES)) | ../$(BUILDPATH)/Makefile.d rm -f $@ gcc-ar -rc $@ $^ diff --git a/src/s2wconfig.h b/src/clefconfig.h similarity index 84% rename from src/s2wconfig.h rename to src/clefconfig.h index cd8a5d4..dd35b3e 100644 --- a/src/s2wconfig.h +++ b/src/clefconfig.h @@ -1,5 +1,5 @@ -#ifndef S2W_S2WCONFIG_H -#define S2W_S2WCONFIG_H +#ifndef CLEF_CLEFCONFIG_H +#define CLEF_CLEFCONFIG_H #define _USE_MATH_DEFINES diff --git a/src/s2wcontext.cpp b/src/clefcontext.cpp similarity index 56% rename from src/s2wcontext.cpp rename to src/clefcontext.cpp index 814f1a1..d8589c7 100644 --- a/src/s2wcontext.cpp +++ b/src/clefcontext.cpp @@ -1,24 +1,24 @@ -#include "s2wcontext.h" +#include "clefcontext.h" #include "codec/sampledata.h" -S2WContext::S2WContext(const OpenFn& openFile) -: S2WContext(false, openFile) +ClefContext::ClefContext(const OpenFn& openFile) +: ClefContext(false, openFile) { // forwarded constructor only } -S2WContext::S2WContext(bool isDawPlugin, const OpenFn& openFile) +ClefContext::ClefContext(bool isDawPlugin, const OpenFn& openFile) : pluginData(nullptr), isDawPlugin(isDawPlugin), openFn(openFile), lastSampleID(0) { // initializers only } -std::unique_ptr S2WContext::openFile(const std::string& path) const +std::unique_ptr ClefContext::openFile(const std::string& path) const { return openFn(path); } -SampleData* S2WContext::getSample(uint64_t sampleID) const +SampleData* ClefContext::getSample(uint64_t sampleID) const { auto iter = sampleCache.find(sampleID); if (iter == sampleCache.end()) { @@ -27,13 +27,13 @@ SampleData* S2WContext::getSample(uint64_t sampleID) const return iter->second.get(); } -void S2WContext::purgeSamples() +void ClefContext::purgeSamples() { sampleCache.clear(); lastSampleID = 0; } -uint64_t S2WContext::nextSampleID() +uint64_t ClefContext::nextSampleID() { do { ++lastSampleID; diff --git a/src/s2wcontext.h b/src/clefcontext.h similarity index 70% rename from src/s2wcontext.h rename to src/clefcontext.h index e594550..db4063a 100644 --- a/src/s2wcontext.h +++ b/src/clefcontext.h @@ -1,14 +1,14 @@ -#ifndef S2W_S2WCONTEXT_H -#define S2W_S2WCONTEXT_H +#ifndef CLEF_CLEFCONTEXT_H +#define CLEF_CLEFCONTEXT_H #include #include "utility.h" #include "codec/sampledata.h" -class S2WContext { +class ClefContext { public: - S2WContext(const OpenFn& openFile = openFstream); - S2WContext(bool isDawPlugin, const OpenFn& openFile = openFstream); + ClefContext(const OpenFn& openFile = openFstream); + ClefContext(bool isDawPlugin, const OpenFn& openFile = openFstream); std::unique_ptr openFile(const std::string& path) const; diff --git a/src/codec/adpcmcodec.cpp b/src/codec/adpcmcodec.cpp index 79d3b8f..4860a67 100644 --- a/src/codec/adpcmcodec.cpp +++ b/src/codec/adpcmcodec.cpp @@ -26,7 +26,7 @@ static const int16_t oki4sStep[] = { }; static const int maxOki4sStep = (sizeof(oki4sStep) >> 1) - 1; -AdpcmCodec::AdpcmCodec(S2WContext* ctx, AdpcmCodec::Format format, int interleave) +AdpcmCodec::AdpcmCodec(ClefContext* ctx, AdpcmCodec::Format format, int interleave) : ICodec(ctx), format(format), predictor{ 0, 0 }, index{ 0, 0 }, interleave(interleave) { if (format == OKI4s) { diff --git a/src/codec/adpcmcodec.h b/src/codec/adpcmcodec.h index 2c012c5..0717f8d 100644 --- a/src/codec/adpcmcodec.h +++ b/src/codec/adpcmcodec.h @@ -1,5 +1,5 @@ -#ifndef S2W_ADPCMCODEC_H -#define S2W_ADPCMCODEC_H +#ifndef CLEF_ADPCMCODEC_H +#define CLEF_ADPCMCODEC_H #include "icodec.h" @@ -11,7 +11,7 @@ class AdpcmCodec : public ICodec { OKI4s, NDS, }; - AdpcmCodec(S2WContext* ctx, Format format, int interleave = 0); + AdpcmCodec(ClefContext* ctx, Format format, int interleave = 0); virtual SampleData* decodeRange(std::vector::const_iterator start, std::vector::const_iterator end, uint64_t sampleID = 0); diff --git a/src/codec/icodec.cpp b/src/codec/icodec.cpp index b30aba3..cf301ec 100644 --- a/src/codec/icodec.cpp +++ b/src/codec/icodec.cpp @@ -1,7 +1,7 @@ #include "icodec.h" #include -ICodec::ICodec(S2WContext* ctx) +ICodec::ICodec(ClefContext* ctx) : ctx(ctx) { // initializers only @@ -9,7 +9,7 @@ ICodec::ICodec(S2WContext* ctx) ICodec::~ICodec() {} -S2WContext* ICodec::context() const +ClefContext* ICodec::context() const { return ctx; } diff --git a/src/codec/icodec.h b/src/codec/icodec.h index 81d4bbb..eef8e41 100644 --- a/src/codec/icodec.h +++ b/src/codec/icodec.h @@ -1,15 +1,15 @@ -#ifndef S2W_ICODEC_H -#define S2W_ICODEC_H +#ifndef CLEF_ICODEC_H +#define CLEF_ICODEC_H #include #include #include #include "sampledata.h" -class S2WContext; +class ClefContext; class ICodec { public: - ICodec(S2WContext* ctx); + ICodec(ClefContext* ctx); virtual ~ICodec(); // TODO: header @@ -18,10 +18,10 @@ class ICodec { virtual SampleData* decodeRange(std::vector::const_iterator start, std::vector::const_iterator end, uint64_t sampleID = 0) = 0; protected: - S2WContext* context() const; + ClefContext* context() const; private: - S2WContext* ctx; + ClefContext* ctx; }; #endif diff --git a/src/codec/msadpcmcodec.cpp b/src/codec/msadpcmcodec.cpp index a0d9652..5b6bd2e 100644 --- a/src/codec/msadpcmcodec.cpp +++ b/src/codec/msadpcmcodec.cpp @@ -14,7 +14,7 @@ static const int16_t msStep[] = { 768, 614, 512, 409, 307, 230, 230, 230, }; -MsAdpcmCodec::MsAdpcmCodec(S2WContext* ctx, uint16_t blockSize, uint16_t channels) +MsAdpcmCodec::MsAdpcmCodec(ClefContext* ctx, uint16_t blockSize, uint16_t channels) : ICodec(ctx), blockSize(blockSize), channels(channels) { // initializers only diff --git a/src/codec/msadpcmcodec.h b/src/codec/msadpcmcodec.h index 407ba50..0b85928 100644 --- a/src/codec/msadpcmcodec.h +++ b/src/codec/msadpcmcodec.h @@ -1,11 +1,11 @@ -#ifndef S2W_MSADPCMCODEC_H -#define S2W_MSADPCMCODEC_H +#ifndef CLEF_MSADPCMCODEC_H +#define CLEF_MSADPCMCODEC_H #include "icodec.h" class MsAdpcmCodec : public ICodec { public: - MsAdpcmCodec(S2WContext* ctx, uint16_t blockSize, uint16_t channels); + MsAdpcmCodec(ClefContext* ctx, uint16_t blockSize, uint16_t channels); virtual SampleData* decodeRange(std::vector::const_iterator start, std::vector::const_iterator end, uint64_t sampleID = 0); diff --git a/src/codec/pcmcodec.cpp b/src/codec/pcmcodec.cpp index 5c13369..2a4e7e9 100644 --- a/src/codec/pcmcodec.cpp +++ b/src/codec/pcmcodec.cpp @@ -1,7 +1,7 @@ #include "pcmcodec.h" #include "utility.h" -PcmCodec::PcmCodec(S2WContext* ctx, int sampleBits, int channels, bool bigEndian) +PcmCodec::PcmCodec(ClefContext* ctx, int sampleBits, int channels, bool bigEndian) : ICodec(ctx), sampleBits(sampleBits), sampleBytes(sampleBits >> 3), channels(channels), bigEndian(bigEndian) { // initializers only diff --git a/src/codec/pcmcodec.h b/src/codec/pcmcodec.h index 3aab258..b74e676 100644 --- a/src/codec/pcmcodec.h +++ b/src/codec/pcmcodec.h @@ -1,11 +1,11 @@ -#ifndef S2W_PCMCODEC_H -#define S2W_PCMCODEC_H +#ifndef CLEF_PCMCODEC_H +#define CLEF_PCMCODEC_H #include "icodec.h" class PcmCodec : public ICodec { public: - PcmCodec(S2WContext* ctx, int sampleBits, int channels = 1, bool bigEndian = true); + PcmCodec(ClefContext* ctx, int sampleBits, int channels = 1, bool bigEndian = true); virtual SampleData* decodeRange(std::vector::const_iterator start, std::vector::const_iterator end, uint64_t sampleID = 0); diff --git a/src/codec/procyoncodec.cpp b/src/codec/procyoncodec.cpp index ef741fb..2d7ed1f 100644 --- a/src/codec/procyoncodec.cpp +++ b/src/codec/procyoncodec.cpp @@ -9,7 +9,7 @@ static const int16_t procyonFactor[][2] = { }; static const int16_t maxProcyonFactor = (sizeof(procyonFactor) >> 2) - 1; -ProcyonCodec::ProcyonCodec(S2WContext* ctx, bool stereo) +ProcyonCodec::ProcyonCodec(ClefContext* ctx, bool stereo) : ICodec(ctx), stereo(stereo) { // initializers only diff --git a/src/codec/procyoncodec.h b/src/codec/procyoncodec.h index 30ba1ed..24113c2 100644 --- a/src/codec/procyoncodec.h +++ b/src/codec/procyoncodec.h @@ -1,11 +1,11 @@ -#ifndef S2W_PROCYONCODEC_H -#define S2W_PROCYONCODEC_H +#ifndef CLEF_PROCYONCODEC_H +#define CLEF_PROCYONCODEC_H #include "icodec.h" class ProcyonCodec : public ICodec { public: - ProcyonCodec(S2WContext* ctx, bool stereo = false); + ProcyonCodec(ClefContext* ctx, bool stereo = false); virtual SampleData* decodeRange(std::vector::const_iterator start, std::vector::const_iterator end, uint64_t sampleID = 0); diff --git a/src/codec/riffcodec.cpp b/src/codec/riffcodec.cpp index 2ef2ccb..95705ed 100644 --- a/src/codec/riffcodec.cpp +++ b/src/codec/riffcodec.cpp @@ -29,7 +29,7 @@ WaveFormatEx::WaveFormatEx(std::vector::const_iterator start, std::vect } } -RiffCodec::RiffCodec(S2WContext* ctx) : ICodec(ctx) +RiffCodec::RiffCodec(ClefContext* ctx) : ICodec(ctx) { // initializers only } diff --git a/src/codec/riffcodec.h b/src/codec/riffcodec.h index bc1972d..4ed4126 100644 --- a/src/codec/riffcodec.h +++ b/src/codec/riffcodec.h @@ -1,5 +1,5 @@ -#ifndef S2W_RIFFCODEC_H -#define S2W_RIFFCODEC_H +#ifndef CLEF_RIFFCODEC_H +#define CLEF_RIFFCODEC_H #include "icodec.h" @@ -23,7 +23,7 @@ struct WaveFormatEx { class RiffCodec : public ICodec { public: - RiffCodec(S2WContext* ctx); + RiffCodec(ClefContext* ctx); virtual SampleData* decodeRange(std::vector::const_iterator start, std::vector::const_iterator end, uint64_t sampleID = 0); }; diff --git a/src/codec/sampledata.cpp b/src/codec/sampledata.cpp index 9b01a7a..399cbb0 100644 --- a/src/codec/sampledata.cpp +++ b/src/codec/sampledata.cpp @@ -1,9 +1,9 @@ #include "sampledata.h" -#include "s2wcontext.h" +#include "clefcontext.h" #include #include -SampleData::SampleData(S2WContext* ctx, uint64_t sampleID, double sampleRate, int loopStart, int loopEnd) +SampleData::SampleData(ClefContext* ctx, uint64_t sampleID, double sampleRate, int loopStart, int loopEnd) : sampleID(sampleID), sampleRate(sampleRate), loopStart(loopStart), loopEnd(loopEnd) { if (sampleID != Uncached && ctx) { @@ -13,7 +13,7 @@ SampleData::SampleData(S2WContext* ctx, uint64_t sampleID, double sampleRate, in m_duration = -1; } -SampleData::SampleData(S2WContext* ctx, double sampleRate, int loopStart, int loopEnd) +SampleData::SampleData(ClefContext* ctx, double sampleRate, int loopStart, int loopEnd) : SampleData(ctx, ctx ? ctx->nextSampleID() : 0, sampleRate, loopStart, loopEnd) { // forwarded constructor only diff --git a/src/codec/sampledata.h b/src/codec/sampledata.h index 4413594..b781a4e 100644 --- a/src/codec/sampledata.h +++ b/src/codec/sampledata.h @@ -1,17 +1,17 @@ -#ifndef S2W_SAMPLEDATA_H -#define S2W_SAMPLEDATA_H +#ifndef CLEF_SAMPLEDATA_H +#define CLEF_SAMPLEDATA_H #include #include -class S2WContext; +class ClefContext; struct SampleData { enum { Uncached = 0xFFFFFFFFFFFFFFFFULL, }; - SampleData(S2WContext* ctx, uint64_t sampleID, double sampleRate = 44100.0, int loopStart = -1, int loopEnd = -1); - SampleData(S2WContext* ctx, double sampleRate = 44100.0, int loopStart = -1, int loopEnd = -1); + SampleData(ClefContext* ctx, uint64_t sampleID, double sampleRate = 44100.0, int loopStart = -1, int loopEnd = -1); + SampleData(ClefContext* ctx, double sampleRate = 44100.0, int loopStart = -1, int loopEnd = -1); uint32_t numSamples() const; double duration() const; diff --git a/src/commandargs.h b/src/commandargs.h index 7bdd1ef..d254140 100644 --- a/src/commandargs.h +++ b/src/commandargs.h @@ -1,5 +1,5 @@ -#ifndef S2W_COMMANDARGS_H -#define S2W_COMMANDARGS_H +#ifndef CLEF_COMMANDARGS_H +#define CLEF_COMMANDARGS_H #include #include diff --git a/src/main.cpp b/src/main.cpp index d1c2c78..0e5c6c2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,14 +1,14 @@ #include "seq/testsequence.h" #include "synth/channel.h" #include "synth/synthcontext.h" -#include "s2wcontext.h" +#include "clefcontext.h" #include "riffwriter.h" #include int main(int argc, char** argv) { - S2WContext s2w; - TestSequence seq(&s2w); - SynthContext ctx(&s2w, 44100); + ClefContext clef; + TestSequence seq(&clef); + SynthContext ctx(&clef, 44100); int numTracks = seq.numTracks(); for (int i = 0; i < numTracks; i++) { ctx.channels.emplace_back(new Channel(&ctx, seq.getTrack(i))); diff --git a/src/plugin/audaciousplugin.h b/src/plugin/audaciousplugin.h index 75542f9..2a333b5 100644 --- a/src/plugin/audaciousplugin.h +++ b/src/plugin/audaciousplugin.h @@ -1,5 +1,5 @@ -#ifndef S2W_AUDACITYPLUGIN_H -#define S2W_AUDACITYPLUGIN_H +#ifndef CLEF_AUDACITYPLUGIN_H +#define CLEF_AUDACITYPLUGIN_H #define WANT_VFS_STDIO_COMPAT #include @@ -95,25 +95,25 @@ class vfsfile_istream : public std::istream { ~vfsfile_istream() { delete rdbuf(nullptr); } }; -template -class Seq2WavPlugin : public InputPlugin { +template +class ClefPlugin : public InputPlugin { struct ExtExpand { std::vector exts; operator const char* const *() const { return exts.data(); } - ExtExpand() : exts(S2WPluginInfo::extensions.size() + 1, nullptr) { - for (int i = 0; i < S2WPluginInfo::extensions.size(); i++) { - exts[i] = S2WPluginInfo::extensions[i].first.c_str(); + ExtExpand() : exts(ClefPluginInfo::extensions.size() + 1, nullptr) { + for (int i = 0; i < ClefPluginInfo::extensions.size(); i++) { + exts[i] = ClefPluginInfo::extensions[i].first.c_str(); } } }; - S2WContext s2w; - S2WPlugin plugin; + ClefContext clef; + ClefPlugin plugin; static ExtExpand extensions; public: - Seq2WavPlugin(); + ClefPlugin(); bool is_our_file(const char* filename, VFSFile& file) { vfsfile_istream vs(&file); @@ -175,22 +175,22 @@ class Seq2WavPlugin : public InputPlugin { bool play(const char* filename, VFSFile& file); }; -static std::unique_ptr s2wAudaciousOpenFile(const std::string& filename) +static std::unique_ptr clefAudaciousOpenFile(const std::string& filename) { return std::unique_ptr(new vfsfile_istream(filename.c_str())); } -template -Seq2WavPlugin::Seq2WavPlugin() +template +ClefPlugin::ClefPlugin() : InputPlugin( PluginInfo{ N_(plugin.pluginName().c_str()), plugin.pluginName().c_str(), plugin.about().c_str() }, InputInfo().with_priority(8).with_exts(extensions) - ), plugin(&s2w) + ), plugin(&clef) { } -template -bool Seq2WavPlugin::play(const char* filename, VFSFile& file) +template +bool ClefPlugin::play(const char* filename, VFSFile& file) { vfsfile_istream vs(&file); bool ok = plugin.play(filename, vs); @@ -213,7 +213,7 @@ bool Seq2WavPlugin::play(const char* filename, VFSFile& file) return ok; } -#define SEQ2WAV_PLUGIN(S2WPluginInfo) \ - template<> Seq2WavPlugin::ExtExpand Seq2WavPlugin::extensions = Seq2WavPlugin::ExtExpand(); \ - EXPORT Seq2WavPlugin aud_plugin_instance; +#define CLEF_PLUGIN(ClefPluginInfo) \ + template<> ClefPlugin::ExtExpand ClefPlugin::extensions = ClefPlugin::ExtExpand(); \ + EXPORT ClefPlugin aud_plugin_instance; #endif diff --git a/src/plugin/baseplugin.cpp b/src/plugin/baseplugin.cpp index 7d3af91..5aeaa76 100644 --- a/src/plugin/baseplugin.cpp +++ b/src/plugin/baseplugin.cpp @@ -5,18 +5,18 @@ #include #include -std::string S2WPluginBase::seq2wavCopyright() +std::string ClefPluginBase::libclefCopyright() { return "\n\n" - "Derived from seq2wav copyright (C) 2020 Adam Higerd\n" + "Derived from libclef, copyright (C) 2020-2024 Adam Higerd\n" "under the terms of the MIT license."; } -TagMap TagsM3UMixin::readTags(S2WContext* s2w, const std::string& filename) +TagMap TagsM3UMixin::readTags(ClefContext* clef, const std::string& filename) { std::string m3uPath = TagsM3U::relativeTo(filename); try { - auto m3uStream(s2w->openFile(m3uPath)); + auto m3uStream(clef->openFile(m3uPath)); if (*m3uStream) { TagsM3U m3u(*m3uStream); TagMap tagMap = m3u.allTags(filename); @@ -30,7 +30,7 @@ TagMap TagsM3UMixin::readTags(S2WContext* s2w, const std::string& filename) return TagMap(); } -std::vector TagsM3UMixin::getSubsongs(S2WContext* s2w, const std::string& filename, std::istream& file) +std::vector TagsM3UMixin::getSubsongs(ClefContext* clef, const std::string& filename, std::istream& file) { std::string m3uPath = TagsM3U::relativeTo(filename); int slashPos = filename.find_last_of(PATH_CHARS); @@ -38,7 +38,7 @@ std::vector TagsM3UMixin::getSubsongs(S2WContext* s2w, const std::s std::string baseName = filename.substr(slashPos + 1, qPos - slashPos - 1); std::vector result; try { - auto m3uStream(s2w->openFile(m3uPath)); + auto m3uStream(clef->openFile(m3uPath)); if (*m3uStream) { TagsM3U m3u(*m3uStream); std::vector trackIds = m3u.findTracksByPrefix(baseName); @@ -61,7 +61,7 @@ std::vector TagsM3UMixin::getSubsongs(S2WContext* s2w, const std::s return result; } -S2WPluginBase::S2WPluginBase(S2WContext* s2w) : s2w(s2w), ctx(nullptr) +ClefPluginBase::ClefPluginBase(ClefContext* clef) : clef(clef), ctx(nullptr) { // initializers only } @@ -77,7 +77,7 @@ std::string toLower(const std::string& str) return str; } -bool S2WPluginBase::matchExtension(const std::string& filename) const +bool ClefPluginBase::matchExtension(const std::string& filename) const { int dotPos = filename.rfind('.'); if (dotPos == std::string::npos) { @@ -92,7 +92,7 @@ bool S2WPluginBase::matchExtension(const std::string& filename) const return false; } -TagMap S2WPluginBase::getTags(const std::string& filename, std::istream& file) const +TagMap ClefPluginBase::getTags(const std::string& filename, std::istream& file) const { try { auto pos = file.tellg(); @@ -125,7 +125,7 @@ TagMap S2WPluginBase::getTags(const std::string& filename, std::istream& file) c } } -int S2WPluginBase::fillBuffer(uint8_t* buffer, int len) +int ClefPluginBase::fillBuffer(uint8_t* buffer, int len) { if (!ctx) { return 0; @@ -133,7 +133,7 @@ int S2WPluginBase::fillBuffer(uint8_t* buffer, int len) return ctx->fillBuffer(buffer, len); } -int S2WPluginBase::channels() const +int ClefPluginBase::channels() const { if (!ctx) { return 0; @@ -141,7 +141,7 @@ int S2WPluginBase::channels() const return ctx->outputChannels; } -int S2WPluginBase::sampleRate() const +int ClefPluginBase::sampleRate() const { if (!ctx) { return 0; @@ -149,7 +149,7 @@ int S2WPluginBase::sampleRate() const return ctx->sampleRate; } -bool S2WPluginBase::play(const std::string& filename, std::istream& file) +bool ClefPluginBase::play(const std::string& filename, std::istream& file) { try { file.seekg(0); @@ -168,7 +168,7 @@ bool S2WPluginBase::play(const std::string& filename, std::istream& file) } } -double S2WPluginBase::currentTime() const +double ClefPluginBase::currentTime() const { if (ctx) { return ctx->currentTime(); @@ -176,14 +176,14 @@ double S2WPluginBase::currentTime() const return 0; } -void S2WPluginBase::seek(double time) +void ClefPluginBase::seek(double time) { if (ctx) { ctx->seek(time); } } -void S2WPluginBase::unload() +void ClefPluginBase::unload() { release(); ctx = nullptr; diff --git a/src/plugin/baseplugin.h b/src/plugin/baseplugin.h index 8379709..58a4391 100644 --- a/src/plugin/baseplugin.h +++ b/src/plugin/baseplugin.h @@ -1,5 +1,5 @@ -#ifndef S2W_BASEPLUGIN_H -#define S2W_BASEPLUGIN_H +#ifndef CLEF_BASEPLUGIN_H +#define CLEF_BASEPLUGIN_H #include #include @@ -9,41 +9,41 @@ #include #include "utility.h" #include "tagmap.h" -#include "s2wcontext.h" +#include "clefcontext.h" #include "synth/synthcontext.h" -class S2WPluginInfo; +class ClefPluginInfo; using ConstPairList = const std::vector>; #ifdef BUILD_CLAP -# define S2WPLUGIN_BANK_EXT static ConstPairList bankExtensions; +# define CLEF_PLUGIN_BANK_EXT static ConstPairList bankExtensions; #else -# define S2WPLUGIN_BANK_EXT +# define CLEF_PLUGIN_BANK_EXT #endif -#define S2WPLUGIN_STATIC_FIELDS \ +#define CLEF_PLUGIN_STATIC_FIELDS \ static const std::string version, pluginName, pluginShortName, about, author, url; \ - static ConstPairList extensions; S2WPLUGIN_BANK_EXT + static ConstPairList extensions; CLEF_PLUGIN_BANK_EXT struct TagsM3UMixin { - static TagMap readTags(S2WContext* s2w, const std::string& filename); - static inline TagMap readTags(S2WContext* s2w, const std::string& filename, std::istream& /* unused */) { return readTags(s2w, filename); } - static std::vector getSubsongs(S2WContext* s2w, const std::string& filename, std::istream& file); + static TagMap readTags(ClefContext* clef, const std::string& filename); + static inline TagMap readTags(ClefContext* clef, const std::string& filename, std::istream& /* unused */) { return readTags(clef, filename); } + static std::vector getSubsongs(ClefContext* clef, const std::string& filename, std::istream& file); }; #ifdef BUILD_DUMMY_PLUGIN struct DummyPluginInfo : public TagsM3UMixin { - S2WPLUGIN_STATIC_FIELDS - static bool isPlayable(S2WContext* s2w, const std::string& filename, std::istream& file, bool ignoreExtension = false) { + CLEF_PLUGIN_STATIC_FIELDS + static bool isPlayable(ClefContext* clef, const std::string& filename, std::istream& file, bool ignoreExtension = false) { return false; } - static double length(S2WContext* s2w, const std::string& filename, std::istream& file) { + static double length(ClefContext* clef, const std::string& filename, std::istream& file) { return 0; } - static double sampleRate(S2WContext* s2w, const std::string& filename, std::istream& file) { + static double sampleRate(ClefContext* clef, const std::string& filename, std::istream& file) { return 44100; } - SynthContext* prepare(S2WContext* s2w, const std::string& filename, std::istream& file) { + SynthContext* prepare(ClefContext* clef, const std::string& filename, std::istream& file) { // Implementations should retain appropriate pointers return nullptr; } @@ -53,18 +53,18 @@ struct DummyPluginInfo : public TagsM3UMixin { }; const std::string DummyPluginInfo::version = "0.0.1"; -const std::string DummyPluginInfo::pluginName = "seq2wav"; +const std::string DummyPluginInfo::pluginName = "dummyClef"; ConstPairList DummyPluginInfo::extensions = { { "dummy", "Dummy files (*.dummy)" } }; const std::string DummyPluginInfo::about = "Dummy plugin copyright (C) 2020 Adam Higerd\n" "Distributed under the MIT license."; #endif -class S2WPluginBase { +class ClefPluginBase { public: - static std::string seq2wavCopyright(); + static std::string libclefCopyright(); - inline S2WContext* context() const { return s2w; } + inline ClefContext* context() const { return clef; } bool matchExtension(const std::string& filename) const; TagMap getTags(const std::string& filename, std::istream& file) const; @@ -92,16 +92,16 @@ class S2WPluginBase { virtual void release() = 0; protected: - S2WPluginBase(S2WContext* s2w); + ClefPluginBase(ClefContext* clef); virtual TagMap getTagsBase(const std::string& filename, std::istream& file) const = 0; - S2WContext* s2w; + ClefContext* clef; SynthContext* ctx; }; template struct GetSubsongs { -static std::vector getSubsongsImpl(S2WContext* s2w, const std::string& filename, std::istream& file) { - (void)s2w; +static std::vector getSubsongsImpl(ClefContext* clef, const std::string& filename, std::istream& file) { + (void)clef; (void)filename; (void)file; return std::vector(); @@ -109,25 +109,25 @@ static std::vector getSubsongsImpl(S2WContext* s2w, const std::stri }; template struct GetSubsongs { -static std::vector getSubsongsImpl(S2WContext* s2w, const std::string& filename, std::istream& file) { +static std::vector getSubsongsImpl(ClefContext* clef, const std::string& filename, std::istream& file) { file.seekg(0); - return Info::getSubsongs(s2w, filename, file); + return Info::getSubsongs(clef, filename, file); } }; template -class S2WPlugin : public S2WPluginBase, public PluginInfo { +class ClefPlugin : public ClefPluginBase, public PluginInfo { public: using Info = PluginInfo; - S2WPlugin(S2WContext* ctx) : S2WPluginBase(ctx) {} + ClefPlugin(ClefContext* ctx) : ClefPluginBase(ctx) {} const std::string& version() const { return Info::version; } const std::string& pluginShortName() const { return Info::pluginShortName; } const std::string& pluginName() const { return Info::pluginName; } const ConstPairList& extensions() const { return Info::extensions; } const std::string& about() const { - static std::string message = Info::about + seq2wavCopyright(); + static std::string message = Info::about + libclefCopyright(); return message; } virtual bool isPlayable(const std::string& filename, std::istream& file, bool ignoreExtension = false) const { @@ -137,22 +137,22 @@ class S2WPlugin : public S2WPluginBase, public PluginInfo { } file.clear(); file.seekg(0); - return Info::isPlayable(s2w, filename, file); + return Info::isPlayable(clef, filename, file); } catch (...) { return false; } } - double length(const std::string& filename, std::istream& file) const { file.seekg(0); return Info::length(s2w, filename, file); } - int sampleRate(const std::string& filename, std::istream& file) const { file.seekg(0); return Info::sampleRate(s2w, filename, file); } - inline int sampleRate() const { return S2WPluginBase::sampleRate(); } + double length(const std::string& filename, std::istream& file) const { file.seekg(0); return Info::length(clef, filename, file); } + int sampleRate(const std::string& filename, std::istream& file) const { file.seekg(0); return Info::sampleRate(clef, filename, file); } + inline int sampleRate() const { return ClefPluginBase::sampleRate(); } - SynthContext* prepare(const std::string& filename, std::istream& file) { file.seekg(0); return Info::prepare(s2w, filename, file); } + SynthContext* prepare(const std::string& filename, std::istream& file) { file.seekg(0); return Info::prepare(clef, filename, file); } void release() { Info::release(); } - std::vector getSubsongs(const std::string& filename, std::istream& file) const { return GetSubsongs::getSubsongsImpl(s2w, filename, file); } + std::vector getSubsongs(const std::string& filename, std::istream& file) const { return GetSubsongs::getSubsongsImpl(clef, filename, file); } protected: - TagMap getTagsBase(const std::string& filename, std::istream& file) const { file.seekg(0); return Info::readTags(s2w, filename, file); } + TagMap getTagsBase(const std::string& filename, std::istream& file) const { file.seekg(0); return Info::readTags(clef, filename, file); } }; #if defined(BUILD_AUDACIOUS) @@ -164,12 +164,12 @@ class S2WPlugin : public S2WPluginBase, public PluginInfo { #elif defined(BUILD_CLAP) #include "plugin/clapplugin.h" #else -namespace S2W { - S2WPluginBase* makePlugin(S2WContext* ctx); +namespace Clef { + ClefPluginBase* makePlugin(ClefContext* ctx); } -#define SEQ2WAV_PLUGIN(PluginInfo) namespace S2W { S2WPluginBase* makePlugin(S2WContext* ctx) { \ - return new S2WPlugin(ctx); \ +#define CLEF_PLUGIN(PluginInfo) namespace Clef { ClefPluginBase* makePlugin(ClefContext* ctx) { \ + return new ClefPlugin(ctx); \ }} #endif diff --git a/src/plugin/clapplugin.cpp b/src/plugin/clapplugin.cpp index 21a5a42..2dc40a0 100644 --- a/src/plugin/clapplugin.cpp +++ b/src/plugin/clapplugin.cpp @@ -11,10 +11,10 @@ #include #define C_P const clap_plugin_t* plugin -#define WRAP_METHOD(RET, method, sig, ...) []sig -> RET { return reinterpret_cast(plugin->plugin_data)->method(__VA_ARGS__); } -#define WRAP_METHOD_VOID(method, sig, ...) []sig { reinterpret_cast(plugin->plugin_data)->method(__VA_ARGS__); } -S2WClapPluginBase::S2WClapPluginBase(const clap_host_t* host) -: host(host), ctx(new S2WContext(true)), synth(nullptr), currentInstID(0xFFFFFFFFFFFFFFFFULL), instrument(nullptr), hostParams(nullptr), mustRescanInfo(true), +#define WRAP_METHOD(RET, method, sig, ...) []sig -> RET { return reinterpret_cast(plugin->plugin_data)->method(__VA_ARGS__); } +#define WRAP_METHOD_VOID(method, sig, ...) []sig { reinterpret_cast(plugin->plugin_data)->method(__VA_ARGS__); } +ClefClapPluginBase::ClefClapPluginBase(const clap_host_t* host) +: host(host), ctx(new ClefContext(true)), synth(nullptr), currentInstID(0xFFFFFFFFFFFFFFFFULL), instrument(nullptr), hostParams(nullptr), mustRescanInfo(true), mustRestart(false), openFileDialog(nullptr), messageDialog(nullptr) { mainThreadID = std::this_thread::get_id(); @@ -48,7 +48,7 @@ S2WClapPluginBase::S2WClapPluginBase(const clap_host_t* host) stateExtension.load = WRAP_METHOD(bool, loadState, (C_P, const clap_istream_t* stream), stream); } -S2WClapPluginBase::~S2WClapPluginBase() +ClefClapPluginBase::~ClefClapPluginBase() { if (synth) { delete synth; @@ -58,7 +58,7 @@ S2WClapPluginBase::~S2WClapPluginBase() } } -bool S2WClapPluginBase::init() +bool ClefClapPluginBase::init() { hostParams = reinterpret_cast(host->get_extension(host, CLAP_EXT_PARAMS)); synth = new SynthContext(ctx, 48000, 2); @@ -66,7 +66,7 @@ bool S2WClapPluginBase::init() return true; } -void S2WClapPluginBase::destroy() +void ClefClapPluginBase::destroy() { if (synth) { delete synth; @@ -75,7 +75,7 @@ void S2WClapPluginBase::destroy() delete this; } -void S2WClapPluginBase::buildContext(const std::string& filePath, uint64_t instID) +void ClefClapPluginBase::buildContext(const std::string& filePath, uint64_t instID) { std::lock_guard lock(synthMutex); seq.reset(); @@ -109,7 +109,7 @@ void S2WClapPluginBase::buildContext(const std::string& filePath, uint64_t instI } } -bool S2WClapPluginBase::activate(double sampleRate, uint32_t minFrames, uint32_t maxFrames) +bool ClefClapPluginBase::activate(double sampleRate, uint32_t minFrames, uint32_t maxFrames) { std::cerr << "activate " << filePath << " " << currentInstID << std::endl; try { @@ -124,7 +124,7 @@ bool S2WClapPluginBase::activate(double sampleRate, uint32_t minFrames, uint32_t std::cerr << message << std::endl; messageDialog = new pfd::message( - s2wPlugin->pluginName(), + clefPlugin->pluginName(), message, pfd::choice::ok, pfd::icon::error @@ -142,22 +142,22 @@ bool S2WClapPluginBase::activate(double sampleRate, uint32_t minFrames, uint32_t return true; } -void S2WClapPluginBase::deactivate() +void ClefClapPluginBase::deactivate() { std::cerr << "deactivate" << std::endl; seq.reset(); } -bool S2WClapPluginBase::startProcessing() +bool ClefClapPluginBase::startProcessing() { return true; } -void S2WClapPluginBase::stopProcessing() +void ClefClapPluginBase::stopProcessing() { } -void S2WClapPluginBase::reset() +void ClefClapPluginBase::reset() { if (!synth) { return; @@ -167,7 +167,7 @@ void S2WClapPluginBase::reset() activate(sampleRate, 0, 0); } -clap_process_status S2WClapPluginBase::process(const clap_process_t* process) +clap_process_status ClefClapPluginBase::process(const clap_process_t* process) { if (messageDialog && messageDialog->ready(0)) { delete messageDialog; @@ -225,7 +225,7 @@ clap_process_status S2WClapPluginBase::process(const clap_process_t* process) } } -double S2WClapPluginBase::eventTimestamp(const clap_event_header_t* event) const +double ClefClapPluginBase::eventTimestamp(const clap_event_header_t* event) const { if (synth) { //return (steadyTime + event->time) * synth->sampleTime; @@ -234,7 +234,7 @@ double S2WClapPluginBase::eventTimestamp(const clap_event_header_t* event) const return -1; } -void S2WClapPluginBase::dispatchEvent(const clap_event_header_t* event) +void ClefClapPluginBase::dispatchEvent(const clap_event_header_t* event) { if (event->space_id != CLAP_CORE_EVENT_SPACE_ID) { return; @@ -269,7 +269,7 @@ void S2WClapPluginBase::dispatchEvent(const clap_event_header_t* event) } } -const void* S2WClapPluginBase::getExtension(const char* id) +const void* ClefClapPluginBase::getExtension(const char* id) { if (!strcmp(id, CLAP_EXT_NOTE_PORTS)) { return ¬ePorts; @@ -283,7 +283,7 @@ const void* S2WClapPluginBase::getExtension(const char* id) return nullptr; } -void S2WClapPluginBase::onMainThread() +void ClefClapPluginBase::onMainThread() { if (mustRestart || !hostParams) { host->request_restart(host); @@ -296,7 +296,7 @@ void S2WClapPluginBase::onMainThread() } } -BaseNoteEvent* S2WClapPluginBase::createNoteEvent(const clap_event_note_t* event) +BaseNoteEvent* ClefClapPluginBase::createNoteEvent(const clap_event_note_t* event) { InstrumentNoteEvent* note = new InstrumentNoteEvent(); note->pitch = event->key; @@ -305,7 +305,7 @@ BaseNoteEvent* S2WClapPluginBase::createNoteEvent(const clap_event_note_t* event return note; } -void S2WClapPluginBase::noteEvent(const clap_event_note_t* event) +void ClefClapPluginBase::noteEvent(const clap_event_note_t* event) { if (currentInstID == 0xFFFFFFFFFFFFFFFFULL) { // No selected instrument (probably no file loaded). @@ -344,9 +344,9 @@ void S2WClapPluginBase::noteEvent(const clap_event_note_t* event) } } -void S2WClapPluginBase::expressionEvent(const clap_event_note_expression_t* event) {} +void ClefClapPluginBase::expressionEvent(const clap_event_note_expression_t* event) {} -void S2WClapPluginBase::paramValueEvent(const clap_event_param_value_t* event) +void ClefClapPluginBase::paramValueEvent(const clap_event_param_value_t* event) { std::cerr << fourccToString(event->param_id) << " = " << event->value << std::endl; if (event->param_id == 'FNAM') { @@ -358,7 +358,7 @@ void S2WClapPluginBase::paramValueEvent(const clap_event_param_value_t* event) return; } std::vector filters; - for (const auto& ext : s2wPlugin->extensions()) { + for (const auto& ext : clefPlugin->extensions()) { filters.push_back(ext.second); filters.push_back("*." + ext.first); } @@ -402,16 +402,16 @@ void S2WClapPluginBase::paramValueEvent(const clap_event_param_value_t* event) } } -void S2WClapPluginBase::paramModEvent(const clap_event_param_mod_t* event) +void ClefClapPluginBase::paramModEvent(const clap_event_param_mod_t* event) { } -void S2WClapPluginBase::transportEvent(const clap_event_transport_t* event) {} -void S2WClapPluginBase::midiEvent(const clap_event_midi_t* event) {} -void S2WClapPluginBase::sysexEvent(const clap_event_midi_sysex_t* event) {} -void S2WClapPluginBase::midi2Event(const clap_event_midi2_t* event) {} +void ClefClapPluginBase::transportEvent(const clap_event_transport_t* event) {} +void ClefClapPluginBase::midiEvent(const clap_event_midi_t* event) {} +void ClefClapPluginBase::sysexEvent(const clap_event_midi_sysex_t* event) {} +void ClefClapPluginBase::midi2Event(const clap_event_midi2_t* event) {} -uint32_t S2WClapPluginBase::notePortCount(bool isInput) const +uint32_t ClefClapPluginBase::notePortCount(bool isInput) const { if (isInput) { return 1; @@ -419,7 +419,7 @@ uint32_t S2WClapPluginBase::notePortCount(bool isInput) const return 0; } -bool S2WClapPluginBase::getNotePort(uint32_t index, bool isInput, clap_note_port_info_t& port) const +bool ClefClapPluginBase::getNotePort(uint32_t index, bool isInput, clap_note_port_info_t& port) const { if (!isInput || index != 0) { return false; @@ -431,7 +431,7 @@ bool S2WClapPluginBase::getNotePort(uint32_t index, bool isInput, clap_note_port return true; } -uint32_t S2WClapPluginBase::audioPortCount(bool isInput) const +uint32_t ClefClapPluginBase::audioPortCount(bool isInput) const { if (isInput) { return 0; @@ -439,7 +439,7 @@ uint32_t S2WClapPluginBase::audioPortCount(bool isInput) const return 1; } -bool S2WClapPluginBase::getAudioPort(uint32_t index, bool isInput, clap_audio_port_info_t& port) const +bool ClefClapPluginBase::getAudioPort(uint32_t index, bool isInput, clap_audio_port_info_t& port) const { if (isInput || index != 0) { return false; @@ -453,12 +453,12 @@ bool S2WClapPluginBase::getAudioPort(uint32_t index, bool isInput, clap_audio_po return true; } -uint32_t S2WClapPluginBase::paramCount() const +uint32_t ClefClapPluginBase::paramCount() const { return paramOrder.size(); } -bool S2WClapPluginBase::paramInfo(uint32_t index, clap_param_info_t& info) const +bool ClefClapPluginBase::paramInfo(uint32_t index, clap_param_info_t& info) const { if (index >= paramOrder.size()) { std::cerr << "unknown param index " << index << std::endl; @@ -501,7 +501,7 @@ bool S2WClapPluginBase::paramInfo(uint32_t index, clap_param_info_t& info) const return true; } -void S2WClapPluginBase::getParamRange(uint32_t id, double& minValue, double& maxValue, double& defaultValue) const +void ClefClapPluginBase::getParamRange(uint32_t id, double& minValue, double& maxValue, double& defaultValue) const { if (id == Sampler::PitchBend || id == BaseOscillator::PitchBend) { minValue = -1.0f; @@ -513,7 +513,7 @@ void S2WClapPluginBase::getParamRange(uint32_t id, double& minValue, double& max maxValue = 1.0f; } -bool S2WClapPluginBase::paramValue(clap_id id, double& value) const +bool ClefClapPluginBase::paramValue(clap_id id, double& value) const { std::lock_guard lock(synthMutex); if (id == 'FNAM') { @@ -541,7 +541,7 @@ bool S2WClapPluginBase::paramValue(clap_id id, double& value) const return true; } -bool S2WClapPluginBase::paramValueText(clap_id id, double value, char* text, uint32_t size) const +bool ClefClapPluginBase::paramValueText(clap_id id, double value, char* text, uint32_t size) const { std::string strValue; if (id == 'FNAM') { @@ -565,7 +565,7 @@ bool S2WClapPluginBase::paramValueText(clap_id id, double value, char* text, uin return true; } -bool S2WClapPluginBase::paramTextValue(clap_id id, const char* text, double& value) const +bool ClefClapPluginBase::paramTextValue(clap_id id, const char* text, double& value) const { if (id == 'FNAM') { return false; @@ -593,11 +593,11 @@ bool S2WClapPluginBase::paramTextValue(clap_id id, const char* text, double& val return success; } -void S2WClapPluginBase::flushParams(const clap_input_events_t* inEvents, const clap_output_events_t* outEvents) +void ClefClapPluginBase::flushParams(const clap_input_events_t* inEvents, const clap_output_events_t* outEvents) { } -IInstrument* S2WClapPluginBase::selectInstrumentByIndex(uint32_t index, bool force, bool rescan) +IInstrument* ClefClapPluginBase::selectInstrumentByIndex(uint32_t index, bool force, bool rescan) { if (index >= synth->numInstruments()) { std::cerr << "instrument index out of range: " << index << std::endl; @@ -606,7 +606,7 @@ IInstrument* S2WClapPluginBase::selectInstrumentByIndex(uint32_t index, bool for return selectInstrumentByID(synth->instrumentID(index), force, rescan); } -IInstrument* S2WClapPluginBase::selectInstrumentByID(uint64_t instrumentID, bool force, bool rescan) +IInstrument* ClefClapPluginBase::selectInstrumentByID(uint64_t instrumentID, bool force, bool rescan) { if (!force && instrumentID == currentInstID) { if (rescan) { @@ -650,7 +650,7 @@ IInstrument* S2WClapPluginBase::selectInstrumentByID(uint64_t instrumentID, bool return found; } -void S2WClapPluginBase::requestParamSync(bool rescanInfo) +void ClefClapPluginBase::requestParamSync(bool rescanInfo) { if (rescanInfo) { mustRescanInfo = rescanInfo; @@ -664,7 +664,7 @@ void S2WClapPluginBase::requestParamSync(bool rescanInfo) } } -bool S2WClapPluginBase::saveState(const clap_ostream_t* stream) +bool ClefClapPluginBase::saveState(const clap_ostream_t* stream) { std::lock_guard lock(synthMutex); if (filePath.empty() || !instrument || synth->channels.empty()) { @@ -690,7 +690,7 @@ bool S2WClapPluginBase::saveState(const clap_ostream_t* stream) return stream->write(stream, state.c_str(), state.size()) == state.size(); } -bool S2WClapPluginBase::loadState(const clap_istream_t* stream) +bool ClefClapPluginBase::loadState(const clap_istream_t* stream) { std::string state; char buffer[1024]; diff --git a/src/plugin/clapplugin.h b/src/plugin/clapplugin.h index 41e9789..c2dcc05 100644 --- a/src/plugin/clapplugin.h +++ b/src/plugin/clapplugin.h @@ -1,5 +1,5 @@ -#ifndef S2W_CLAPPLUGIN_H -#define S2W_CLAPPLUGIN_H +#ifndef CLEF_CLAPPLUGIN_H +#define CLEF_CLAPPLUGIN_H #ifdef BUILD_CLAP #include "plugin/baseplugin.h" @@ -15,18 +15,18 @@ namespace pfd { class message; } -class S2WClapPluginBase +class ClefClapPluginBase { public: clap_plugin_t plugin; const clap_host_t* host; - S2WContext* ctx; - S2WPluginBase* s2wPlugin; + ClefContext* ctx; + ClefPluginBase* clefPlugin; SynthContext* synth; RealTimeTrack seq; - S2WClapPluginBase(const clap_host_t* host); - ~S2WClapPluginBase(); + ClefClapPluginBase(const clap_host_t* host); + ~ClefClapPluginBase(); virtual bool init(); virtual void destroy(); @@ -107,30 +107,30 @@ class S2WClapPluginBase pfd::message* messageDialog; }; -template -class S2WClapPlugin : public S2WClapPluginBase +template +class ClefClapPlugin : public ClefClapPluginBase { public: - using PluginBase = S2WClapPlugin; - using PluginInfo = S2WPluginInfo; + using PluginBase = ClefClapPlugin; + using PluginInfo = ClefPluginInfo; - S2WClapPlugin(const clap_host_t* host) : S2WClapPluginBase(host) + ClefClapPlugin(const clap_host_t* host) : ClefClapPluginBase(host) { - s2wPlugin = new S2WPlugin(ctx); + clefPlugin = new ClefPlugin(ctx); } SynthContext* createContext(const std::string& filename, std::istream& file) { - return s2wPlugin->prepare(filename, file); + return clefPlugin->prepare(filename, file); } }; -template -struct S2WPluginFactory +template +struct ClefPluginFactory { static const clap_plugin_descriptor_t* descriptor() { - static std::string id("s2w." + S2WPluginInfo::pluginShortName); + static std::string id("clef." + ClefPluginInfo::pluginShortName); static const char* features[] = { CLAP_PLUGIN_FEATURE_INSTRUMENT, @@ -142,13 +142,13 @@ struct S2WPluginFactory static const clap_plugin_descriptor_t desc = { .clap_version = CLAP_VERSION_INIT, .id = id.c_str(), - .name = S2WPluginInfo::pluginName.c_str(), - .vendor = S2WPluginInfo::author.c_str(), - .url = S2WPluginInfo::url.c_str(), - .manual_url = S2WPluginInfo::url.c_str(), - .support_url = S2WPluginInfo::url.c_str(), - .version = S2WPluginInfo::version.c_str(), - .description = S2WPluginInfo::about.c_str(), + .name = ClefPluginInfo::pluginName.c_str(), + .vendor = ClefPluginInfo::author.c_str(), + .url = ClefPluginInfo::url.c_str(), + .manual_url = ClefPluginInfo::url.c_str(), + .support_url = ClefPluginInfo::url.c_str(), + .version = ClefPluginInfo::version.c_str(), + .description = ClefPluginInfo::about.c_str(), .features = features, }; @@ -164,20 +164,20 @@ struct S2WPluginFactory if (!clap_version_is_compatible(host->clap_version) || std::strcmp(pluginID, descriptor()->id)) { return nullptr; } - auto* plugin = new typename S2WPluginInfo::ClapPlugin(host); + auto* plugin = new typename ClefPluginInfo::ClapPlugin(host); plugin->plugin.desc = descriptor(); return &plugin->plugin; }, }; }; -#define SEQ2WAV_PLUGIN(S2WPluginInfo) \ +#define CLEF_PLUGIN(ClefPluginInfo) \ extern "C" const clap_plugin_entry_t clap_entry = { \ .clap_version = CLAP_VERSION_INIT, \ .init = [](const char *path) -> bool { return true; }, \ .deinit = []() {}, \ .get_factory = [] (const char *factoryID) -> const void* { \ - return strcmp(factoryID, CLAP_PLUGIN_FACTORY_ID) ? nullptr : &S2WPluginFactory::pluginFactory; \ + return strcmp(factoryID, CLAP_PLUGIN_FACTORY_ID) ? nullptr : &ClefPluginFactory::pluginFactory; \ }, \ }; @@ -185,17 +185,17 @@ struct S2WPluginFactory using clap_host_t = void; -class S2WClapPluginBase +class ClefClapPluginBase { public: - S2WClapPluginBase(const void*) {} + ClefClapPluginBase(const void*) {} }; -template -class S2WClapPlugin : public S2WClapPluginBase +template +class ClefClapPlugin : public ClefClapPluginBase { public: - S2WClapPlugin(const void*) {} + ClefClapPlugin(const void*) {} }; #endif diff --git a/src/plugin/foobarplugin.h b/src/plugin/foobarplugin.h index e4d479e..1692f18 100644 --- a/src/plugin/foobarplugin.h +++ b/src/plugin/foobarplugin.h @@ -1,8 +1,8 @@ -#ifndef S2W_FOOBARPLUGIN_H -#define S2W_FOOBARPLUGIN_H +#ifndef CLEF_FOOBARPLUGIN_H +#define CLEF_FOOBARPLUGIN_H #include "foobar2000/SDK/foobar2000.h" -#include "s2wconfig.h" +#include "clefconfig.h" #include "plugin/baseplugin.h" #include "codec/sampledata.h" #include "synth/synthcontext.h" @@ -118,22 +118,22 @@ class foofile_istream : public std::istream { static abort_callback_impl dummyAbort; -static std::unique_ptr s2wFoobarOpenFile(const std::string& filename) +static std::unique_ptr clefFoobarOpenFile(const std::string& filename) { auto stream = std::unique_ptr(new foofile_istream(filename, dummyAbort)); stream->seekg(0); return stream; } -template -class input_seq2wav : public input_stubs { - using PluginType = S2WPlugin; +template +class input_clef : public input_stubs { + using PluginType = ClefPlugin; public: static PluginType staticPlugin; - S2WContext s2w; + ClefContext clef; PluginType plugin; - input_seq2wav(): s2w(s2wFoobarOpenFile), plugin(&s2w) {} + input_clef(): clef(clefFoobarOpenFile), plugin(&clef) {} void open(service_ptr_t p_filehint, const char* p_path, t_input_open_reason p_reason, abort_callback& p_abort) { foofile_istream file(p_filehint, p_path, p_reason, p_abort); @@ -172,7 +172,7 @@ class input_seq2wav : public input_stubs { } void decode_initialize(unsigned p_flags, abort_callback& p_abort) { - s2w.purgeSamples(); + clef.purgeSamples(); p_abort.check(); foofile_istream stream(m_file, p_abort); bool ok = plugin.play(m_filename, stream); @@ -221,7 +221,7 @@ class input_seq2wav : public input_stubs { std::string m_filename; }; -bool s2wFoobarMeta(const S2WPluginBase& plugin) +bool clefFoobarMeta(const ClefPluginBase& plugin) { DECLARE_COMPONENT_VERSION_COPY(plugin.pluginName().c_str(), plugin.version().c_str(), plugin.about().c_str()); @@ -238,13 +238,13 @@ bool s2wFoobarMeta(const S2WPluginBase& plugin) return true; } -#define SEQ2WAV_PLUGIN(S2WPluginInfo) \ - using S2W = input_seq2wav; \ - template<> S2WPlugin S2W::staticPlugin = S2WPlugin(nullptr); \ - DECLARE_COMPONENT_VERSION_COPY(S2W::staticPlugin.pluginName().c_str(), S2W::staticPlugin.version().c_str(), S2W::staticPlugin.about().c_str()); \ - static bool metaOK = s2wFoobarMeta(S2W::staticPlugin); \ - static input_singletrack_factory_t> g_input_seq2wav_factory; \ - static std::string pluginFilename = "foo_input_" + S2WPluginInfo::pluginShortName + ".dll"; \ +#define CLEF_PLUGIN(ClefPluginInfo) \ + using Clef = input_clef; \ + template<> ClefPlugin Clef::staticPlugin = ClefPlugin(nullptr); \ + DECLARE_COMPONENT_VERSION_COPY(Clef::staticPlugin.pluginName().c_str(), Clef::staticPlugin.version().c_str(), Clef::staticPlugin.about().c_str()); \ + static bool metaOK = clefFoobarMeta(Clef::staticPlugin); \ + static input_singletrack_factory_t> g_input_clef_factory; \ + static std::string pluginFilename = "foo_input_" + ClefPluginInfo::pluginShortName + ".dll"; \ VALIDATE_COMPONENT_FILENAME(pluginFilename.c_str()); #endif diff --git a/src/plugin/realtimetrack.h b/src/plugin/realtimetrack.h index edb7fa8..f1bb1b3 100644 --- a/src/plugin/realtimetrack.h +++ b/src/plugin/realtimetrack.h @@ -1,5 +1,5 @@ -#ifndef S2W_REALTIMETRACK_H -#define S2W_REALTIMETRACK_H +#ifndef CLEF_REALTIMETRACK_H +#define CLEF_REALTIMETRACK_H #include "seq/itrack.h" #include diff --git a/src/plugin/winampplugin.h b/src/plugin/winampplugin.h index 3bd0df8..f898b9e 100644 --- a/src/plugin/winampplugin.h +++ b/src/plugin/winampplugin.h @@ -1,8 +1,8 @@ -#ifndef S2W_WINAMPPLUGIN_H -#define S2W_WINAMPPLUGIN_H +#ifndef Clef_WINAMPPLUGIN_H +#define Clef_WINAMPPLUGIN_H #define UNICODE_INPUT_PLUGIN -#include "s2wconfig.h" +#include "clefconfig.h" #include #include "in2.h" #include "wa_ipc.h" @@ -35,14 +35,14 @@ static ConstPairList fileInfoTags = { { "comment", "Comment" }, }; -template -class S2WModule : public In_Module { +template +class ClefModule : public In_Module { struct ExtExpand { std::vector exts; operator char*() { return exts.data(); } ExtExpand() { - for (const auto& iter : S2WPluginInfo::extensions) { + for (const auto& iter : ClefPluginInfo::extensions) { exts.insert(exts.end(), iter.first.begin(), iter.first.end()); exts.push_back('\0'); exts.insert(exts.end(), iter.second.begin(), iter.second.end()); @@ -52,12 +52,12 @@ class S2WModule : public In_Module { } }; - static S2WContext s2w; - static S2WPlugin plugin; + static ClefContext clef; + static ClefPlugin plugin; static ExtExpand extensions; public: - static S2WModule* instance() { - static S2WModule module; + static ClefModule* instance() { + static ClefModule module; return &module; } @@ -77,7 +77,7 @@ class S2WModule : public In_Module { title = filename = instance()->currentTrack; *outMS = instance()->length * 1000; } - auto file = s2w.openFile(filename); + auto file = clef.openFile(filename); TagMap tagMap(plugin.getTags(filename, *file)); if (!isCurrent) { std::string len = tagMap.count("length_seconds_fp") ? tagMap.at("length_seconds_fp") : std::string(); @@ -95,7 +95,7 @@ class S2WModule : public In_Module { } static int infoBox(const in_char *inFilename, HWND hwndParent) { std::string filename = toUtf8(inFilename); - auto file = s2w.openFile(filename); + auto file = clef.openFile(filename); TagMap tagMap(plugin.getTags(filename, *file)); std::ostringstream ss; ss << "Filename:" << std::endl << filename << std::endl << std::endl; @@ -116,7 +116,7 @@ class S2WModule : public In_Module { static int isOurFile(const in_char *fn) { std::string path = toUtf8(fn); - auto file = s2w.openFile(path); + auto file = clef.openFile(path); return plugin.isPlayable(path, *file); } static int play(const in_char* fn) { return instance()->play(toUtf8(fn)); } @@ -133,13 +133,13 @@ class S2WModule : public In_Module { thread.reset(nullptr); } try { - auto file = s2w.openFile(fn); + auto file = clef.openFile(fn); length = plugin.length(fn, *file); } catch (std::exception& e) { std::cerr << "Error reading length: " << e.what() << std::endl; return 1; } - auto file = s2w.openFile(fn); + auto file = clef.openFile(fn); bool ok = plugin.play(fn, *file); if (!ok) { plugin.unload(); @@ -247,11 +247,11 @@ class S2WModule : public In_Module { bool running; bool paused; - S2WModule(); + ClefModule(); }; -template -S2WModule::S2WModule() +template +ClefModule::ClefModule() : In_Module(In_Module{ IN_VER, const_cast(plugin.pluginShortName().c_str()), @@ -260,26 +260,26 @@ S2WModule::S2WModule() extensions, 1, // seekable 1, // uses output - &S2WModule::config, - &S2WModule::about, - &S2WModule::init, - &S2WModule::quit, - &S2WModule::getFileInfo, - &S2WModule::infoBox, - &S2WModule::isOurFile, - &S2WModule::play, - &S2WModule::pause, - &S2WModule::unpause, - &S2WModule::isPaused, - &S2WModule::stop, - &S2WModule::getLength, - &S2WModule::getOutputTime, - &S2WModule::setOutputTime, - &S2WModule::setVolume, - &S2WModule::setPan, + &ClefModule::config, + &ClefModule::about, + &ClefModule::init, + &ClefModule::quit, + &ClefModule::getFileInfo, + &ClefModule::infoBox, + &ClefModule::isOurFile, + &ClefModule::play, + &ClefModule::pause, + &ClefModule::unpause, + &ClefModule::isPaused, + &ClefModule::stop, + &ClefModule::getLength, + &ClefModule::getOutputTime, + &ClefModule::setOutputTime, + &ClefModule::setVolume, + &ClefModule::setPan, 0, 0, 0, 0, 0, 0, 0, 0, 0, // visualizer parameters 0, 0, // DSP parameters - &S2WModule::eqSet, + &ClefModule::eqSet, nullptr, // setInfo 0 // outMod }) @@ -292,10 +292,10 @@ S2WModule::S2WModule() length = 0; } -#define SEQ2WAV_PLUGIN(S2WPluginInfo) \ - template<> S2WContext S2WModule::s2w = S2WContext(); \ - template<> S2WPlugin S2WModule::plugin = S2WPlugin(&S2WModule::s2w); \ - template<> S2WModule::ExtExpand S2WModule::extensions = S2WModule::ExtExpand(); \ - extern "C" EXPORT In_Module* winampGetInModule2() { return S2WModule::instance(); } +#define CLEF_PLUGIN(ClefPluginInfo) \ + template<> ClefContext ClefModule::clef = ClefContext(); \ + template<> ClefPlugin ClefModule::plugin = ClefPlugin(&ClefModule::clef); \ + template<> ClefModule::ExtExpand ClefModule::extensions = ClefModule::ExtExpand(); \ + extern "C" EXPORT In_Module* winampGetInModule2() { return ClefModule::instance(); } #endif diff --git a/src/riffwriter.h b/src/riffwriter.h index cf5dede..df2b711 100644 --- a/src/riffwriter.h +++ b/src/riffwriter.h @@ -1,5 +1,5 @@ -#ifndef S2W_RIFFWRITER_H -#define S2W_RIFFWRITER_H +#ifndef CLEF_RIFFWRITER_H +#define CLEF_RIFFWRITER_H #include #include diff --git a/src/seq/isequence.cpp b/src/seq/isequence.cpp index 591d606..54ac7e0 100644 --- a/src/seq/isequence.cpp +++ b/src/seq/isequence.cpp @@ -1,7 +1,7 @@ #include "isequence.h" #include "sequenceevent.h" -ISequence::ISequence(S2WContext* ctx) +ISequence::ISequence(ClefContext* ctx) : ctx(ctx) { // initializers only @@ -9,7 +9,7 @@ ISequence::ISequence(S2WContext* ctx) ISequence::~ISequence() {} -S2WContext* ISequence::context() const +ClefContext* ISequence::context() const { return ctx; } @@ -34,7 +34,7 @@ bool ISequence::isFinished() const return true; } -StreamSequence::StreamSequence(S2WContext* ctx, uint64_t sampleID, double startTime) +StreamSequence::StreamSequence(ClefContext* ctx, uint64_t sampleID, double startTime) : BaseSequence(ctx) { BasicTrack* track = new BasicTrack; diff --git a/src/seq/isequence.h b/src/seq/isequence.h index 3be3824..f0c2e98 100644 --- a/src/seq/isequence.h +++ b/src/seq/isequence.h @@ -1,15 +1,15 @@ -#ifndef S2W_ISEQUENCE_H -#define S2W_ISEQUENCE_H +#ifndef CLEF_ISEQUENCE_H +#define CLEF_ISEQUENCE_H #include #include #include #include "itrack.h" -class S2WContext; +class ClefContext; class ISequence { public: - ISequence(S2WContext* ctx); + ISequence(ClefContext* ctx); virtual ~ISequence(); @@ -27,16 +27,16 @@ class ISequence { virtual ITrack* getTrack(int index) = 0; protected: - S2WContext* context() const; + ClefContext* context() const; private: - S2WContext* ctx; + ClefContext* ctx; }; template class BaseSequence : public ISequence { public: - BaseSequence(S2WContext* ctx) : ISequence(ctx) {} + BaseSequence(ClefContext* ctx) : ISequence(ctx) {} virtual int numTracks() const { return tracks.size(); @@ -60,7 +60,7 @@ class BaseSequence : public ISequence { class StreamSequence : public BaseSequence<> { public: - StreamSequence(S2WContext* ctx, uint64_t sampleID, double startTime = 0); + StreamSequence(ClefContext* ctx, uint64_t sampleID, double startTime = 0); }; #endif diff --git a/src/seq/itrack.h b/src/seq/itrack.h index 4c14996..ac3a879 100644 --- a/src/seq/itrack.h +++ b/src/seq/itrack.h @@ -1,5 +1,5 @@ -#ifndef S2W_ITRACK_H -#define S2W_ITRACK_H +#ifndef CLEF_ITRACK_H +#define CLEF_ITRACK_H #include "sequenceevent.h" #include diff --git a/src/seq/sequenceevent.h b/src/seq/sequenceevent.h index f36e800..d072068 100644 --- a/src/seq/sequenceevent.h +++ b/src/seq/sequenceevent.h @@ -1,5 +1,5 @@ -#ifndef S2W_SEQUENCEEVENT_H -#define S2W_SEQUENCEEVENT_H +#ifndef CLEF_SEQUENCEEVENT_H +#define CLEF_SEQUENCEEVENT_H #include #include diff --git a/src/seq/testsequence.cpp b/src/seq/testsequence.cpp index d802fc5..4a1922a 100644 --- a/src/seq/testsequence.cpp +++ b/src/seq/testsequence.cpp @@ -6,7 +6,7 @@ static const double testNotes[] = { 440, 554.36, 659.26, 880, 1108.73 }; -TestSequence::TestSequence(S2WContext* ctx) : BaseSequence(ctx) +TestSequence::TestSequence(ClefContext* ctx) : BaseSequence(ctx) { RiffCodec riff(ctx); SampleData* sample = riff.decodeFile("cembalo-1.wav"); diff --git a/src/seq/testsequence.h b/src/seq/testsequence.h index 6d0e6a4..73ad1eb 100644 --- a/src/seq/testsequence.h +++ b/src/seq/testsequence.h @@ -1,12 +1,12 @@ -#ifndef S2W_TESTSEQUENCE_H -#define S2W_TESTSEQUENCE_H +#ifndef CLEF_TESTSEQUENCE_H +#define CLEF_TESTSEQUENCE_H #include "isequence.h" #include class TestSequence : public BaseSequence<> { public: - TestSequence(S2WContext* ctx); + TestSequence(ClefContext* ctx); }; #endif diff --git a/src/synth/audionode.h b/src/synth/audionode.h index 0aa208a..96b184a 100644 --- a/src/synth/audionode.h +++ b/src/synth/audionode.h @@ -1,7 +1,7 @@ -#ifndef S2W_AUDIONODE_H -#define S2W_AUDIONODE_H +#ifndef CLEF_AUDIONODE_H +#define CLEF_AUDIONODE_H -#include "s2wconfig.h" +#include "clefconfig.h" #include "audioparam.h" class SynthContext; class IModulator; diff --git a/src/synth/audioparam.h b/src/synth/audioparam.h index a38fe2a..1208be6 100644 --- a/src/synth/audioparam.h +++ b/src/synth/audioparam.h @@ -1,7 +1,7 @@ -#ifndef S2W_AUDIOPARAM_H -#define S2W_AUDIOPARAM_H +#ifndef CLEF_AUDIOPARAM_H +#define CLEF_AUDIOPARAM_H -#include "s2wconfig.h" +#include "clefconfig.h" #include #include class AudioNode; diff --git a/src/synth/automationnode.h b/src/synth/automationnode.h index 4b859cc..3164c18 100644 --- a/src/synth/automationnode.h +++ b/src/synth/automationnode.h @@ -1,5 +1,5 @@ -#ifndef S2W_AUTOMATIONNODE_H -#define S2W_AUTOMATIONNODE_H +#ifndef CLEF_AUTOMATIONNODE_H +#define CLEF_AUTOMATIONNODE_H #include "audionode.h" #include diff --git a/src/synth/channel.cpp b/src/synth/channel.cpp index 3a4a321..396925c 100644 --- a/src/synth/channel.cpp +++ b/src/synth/channel.cpp @@ -1,6 +1,6 @@ #include "channel.h" #include "synthcontext.h" -#include "s2wcontext.h" +#include "clefcontext.h" #include "iinstrument.h" #include "seq/itrack.h" #include "seq/sequenceevent.h" diff --git a/src/synth/channel.h b/src/synth/channel.h index 130b843..8041581 100644 --- a/src/synth/channel.h +++ b/src/synth/channel.h @@ -1,7 +1,7 @@ -#ifndef S2W_CHANNEL_H -#define S2W_CHANNEL_H +#ifndef CLEF_CHANNEL_H +#define CLEF_CHANNEL_H -#include "s2wconfig.h" +#include "clefconfig.h" #include #include #include diff --git a/src/synth/envelope.h b/src/synth/envelope.h index 8682407..f82a95e 100644 --- a/src/synth/envelope.h +++ b/src/synth/envelope.h @@ -1,5 +1,5 @@ -#ifndef S2W_ENVELOPE_H -#define S2W_ENVELOPE_H +#ifndef CLEF_ENVELOPE_H +#define CLEF_ENVELOPE_H #include "audionode.h" #include "audioparam.h" diff --git a/src/synth/iinstrument.cpp b/src/synth/iinstrument.cpp index 4d12617..4b7ddbc 100644 --- a/src/synth/iinstrument.cpp +++ b/src/synth/iinstrument.cpp @@ -3,7 +3,7 @@ #include "sampler.h" #include "oscillator.h" #include "synthcontext.h" -#include "s2wcontext.h" +#include "clefcontext.h" #include "seq/sequenceevent.h" #include @@ -68,7 +68,7 @@ Channel::Note* DefaultInstrument::noteEvent(Channel* channel, std::shared_ptrduration; node.reset(osc); } else if (SampleEvent* sampEvent = event->cast()) { - SampleData* sampleData = channel->ctx->s2wContext()->getSample(sampEvent->sampleID); + SampleData* sampleData = channel->ctx->clefContext()->getSample(sampEvent->sampleID); if (!sampleData) { std::cerr << "ERROR: sample " << std::hex << sampEvent->sampleID << std::dec << " not found" << std::endl; return nullptr; diff --git a/src/synth/iinstrument.h b/src/synth/iinstrument.h index d91b59d..71c5ebe 100644 --- a/src/synth/iinstrument.h +++ b/src/synth/iinstrument.h @@ -1,5 +1,5 @@ -#ifndef S2W_IINSTRUMENT_H -#define S2W_IINSTRUMENT_H +#ifndef CLEF_IINSTRUMENT_H +#define CLEF_IINSTRUMENT_H #include #include "channel.h" diff --git a/src/synth/iinterpolator.h b/src/synth/iinterpolator.h index a07b654..68aadd3 100644 --- a/src/synth/iinterpolator.h +++ b/src/synth/iinterpolator.h @@ -1,7 +1,7 @@ -#ifndef S2W_IINTERPOLATOR_H -#define S2W_IINTERPOLATOR_H +#ifndef CLEF_IINTERPOLATOR_H +#define CLEF_IINTERPOLATOR_H -#include "s2wconfig.h" +#include "clefconfig.h" #include #include struct SampleData; diff --git a/src/synth/imodulator.h b/src/synth/imodulator.h index f00fe86..67b85ca 100644 --- a/src/synth/imodulator.h +++ b/src/synth/imodulator.h @@ -1,5 +1,5 @@ -#ifndef S2W_IMODULATOR_H -#define S2W_IMODULATOR_H +#ifndef CLEF_IMODULATOR_H +#define CLEF_IMODULATOR_H #include "audionode.h" #include "iinterpolator.h" diff --git a/src/synth/oscillator.h b/src/synth/oscillator.h index 88a0142..5fee596 100644 --- a/src/synth/oscillator.h +++ b/src/synth/oscillator.h @@ -1,5 +1,5 @@ -#ifndef S2W_OSCILLATOR_H -#define S2W_OSCILLATOR_H +#ifndef CLEF_OSCILLATOR_H +#define CLEF_OSCILLATOR_H #include "audionode.h" diff --git a/src/synth/sampler.h b/src/synth/sampler.h index 31acc21..13d3396 100644 --- a/src/synth/sampler.h +++ b/src/synth/sampler.h @@ -1,5 +1,5 @@ -#ifndef S2W_SAMPLER_H -#define S2W_SAMPLER_H +#ifndef CLEF_SAMPLER_H +#define CLEF_SAMPLER_H #include "audionode.h" #include "codec/sampledata.h" diff --git a/src/synth/synthcontext.cpp b/src/synth/synthcontext.cpp index d034b49..3e5d669 100644 --- a/src/synth/synthcontext.cpp +++ b/src/synth/synthcontext.cpp @@ -8,7 +8,7 @@ static const int BUFFER_SIZE = 10240; -SynthContext::SynthContext(S2WContext* ctx, double sampleRate, int outputChannels) +SynthContext::SynthContext(ClefContext* ctx, double sampleRate, int outputChannels) : sampleRate(sampleRate), sampleTime(1.0 / sampleRate), outputChannels(outputChannels), interpolator(IInterpolator::get(IInterpolator::Zero)), mixBuffer(BUFFER_SIZE >> 1), currentTimestamp(0), maximumTimestamp(0), ctx(ctx) @@ -20,7 +20,7 @@ SynthContext::~SynthContext() { } -S2WContext* SynthContext::s2wContext() const +ClefContext* SynthContext::clefContext() const { return ctx; } diff --git a/src/synth/synthcontext.h b/src/synth/synthcontext.h index e5d3206..4cb7748 100644 --- a/src/synth/synthcontext.h +++ b/src/synth/synthcontext.h @@ -1,5 +1,5 @@ -#ifndef S2W_SYNTHCONTEXT_H -#define S2W_SYNTHCONTEXT_H +#ifndef CLEF_SYNTHCONTEXT_H +#define CLEF_SYNTHCONTEXT_H #include #include @@ -11,14 +11,14 @@ class IInterpolator; class ITrack; class RiffWriter; class IInstrument; -class S2WContext; +class ClefContext; class SynthContext { public: - SynthContext(S2WContext* ctx, double sampleRate, int outputChannels = 2); + SynthContext(ClefContext* ctx, double sampleRate, int outputChannels = 2); ~SynthContext(); - S2WContext* s2wContext() const; + ClefContext* clefContext() const; const double sampleRate; const double sampleTime; @@ -55,7 +55,7 @@ class SynthContext { private: std::vector mixBuffer; double currentTimestamp, maximumTimestamp; - S2WContext* ctx; + ClefContext* ctx; }; #endif diff --git a/src/tagmap.h b/src/tagmap.h index 3269d0f..a53212c 100644 --- a/src/tagmap.h +++ b/src/tagmap.h @@ -1,7 +1,7 @@ -#ifndef S2W_TAGSM3U_H -#define S2W_TAGSM3U_H +#ifndef CLEF_TAGSM3U_H +#define CLEF_TAGSM3U_H -#include "s2wconfig.h" +#include "clefconfig.h" #include #include #include diff --git a/src/utility.h b/src/utility.h index 458e975..f3dea4e 100644 --- a/src/utility.h +++ b/src/utility.h @@ -1,7 +1,7 @@ -#ifndef S2W_UTILITY_H -#define S2W_UTILITY_H +#ifndef CLEF_UTILITY_H +#define CLEF_UTILITY_H -#include "s2wconfig.h" +#include "clefconfig.h" #include #include #include diff --git a/template/.gitignore b/template/.gitignore index 15d895f..85a40ed 100644 --- a/template/.gitignore +++ b/template/.gitignore @@ -38,4 +38,4 @@ plugins/pfc plugins/libPPUI # de-ignore submodule -!/seq2wav +!/libclef diff --git a/template/.gitmodules b/template/.gitmodules index 0965814..219cd62 100644 --- a/template/.gitmodules +++ b/template/.gitmodules @@ -1,3 +1,3 @@ -[submodule "seq2wav"] - path = seq2wav - url = https://bitbucket.org/ahigerd/seq2wav +[submodule "libclef"] + path = libclef + url = https://github.com/ahigerd/libclef diff --git a/template/LICENSE.md b/template/LICENSE.md index b1fa3a1..eafa4eb 100644 --- a/template/LICENSE.md +++ b/template/LICENSE.md @@ -1,8 +1,8 @@ This sample project has not been properly customized yet. -This project is based upon seq2wav, distributed under the following terms: +This project is based upon libclef, distributed under the following terms: -seq2wav is copyright (c) 2020 Adam Higerd +libclef is copyright (c) 2020-2024 Adam Higerd Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/template/Makefile b/template/Makefile index 3f785f0..b5a4bb4 100644 --- a/template/Makefile +++ b/template/Makefile @@ -22,65 +22,65 @@ foobar: foo_input_$(PLUGIN_NAME).dll clap: $(PLUGIN_NAME).clap -seq2wav/src: +libclef/src: git submodule update --init --recursive ifeq ($(CROSS),msvc) -depends.mak: seq2wav/src $(wildcard src/*.h src/*.cpp src/*/*.h src/*/*.cpp plugins/*.cpp seq2wav/src/*.cpp seq2wav/src/*/*.h seq2wav/src/*/*.cpp seq2wav/src/*/*.h) +depends.mak: libclef/src $(wildcard src/*.h src/*.cpp src/*/*.h src/*/*.cpp plugins/*.cpp libclef/src/*.cpp libclef/src/*/*.h libclef/src/*/*.cpp libclef/src/*/*.h) $(WINE) cmd /c buildvs.cmd depends foo_input_$(PLUGIN_NAME).$(DLL) in_$(PLUGIN_NAME).$(DLL) aud_$(PLUGIN_NAME).$(DLL) clean: FORCE depends.mak MAKEFLAGS= $(WINE) nmake /f msvc32.mak $@ else -seq2wav/$(BUILDPATH)/libseq2wav.a seq2wav/$(BUILDPATH)/libseq2wav_d.a: seq2wav/src $(wildcard seq2wav/src/*.cpp seq2wav/*/*.h seq2wav/src/*/*.cpp seq2wav/*/*/*.h) - $(MAKE) -C seq2wav $(BUILDPATH)/$(notdir $@) +libclef/$(BUILDPATH)/libclef.a libclef/$(BUILDPATH)/libclef_d.a: libclef/src $(wildcard libclef/src/*.cpp libclef/*/*.h libclef/src/*/*.cpp libclef/*/*/*.h) + +$(MAKE) -C libclef $(BUILDPATH)/$(notdir $@) $(BUILDPATH)/Makefile.d: $(wildcard src/*.cpp src/*/*.cpp src/*.h src/*/*.h) Makefile src/Makefile config.mak - $(MAKE) -C src ../$@ + +$(MAKE) -C src ../$@ -$(PLUGIN_NAME)$(EXE): src/Makefile $(BUILDPATH)/Makefile.d config.mak seq2wav/$(BUILDPATH)/libseq2wav.a - $(MAKE) -C src ../$@ +$(PLUGIN_NAME)$(EXE): src/Makefile $(BUILDPATH)/Makefile.d config.mak libclef/$(BUILDPATH)/libclef.a + +$(MAKE) -C src ../$@ -$(PLUGIN_NAME)_d$(EXE): src/Makefile $(BUILDPATH)/Makefile.d config.mak seq2wav/$(BUILDPATH)/libseq2wav_d.a - $(MAKE) -C src ../$@ +$(PLUGIN_NAME)_d$(EXE): src/Makefile $(BUILDPATH)/Makefile.d config.mak libclef/$(BUILDPATH)/libclef_d.a + +$(MAKE) -C src ../$@ -$(BUILDPATH)/lib$(PLUGIN_NAME).a: src/Makefile $(BUILDPATH)/Makefile.d config.mak seq2wav/$(BUILDPATH)/libseq2wav.a - $(MAKE) -C src ../$@ +$(BUILDPATH)/lib$(PLUGIN_NAME).a: src/Makefile $(BUILDPATH)/Makefile.d config.mak libclef/$(BUILDPATH)/libclef.a + +$(MAKE) -C src ../$@ -$(BUILDPATH)/lib$(PLUGIN_NAME)_d.a: src/Makefile $(BUILDPATH)/Makefile.d config.mak seq2wav/$(BUILDPATH)/libseq2wav_d.a - $(MAKE) -C src ../$@ +$(BUILDPATH)/lib$(PLUGIN_NAME)_d.a: src/Makefile $(BUILDPATH)/Makefile.d config.mak libclef/$(BUILDPATH)/libclef_d.a + +$(MAKE) -C src ../$@ -gui/Makefile: gui/gui.pro seq2wav/gui/gui.pri Makefile config.mak - cd gui && $(QMAKE) BUILDPATH=../$(BUILDPATH) PLUGIN_NAME=$(PLUGIN_NAME) S2W_LDFLAGS="$(LDFLAGS_R)" +gui/Makefile: gui/gui.pro libclef/gui/gui.pri Makefile config.mak + cd gui && $(QMAKE) BUILDPATH=../$(BUILDPATH) PLUGIN_NAME=$(PLUGIN_NAME) CLEF_LDFLAGS="$(LDFLAGS_R)" -gui/Makefile.debug: gui/gui.pro seq2wav/gui/gui.pri Makefile config.mak - cd gui && $(QMAKE) -o Makefile.debug BUILD_DEBUG=1 BUILDPATH=../$(BUILDPATH) PLUGIN_NAME=$(PLUGIN_NAME) S2W_LDFLAGS="$(LDFLAGS_D)" +gui/Makefile.debug: gui/gui.pro libclef/gui/gui.pri Makefile config.mak + cd gui && $(QMAKE) -o Makefile.debug BUILD_DEBUG=1 BUILDPATH=../$(BUILDPATH) PLUGIN_NAME=$(PLUGIN_NAME) CLEF_LDFLAGS="$(LDFLAGS_D)" -$(PLUGIN_NAME)_gui$(EXE): src/Makefile $(BUILDPATH)/Makefile.d config.mak seq2wav/$(BUILDPATH)/libseq2wav.a gui/Makefile $(BUILDPATH)/lib$(PLUGIN_NAME).a - $(MAKE) -C gui +$(PLUGIN_NAME)_gui$(EXE): src/Makefile $(BUILDPATH)/Makefile.d config.mak libclef/$(BUILDPATH)/libclef.a gui/Makefile $(BUILDPATH)/lib$(PLUGIN_NAME).a + +$(MAKE) -C gui -$(PLUGIN_NAME)_gui_d$(EXE): src/Makefile $(BUILDPATH)/Makefile.d config.mak seq2wav/$(BUILDPATH)/libseq2wav_d.a gui/Makefile.debug $(BUILDPATH)/lib$(PLUGIN_NAME)_d.a - $(MAKE) -C gui -f Makefile.debug +$(PLUGIN_NAME)_gui_d$(EXE): src/Makefile $(BUILDPATH)/Makefile.d config.mak libclef/$(BUILDPATH)/libclef_d.a gui/Makefile.debug $(BUILDPATH)/lib$(PLUGIN_NAME)_d.a + +$(MAKE) -C gui -f Makefile.debug -aud_$(PLUGIN_NAME).$(DLL): $(PLUGIN_NAME)$(EXE) seq2wav/$(BUILDPATH)/libseq2wav.a plugins/Makefile config.mak plugins/s2wplugin.cpp - $(MAKE) -C plugins ../$@ +aud_$(PLUGIN_NAME).$(DLL): $(PLUGIN_NAME)$(EXE) libclef/$(BUILDPATH)/libclef.a plugins/Makefile config.mak plugins/clefplugin.cpp + +$(MAKE) -C plugins ../$@ -aud_$(PLUGIN_NAME)_d.$(DLL): seq2wav/$(BUILDPATH)/libseq2wav_d.a $(PLUGIN_NAME)_d$(EXE) plugins/Makefile config.mak plugins/s2wplugin.cpp - $(MAKE) -C plugins ../$@ +aud_$(PLUGIN_NAME)_d.$(DLL): libclef/$(BUILDPATH)/libclef_d.a $(PLUGIN_NAME)_d$(EXE) plugins/Makefile config.mak plugins/clefplugin.cpp + +$(MAKE) -C plugins ../$@ ifeq ($(OS),Windows_NT) -in_$(PLUGIN_NAME).$(DLL): $(PLUGIN_NAME)$(EXE) seq2wav/$(BUILDPATH)/libseq2wav.a plugins/Makefile config.mak plugins/s2wplugin.cpp - $(MAKE) -C plugins ../$@ +in_$(PLUGIN_NAME).$(DLL): $(PLUGIN_NAME)$(EXE) libclef/$(BUILDPATH)/libclef.a plugins/Makefile config.mak plugins/clefplugin.cpp + +$(MAKE) -C plugins ../$@ -in_$(PLUGIN_NAME)_d.$(DLL): $(PLUGIN_NAME)_d$(EXE) seq2wav/$(BUILDPATH)/libseq2wav_d.a plugins/Makefile config.mak plugins/s2wplugin.cpp - $(MAKE) -C plugins ../$@ +in_$(PLUGIN_NAME)_d.$(DLL): $(PLUGIN_NAME)_d$(EXE) libclef/$(BUILDPATH)/libclef_d.a plugins/Makefile config.mak plugins/clefplugin.cpp + +$(MAKE) -C plugins ../$@ else in_$(PLUGIN_NAME).dll in_$(PLUGIN_NAME)_d.dll: FORCE - $(MAKE) CROSS=mingw $@ + +$(MAKE) CROSS=mingw $@ endif -$(PLUGIN_NAME).clap: $(PLUGIN_NAME)$(EXE) seq2wav/$(BUILDPATH)/libseq2wav.a plugins/Makefile config.mak plugins/s2wplugin.cpp - $(MAKE) -C plugins ../$@ +$(PLUGIN_NAME).clap: $(PLUGIN_NAME)$(EXE) libclef/$(BUILDPATH)/libclef.a plugins/Makefile config.mak plugins/clefplugin.cpp + +$(MAKE) -C plugins ../$@ guiclean: FORCE -[ -f gui/Makefile ] && $(MAKE) -C gui distclean @@ -89,7 +89,7 @@ guiclean: FORCE clean: guiclean FORCE -rm -f $(BUILDPATH)/*.o $(BUILDPATH)/*/*.o $(BUILDPATH)/Makefile.d -rm -f $(PLUGIN_NAME)$(EXE) $(PLUGIN_NAME)_d$(EXE) $(PLUGIN_NAME)_gui$(EXE) $(PLUGIN_NAME)_gui_d$(EXE) *.$(DLL) - -$(MAKE) -C seq2wav clean + -$(MAKE) -C libclef clean endif FORCE: diff --git a/template/README.md b/template/README.md index 3905f46..a802316 100644 --- a/template/README.md +++ b/template/README.md @@ -1,7 +1,7 @@ Template ======== -This is a template for creating a project based on seq2wav. It cannot be built as-is. +This is a template for creating a project based on libclef. It cannot be built as-is. Be sure to modify `config.mak` to set `PLUGIN_NAME` appropriately, and change the filenames in `buildvs.cmd` to refer to the same name instead of `template`. @@ -50,7 +50,7 @@ License ------- You should fill in the copyright and licensing information for your project here. -This project is based upon seq2wav, copyright (c) 2020-2023 Adam Higerd and distributed +This project is based upon libclef, copyright (c) 2020-2024 Adam Higerd and distributed under the terms of the [MIT license](LICENSE.md). [CLAP](https://cleveraudio.org/) is an open-source audio plugin format. The diff --git a/template/config.mak b/template/config.mak index 13d8b59..5d59b1c 100644 --- a/template/config.mak +++ b/template/config.mak @@ -1,2 +1,2 @@ PLUGIN_NAME = sample --include $(ROOTPATH)seq2wav/config.mak +-include $(ROOTPATH)libclef/config.mak diff --git a/template/gui/gui.pro b/template/gui/gui.pro index 969a5f7..f149f19 100644 --- a/template/gui/gui.pro +++ b/template/gui/gui.pro @@ -2,6 +2,6 @@ isEmpty(BUILDPATH) { error("BUILDPATH must be set") } BUILDPATH = $$absolute_path($$BUILDPATH) -include($$BUILDPATH/../seq2wav/gui/gui.pri) +include($$BUILDPATH/../libclef/gui/gui.pri) -SOURCES += main.cpp ../plugins/s2wplugin.cpp +SOURCES += main.cpp ../plugins/clefplugin.cpp diff --git a/template/gui/main.cpp b/template/gui/main.cpp index b53d345..738f2d5 100644 --- a/template/gui/main.cpp +++ b/template/gui/main.cpp @@ -1,19 +1,19 @@ #include #include "mainwindow.h" -#include "s2wcontext.h" +#include "clefcontext.h" #include "synth/synthcontext.h" #include "plugin/baseplugin.h" #include int main(int argc, char** argv) { - S2WContext ctx; - S2WPluginBase* plugin = S2W::makePlugin(&ctx); + ClefContext ctx; + ClefPluginBase* plugin = Clef::makePlugin(&ctx); QCoreApplication::setApplicationName(QString::fromStdString(plugin->pluginName())); QCoreApplication::setApplicationVersion(QString::fromStdString(plugin->version())); - QCoreApplication::setOrganizationName("seq2wav"); - QCoreApplication::setOrganizationDomain("seq2wav" + QString::fromStdString(plugin->pluginShortName())); + QCoreApplication::setOrganizationName("clef"); + QCoreApplication::setOrganizationDomain("clef." + QString::fromStdString(plugin->pluginShortName())); QApplication app(argc, argv); MainWindow mw(plugin); diff --git a/template/msvc32.mak b/template/msvc32.mak index c845cbb..4e203d3 100644 --- a/template/msvc32.mak +++ b/template/msvc32.mak @@ -12,22 +12,22 @@ winamp: "in_$(PLUGIN_NAME).dll" foobar: "foo_input_$(PLUGIN_NAME).dll" -seq2wav\src: +libclef\src: git submodules update --init --recursive !include depends.mak .cpp.obj: - $(CPP) /std:c++latest /DUNICODE /D_UNICODE /DNDEBUG /O2 /EHsc /I src /I seq2wav\src /I plugins\foobar2000 /I plugins /c /Fo$@ $< + $(CPP) /std:c++latest /DUNICODE /D_UNICODE /DNDEBUG /O2 /EHsc /I src /I libclef\src /I plugins\foobar2000 /I plugins /c /Fo$@ $< -plugins\foobarplugin.obj: plugins\s2wplugin.cpp seq2wav\src\plugin\foobarplugin.h FORCE - $(CPP) /std:c++latest /DUNICODE /D_UNICODE /DNDEBUG /DBUILD_FOOBAR /O2 /EHsc /I src /I seq2wav\src /I plugins\foobar2000 /I plugins /c /Fo$@ plugins\s2wplugin.cpp +plugins\foobarplugin.obj: plugins\clefplugin.cpp libclef\src\plugin\foobarplugin.h FORCE + $(CPP) /std:c++latest /DUNICODE /D_UNICODE /DNDEBUG /DBUILD_FOOBAR /O2 /EHsc /I src /I libclef\src /I plugins\foobar2000 /I plugins /c /Fo$@ plugins\clefplugin.cpp -plugins\audaciousplugin.obj: plugins\s2wplugin.cpp seq2wav\src\plugin\audaciousplugin.h FORCE - $(CPP) /std:c++latest /DUNICODE /D_UNICODE /DNDEBUG /DBUILD_AUDACIOUS /O2 /EHsc /I src /I seq2wav\src /c /Fo$@ plugins\s2wplugin.cpp +plugins\audaciousplugin.obj: plugins\clefplugin.cpp libclef\src\plugin\audaciousplugin.h FORCE + $(CPP) /std:c++latest /DUNICODE /D_UNICODE /DNDEBUG /DBUILD_AUDACIOUS /O2 /EHsc /I src /I libclef\src /c /Fo$@ plugins\clefplugin.cpp -plugins\winampplugin.obj: plugins\s2wplugin.cpp seq2wav\src\plugin\winampplugin.h FORCE - $(CPP) /std:c++latest /DUNICODE /D_UNICODE /DNDEBUG /DBUILD_WINAMP /O2 /EHsc /I src /I seq2wav\src /c /Fo$@ plugins\s2wplugin.cpp +plugins\winampplugin.obj: plugins\clefplugin.cpp libclef\src\plugin\winampplugin.h FORCE + $(CPP) /std:c++latest /DUNICODE /D_UNICODE /DNDEBUG /DBUILD_WINAMP /O2 /EHsc /I src /I libclef\src /c /Fo$@ plugins\clefplugin.cpp "$(PLUGIN_NAME).exe": src\main.obj link.exe /subsystem:console /out:$@ $** diff --git a/template/plugins/Makefile b/template/plugins/Makefile index 20768cf..09892c9 100644 --- a/template/plugins/Makefile +++ b/template/plugins/Makefile @@ -4,21 +4,21 @@ include ../config.mak OBJS_R = $(filter-out ../$(BUILDPATH)/gui/% ../$(BUILDPATH)/gui_d/% %_d.o ../$(BUILDPATH)/main.o,$(wildcard ../$(BUILDPATH)/*.o ../$(BUILDPATH)/*/*.o)) OBJS_D = $(filter-out ../$(BUILDPATH)/gui/% ../$(BUILDPATH)/gui_d/% ../$(BUILDPATH)/main_d.o,$(wildcard ../$(BUILDPATH)/*_d.o ../$(BUILDPATH)/*/*_d.o)) -../aud_$(PLUGIN_NAME).$(DLL): $(OBJS_R) ../seq2wav/$(BUILDPATH)/libseq2wav.a $(wildcard ../seq2wav/src/plugins/*.h) s2wplugin.cpp Makefile - $(CXX) -shared -o $@ $(CXXFLAGS_R) -DBUILD_AUDACIOUS s2wplugin.cpp $(shell pkg-config --cflags --libs audacious) $(OBJS_R) $(LDFLAGS_R) +../aud_$(PLUGIN_NAME).$(DLL): $(OBJS_R) ../libclef/$(BUILDPATH)/libclef.a $(wildcard ../libclef/src/plugins/*.h) clefplugin.cpp Makefile + $(CXX) -shared -o $@ $(CXXFLAGS_R) -DBUILD_AUDACIOUS clefplugin.cpp $(shell pkg-config --cflags --libs audacious) $(OBJS_R) $(LDFLAGS_R) strip $@ -../aud_$(PLUGIN_NAME)_d.$(DLL): $(OBJS_D) ../seq2wav/$(BUILDPATH)/libseq2wav_d.$(DLL) $(wildcard ../seq2wav/src/plugins/*.h) s2wplugin.cpp Makefile - $(CXX) -shared -o $@ $(CXXFLAGS_D) -DBUILD_AUDACIOUS s2wplugin.cpp $(shell pkg-config --cflags --libs audacious) $(OBJS_D) $(LDFLAGS_D) +../aud_$(PLUGIN_NAME)_d.$(DLL): $(OBJS_D) ../libclef/$(BUILDPATH)/libclef_d.$(DLL) $(wildcard ../libclef/src/plugins/*.h) clefplugin.cpp Makefile + $(CXX) -shared -o $@ $(CXXFLAGS_D) -DBUILD_AUDACIOUS clefplugin.cpp $(shell pkg-config --cflags --libs audacious) $(OBJS_D) $(LDFLAGS_D) -../in_$(PLUGIN_NAME).$(DLL): $(OBJS_R) ../seq2wav/$(BUILDPATH)/libseq2wav.a $(wildcard ../seq2wav/src/plugins/*.h) s2wplugin.cpp Makefile - $(CXX) -shared -o $@ $(CXXFLAGS_R) -DBUILD_WINAMP s2wplugin.cpp $(OBJS_R) $(LDFLAGS_R) +../in_$(PLUGIN_NAME).$(DLL): $(OBJS_R) ../libclef/$(BUILDPATH)/libclef.a $(wildcard ../libclef/src/plugins/*.h) clefplugin.cpp Makefile + $(CXX) -shared -o $@ $(CXXFLAGS_R) -DBUILD_WINAMP clefplugin.cpp $(OBJS_R) $(LDFLAGS_R) strip $@ -../in_$(PLUGIN_NAME)_d.$(DLL): $(OBJS_D) ../seq2wav/$(BUILDPATH)/libseq2wav_d.$(DLL) $(wildcard ../seq2wav/src/plugins/*.h) s2wplugin.cpp Makefile - $(CXX) -shared -o $@ $(CXXFLAGS_D) -DBUILD_WINAMP s2wplugin.cpp $(OBJS_D) $(LDFLAGS_D) +../in_$(PLUGIN_NAME)_d.$(DLL): $(OBJS_D) ../libclef/$(BUILDPATH)/libclef_d.$(DLL) $(wildcard ../libclef/src/plugins/*.h) clefplugin.cpp Makefile + $(CXX) -shared -o $@ $(CXXFLAGS_D) -DBUILD_WINAMP clefplugin.cpp $(OBJS_D) $(LDFLAGS_D) -../$(PLUGIN_NAME).clap: $(OBJS_R) ../seq2wav/$(BUILDPATH)/libseq2wav.a $(wildcard ../seq2wav/src/plugins/*.h) s2wplugin.cpp ../seq2wav/src/plugin/clapplugin.cpp Makefile - $(CXX) -shared -o $@ $(CXXFLAGS_R) -DBUILD_CLAP -Iclap/include s2wplugin.cpp ../seq2wav/src/plugin/clapplugin.cpp $(OBJS_R) $(LDFLAGS_R) +../$(PLUGIN_NAME).clap: $(OBJS_R) ../libclef/$(BUILDPATH)/libclef.a $(wildcard ../libclef/src/plugins/*.h) clefplugin.cpp ../libclef/src/plugin/clapplugin.cpp Makefile + $(CXX) -shared -o $@ $(CXXFLAGS_R) -DBUILD_CLAP -Iclap/include clefplugin.cpp ../libclef/src/plugin/clapplugin.cpp $(OBJS_R) $(LDFLAGS_R) FORCE: diff --git a/template/plugins/s2wplugin.cpp b/template/plugins/clefplugin.cpp similarity index 65% rename from template/plugins/s2wplugin.cpp rename to template/plugins/clefplugin.cpp index c257a41..1509ec6 100644 --- a/template/plugins/s2wplugin.cpp +++ b/template/plugins/clefplugin.cpp @@ -11,10 +11,10 @@ // this instead of standard library functions to open additional files in order to use // the host's virtual filesystem. -struct S2WPluginInfo { - S2WPLUGIN_STATIC_FIELDS +struct ClefPluginInfo { + CLEF_PLUGIN_STATIC_FIELDS #ifdef BUILD_CLAP - using ClapPlugin = S2WClapPlugin; + using ClapPlugin = ClefClapPlugin; #endif static bool isPlayable(std::istream& file) { @@ -23,25 +23,25 @@ struct S2WPluginInfo { return false; } - static int sampleRate(S2WContext* ctx, const std::string& filename, std::istream& file) { + static int sampleRate(ClefContext* ctx, const std::string& filename, std::istream& file) { // Implementations should return the sample rate of the file. // This can be hard-coded if the plugin always uses the same sample rate. return 48000; } - static double length(S2WContext* ctx, const std::string& filename, std::istream& file) { + static double length(ClefContext* ctx, const std::string& filename, std::istream& file) { // Implementations should return the length of the file in seconds. return 0; } - static TagMap readTags(S2WContext* ctx, const std::string& filename, std::istream& file) { + static TagMap readTags(ClefContext* ctx, const std::string& filename, std::istream& file) { // Implementations should read the tags from the file. // If the file format does not support embedded tags, consider // inheriting from TagsM3UMixin and removing this function. return TagMap(); } - SynthContext* prepare(S2WContext* ctx, const std::string& filename, std::istream& file) { + SynthContext* prepare(ClefContext* ctx, const std::string& filename, std::istream& file) { // Prepare to play the file. Load any necessary data into memory and store any // applicable state in members on this plugin object. @@ -56,12 +56,12 @@ struct S2WPluginInfo { } }; -const std::string S2WPluginInfo::version = "0.0.1"; -const std::string S2WPluginInfo::pluginName = "Template Plugin"; -const std::string S2WPluginInfo::pluginShortName = "template"; -ConstPairList S2WPluginInfo::extensions = { { "dummy", "Dummy files (*.dummy)" } }; -const std::string S2WPluginInfo::about = - "Template Plugin copyright (C) 2020-2022 Adam Higerd\n" +const std::string ClefPluginInfo::version = "0.0.1"; +const std::string ClefPluginInfo::pluginName = "Template Plugin"; +const std::string ClefPluginInfo::pluginShortName = "template"; +ConstPairList ClefPluginInfo::extensions = { { "dummy", "Dummy files (*.dummy)" } }; +const std::string ClefPluginInfo::about = + "Template Plugin copyright (C) 2020-2024 Adam Higerd\n" "Distributed under the MIT license."; -SEQ2WAV_PLUGIN(S2WPluginInfo); +CLEF_PLUGIN(ClefPluginInfo); diff --git a/template/src/Makefile b/template/src/Makefile index edaaf62..2467fd4 100644 --- a/template/src/Makefile +++ b/template/src/Makefile @@ -7,18 +7,18 @@ OBJS_D = $(patsubst %.cpp, ../$(BUILDPATH)/%_d.o, $(SOURCES)) MAIN_R = ../$(BUILDPATH)/main.o MAIN_D = ../$(BUILDPATH)/main_d.o -../$(PLUGIN_NAME)$(EXE): ../seq2wav/$(BUILDPATH)/libseq2wav.a $(OBJS_R) $(MAIN_R) +../$(PLUGIN_NAME)$(EXE): ../libclef/$(BUILDPATH)/libclef.a $(OBJS_R) $(MAIN_R) $(CXX) -o $@ $(MAIN_R) $(OBJS_R) $(LDFLAGS_R) strip $@ -../$(PLUGIN_NAME)_d$(EXE): ../seq2wav/$(BUILDPATH)/libseq2wav_d.a $(OBJS_D) $(MAIN_D) +../$(PLUGIN_NAME)_d$(EXE): ../libclef/$(BUILDPATH)/libclef_d.a $(OBJS_D) $(MAIN_D) $(CXX) -o $@ $(MAIN_D) $(OBJS_D) $(LDFLAGS_D) -../$(BUILDPATH)/lib$(PLUGIN_NAME).a: ../seq2wav/$(BUILDPATH)/libseq2wav.a $(filter-out ../$(BUILDPATH)/main.o,$(OBJS_R)) +../$(BUILDPATH)/lib$(PLUGIN_NAME).a: ../libclef/$(BUILDPATH)/libclef.a $(filter-out ../$(BUILDPATH)/main.o,$(OBJS_R)) rm -f $@ gcc-ar -rc $@ $(OBJS_R) -../$(BUILDPATH)/lib$(PLUGIN_NAME)_d.a: ../seq2wav/$(BUILDPATH)/libseq2wav_d.a $(filter-out ../$(BUILDPATH)/main_d.o,$(OBJS_R)) +../$(BUILDPATH)/lib$(PLUGIN_NAME)_d.a: ../libclef/$(BUILDPATH)/libclef_d.a $(filter-out ../$(BUILDPATH)/main_d.o,$(OBJS_R)) rm -f $@ gcc-ar -rc $@ $(OBJS_D) diff --git a/template/src/main.cpp b/template/src/main.cpp index 3c289c2..9b7959a 100644 --- a/template/src/main.cpp +++ b/template/src/main.cpp @@ -1,4 +1,4 @@ -#include "s2wcontext.h" +#include "clefcontext.h" #include "riffwriter.h" #include "synth/synthcontext.h" @@ -6,8 +6,8 @@ int main(int argc, char** argv) { // This sample main() function does nothing but // generate a valid but empty wave file. - S2WContext s2w; - SynthContext context(&s2w, 44100, 2); + ClefContext clef; + SynthContext context(&clef, 44100, 2); RiffWriter riff(context->sampleRate, true, sampleLength * 2); riff.open("output.wav"); context->save(&riff);