finished saving/loading vsts

This commit is contained in:
itsmattkc
2019-01-09 14:11:39 +11:00
parent 9e8fe16005
commit b34f7a2900
4 changed files with 35 additions and 40 deletions
+26
View File
@@ -7,6 +7,8 @@
#include <QPushButton>
#include <QDialog>
#include <QMessageBox>
#include <QFile>
#include <QXmlStreamWriter>
#include "playback/audio.h"
#include "mainwindow.h"
@@ -30,6 +32,9 @@ extern "C" {
case audioMasterGetCurrentProcessLevel:
return 0;
// Handle other opcodes here... there will be lots of them
case audioMasterEndEdit: // change made
mainWindow->setWindowModified(true);
break;
default:
dout << "[INFO] Plugin requested unhandled opcode" << opcode;
break;
@@ -214,6 +219,27 @@ void VSTHostWin::process_audio(double timecode_start, double timecode_end, quint
}
}
void VSTHostWin::custom_load(QXmlStreamReader &stream) {
if (stream.name() == "plugindata") {
stream.readNext();
QByteArray b = QByteArray::fromBase64(stream.text().toUtf8());
const char* data = b.constData();
if (plugin != NULL) {
dispatcher(plugin, effSetChunk, 0, (VstInt32) b.size(), (void*) b.constData(), 0);
}
}
}
void VSTHostWin::save(QXmlStreamWriter &stream) {
Effect::save(stream);
if (plugin != NULL) {
char* p = NULL;
VstInt32 length = dispatcher(plugin, effGetChunk, 0, 0, &p, 0);
QByteArray b(p, length);
stream.writeTextElement("plugindata", b.toBase64());
}
}
void VSTHostWin::show_interface(bool show) {
dialog->setVisible(show);
}
+3
View File
@@ -17,6 +17,9 @@ public:
VSTHostWin(Clip* c, const EffectMeta* em);
~VSTHostWin();
void process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int channel_count);
void custom_load(QXmlStreamReader& stream);
void save(QXmlStreamWriter& stream);
private slots:
void show_interface(bool show);
void uncheck_show_button();
+4 -39
View File
@@ -641,42 +641,6 @@ void Effect::load(QXmlStreamReader& stream) {
while (!stream.atEnd() && !(stream.name() == "row" && stream.isEndElement())) {
stream.readNext();
// read keyframes
/*if (stream.name() == "keyframes" && stream.isStartElement()) {
for (int k=0;k<stream.attributes().size();k++) {
const QXmlStreamAttribute& attr = stream.attributes().at(k);
if (attr.name() == "enabled") {
row->setKeyframing(attr.value() == "1");
}
}
if (row->isKeyframing()) {
stream.readNext();
while (!stream.atEnd() && !(stream.name() == "keyframes" && stream.isEndElement())) {
if (stream.name() == "key" && stream.isStartElement()) {
long keyframe_frame;
int keyframe_type;
for (int k=0;k<stream.attributes().size();k++) {
const QXmlStreamAttribute& attr = stream.attributes().at(k);
if (attr.name() == "frame") {
keyframe_frame = attr.value().toLong();
} else if (attr.name() == "type") {
keyframe_type = attr.value().toInt();
}
}
for (int k=0;k<row->fieldCount();k++) {
EffectField* field = row->field(k);
EffectKeyframe key;
key.time = keyframe_frame;
key.type = keyframe_type;
field->keyframes.append(key);
}
}
stream.readNext();
}
}
stream.readNext();
}*/
// read field
if (stream.name() == "field" && stream.isStartElement()) {
if (field_count < row->fieldCount()) {
@@ -698,9 +662,6 @@ void Effect::load(QXmlStreamReader& stream) {
}
}
// TODO DEPRECATED, only used for backwards compatibility with 180820
if (!found_field_by_id) dout << "[INFO] Found field by field number";
EffectField* field = row->field(field_number);
// get current field value
@@ -752,10 +713,14 @@ void Effect::load(QXmlStreamReader& stream) {
dout << "[ERROR] Too many rows for effect" << id << ". Project might be corrupt. (Got" << row_count << ", expected <" << rows.size()-1 << ")";
}
row_count++;
} else if (stream.isStartElement()) {
custom_load(stream);
}
}
}
void Effect::custom_load(QXmlStreamReader &stream) {}
void Effect::save(QXmlStreamWriter& stream) {
stream.writeAttribute("name", meta->name);
stream.writeAttribute("enabled", QString::number(is_enabled()));
+2 -1
View File
@@ -136,7 +136,8 @@ public:
void copy_field_keyframes(Effect *e);
void load(QXmlStreamReader& stream);
void save(QXmlStreamWriter& stream);
virtual void custom_load(QXmlStreamReader& stream);
virtual void save(QXmlStreamWriter& stream);
// glsl handling
bool is_open();