Skip to content

Commit fa581d5

Browse files
committed
Lv2Plugin into mainline
1 parent afbf292 commit fa581d5

File tree

5 files changed

+34
-28
lines changed

5 files changed

+34
-28
lines changed

src/download_test_plugin/RecordPlugin.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
// using namespace lv2c::lv2_plugin;
2828

2929

30-
static REGISTRATION_DECLARATION PluginRegistration<RecordPlugin> registration(RecordPlugin::URI);
30+
static REGISTRATION_DECLARATION PluginRegistration<ToobRecordMono> registration(ToobRecordMono::URI);
3131

3232
constexpr char PREFERRED_PATH_SEPARATOR = std::filesystem::path::preferred_separator;
3333

3434

3535

36-
RecordPlugin::RecordPlugin(
36+
ToobRecordMono::ToobRecordMono(
3737
double rate,
3838
const char *bundle_path,
3939
const LV2_Feature *const *features)
@@ -109,7 +109,7 @@ void generate_datetime_filename(char* buffer, size_t buffer_size, const char* pr
109109
}
110110
}
111111

112-
void RecordPlugin::MakeNewRecordingFilename()
112+
void ToobRecordMono::MakeNewRecordingFilename()
113113
{
114114
this->recordingFilePath = this->recordingDirectory;
115115

@@ -122,14 +122,14 @@ void RecordPlugin::MakeNewRecordingFilename()
122122

123123
}
124124

125-
void RecordPlugin::Activate()
125+
void ToobRecordMono::Activate()
126126
{
127127
this->activated = true;
128128
super::Activate();
129129
this->state = PluginState::Idle;
130130
}
131131

132-
void RecordPlugin::UpdateOutputControls(size_t samplesInFrame)
132+
void ToobRecordMono::UpdateOutputControls(size_t samplesInFrame)
133133
{
134134
if (state == PluginState::Recording)
135135
{
@@ -159,7 +159,7 @@ void RecordPlugin::UpdateOutputControls(size_t samplesInFrame)
159159
}
160160
}
161161

162-
void RecordPlugin::StopRecording()
162+
void ToobRecordMono::StopRecording()
163163
{
164164
if (this->state == PluginState::Recording)
165165
{
@@ -168,7 +168,7 @@ void RecordPlugin::StopRecording()
168168
SetFilePath(this->recordingFilePath.c_str());
169169
}
170170
}
171-
void RecordPlugin::Run(uint32_t n_samples)
171+
void ToobRecordMono::Run(uint32_t n_samples)
172172
{
173173
auto src = in.Get();
174174
auto dst = out.Get();
@@ -229,14 +229,14 @@ void RecordPlugin::Run(uint32_t n_samples)
229229
}
230230
}
231231

232-
void RecordPlugin::Deactivate()
232+
void ToobRecordMono::Deactivate()
233233
{
234234
this->activated = false;
235235
super::Deactivate();
236236
}
237237

238238

239-
bool RecordPlugin::OnPatchPathSet(LV2_URID propertyUrid,const char*value)
239+
bool ToobRecordMono::OnPatchPathSet(LV2_URID propertyUrid,const char*value)
240240
{
241241
if (propertyUrid == this->audioFile_urid)
242242
{
@@ -246,15 +246,15 @@ bool RecordPlugin::OnPatchPathSet(LV2_URID propertyUrid,const char*value)
246246
return false;
247247

248248
}
249-
const char* RecordPlugin::OnGetPatchPropertyValue(LV2_URID propertyUrid) {
249+
const char* ToobRecordMono::OnGetPatchPropertyValue(LV2_URID propertyUrid) {
250250
if (propertyUrid == this->audioFile_urid)
251251
{
252252
return this->filePath.c_str();
253253
}
254254
return nullptr;
255255
}
256256

257-
void RecordPlugin::SetFilePath(const char*filename)
257+
void ToobRecordMono::SetFilePath(const char*filename)
258258
{
259259
this->filePath = filename;
260260
if (activated)

src/download_test_plugin/RecordPlugin.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ using namespace lv2c::lv2_plugin;
3232
using namespace record_plugin;
3333

3434

35-
class RecordPlugin : public record_plugin::RecordPluginBase
35+
class ToobRecordMono : public record_plugin::RecordPluginBase
3636
{
3737
public:
3838
using super = record_plugin::RecordPluginBase;
@@ -41,9 +41,9 @@ class RecordPlugin : public record_plugin::RecordPluginBase
4141
const char *bundle_path,
4242
const LV2_Feature *const *features)
4343
{
44-
return new RecordPlugin(rate, bundle_path, features);
44+
return new ToobRecordMono(rate, bundle_path, features);
4545
}
46-
RecordPlugin(double rate,
46+
ToobRecordMono(double rate,
4747
const char *bundle_path,
4848
const LV2_Feature *const *features);
4949

src/generate_lv2c_plugin_info/ClassFileWriter.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,8 @@ void ClassFileWriter::WritePluginBase(const std::string&nameSpace,const std::str
536536
{
537537
return;
538538
}
539-
s << Tab() << "#include \"lv2_plugin/Lv2Plugin.hpp\"" << endl;
540-
s << Tab() << "#include \"lv2_plugin/Lv2Ports.hpp\"" << endl;
539+
s << Tab() << "#include <lv2_plugin/Lv2Plugin.hpp>" << endl;
540+
s << Tab() << "#include <lv2_plugin/Lv2Ports.hpp>" << endl;
541541

542542
s << Tab() << "using namespace lv2c::lv2_plugin;" << endl;
543543
s << endl;
@@ -734,7 +734,8 @@ void ClassFileWriter::WritePluginBase(const std::string&nameSpace,const std::str
734734
{
735735
outputAtomPortName = "nullptr";
736736
}
737-
s << Tab() << "SetAtomPortBuffers(" << inputAtomPortName << ", " << outputAtomPortName << ");" << endl;
737+
s << Tab() << "SetAtomPortBuffers((LV2_Atom_Sequence*)(" << inputAtomPortName <<
738+
"), (LV2_Atom_Sequence*)(" << outputAtomPortName << "));" << endl;
738739

739740

740741
for (const auto&initStatement: initStatements)

src/lv2_plugin/include/lv2_plugin/Lv2Plugin.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ namespace lv2c
9393
void LogNote(const char *fmt, ...);
9494
void LogTrace(const char *fmt, ...);
9595

96+
void LogError(const std::string&msg) { LogError("%s",msg.c_str()); };
97+
9698
public:
9799
virtual ~Lv2Plugin() {}
98100

src/lv2_plugin/include/lv2_plugin/Lv2Ports.hpp

+14-11
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@
2727
#include <cstdint>
2828
#include <cmath>
2929

30+
31+
3032
namespace lv2c::lv2_plugin
3133
{
3234
#ifndef AF2DB_H_
3335
#define AF2DB_H_
3436

35-
inline float Af2Db(float value) {
37+
inline float AF2Db(float value) {
3638
// af = pow(10,db/20) = exp(log(10)*db/20)
3739
// log(af) = log(10)*db/20
3840
// db = log(af)*20/log(10)
@@ -42,7 +44,7 @@ namespace lv2c::lv2_plugin
4244
return std::log(value)*K;
4345
}
4446

45-
inline float Db2Af(float db, float minValue)
47+
inline float Db2AF(float db, float minValue)
4648
{
4749
if (db == minValue) {
4850
return 0;
@@ -346,22 +348,22 @@ namespace lv2c::lv2_plugin
346348
public:
347349
void SetData(void*pData)
348350
{
349-
this->pData = (LV2_Atom_Sequence*)pData;
351+
this->pData = (void*)pData;
350352
}
351-
LV2_Atom_Sequence*Get() const { return pData; }
353+
void*Get() const { return pData; }
352354
private:
353-
LV2_Atom_Sequence *pData = nullptr;
355+
void *pData = nullptr;
354356
};
355357

356358
class AtomOutputPort {
357359
public:
358360
void SetData(void*pData)
359361
{
360-
this->pData = ( LV2_Atom_Sequence*)pData;
362+
this->pData = ( void*)pData;
361363
}
362-
LV2_Atom_Sequence*Get() const { return pData; }
364+
void*Get() const { return pData; }
363365
private:
364-
LV2_Atom_Sequence *pData = nullptr;
366+
void *pData = nullptr;
365367
};
366368

367369

@@ -517,7 +519,7 @@ namespace lv2c::lv2_plugin
517519
sampleCount -= updateRate;
518520
if (pOut)
519521
{
520-
float value = Af2Db(maxValue);
522+
float value = AF2Db(maxValue);
521523
if (value < minDb)
522524
{
523525
value = minDb;
@@ -546,7 +548,7 @@ namespace lv2c::lv2_plugin
546548
sampleCount -= updateRate;
547549
if (pOut)
548550
{
549-
float value = Af2Db(maxValue);
551+
float value = AF2Db(maxValue);
550552
if (value < minDb)
551553
value = minDb;
552554
if (value > maxDb)
@@ -557,4 +559,5 @@ namespace lv2c::lv2_plugin
557559
}
558560
}
559561
};
560-
}
562+
}
563+

0 commit comments

Comments
 (0)