Initial release

This commit is contained in:
civ
2026-08-16 18:24:52 +07:00
commit 876886a39a
13244 changed files with 2353959 additions and 0 deletions
@@ -0,0 +1,48 @@
//-----------------------------------------------------------------------------
// Project : VST SDK
//
// Category : Examples
// Filename : public.sdk/samples/vst/pitchnames/source/factory.cpp
// Created by : Steinberg, 12/2010
// Description :
//
//-----------------------------------------------------------------------------
// This file is part of a Steinberg SDK. It is subject to the license terms
// in the LICENSE file found in the top-level directory of this distribution
// and at www.steinberg.net/sdklicenses.
// No part of the SDK, including this file, may be copied, modified, propagated,
// or distributed except according to the terms contained in the LICENSE file.
//-----------------------------------------------------------------------------
#include "public.sdk/source/main/pluginfactory.h"
#include "pitchnames.h"
#include "version.h" // for versioning
#define stringPluginName "PitchNames"
BEGIN_FACTORY_DEF (stringCompanyName, stringCompanyWeb, stringCompanyEmail)
//---First plug-in included in this factory-------
// its kVstAudioEffectClass component
DEF_CLASS2 (INLINE_UID_FROM_FUID(Steinberg::Vst::PitchNamesProcessor::cid),
PClassInfo::kManyInstances,
kVstAudioEffectClass,
stringPluginName,
Vst::kDistributable,
"Instrument",
FULL_VERSION_STR, // Plug-in version (to be changed)
kVstVersionString,
Steinberg::Vst::PitchNamesProcessor::createInstance)
DEF_CLASS2 (INLINE_UID_FROM_FUID(Steinberg::Vst::PitchNamesController::cid),
PClassInfo::kManyInstances,
kVstComponentControllerClass,
stringPluginName, // controller name (can be the same as the component name)
0, // not used here
"", // not used here
FULL_VERSION_STR, // Plug-in version (to be changed)
kVstVersionString,
Steinberg::Vst::PitchNamesController::createInstance)
END_FACTORY
@@ -0,0 +1,190 @@
//-----------------------------------------------------------------------------
// Project : VST SDK
//
// Category : Examples
// Filename : public.sdk/samples/vst/pitchnames/source/pitchnames.cpp
// Created by : Steinberg, 12/2010
// Description : A VST 3 instrument which shows the usage of pitch names for the most simple
// case that only the root Unit is defined
//
//-----------------------------------------------------------------------------
// This file is part of a Steinberg SDK. It is subject to the license terms
// in the LICENSE file found in the top-level directory of this distribution
// and at www.steinberg.net/sdklicenses.
// No part of the SDK, including this file, may be copied, modified, propagated,
// or distributed except according to the terms contained in the LICENSE file.
//-----------------------------------------------------------------------------
#include "pitchnames.h"
#include "pitchnamesdatabrowsersource.h"
#include "pluginterfaces/base/ustring.h"
using namespace VSTGUI;
#define MULTI_CHANNEL_SCENARIO 1
namespace Steinberg {
namespace Vst {
//-----------------------------------------------------------------------------
FUID PitchNamesController::cid (0xB9123C35, 0x0FFD404C, 0x826774E0, 0x00819A0C);
FUID PitchNamesProcessor::cid (0x32ECDB17, 0xD0894B22, 0xAF9759F8, 0xF5D58DD4);
#if MULTI_CHANNEL_SCENARIO
static ProgramListID kProgramList0ID = 0;
static ProgramListID kProgramList1ID = 1;
static UnitID kChannel0UnitId = 'ch00';
static UnitID kChannel1UnitId = 'ch01';
#else
static ProgramListID kProgramListID = 0;
#endif
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
tresult PLUGIN_API PitchNamesController::initialize (FUnknown* context)
{
tresult result = EditControllerEx1::initialize (context);
if (result == kResultOk)
{
#if MULTI_CHANNEL_SCENARIO
addUnit (new Unit (String ("Root"), kRootUnitId, kNoParentUnitId));
addUnit (new Unit (String ("Channel 0"), kChannel0UnitId, kRootUnitId, kProgramList0ID));
addUnit (new Unit (String ("Channel 1"), kChannel1UnitId, kRootUnitId, kProgramList1ID));
auto* list = new ProgramListWithPitchNames (String ("ProgramList 0"), kProgramList0ID,
kChannel0UnitId);
list->addProgram (String ("Init 1"));
list->setPitchName (0, 0, String ("Channel 0 First Item"));
addProgramList (list);
parameters.addParameter (list->getParameter ());
list = new ProgramListWithPitchNames (String ("ProgramList 1"), kProgramList1ID,
kChannel1UnitId);
list->addProgram (String ("Init 1"));
list->setPitchName (0, 0, String ("Channel 1 First Item"));
addProgramList (list);
parameters.addParameter (list->getParameter ());
#else
addUnit (new Unit (String ("Root"), kRootUnitId, kNoParentUnitId, kProgramListID));
ProgramListWithPitchNames* list =
new ProgramListWithPitchNames (String ("ProgramList"), kProgramListID, kRootUnitId);
list->addProgram (String ("Init 1"));
list->setPitchName (0, 38, String ("Snare"));
list->setPitchName (0, 42, String ("Closed Hi-Hat"));
list->setPitchName (0, 45, String ("Low Tom"));
addProgramList (list);
parameters.addParameter (list->getParameter ());
#endif
}
return result;
}
//-----------------------------------------------------------------------------
tresult PLUGIN_API PitchNamesController::getUnitByBus (MediaType type, BusDirection dir,
int32 busIndex, int32 channel,
UnitID& unitId /*out*/)
{
if (type == kEvent && dir == kInput)
{
#if MULTI_CHANNEL_SCENARIO
if (busIndex == 0)
{
if (channel == 0)
{
unitId = kChannel0UnitId;
return kResultTrue;
}
else if (channel == 1)
{
unitId = kChannel1UnitId;
return kResultTrue;
}
}
#else
if (busIndex == 0 && channel == 0)
{
unitId = kRootUnitId;
return kResultTrue;
}
#endif
}
return kResultFalse;
}
//-----------------------------------------------------------------------------
IPlugView* PLUGIN_API PitchNamesController::createView (FIDString name)
{
if (ConstString (name) == ViewType::kEditor)
{
return new VST3Editor (this, "PitchNamesEditor", "pitchnames.uidesc");
}
return nullptr;
}
//-----------------------------------------------------------------------------
CView* PitchNamesController::createCustomView (UTF8StringPtr name, const UIAttributes& /*attributes*/,
const IUIDescription* /*description*/,
VST3Editor* /*editor*/)
{
#if MULTI_CHANNEL_SCENARIO
if (ConstString (name) == "PitchNamesDataBrowser")
{
IDataBrowserDelegate* dataSource = new PitchNamesDataBrowserSource (this, kChannel0UnitId);
return new CDataBrowser (CRect (0, 0, 100, 100), dataSource,
CDataBrowser::kDrawRowLines | CDataBrowser::kDrawColumnLines |
CDataBrowser::kDrawHeader | CDataBrowser::kVerticalScrollbar);
}
#else
if (ConstString (name) == "PitchNamesDataBrowser")
{
IDataBrowser* dataSource = new PitchNamesDataBrowserSource (this, kRootUnitId);
return new CDataBrowser (CRect (0, 0, 100, 100), 0, dataSource,
CDataBrowser::kDrawRowLines | CDataBrowser::kDrawColumnLines |
CDataBrowser::kDrawHeader | CDataBrowser::kVerticalScrollbar);
}
#endif
return nullptr;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
PitchNamesProcessor::PitchNamesProcessor () { setControllerClass (PitchNamesController::cid); }
//-----------------------------------------------------------------------------
tresult PLUGIN_API PitchNamesProcessor::initialize (FUnknown* context)
{
tresult result = AudioEffect::initialize (context);
if (result == kResultOk)
{
addAudioOutput (USTRING ("Audio Output"), SpeakerArr::kStereo);
#if MULTI_CHANNEL_SCENARIO
addEventInput (USTRING ("Event Input"), 2);
#else
addEventInput (USTRING ("Event Input"), 1);
#endif
}
return result;
}
//-----------------------------------------------------------------------------
tresult PLUGIN_API PitchNamesProcessor::process (ProcessData& data)
{
if (data.numSamples && data.numOutputs)
{
for (int32 i = 0; i < data.outputs[0].numChannels; i++)
memset (data.outputs[0].channelBuffers32[i], 0, data.numSamples * sizeof (float));
data.outputs[0].silenceFlags = 3;
}
return kResultOk;
}
}
} // namespaces
@@ -0,0 +1,64 @@
//-----------------------------------------------------------------------------
// Project : VST SDK
//
// Category : Examples
// Filename : public.sdk/samples/vst/pitchnames/source/pitchnames.h
// Created by : Steinberg, 12/2010
// Description :
//
//-----------------------------------------------------------------------------
// This file is part of a Steinberg SDK. It is subject to the license terms
// in the LICENSE file found in the top-level directory of this distribution
// and at www.steinberg.net/sdklicenses.
// No part of the SDK, including this file, may be copied, modified, propagated,
// or distributed except according to the terms contained in the LICENSE file.
//-----------------------------------------------------------------------------
#pragma once
#include "public.sdk/source/vst/vsteditcontroller.h"
#include "public.sdk/source/vst/vstaudioeffect.h"
#include "base/source/fstring.h"
#include "vstgui/plugin-bindings/vst3editor.h"
namespace Steinberg {
namespace Vst {
//-----------------------------------------------------------------------------
class PitchNamesController : public EditControllerEx1, public VSTGUI::VST3EditorDelegate
{
public:
tresult PLUGIN_API initialize (FUnknown* context) SMTG_OVERRIDE;
tresult PLUGIN_API getUnitByBus (MediaType type, BusDirection dir, int32 busIndex,
int32 channel, UnitID& unitId /*out*/) SMTG_OVERRIDE;
IPlugView* PLUGIN_API createView (FIDString name) SMTG_OVERRIDE;
VSTGUI::CView* createCustomView (VSTGUI::UTF8StringPtr name,
const VSTGUI::UIAttributes& attributes,
const VSTGUI::IUIDescription* description,
VSTGUI::VST3Editor* editor) SMTG_OVERRIDE;
static FUnknown* createInstance (void*)
{
return (IEditController*)new PitchNamesController ();
}
static FUID cid;
};
//-----------------------------------------------------------------------------
class PitchNamesProcessor : public AudioEffect
{
public:
PitchNamesProcessor ();
tresult PLUGIN_API initialize (FUnknown* context) SMTG_OVERRIDE;
tresult PLUGIN_API process (ProcessData& data) SMTG_OVERRIDE;
static FUnknown* createInstance (void*) { return (IAudioProcessor*)new PitchNamesProcessor (); }
static FUID cid;
};
}
} // namespaces
@@ -0,0 +1,246 @@
//-----------------------------------------------------------------------------
// Project : VST SDK
//
// Category : Examples
// Filename : public.sdk/samples/vst/pitchnames/source/pitchnamesdatabrowsersource.cpp
// Created by : Steinberg, 12/2010
// Description :
//
//-----------------------------------------------------------------------------
// This file is part of a Steinberg SDK. It is subject to the license terms
// in the LICENSE file found in the top-level directory of this distribution
// and at www.steinberg.net/sdklicenses.
// No part of the SDK, including this file, may be copied, modified, propagated,
// or distributed except according to the terms contained in the LICENSE file.
//-----------------------------------------------------------------------------
#include "pitchnamesdatabrowsersource.h"
#include "public.sdk/source/vst/utility/stringconvert.h"
#include "pluginterfaces/base/ustring.h"
using namespace Steinberg;
using namespace Steinberg::Vst;
namespace VSTGUI {
//-----------------------------------------------------------------------------
PitchNamesDataBrowserSource::PitchNamesDataBrowserSource (EditControllerEx1* editController,
Steinberg::Vst::UnitID unitID)
: pitchnames (nullptr)
{
UnitInfo info {0};
int32_t unitCount = editController->getUnitCount ();
for (int32_t i = 0; i < unitCount; i++)
{
editController->getUnitInfo (i, info);
if (info.id == unitID)
break;
}
if (info.id == unitID && info.programListId != kNoProgramListId)
{
if (editController->hasProgramPitchNames (info.programListId, 0) == kResultTrue)
{
pitchnames = FCast<ProgramListWithPitchNames> (
editController->getProgramList (info.programListId));
}
}
}
//-----------------------------------------------------------------------------
PitchNamesDataBrowserSource::~PitchNamesDataBrowserSource () {}
//-----------------------------------------------------------------------------
int32_t PitchNamesDataBrowserSource::dbGetNumRows (CDataBrowser* /*browser*/)
{
if (pitchnames)
return 128;
return 0;
}
//-----------------------------------------------------------------------------
int32_t PitchNamesDataBrowserSource::dbGetNumColumns (CDataBrowser* /*browser*/) { return 2; }
//-----------------------------------------------------------------------------
bool PitchNamesDataBrowserSource::dbGetColumnDescription (int32_t /*index*/, CCoord& /*minWidth*/,
CCoord& /*maxWidth*/, CDataBrowser* /*browser*/)
{
return false;
}
//-----------------------------------------------------------------------------
CCoord PitchNamesDataBrowserSource::dbGetCurrentColumnWidth (int32_t index, CDataBrowser* browser)
{
const CCoord pitchWidth = 40;
if (index == 0)
return pitchWidth;
return browser->getWidth () - pitchWidth;
}
//-----------------------------------------------------------------------------
void PitchNamesDataBrowserSource::dbSetCurrentColumnWidth (int32_t /*index*/, const CCoord& /*width*/,
CDataBrowser* /*browser*/)
{
}
//-----------------------------------------------------------------------------
CCoord PitchNamesDataBrowserSource::dbGetRowHeight (CDataBrowser* /*browser*/) { return 18; }
//-----------------------------------------------------------------------------
bool PitchNamesDataBrowserSource::dbGetLineWidthAndColor (CCoord& width, CColor& color,
CDataBrowser* /*browser*/)
{
width = 1.;
color = kGreyCColor;
return true;
}
//-----------------------------------------------------------------------------
void PitchNamesDataBrowserSource::dbDrawHeader (CDrawContext* context, const CRect& size,
int32_t column, int32_t /*flags*/,
CDataBrowser* /*browser*/)
{
context->setDrawMode (kAliasing);
context->setFillColor (kGreyCColor);
context->drawRect (size, kDrawFilled);
std::string name;
switch (column)
{
case 0: name = "Note"; break;
case 1: name = "Pitch Name"; break;
}
context->setFont (kNormalFont);
context->setFontColor (kBlackCColor);
context->drawString (name.data (), size);
}
//-----------------------------------------------------------------------------
void PitchNamesDataBrowserSource::getPitchName (int16_t pitch, std::string& name)
{
String128 pitchName;
if (pitchnames->getPitchName (0, pitch, pitchName) == kResultTrue)
{
name = Vst::StringConvert::convert (pitchName);
}
}
//-----------------------------------------------------------------------------
void PitchNamesDataBrowserSource::dbDrawCell (CDrawContext* context, const CRect& size, int32_t row,
int32_t column, int32_t flags, CDataBrowser* browser)
{
if (pitchnames == nullptr)
return;
if (flags & kRowSelected)
{
CFrame* frame = browser->getFrame ();
CColor focusColor (255, 0, 0, 100);
if (frame && frame->focusDrawingEnabled ())
focusColor = frame->getFocusColor ();
focusColor.alpha /= 2;
context->setFillColor (focusColor);
context->drawRect (size, kDrawFilled);
}
std::string cellValue;
switch (column)
{
case 0:
{
static const char* noteNames[] = {"C", "C#", "D", "D#", "E", "F",
"F#", "G", "G#", "A", "A#", "B"};
int32_t octave = row / 12;
cellValue = noteNames[row - octave * 12];
cellValue += std::to_string (octave - 2);
break;
}
case 1:
{
getPitchName ((int16_t)row, cellValue);
break;
}
}
CRect cellSize (size);
cellSize.inset (5, 0);
context->setFont (kNormalFontSmall);
context->setFontColor (kBlackCColor);
context->drawString (cellValue.data (), cellSize, kLeftText);
}
//-----------------------------------------------------------------------------
CMouseEventResult PitchNamesDataBrowserSource::dbOnMouseDown (const CPoint& /*where*/,
const CButtonState& buttons,
int32_t row, int32_t column,
CDataBrowser* browser)
{
if (buttons.isLeftButton () && buttons.isDoubleClick () && column == 1)
{
std::string pitchName;
getPitchName ((int16_t)row, pitchName);
browser->beginTextEdit (CDataBrowser::Cell (row, column), pitchName.data ());
}
return kMouseDownEventHandledButDontNeedMovedOrUpEvents;
}
//-----------------------------------------------------------------------------
CMouseEventResult PitchNamesDataBrowserSource::dbOnMouseMoved (const CPoint& /*where*/,
const CButtonState& /*buttons*/,
int32_t /*row*/, int32_t /*column*/,
CDataBrowser* /*browser*/)
{
return kMouseEventNotHandled;
}
//-----------------------------------------------------------------------------
CMouseEventResult PitchNamesDataBrowserSource::dbOnMouseUp (const CPoint& /*where*/,
const CButtonState& /*buttons*/,
int32_t /*row*/, int32_t /*column*/,
CDataBrowser* /*browser*/)
{
return kMouseEventNotHandled;
}
//-----------------------------------------------------------------------------
void PitchNamesDataBrowserSource::dbSelectionChanged (CDataBrowser* /*browser*/) {}
//-----------------------------------------------------------------------------
void PitchNamesDataBrowserSource::dbCellTextChanged (int32_t row, int32_t /*column*/,
UTF8StringPtr newText, CDataBrowser* /*browser*/)
{
if (pitchnames)
{
UString128 str (newText);
if (str.getLength () == 0)
pitchnames->removePitchName (0, (int16)row);
else
pitchnames->setPitchName (0, (int16)row, str);
}
}
//-----------------------------------------------------------------------------
void PitchNamesDataBrowserSource::dbCellSetupTextEdit (int32_t /*row*/, int32_t /*column*/,
CTextEdit* textEditControl,
CDataBrowser* /*browser*/)
{
textEditControl->setBackColor (kWhiteCColor);
textEditControl->setFont (kNormalFontSmall);
textEditControl->setFontColor (kRedCColor);
textEditControl->setTextInset (CPoint (5, 0));
textEditControl->setHoriAlign (kLeftText);
}
//-----------------------------------------------------------------------------
int32_t PitchNamesDataBrowserSource::dbOnKeyDown (const VstKeyCode& key, CDataBrowser* browser)
{
if (key.virt == VKEY_RETURN && browser->getSelectedRow () != CDataBrowser::kNoSelection)
{
std::string pitchName;
getPitchName ((int16_t)browser->getSelectedRow (), pitchName);
browser->beginTextEdit (CDataBrowser::Cell (browser->getSelectedRow (), 1), pitchName.data ());
return 1;
}
return -1;
}
} // namespace
@@ -0,0 +1,70 @@
//-----------------------------------------------------------------------------
// Project : VST SDK
//
// Category : Examples
// Filename : public.sdk/samples/vst/pitchnames/source/pitchnamesdatabrowsersource.h
// Created by : Steinberg, 12/2010
// Description :
//
//-----------------------------------------------------------------------------
// This file is part of a Steinberg SDK. It is subject to the license terms
// in the LICENSE file found in the top-level directory of this distribution
// and at www.steinberg.net/sdklicenses.
// No part of the SDK, including this file, may be copied, modified, propagated,
// or distributed except according to the terms contained in the LICENSE file.
//-----------------------------------------------------------------------------
#pragma once
#include "public.sdk/source/vst/vsteditcontroller.h"
#include "vstgui/vstgui.h"
#include <string>
namespace VSTGUI {
//-----------------------------------------------------------------------------
class PitchNamesDataBrowserSource : public CBaseObject, public DataBrowserDelegateAdapter
{
public:
PitchNamesDataBrowserSource (Steinberg::Vst::EditControllerEx1* editController,
Steinberg::Vst::UnitID unitID);
~PitchNamesDataBrowserSource ();
int32_t dbGetNumRows (CDataBrowser* browser) SMTG_OVERRIDE;
int32_t dbGetNumColumns (CDataBrowser* browser) SMTG_OVERRIDE;
bool dbGetColumnDescription (int32_t index, CCoord& minWidth, CCoord& maxWidth,
CDataBrowser* browser) SMTG_OVERRIDE;
CCoord dbGetCurrentColumnWidth (int32_t index, CDataBrowser* browser) SMTG_OVERRIDE;
void dbSetCurrentColumnWidth (int32_t index, const CCoord& width,
CDataBrowser* browser) SMTG_OVERRIDE;
CCoord dbGetRowHeight (CDataBrowser* browser) SMTG_OVERRIDE;
bool dbGetLineWidthAndColor (CCoord& width, CColor& color, CDataBrowser* browser) SMTG_OVERRIDE;
void dbDrawHeader (CDrawContext* context, const CRect& size, int32_t column, int32_t flags,
CDataBrowser* browser) SMTG_OVERRIDE;
void dbDrawCell (CDrawContext* context, const CRect& size, int32_t row, int32_t column,
int32_t flags, CDataBrowser* browser) SMTG_OVERRIDE;
CMouseEventResult dbOnMouseDown (const CPoint& where, const CButtonState& buttons, int32_t row,
int32_t column, CDataBrowser* browser) SMTG_OVERRIDE;
CMouseEventResult dbOnMouseMoved (const CPoint& where, const CButtonState& buttons, int32_t row,
int32_t column, CDataBrowser* browser) SMTG_OVERRIDE;
CMouseEventResult dbOnMouseUp (const CPoint& where, const CButtonState& buttons, int32_t row,
int32_t column, CDataBrowser* browser) SMTG_OVERRIDE;
void dbSelectionChanged (CDataBrowser* browser) SMTG_OVERRIDE;
void dbCellTextChanged (int32_t row, int32_t column, UTF8StringPtr newText,
CDataBrowser* browser) SMTG_OVERRIDE;
void dbCellSetupTextEdit (int32_t row, int32_t column, CTextEdit* textEditControl,
CDataBrowser* browser) SMTG_OVERRIDE;
int32_t dbOnKeyDown (const VstKeyCode& key, CDataBrowser* browser) SMTG_OVERRIDE;
protected:
void getPitchName (int16_t pitch, std::string& name);
Steinberg::Vst::ProgramListWithPitchNames* pitchnames;
};
} // namespace
@@ -0,0 +1,35 @@
//------------------------------------------------------------------------
// Project : VST SDK
//
// Category : Examples
// Filename : public.sdk/samples/vst/pitchnames/source/version.h
// Created by : Steinberg, 12/2010
// Description : Example of handle the versioning and copyright info of pitchnames plug-in
// used for the resources (RC file for example)
//
//-----------------------------------------------------------------------------
// This file is part of a Steinberg SDK. It is subject to the license terms
// in the LICENSE file found in the top-level directory of this distribution
// and at www.steinberg.net/sdklicenses.
// No part of the SDK, including this file, may be copied, modified, propagated,
// or distributed except according to the terms contained in the LICENSE file.
//-----------------------------------------------------------------------------
#pragma once
#include "pluginterfaces/base/fplatform.h"
// Plain project version file generated by cmake
#include "projectversion.h"
#define stringOriginalFilename "PitchNames.vst3"
#if SMTG_PLATFORM_64
#define stringFileDescription "PitchNames VST3-SDK (64Bit)"
#else
#define stringFileDescription "PitchNames VST3-SDK"
#endif
#define stringCompanyWeb "http://www.steinberg.net"
#define stringCompanyEmail "mailto:info@steinberg.de"
#define stringCompanyName "Steinberg Media Technologies"
#define stringLegalCopyright "© 2025 Steinberg Media Technologies"
#define stringLegalTrademarks "VST is a trademark of Steinberg Media Technologies GmbH"