1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
//-------------------------------------------------------------------------------------------------------
// VST Plug-Ins SDK
// Version 2.4 $Date: 2006/11/13 09:08:27 $
//
// Category : VST 2.x SDK Samples
// Filename : surrounddelay.cpp
// Created by : Steinberg Media Technologies
// Description : Simple Surround Delay plugin with Editor using VSTGUI
//
// � 2006, Steinberg Media Technologies, All Rights Reserved
//-------------------------------------------------------------------------------------------------------
#ifndef __surrounddelay__
#include "surrounddelay.h"
#endif
#ifndef __sdeditor__
#include "editor/sdeditor.h"
#endif
#include <string.h>
#include <stdio.h>
//-------------------------------------------------------------------------------------------------------
AudioEffect* createEffectInstance (audioMasterCallback audioMaster)
{
return new SurroundDelay (audioMaster);
}
//-----------------------------------------------------------------------------
SurroundDelay::SurroundDelay (audioMasterCallback audioMaster)
: ADelay (audioMaster)
, plugInput (0)
, plugOutput (0)
{
// The first buffer is allocated in ADelay's constructor
for (int i = 1; i < MAX_CHANNELS; i++)
{
sBuffers[i] = new float[size];
}
setNumInputs (MAX_CHANNELS);
setNumOutputs (MAX_CHANNELS);
// We initialize the arrangements to default values.
// Nevertheless, the host should modify them via
// appropriate calls to setSpeakerArrangement.
allocateArrangement (&plugInput, MAX_CHANNELS);
plugInput->type = kSpeakerArr51;
allocateArrangement (&plugOutput, MAX_CHANNELS);
plugOutput->type = kSpeakerArr51;
setUniqueID ('SDlE'); // this should be unique, use the Steinberg web page for plugin Id registration
// create the editor
editor = new SDEditor (this);
resume ();
}
//-----------------------------------------------------------------------------
SurroundDelay::~SurroundDelay ()
{
sBuffers[0] = 0;
// We let ~ADelay delete "buffer"...
for (int i = 1; i < MAX_CHANNELS; i++)
{
if (sBuffers[i])
{
delete[] sBuffers[i];
}
sBuffers[i] = 0;
}
deallocateArrangement (&plugInput);
deallocateArrangement (&plugOutput);
}
//------------------------------------------------------------------------
void SurroundDelay::resume ()
{
memset (buffer, 0, size * sizeof (float));
sBuffers[0] = buffer;
for (int i = 1; i < MAX_CHANNELS; i++)
{
memset (sBuffers[i], 0, size * sizeof (float));
}
}
//------------------------------------------------------------------------
bool SurroundDelay::getSpeakerArrangement (VstSpeakerArrangement** pluginInput, VstSpeakerArrangement** pluginOutput)
{
*pluginInput = plugInput;
*pluginOutput = plugOutput;
return true;
}
//------------------------------------------------------------------------
bool SurroundDelay::setSpeakerArrangement (VstSpeakerArrangement* pluginInput,
VstSpeakerArrangement* pluginOutput)
{
if (!pluginOutput || !pluginInput)
return false;
bool result = true;
// This plug-in can act on any speaker arrangement,
// provided that there are the same number of inputs/outputs.
if (pluginInput->numChannels > MAX_CHANNELS)
{
// This plug-in can't have so many channels. So we answer
// false, and we set the input arrangement with the maximum
// number of channels possible
result = false;
allocateArrangement (&plugInput, MAX_CHANNELS);
plugInput->type = kSpeakerArr51;
}
else
{
matchArrangement (&plugInput, pluginInput);
}
if (pluginOutput->numChannels != plugInput->numChannels)
{
// This plug-in only deals with symetric IO configurations...
result = false;
matchArrangement (&plugOutput, plugInput);
}
else
{
matchArrangement (&plugOutput, pluginOutput);
}
return result;
}
//------------------------------------------------------------------------
void SurroundDelay::processReplacing (float** inputs, float** outputs, VstInt32 sampleframes)
{
float* inputs2[1];
float* outputs2[2];
outputs2[1] = NULL;
long cursorTemp = cursor;
for (int i = 0; i < plugInput->numChannels; i++)
{
cursor = cursorTemp;
buffer = sBuffers[i];
inputs2[0] = inputs[i];
outputs2[0] = outputs[i];
ADelay::processReplacing (inputs2, outputs2, sampleframes);
}
buffer = sBuffers[0];
}
//-----------------------------------------------------------------------------
void SurroundDelay::setParameter (VstInt32 index, float value)
{
ADelay::setParameter (index, value);
if (editor)
((AEffGUIEditor*)editor)->setParameter (index, value);
}
|