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,20 @@
cmake_minimum_required(VERSION 3.25.0)
project(smtg-vst3-syncdelay
VERSION ${vstsdk_VERSION}.0
DESCRIPTION "Steinberg VST 3 Sync Delay example"
)
smtg_add_vst3plugin(sync-delay
source/sync.h
source/syncdelaycontroller.cpp
source/syncdelaycontroller.h
source/syncdelayfactory.cpp
source/syncdelayids.h
source/syncdelayprocessor.cpp
source/syncdelayprocessor.h
source/syncdelayversion.h
)
smtg_target_setup_as_vst3_example(sync-delay)
@@ -0,0 +1,18 @@
# Sync Delay
## Introduction
**Sync Delay** is a simple FX plug-in showing how to support [IProcessContextRequirements](https://steinbergmedia.github.io/vst3_dev_portal/pages/Technical+Documentation/Change+History/3.7.0/IProcessContextRequirements.html).
> See also: [Online Documentation](https://steinbergmedia.github.io/vst3_dev_portal/pages/What+is+the+VST+3+SDK/Plug-in+Examples.html#sync-delay).
## 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,45 @@
#include <windows.h>
#include "../source/syncdelayversion.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
@@ -0,0 +1,58 @@
//-----------------------------------------------------------------------------
// Project : VST SDK
//
// Category : Examples
// Filename : public.sdk/samples/vst/syncdelay/source/sync.h
// Created by : Steinberg, 01/2020
// 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 "pluginterfaces/vst/vsttypes.h"
#include <array>
#include <cassert>
//------------------------------------------------------------------------
namespace Steinberg {
namespace Vst {
//------------------------------------------------------------------------
struct SyncEntry
{
double value;
const TChar* title;
};
//------------------------------------------------------------------------
static constexpr std::array<SyncEntry, 18> Synced = {{
{4.000, STR16 ("1/1")},
{2.000, STR16 ("1/2")},
{1.000, STR16 ("1/4")},
{0.500, STR16 ("1/8")},
{0.250, STR16 ("1/16")},
{0.125, STR16 ("1/32")},
{8.000 / 3., STR16 ("1/1 T")},
{4.000 / 3., STR16 ("1/2 T")},
{2.000 / 3., STR16 ("1/4 T")},
{1.000 / 3., STR16 ("1/8 T")},
{0.500 / 3., STR16 ("1/16 T")},
{0.250 / 3., STR16 ("1/32 T")},
{6.000, STR16 ("1/1 D")},
{3.000, STR16 ("1/2 D")},
{1.500, STR16 ("1/4 D")},
{0.750, STR16 ("1/8 D")},
{0.375, STR16 ("1/16 D")},
{0.1875, STR16 ("1/32 D")},
}};
//------------------------------------------------------------------------
} // Vst
} // Steinberg
@@ -0,0 +1,69 @@
//-----------------------------------------------------------------------------
// Project : VST SDK
//
// Category : Examples
// Filename : public.sdk/samples/vst/syncdelay/source/syncdelaycontroller.cpp
// Created by : Steinberg, 01/2020
// 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 "syncdelaycontroller.h"
#include "sync.h"
#include "syncdelayids.h"
#include "base/source/fstreamer.h"
#include "pluginterfaces/base/futils.h"
#include "pluginterfaces/base/ibstream.h"
#include "pluginterfaces/base/ustring.h"
namespace Steinberg {
namespace Vst {
//-----------------------------------------------------------------------------
tresult PLUGIN_API SyncDelayController::initialize (FUnknown* context)
{
auto result = EditController::initialize (context);
if (result == kResultTrue)
{
auto delayParam = new StringListParameter (STR16 ("Delay"), kDelayId, nullptr);
for (const auto& entry : Synced)
delayParam->appendString (entry.title);
parameters.addParameter (delayParam); // parameters takes ownership of delayParam
parameters.addParameter (STR16 ("Bypass"), nullptr, 1, 0,
ParameterInfo::kCanAutomate | ParameterInfo::kIsBypass, kBypassId);
}
return kResultTrue;
}
//------------------------------------------------------------------------
tresult PLUGIN_API SyncDelayController::setComponentState (IBStream* state)
{
if (!state)
return kResultFalse;
IBStreamer streamer (state, kLittleEndian);
uint32 savedDelay = 0;
if (streamer.readInt32u (savedDelay) == false)
return kResultFalse;
int32 savedBypassState = 0;
if (streamer.readInt32 (savedBypassState) == false)
return kResultFalse;
setParamNormalized (kDelayId, ToNormalized<ParamValue> (savedDelay, static_cast<int32> (Synced.size () - 1)));
setParamNormalized (kBypassId, savedBypassState ? 1 : 0);
return kResultOk;
}
//------------------------------------------------------------------------
} // namespace Vst
} // namespace Steinberg
@@ -0,0 +1,51 @@
//-----------------------------------------------------------------------------
// Project : VST SDK
//
// Category : Examples
// Filename : public.sdk/samples/vst/syncdelay/source/syncdelaycontroller.h
// Created by : Steinberg, 01/2020
// 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 "sync.h"
#include "public.sdk/source/vst/vsteditcontroller.h"
namespace Steinberg {
namespace Vst {
//-----------------------------------------------------------------------------
class SyncDelayController : public EditController
{
public:
//------------------------------------------------------------------------
// create function required for plug-in factory,
// it will be called to create new instances of this controller
//------------------------------------------------------------------------
static FUnknown* createInstance (void*)
{
return static_cast<IEditController*> (new SyncDelayController ());
}
//---from IPluginBase--------
tresult PLUGIN_API initialize (FUnknown* context) SMTG_OVERRIDE;
//---from EditController-----
tresult PLUGIN_API setComponentState (IBStream* state) SMTG_OVERRIDE;
//---Interface---------
OBJ_METHODS (SyncDelayController, EditController)
REFCOUNT_METHODS (EditController)
};
//------------------------------------------------------------------------
} // namespace Vst
} // namespace Steinberg
@@ -0,0 +1,38 @@
//-----------------------------------------------------------------------------
// Project : VST SDK
//
// Category : Examples
// Filename : public.sdk/samples/vst/syncdelay/source/syncdelayfactory.cpp
// Created by : Steinberg, 01/2020
// 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 "syncdelaycontroller.h"
#include "syncdelayids.h"
#include "syncdelayprocessor.h"
#include "syncdelayversion.h"
#include "public.sdk/source/main/pluginfactory.h"
#define stringPluginName "SyncDelay"
BEGIN_FACTORY_DEF (stringCompanyName, stringCompanyWeb, stringCompanyEmail)
//---First plug-in included in this factory-------
// its kVstAudioEffectClass component
DEF_CLASS2 (INLINE_UID_FROM_FUID (Steinberg::Vst::SyncDelayProcessorUID),
PClassInfo::kManyInstances, kVstAudioEffectClass, stringPluginName, Vst::kDistributable,
"Fx|Delay", FULL_VERSION_STR, kVstVersionString,
Steinberg::Vst::SyncDelayProcessor::createInstance)
DEF_CLASS2 (INLINE_UID_FROM_FUID (Steinberg::Vst::SyncDelayControllerUID),
PClassInfo::kManyInstances, kVstComponentControllerClass, stringPluginName "Controller",
0, "", FULL_VERSION_STR, kVstVersionString,
Steinberg::Vst::SyncDelayController::createInstance)
END_FACTORY
@@ -0,0 +1,35 @@
//-----------------------------------------------------------------------------
// Project : VST SDK
//
// Category : Examples
// Filename : public.sdk/samples/vst/syncdelay/source/syncdelayids.h
// Created by : Steinberg, 01/2020
// 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
namespace Steinberg {
namespace Vst {
// parameter tags
enum
{
kDelayId = 100,
kBypassId = 101
};
// unique class ids
static const FUID SyncDelayProcessorUID (0x73088025, 0xDFC14D03, 0xACFEE5B5, 0x0D2C4356);
static const FUID SyncDelayControllerUID (0x2B00D28A, 0x0A1F4A87, 0xB65DD9A1, 0xB315804B);
//------------------------------------------------------------------------
} // namespace Vst
} // namespace Steinberg
@@ -0,0 +1,258 @@
//-----------------------------------------------------------------------------
// Project : VST SDK
//
// Category : Examples
// Filename : public.sdk/samples/vst/syncdelay/source/syncdelayprocessor.cpp
// Created by : Steinberg, 01/2020
// 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 "syncdelayprocessor.h"
#include "sync.h"
#include "syncdelayids.h"
#include "base/source/fstreamer.h"
#include "pluginterfaces/base/futils.h"
#include "pluginterfaces/base/ibstream.h"
#include "pluginterfaces/base/ustring.h"
#include "pluginterfaces/vst/ivstparameterchanges.h"
#include "pluginterfaces/vst/ivstprocesscontext.h"
#include <algorithm>
#include <cmath>
#include <cstdlib>
namespace Steinberg {
namespace Vst {
static constexpr auto maxDelaySeconds = 5;
//-----------------------------------------------------------------------------
SyncDelayProcessor::SyncDelayProcessor ()
{
setControllerClass (SyncDelayControllerUID);
processContextRequirements.needTempo ();
}
//-----------------------------------------------------------------------------
tresult PLUGIN_API SyncDelayProcessor::initialize (FUnknown* context)
{
auto result = AudioEffect::initialize (context);
if (result == kResultTrue)
{
addAudioInput (STR16 ("AudioInput"), SpeakerArr::kStereo);
addAudioOutput (STR16 ("AudioOutput"), SpeakerArr::kStereo);
mNumChannels = 2;
}
return result;
}
//-----------------------------------------------------------------------------
tresult PLUGIN_API SyncDelayProcessor::setBusArrangements (SpeakerArrangement* inputs, int32 numIns,
SpeakerArrangement* outputs,
int32 numOuts)
{
// we only support one in and output bus and these busses must have the same number of channels
if (numIns == 1 && numOuts == 1 && inputs[0] == outputs[0])
{
tresult res = AudioEffect::setBusArrangements (inputs, numIns, outputs, numOuts);
if (res == kResultOk)
mNumChannels = SpeakerArr::getChannelCount (outputs[0]);
return res;
}
return kResultFalse;
}
//-----------------------------------------------------------------------------
tresult PLUGIN_API SyncDelayProcessor::setActive (TBool state)
{
if (mBuffer)
{
for (int32 channel = 0; channel < mNumChannels; channel++)
{
std::free (mBuffer[channel]);
}
std::free (mBuffer);
mBuffer = nullptr;
}
if (state)
{
mBuffer = static_cast<float**> (std::malloc (mNumChannels * sizeof (float*)));
if (mBuffer)
{
// use a maximum of 5 seconds delay time
mBufferSizeInSamples =
static_cast<uint32> (std::ceil (processSetup.sampleRate) * maxDelaySeconds);
auto size = static_cast<size_t> (mBufferSizeInSamples * sizeof (float));
for (int32 channel = 0; channel < mNumChannels; channel++)
{
mBuffer[channel] = static_cast<float*> (std::malloc (size));
}
resetDelay ();
}
mDelayIndex = FromNormalized<ParamValue> (0, static_cast<int32> (Synced.size () - 1));
mBypassProcessor.setup (*this, processSetup, 0);
}
else
{
mBypassProcessor.reset ();
}
return AudioEffect::setActive (state);
}
//------------------------------------------------------------------------
void SyncDelayProcessor::calculateDelay ()
{
mDelayInSamples =
static_cast<uint32> ((60. / mTempo) * Synced[mDelayIndex].value * processSetup.sampleRate);
mDelayInSamples = Bound (uint32 (1), mBufferSizeInSamples, mDelayInSamples);
}
//------------------------------------------------------------------------
void SyncDelayProcessor::doParameterChanges (IParameterChanges& changes)
{
auto numParamsChanged = changes.getParameterCount ();
for (int32 index = 0; index < numParamsChanged; index++)
{
if (auto queue = changes.getParameterData (index))
{
ParamValue value;
int32 sampleOffset;
auto numPoints = queue->getPointCount ();
switch (queue->getParameterId ())
{
case kDelayId:
{
if (queue->getPoint (numPoints - 1, sampleOffset, value) == kResultTrue)
{
mDelayIndex = FromNormalized<ParamValue> (
value, static_cast<int32> (Synced.size () - 1));
}
break;
}
case kBypassId:
{
if (queue->getPoint (numPoints - 1, sampleOffset, value) == kResultTrue)
{
mBypassProcessor.setActive (value > 0.5);
}
break;
}
}
}
}
}
//-----------------------------------------------------------------------------
bool SyncDelayProcessor::resetDelay ()
{
if (!mBuffer)
return false;
auto size = static_cast<size_t> (mBufferSizeInSamples * sizeof (float));
for (int32 channel = 0; channel < mNumChannels; channel++)
{
if (mBuffer[channel])
memset (mBuffer[channel], 0, size);
}
mBufferPos = 0;
return true;
}
//-----------------------------------------------------------------------------
tresult PLUGIN_API SyncDelayProcessor::setProcessing (TBool state)
{
if (state)
{
resetDelay ();
}
return kResultOk;
}
//-----------------------------------------------------------------------------
tresult PLUGIN_API SyncDelayProcessor::process (ProcessData& data)
{
if (data.processContext && data.processContext->state & ProcessContext::kTempoValid)
{
if (data.processContext->tempo != mTempo)
{
mTempo = data.processContext->tempo;
}
}
if (data.inputParameterChanges)
{
doParameterChanges (*data.inputParameterChanges);
}
if (mBypassProcessor.isActive ())
{
mBypassProcessor.process (data);
}
else if (data.numSamples > 0)
{
calculateDelay ();
for (int32 channel = 0; channel < mNumChannels; channel++)
{
auto inputChannel = data.inputs[0].channelBuffers32[channel];
auto outputChannel = data.outputs[0].channelBuffers32[channel];
auto tempBufferPos = mBufferPos;
for (int32 sampleIndex = 0; sampleIndex < data.numSamples; sampleIndex++)
{
auto sampleValue = inputChannel[sampleIndex];
outputChannel[sampleIndex] = mBuffer[channel][tempBufferPos];
mBuffer[channel][tempBufferPos] = sampleValue;
tempBufferPos++;
if (tempBufferPos >= mDelayInSamples)
tempBufferPos = 0;
}
}
mBufferPos += data.numSamples;
while (mDelayInSamples && mBufferPos >= mDelayInSamples)
mBufferPos -= mDelayInSamples;
}
return kResultTrue;
}
//------------------------------------------------------------------------
tresult PLUGIN_API SyncDelayProcessor::setState (IBStream* state)
{
if (!state)
return kResultFalse;
IBStreamer streamer (state, kLittleEndian);
uint32 savedDelayIndex = 0;
if (streamer.readInt32u (savedDelayIndex) == false)
return kResultFalse;
int32 savedBypassState = 0;
if (streamer.readInt32 (savedBypassState) == false)
return kResultFalse;
mDelayIndex = savedDelayIndex;
mBypassProcessor.setActive (savedBypassState > 0);
return kResultOk;
}
//------------------------------------------------------------------------
tresult PLUGIN_API SyncDelayProcessor::getState (IBStream* state)
{
IBStreamer streamer (state, kLittleEndian);
streamer.writeInt32u (mDelayIndex);
streamer.writeInt32 (mBypassProcessor.isActive () ? 1 : 0);
return kResultOk;
}
//------------------------------------------------------------------------
} // namespace Vst
} // namespace Steinberg
@@ -0,0 +1,67 @@
//-----------------------------------------------------------------------------
// Project : VST SDK
//
// Category : Examples
// Filename : public.sdk/samples/vst/syncdelay/source/syncdelayprocessor.h
// Created by : Steinberg, 01/2020
// 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/vstaudioeffect.h"
#include "public.sdk/source/vst/vstbypassprocessor.h"
namespace Steinberg {
namespace Vst {
//-----------------------------------------------------------------------------
class SyncDelayProcessor : public AudioEffect
{
public:
SyncDelayProcessor ();
tresult PLUGIN_API initialize (FUnknown* context) SMTG_OVERRIDE;
tresult PLUGIN_API setBusArrangements (SpeakerArrangement* inputs, int32 numIns,
SpeakerArrangement* outputs,
int32 numOuts) SMTG_OVERRIDE;
tresult PLUGIN_API setActive (TBool state) SMTG_OVERRIDE;
tresult PLUGIN_API setProcessing (TBool state) SMTG_OVERRIDE;
tresult PLUGIN_API process (ProcessData& data) SMTG_OVERRIDE;
//------------------------------------------------------------------------
tresult PLUGIN_API setState (IBStream* state) SMTG_OVERRIDE;
tresult PLUGIN_API getState (IBStream* state) SMTG_OVERRIDE;
static FUnknown* createInstance (void*)
{
return static_cast<IAudioProcessor*> (new SyncDelayProcessor ());
}
protected:
void doParameterChanges (IParameterChanges& changes);
void calculateDelay ();
bool resetDelay ();
BypassProcessor<Vst::Sample32> mBypassProcessor;
uint32 mDelayIndex {0};
uint32 mDelayInSamples {1};
uint32 mBufferSizeInSamples {0};
double mTempo {120};
float** mBuffer {nullptr};
uint32 mBufferPos {0};
int32 mNumChannels {0};
};
//------------------------------------------------------------------------
} // namespace Vst
} // namespace Steinberg
@@ -0,0 +1,35 @@
//------------------------------------------------------------------------
// Project : VST SDK
//
// Category : Examples
// Filename : public.sdk/samples/vst/syncdelay/source/syncdelayversion.h
// Created by : Steinberg, 01/2020
// Description : Example of handle the versioning and copyright info of syncdelay plugin
// 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 "syncdelay.vst3"
#if SMTG_PLATFORM_64
#define stringFileDescription "SyncDelay VST3-SDK (64Bit)"
#else
#define stringFileDescription "SyncDelay 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"