mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 03:50:11 +02:00
Read preset meta data in the same way as contexts
This commit is contained in:
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
#include "attribute-list.h"
|
#include "attribute-list.h"
|
||||||
|
|
||||||
|
#include <pluginterfaces/vst/vstpresetkeys.h>
|
||||||
|
|
||||||
#include "pluginterfaces/vst/ivstchannelcontextinfo.h"
|
#include "pluginterfaces/vst/ivstchannelcontextinfo.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -47,6 +49,31 @@ const static char* channel_context_integer_keys[] = {
|
|||||||
const static char* channel_context_binary_keys[] = {
|
const static char* channel_context_binary_keys[] = {
|
||||||
Steinberg::Vst::ChannelContext::kChannelImageKey};
|
Steinberg::Vst::ChannelContext::kChannelImageKey};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* These are the meta data keys used for `IStreamAttributes`. We need to keep
|
||||||
|
* track of this because `IAttributeList` has no way to just iterate over the
|
||||||
|
* stored keys. We'll read these from the host if the host supports this
|
||||||
|
* interface, and if the plugin writes an attribute with one of these keys we'll
|
||||||
|
* write the value back to the host.
|
||||||
|
*
|
||||||
|
* TODO: There's also `Steinberg::Vst::PresetAttributes::kFilePathStringType`
|
||||||
|
* This would require translating between Windows and Unix style paths,
|
||||||
|
* which we can't easily do outside of Wine. If this ends up being
|
||||||
|
* important, then we'll have to shell out to `winepath` which is not
|
||||||
|
* ideal. On the Wine side we can just use the `wine_get_dos_file_name`
|
||||||
|
* and `wine_get_unix_file_name` functions instead. Requesting this should
|
||||||
|
* also use a 1024 character buffer.
|
||||||
|
*/
|
||||||
|
const static char* stream_meta_data_string_keys[] = {
|
||||||
|
Steinberg::Vst::PresetAttributes::kPlugInName,
|
||||||
|
Steinberg::Vst::PresetAttributes::kPlugInCategory,
|
||||||
|
Steinberg::Vst::PresetAttributes::kInstrument,
|
||||||
|
Steinberg::Vst::PresetAttributes::kStyle,
|
||||||
|
Steinberg::Vst::PresetAttributes::kCharacter,
|
||||||
|
Steinberg::Vst::PresetAttributes::kStateType,
|
||||||
|
Steinberg::Vst::PresetAttributes::kName,
|
||||||
|
Steinberg::Vst::PresetAttributes::kFileName};
|
||||||
|
|
||||||
YaAttributeList::YaAttributeList(){FUNKNOWN_CTOR}
|
YaAttributeList::YaAttributeList(){FUNKNOWN_CTOR}
|
||||||
|
|
||||||
YaAttributeList::~YaAttributeList() {
|
YaAttributeList::~YaAttributeList() {
|
||||||
@@ -115,6 +142,23 @@ YaAttributeList YaAttributeList::read_channel_context(
|
|||||||
return attributes;
|
return attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
YaAttributeList YaAttributeList::read_stream_attributes(
|
||||||
|
Steinberg::Vst::IAttributeList* stream_attributes) {
|
||||||
|
YaAttributeList attributes{};
|
||||||
|
// Copy over all predefined preset meta data. `IAttributeList` does not
|
||||||
|
// offer any interface to enumerate the stored keys.
|
||||||
|
Steinberg::Vst::String128 vst_string{0};
|
||||||
|
for (const auto& key : stream_meta_data_string_keys) {
|
||||||
|
vst_string[0] = 0;
|
||||||
|
if (stream_attributes->getString(key, vst_string, sizeof(vst_string)) ==
|
||||||
|
Steinberg::kResultOk) {
|
||||||
|
attributes.setString(key, vst_string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return attributes;
|
||||||
|
}
|
||||||
|
|
||||||
tresult PLUGIN_API YaAttributeList::setInt(AttrID id, int64 value) {
|
tresult PLUGIN_API YaAttributeList::setInt(AttrID id, int64 value) {
|
||||||
attrs_int[id] = value;
|
attrs_int[id] = value;
|
||||||
return Steinberg::kResultOk;
|
return Steinberg::kResultOk;
|
||||||
|
|||||||
@@ -60,6 +60,14 @@ class YaAttributeList : public Steinberg::Vst::IAttributeList {
|
|||||||
static YaAttributeList read_channel_context(
|
static YaAttributeList read_channel_context(
|
||||||
Steinberg::Vst::IAttributeList* context);
|
Steinberg::Vst::IAttributeList* context);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read the the meta data attributes provided by `IBStraem`s that support
|
||||||
|
* `IStreamAttributes`. This works the same was as
|
||||||
|
* `YaAttributeList::read_channel_context`.
|
||||||
|
*/
|
||||||
|
static YaAttributeList read_stream_attributes(
|
||||||
|
Steinberg::Vst::IAttributeList* stream_attributes);
|
||||||
|
|
||||||
virtual tresult PLUGIN_API setInt(AttrID id, int64 value) override;
|
virtual tresult PLUGIN_API setInt(AttrID id, int64 value) override;
|
||||||
virtual tresult PLUGIN_API getInt(AttrID id, int64& value) override;
|
virtual tresult PLUGIN_API getInt(AttrID id, int64& value) override;
|
||||||
virtual tresult PLUGIN_API setFloat(AttrID id, double value) override;
|
virtual tresult PLUGIN_API setFloat(AttrID id, double value) override;
|
||||||
|
|||||||
@@ -16,36 +16,9 @@
|
|||||||
|
|
||||||
#include "bstream.h"
|
#include "bstream.h"
|
||||||
|
|
||||||
#include <pluginterfaces/vst/vstpresetkeys.h>
|
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
/**
|
|
||||||
* These are the meta data keys used for `IStreamAttributes`. We need to keep
|
|
||||||
* track of this because `IAttributeList` has no way to just iterate over the
|
|
||||||
* stored keys. We'll read these from the host if the host supports this
|
|
||||||
* interface, and if the plugin writes an attribute with one of these keys we'll
|
|
||||||
* write the value back to the host.
|
|
||||||
*
|
|
||||||
* TODO: There's also `Steinberg::Vst::PresetAttributes::kFilePathStringType`
|
|
||||||
* This would require translating between Windows and Unix style paths,
|
|
||||||
* which we can't easily do outside of Wine. If this ends up being
|
|
||||||
* important, then we'll have to shell out to `winepath` which is not
|
|
||||||
* ideal. On the Wine side we can just use the `wine_get_dos_file_name`
|
|
||||||
* and `wine_get_unix_file_name` functions instead. Requesting this should
|
|
||||||
* also use a 1024 character buffer.
|
|
||||||
*/
|
|
||||||
const static char* stream_meta_data_keys[] = {
|
|
||||||
Steinberg::Vst::PresetAttributes::kPlugInName,
|
|
||||||
Steinberg::Vst::PresetAttributes::kPlugInCategory,
|
|
||||||
Steinberg::Vst::PresetAttributes::kInstrument,
|
|
||||||
Steinberg::Vst::PresetAttributes::kStyle,
|
|
||||||
Steinberg::Vst::PresetAttributes::kCharacter,
|
|
||||||
Steinberg::Vst::PresetAttributes::kStateType,
|
|
||||||
Steinberg::Vst::PresetAttributes::kName,
|
|
||||||
Steinberg::Vst::PresetAttributes::kFileName};
|
|
||||||
|
|
||||||
YaBStream::YaBStream(){FUNKNOWN_CTOR}
|
YaBStream::YaBStream(){FUNKNOWN_CTOR}
|
||||||
|
|
||||||
YaBStream::YaBStream(Steinberg::IBStream* stream) {
|
YaBStream::YaBStream(Steinberg::IBStream* stream) {
|
||||||
@@ -86,19 +59,12 @@ YaBStream::YaBStream(Steinberg::IBStream* stream) {
|
|||||||
file_name.emplace(tchar_pointer_to_u16string(vst_string));
|
file_name.emplace(tchar_pointer_to_u16string(vst_string));
|
||||||
}
|
}
|
||||||
|
|
||||||
attributes.emplace();
|
|
||||||
if (Steinberg::IPtr<Steinberg::Vst::IAttributeList>
|
if (Steinberg::IPtr<Steinberg::Vst::IAttributeList>
|
||||||
stream_attributes_list = stream_attributes->getAttributes()) {
|
stream_attributes_list = stream_attributes->getAttributes()) {
|
||||||
// Copy over all predefined meta data keys. `IAttributeList` does
|
attributes.emplace(YaAttributeList::read_stream_attributes(
|
||||||
// not offer any interface to enumerate the stored keys.
|
stream_attributes_list));
|
||||||
for (const auto& key : stream_meta_data_keys) {
|
} else {
|
||||||
vst_string[0] = 0;
|
attributes.emplace();
|
||||||
if (stream_attributes_list->getString(key, vst_string,
|
|
||||||
sizeof(vst_string)) ==
|
|
||||||
Steinberg::kResultOk) {
|
|
||||||
attributes->setString(key, vst_string);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user