Initial release
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
|
||||
if(NOT SMTG_ENABLE_VSTGUI_SUPPORT)
|
||||
return()
|
||||
endif()
|
||||
|
||||
cmake_minimum_required(VERSION 3.25.0)
|
||||
|
||||
project(smtg-vst3-pitchnames
|
||||
VERSION ${vstsdk_VERSION}.0
|
||||
DESCRIPTION "Steinberg VST 3 Pitch Names example"
|
||||
)
|
||||
|
||||
smtg_add_vst3plugin(pitch-names
|
||||
source/factory.cpp
|
||||
source/pitchnames.cpp
|
||||
source/pitchnames.h
|
||||
source/pitchnamesdatabrowsersource.cpp
|
||||
source/pitchnamesdatabrowsersource.h
|
||||
source/version.h
|
||||
)
|
||||
|
||||
target_link_libraries(pitch-names
|
||||
PRIVATE
|
||||
vstgui_support
|
||||
)
|
||||
|
||||
smtg_target_setup_as_vst3_example(pitch-names)
|
||||
@@ -0,0 +1,18 @@
|
||||
# PitchNames
|
||||
|
||||
## Introduction
|
||||
|
||||
**PitchNames** is a simple Instrument showing [PitchNames](https://steinbergmedia.github.io/vst3_dev_portal/pages/Technical+Documentation/Presets+Program+Lists/Index.html?highlight=PitchNames#pitch-names) support.
|
||||
|
||||
> See also: [Online Documentation](https://steinbergmedia.github.io/vst3_dev_portal/pages/What+is+the+VST+3+SDK/Plug-in+Examples.html#pitchnames).
|
||||
|
||||
## Getting Started
|
||||
|
||||
This plug-in is part of the VST 3 SDK package. It is created with the VST 3 SDK root project.
|
||||
|
||||
> See the top-level README of the VST 3 SDK: https://github.com/steinbergmedia/vst3sdk.git
|
||||
|
||||
## Getting Help
|
||||
|
||||
* Read through the SDK documentation on the **[VST 3 Developer Portal](https://steinbergmedia.github.io/vst3_dev_portal/pages/index.html)**
|
||||
* Ask some real people in the official **[VST 3 Developer Forum](https://forums.steinberg.net/c/developer/103)**
|
||||
@@ -0,0 +1,46 @@
|
||||
#include <windows.h>
|
||||
#include "pluginterfaces/base/fplatform.h"
|
||||
#include "../source/version.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Version
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION MAJOR_VERSION_INT,SUB_VERSION_INT,RELEASE_NUMBER_INT,BUILD_NUMBER_INT
|
||||
PRODUCTVERSION MAJOR_VERSION_INT,SUB_VERSION_INT,RELEASE_NUMBER_INT,BUILD_NUMBER_INT
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x40004L
|
||||
FILETYPE 0x1L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040004e4"
|
||||
BEGIN
|
||||
VALUE "FileVersion", FULL_VERSION_STR
|
||||
VALUE "ProductVersion", FULL_VERSION_STR
|
||||
VALUE "OriginalFilename", stringOriginalFilename
|
||||
VALUE "FileDescription", stringFileDescription
|
||||
VALUE "InternalName", stringFileDescription
|
||||
VALUE "ProductName", stringFileDescription
|
||||
VALUE "CompanyName", stringCompanyName
|
||||
VALUE "LegalCopyright", stringLegalCopyright
|
||||
VALUE "LegalTrademarks", stringLegalTrademarks
|
||||
//VALUE "PrivateBuild", " \0"
|
||||
//VALUE "SpecialBuild", " \0"
|
||||
//VALUE "Comments", " \0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x400, 1252
|
||||
END
|
||||
END
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<vstgui-ui-description version="1">
|
||||
<fonts>
|
||||
</fonts>
|
||||
<colors>
|
||||
<color name="Background" rgba="#414a4eff"/>
|
||||
<color name="Focus" rgba="#6565ffff"/>
|
||||
</colors>
|
||||
<template autosize="left right top bottom " background-color="Background" class="CViewContainer" maxSize="700, 10000" minSize="200, 300" name="PitchNamesEditor" origin="0, 0" size="697, 704" transparent="false">
|
||||
<view auto-drag-scrolling="false" autosize="left right top bottom " background-color="~ WhiteCColor" bordered="false" class="CScrollView" container-size="679, 2432" custom-view-name="PitchNamesDataBrowser" horizontal-scrollbar="false" origin="10, 40" scrollbar-background-color="~ TransparentCColor" scrollbar-frame-color="~ BlackCColor" scrollbar-scroller-color="Background" scrollbar-width="16" size="677, 654" transparent="false" vertical-scrollbar="true"/>
|
||||
<view autosize="left right top " back-color="~ BlackCColor" background-offset="0, 0" class="CTextLabel" default-value="0.5" font="~ NormalFontBig" font-antialias="true" font-color="~ WhiteCColor" frame-color="~ BlackCColor" max-value="1" min-value="0" origin="10, 10" shadow-color="~ RedCColor" size="677, 20" style-3D-in="false" style-3D-out="false" style-no-draw="false" style-no-frame="false" style-no-text="false" style-shadow-text="false" text-alignment="center" text-inset="0, 0" title="VST3 PitchNames Example" transparent="true" wheel-inc-value="0.1"/>
|
||||
</template>
|
||||
<custom>
|
||||
<attributes name="UIViewInspector" windowSize="116, 251, 607, 836"/>
|
||||
<attributes gridsize="10" name="UIEditFrame" uidescPath="/Volumes/maintrunk/maintrunk/public.sdk/samples/vst/pitchnames/resources/pitchnames.uidesc"/>
|
||||
<attributes frame-enable-focus-drawing="true" frame-focus-color="Focus" frame-focus-width="2" name="VST3Editor"/>
|
||||
</custom>
|
||||
<bitmaps/>
|
||||
<control-tags/>
|
||||
</vstgui-ui-description>
|
||||
@@ -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
|
||||
+190
@@ -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
|
||||
Vendored
+246
@@ -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
|
||||
Vendored
+70
@@ -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"
|
||||
Reference in New Issue
Block a user