mirror of
https://codeberg.org/armin/justasample.git
synced 2026-09-01 12:20:48 +02:00
init
This commit is contained in:
commit
d21bc831e1
178 changed files with 24136 additions and 0 deletions
131
Source/Utilities/Reaper/ReaperVST3Extensions.cpp
Normal file
131
Source/Utilities/Reaper/ReaperVST3Extensions.cpp
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
/*
|
||||
==============================================================================
|
||||
|
||||
ReaperVST3Extensions.cpp
|
||||
Created: 14 May 2025 9:43:44pm
|
||||
Author: binya
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#include "ReaperVST3Extensions.h"
|
||||
|
||||
namespace reaper
|
||||
{
|
||||
DEF_CLASS_IID(IReaperHostApplication)
|
||||
}
|
||||
|
||||
juce::String ReaperVST3Extensions::getNamedConfigParam(const juce::String& paramName) const
|
||||
{
|
||||
if (GetSetMediaTrackInfo_String == nullptr || GetTrack == nullptr || trackIndex < 0)
|
||||
return {};
|
||||
|
||||
MediaTrack* track = GetTrack(nullptr, trackIndex);
|
||||
|
||||
if (track == nullptr)
|
||||
return {};
|
||||
|
||||
// If our track index has not yet been updated, exit early
|
||||
if (GetTrackGUID(track) != trackGUID)
|
||||
return {};
|
||||
|
||||
constexpr int buffSize = 512;
|
||||
char buffer[buffSize] = {};
|
||||
|
||||
bool success = GetSetMediaTrackInfo_String(track, paramName.getCharPointer(), buffer, false);
|
||||
|
||||
if (!success || buffer[0] == 0)
|
||||
return {};
|
||||
|
||||
return juce::String::fromUTF8(buffer);
|
||||
}
|
||||
|
||||
void ReaperVST3Extensions::setNamedConfigParam(const juce::String& paramName, const juce::String& value) const
|
||||
{
|
||||
if (GetSetMediaTrackInfo_String == nullptr || GetTrack == nullptr || trackIndex < 0)
|
||||
return;
|
||||
|
||||
MediaTrack* track = GetTrack(nullptr, trackIndex);
|
||||
|
||||
if (track == nullptr)
|
||||
return;
|
||||
|
||||
// If our track index has not yet been updated, exit early
|
||||
if (GetTrackGUID(track) != trackGUID)
|
||||
return;
|
||||
|
||||
GetSetMediaTrackInfo_String(track, paramName.getCharPointer(), value.getCharPointer().getAddress(), true);
|
||||
}
|
||||
|
||||
void ReaperVST3Extensions::setIHostApplication(Steinberg::FUnknown* ptr)
|
||||
{
|
||||
if (ptr == nullptr)
|
||||
return;
|
||||
|
||||
void* rawInterface = nullptr;
|
||||
|
||||
if (ptr->queryInterface(reaper::IReaperHostApplication::iid, &rawInterface) == Steinberg::kResultOk)
|
||||
{
|
||||
if (void* fnPtr = static_cast<reaper::IReaperHostApplication*> (rawInterface)->getReaperApi("GetSetMediaTrackInfo_String"))
|
||||
{
|
||||
GetSetMediaTrackInfo_String = reinterpret_cast<bool (*)(MediaTrack*, const char*, char*, bool)>(fnPtr);
|
||||
}
|
||||
|
||||
if (void* fnPtr = static_cast<reaper::IReaperHostApplication*> (rawInterface)->getReaperApi("GetTrack"))
|
||||
{
|
||||
GetTrack = reinterpret_cast<MediaTrack * (*)(ReaProject*, int)>(fnPtr);
|
||||
}
|
||||
|
||||
if (void* fnPtr = static_cast<reaper::IReaperHostApplication*> (rawInterface)->getReaperApi("GetTrackGUID"))
|
||||
{
|
||||
GetTrackGUID = reinterpret_cast<GUID * (*)(MediaTrack*)>(fnPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int32_t ReaperVST3Extensions::queryIEditController(const Steinberg::TUID string, void** obj)
|
||||
{
|
||||
#if JAS_VST3_REAPER_INTEGRATION
|
||||
if (obj == nullptr)
|
||||
return -1;
|
||||
|
||||
if (Steinberg::FUnknownPrivate::iidEqual(string, Steinberg::Vst::ChannelContext::IInfoListener::iid))
|
||||
{
|
||||
*obj = static_cast<Steinberg::Vst::ChannelContext::IInfoListener*>(this);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*obj = nullptr;
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
Steinberg::tresult ReaperVST3Extensions::queryInterface(const Steinberg::TUID /*_iid*/, void** /*obj*/)
|
||||
{
|
||||
return Steinberg::kNoInterface;
|
||||
}
|
||||
|
||||
Steinberg::uint32 ReaperVST3Extensions::addRef()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
Steinberg::uint32 ReaperVST3Extensions::release()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
Steinberg::tresult ReaperVST3Extensions::setChannelContextInfos(Steinberg::Vst::IAttributeList* list)
|
||||
{
|
||||
if (!list || GetTrackGUID == nullptr)
|
||||
return Steinberg::kResultFalse;
|
||||
|
||||
Steinberg::int64 idx = -1;
|
||||
if (list->getInt(Steinberg::Vst::ChannelContext::kChannelIndexKey, idx) == Steinberg::kResultTrue)
|
||||
{
|
||||
trackIndex = static_cast<int>(idx) - 1;
|
||||
trackGUID = GetTrackGUID(GetTrack(nullptr, trackIndex));
|
||||
}
|
||||
|
||||
return Steinberg::kResultOk;
|
||||
}
|
||||
56
Source/Utilities/Reaper/ReaperVST3Extensions.h
Normal file
56
Source/Utilities/Reaper/ReaperVST3Extensions.h
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
==============================================================================
|
||||
|
||||
ReaperVST3Extensions.h
|
||||
Created: 14 May 2025 9:38:25pm
|
||||
Author: binya
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <JuceHeader.h>
|
||||
|
||||
#include <reaper_plugin.h>
|
||||
#include "pluginterfaces/base/funknown.h"
|
||||
#include "pluginterfaces/vst/ivstchannelcontextinfo.h"
|
||||
|
||||
namespace reaper
|
||||
{
|
||||
using namespace Steinberg;
|
||||
using INT_PTR = juce::pointer_sized_int;
|
||||
using uint32 = Steinberg::uint32;
|
||||
|
||||
#include <reaper_vst3_interfaces.h>
|
||||
}
|
||||
|
||||
class ReaperVST3Extensions final : public juce::VST3ClientExtensions, public Steinberg::Vst::ChannelContext::IInfoListener
|
||||
{
|
||||
public:
|
||||
ReaperVST3Extensions() = default;
|
||||
~ReaperVST3Extensions() override = default;
|
||||
|
||||
juce::String getNamedConfigParam(const juce::String& paramName) const;
|
||||
void setNamedConfigParam(const juce::String& paramName, const juce::String& value) const;
|
||||
|
||||
void setIHostApplication(Steinberg::FUnknown* ptr) override;
|
||||
int32_t queryIEditController(const Steinberg::TUID, void** obj) override;
|
||||
|
||||
Steinberg::tresult PLUGIN_API setChannelContextInfos(Steinberg::Vst::IAttributeList* list) override;
|
||||
|
||||
Steinberg::tresult PLUGIN_API queryInterface(const Steinberg::TUID _iid, void** obj) override;
|
||||
Steinberg::uint32 PLUGIN_API addRef() override;
|
||||
Steinberg::uint32 PLUGIN_API release() override;
|
||||
|
||||
private:
|
||||
// https://github.com/justinfrankel/reaper-sdk/blob/main/sdk/reaper_plugin_functions.h
|
||||
bool (*GetSetMediaTrackInfo_String)(MediaTrack* tr, const char* parmname, char* stringNeedBig, bool setNewValue);
|
||||
MediaTrack* (*GetTrack)(ReaProject* proj, int trackidx) { nullptr };
|
||||
GUID* (*GetTrackGUID)(MediaTrack* tr) { nullptr };
|
||||
|
||||
GUID* trackGUID{ nullptr };
|
||||
int trackIndex{ -1 };
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ReaperVST3Extensions)
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue