Implement IUnitInfo::getProgramPitchName

This commit is contained in:
Robbert van der Helm
2020-12-26 23:20:13 +01:00
parent e414c58a7a
commit d34b399ba0
6 changed files with 91 additions and 5 deletions
+23
View File
@@ -492,6 +492,17 @@ bool Vst3Logger::log_request(bool is_host_vst,
}); });
} }
bool Vst3Logger::log_request(bool is_host_vst,
const YaUnitInfo::GetProgramPitchName& request) {
return log_request_base(is_host_vst, [&](auto& message) {
message << request.instance_id
<< ": IUnitInfo::getProgramPitchName(listId = "
<< request.list_id
<< ", programIndex = " << request.program_index
<< ", midiPitch = " << request.midi_pitch << ", &name)";
});
}
bool Vst3Logger::log_request( bool Vst3Logger::log_request(
bool is_host_vst, bool is_host_vst,
const YaAudioProcessor::SetBusArrangements& request) { const YaAudioProcessor::SetBusArrangements& request) {
@@ -938,6 +949,18 @@ void Vst3Logger::log_response(
}); });
} }
void Vst3Logger::log_response(
bool is_host_vst,
const YaUnitInfo::GetProgramPitchNameResponse& response) {
log_response_base(is_host_vst, [&](auto& message) {
message << response.result.string();
if (response.result == Steinberg::kResultOk) {
message << ", \"" << VST3::StringConvert::convert(response.name)
<< "\"";
}
});
}
void Vst3Logger::log_response( void Vst3Logger::log_response(
bool is_host_vst, bool is_host_vst,
const YaAudioProcessor::GetBusArrangementResponse& response) { const YaAudioProcessor::GetBusArrangementResponse& response) {
+3
View File
@@ -115,6 +115,7 @@ class Vst3Logger {
bool log_request(bool is_host_vst, const YaUnitInfo::GetProgramName&); bool log_request(bool is_host_vst, const YaUnitInfo::GetProgramName&);
bool log_request(bool is_host_vst, const YaUnitInfo::GetProgramInfo&); bool log_request(bool is_host_vst, const YaUnitInfo::GetProgramInfo&);
bool log_request(bool is_host_vst, const YaUnitInfo::HasProgramPitchNames&); bool log_request(bool is_host_vst, const YaUnitInfo::HasProgramPitchNames&);
bool log_request(bool is_host_vst, const YaUnitInfo::GetProgramPitchName&);
bool log_request(bool is_host_vst, bool log_request(bool is_host_vst,
const YaAudioProcessor::SetBusArrangements&); const YaAudioProcessor::SetBusArrangements&);
@@ -175,6 +176,8 @@ class Vst3Logger {
const YaUnitInfo::GetProgramNameResponse&); const YaUnitInfo::GetProgramNameResponse&);
void log_response(bool is_host_vst, void log_response(bool is_host_vst,
const YaUnitInfo::GetProgramInfoResponse&); const YaUnitInfo::GetProgramInfoResponse&);
void log_response(bool is_host_vst,
const YaUnitInfo::GetProgramPitchNameResponse&);
void log_response(bool is_host_vst, void log_response(bool is_host_vst,
const YaAudioProcessor::GetBusArrangementResponse&); const YaAudioProcessor::GetBusArrangementResponse&);
+2 -1
View File
@@ -106,7 +106,8 @@ using ControlRequest = std::variant<Vst3PlugViewProxy::Destruct,
YaUnitInfo::GetProgramListInfo, YaUnitInfo::GetProgramListInfo,
YaUnitInfo::GetProgramName, YaUnitInfo::GetProgramName,
YaUnitInfo::GetProgramInfo, YaUnitInfo::GetProgramInfo,
YaUnitInfo::HasProgramPitchNames>; YaUnitInfo::HasProgramPitchNames,
YaUnitInfo::GetProgramPitchName>;
template <typename S> template <typename S>
void serialize(S& s, ControlRequest& payload) { void serialize(S& s, ControlRequest& payload) {
@@ -212,7 +212,7 @@ class YaUnitInfo : public Steinberg::Vst::IUnitInfo {
Steinberg::Vst::String128 name /*out*/) override = 0; Steinberg::Vst::String128 name /*out*/) override = 0;
/** /**
* The response code and returned name for a call to * The response code and returned value for a call to
* `IUnitInfo::getPrograminfo(list_id, program_index, attribute_name, * `IUnitInfo::getPrograminfo(list_id, program_index, attribute_name,
* &attribute_value)`. * &attribute_value)`.
*/ */
@@ -279,6 +279,46 @@ class YaUnitInfo : public Steinberg::Vst::IUnitInfo {
virtual tresult PLUGIN_API virtual tresult PLUGIN_API
hasProgramPitchNames(Steinberg::Vst::ProgramListID listId, hasProgramPitchNames(Steinberg::Vst::ProgramListID listId,
int32 programIndex) override = 0; int32 programIndex) override = 0;
/**
* The response code and returned name for a call to
* `IUnitInfo::getProgramPitchName(list_id, program_index, midi_pitch,
* &name)`.
*/
struct GetProgramPitchNameResponse {
UniversalTResult result;
std::u16string name;
template <typename S>
void serialize(S& s) {
s.object(result);
s.text2b(name, std::extent_v<Steinberg::Vst::String128>);
}
};
/**
* Message to pass through a call to
* `IUnitInfo::getProgramPitchName(list_id, program_index, midi_pitch,
* &name)` to the Wine plugin host.
*/
struct GetProgramPitchName {
using Response = GetProgramPitchNameResponse;
native_size_t instance_id;
Steinberg::Vst::ProgramListID list_id;
int32 program_index;
int16 midi_pitch;
template <typename S>
void serialize(S& s) {
s.value8b(instance_id);
s.value4b(list_id);
s.value4b(program_index);
s.value2b(midi_pitch);
}
};
virtual tresult PLUGIN_API virtual tresult PLUGIN_API
getProgramPitchName(Steinberg::Vst::ProgramListID listId, getProgramPitchName(Steinberg::Vst::ProgramListID listId,
int32 programIndex, int32 programIndex,
+10 -3
View File
@@ -523,9 +523,16 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getProgramPitchName(
int32 programIndex, int32 programIndex,
int16 midiPitch, int16 midiPitch,
Steinberg::Vst::String128 name /*out*/) { Steinberg::Vst::String128 name /*out*/) {
// TODO: Implement const GetProgramPitchNameResponse response = bridge.send_message(
bridge.logger.log("TODO: IUnitInfo::getProgramPitchName()"); YaUnitInfo::GetProgramPitchName{.instance_id = instance_id(),
return Steinberg::kNotImplemented; .list_id = listId,
.program_index = programIndex,
.midi_pitch = midiPitch});
std::copy(response.name.begin(), response.name.end(), name);
name[response.name.size()] = 0;
return response.result;
} }
Steinberg::Vst::UnitID PLUGIN_API Vst3PluginProxyImpl::getSelectedUnit() { Steinberg::Vst::UnitID PLUGIN_API Vst3PluginProxyImpl::getSelectedUnit() {
+12
View File
@@ -627,6 +627,18 @@ void Vst3Bridge::run() {
.unit_info->hasProgramPitchNames(request.list_id, .unit_info->hasProgramPitchNames(request.list_id,
request.program_index); request.program_index);
}, },
[&](const YaUnitInfo::GetProgramPitchName& request)
-> YaUnitInfo::GetProgramPitchName::Response {
Steinberg::Vst::String128 name{0};
const tresult result =
object_instances[request.instance_id]
.unit_info->getProgramPitchName(
request.list_id, request.program_index,
request.midi_pitch, name);
return YaUnitInfo::GetProgramPitchNameResponse{
.result = result, .name = tchar_pointer_to_u16string(name)};
},
}); });
} }