comparison devuvuzelator-vst.cpp @ 2:e621e794011f

* VST build fixes
author Chris Cannam
date Fri, 11 Jun 2010 11:44:45 +0100
parents 0d2126c32309
children 8b79175c9f02
comparison
equal deleted inserted replaced
1:0d2126c32309 2:e621e794011f
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 2
3 #include <alloca.h> 3 #define _USE_MATH_DEFINES
4
4 #include <iostream> 5 #include <iostream>
5 #include <cmath> 6 #include <cmath>
6 7 #include <cstdio>
7 #include <vst2.x/audioeffect.h> 8 #include <malloc.h>
9
10 #include "public.sdk/source/vst2.x/audioeffect.h"
11
12 #define snprintf _snprintf
13 #define alloca _alloca
8 14
9 #define FFTSIZE 1024 15 #define FFTSIZE 1024
10 16
11 class Devuvuzelator : public AudioEffect 17 class Devuvuzelator : public AudioEffect
12 { 18 {
58 void processSpectralFrame(); 64 void processSpectralFrame();
59 65
60 static void fft(unsigned int n, bool inverse, 66 static void fft(unsigned int n, bool inverse,
61 double *ri, double *ii, double *ro, double *io); 67 double *ri, double *ii, double *ro, double *io);
62 68
63 int m_sampleRate; 69 float m_sampleRate;
64 float *m_input; 70 float *m_input;
65 float *m_output; 71 float *m_output;
66 72
67 float m_low; 73 float m_low;
68 float m_high; 74 float m_high;
69 float m_fundamental; 75 float m_fundamental;
70 float m_bandwidth; 76 float m_bandwidth;
71 float m_harmonics; 77 int m_harmonics;
72 float m_reduction; 78 float m_reduction;
73 79
74 const int m_fftsize; 80 const int m_fftsize;
75 const int m_increment; 81 const int m_increment;
76 int m_fill; 82 int m_fill;
103 switch (index) { 109 switch (index) {
104 case 0: return (m_low + 80) / 80; 110 case 0: return (m_low + 80) / 80;
105 case 1: return (m_high + 80) / 80; 111 case 1: return (m_high + 80) / 80;
106 case 2: return (m_fundamental - 110) / 440; 112 case 2: return (m_fundamental - 110) / 440;
107 case 3: return (m_bandwidth - 20) / 80; 113 case 3: return (m_bandwidth - 20) / 80;
108 case 4: return (m_harmonics / 6.0); 114 case 4: return (m_harmonics / 6.f);
109 case 5: return m_reduction / 20; 115 case 5: return m_reduction / 20;
110 } 116 }
117 return 0;
111 } 118 }
112 119
113 // NB! The max name length for VST parameter names, labels 120 // NB! The max name length for VST parameter names, labels
114 // (i.e. units) and display values (i.e. string renderings of current 121 // (i.e. units) and display values (i.e. string renderings of current
115 // value) is a rather amazing 8 bytes 122 // value) is a rather amazing 8 bytes
130 } 137 }
131 138
132 void 139 void
133 Devuvuzelator::getParameterDisplay(VstInt32 index, char *label) 140 Devuvuzelator::getParameterDisplay(VstInt32 index, char *label)
134 { 141 {
135 float *params[NumParams] = { 142 switch (index) {
136 m_low, 143 case 0: snprintf(label, kVstMaxParamStrLen, "%f", m_low); break;
137 m_high, 144 case 1: snprintf(label, kVstMaxParamStrLen, "%f", m_high); break;
138 m_fundamental, 145 case 2: snprintf(label, kVstMaxParamStrLen, "%f", m_fundamental); break;
139 m_bandwidth, 146 case 3: snprintf(label, kVstMaxParamStrLen, "%f", m_bandwidth); break;
140 m_harmonics, 147 case 4: snprintf(label, kVstMaxParamStrLen, "%d", m_harmonics); break;
141 m_reduction, 148 case 5: snprintf(label, kVstMaxParamStrLen, "%f", m_reduction); break;
142 }; 149 }
143
144 snprintf(label, kVstMaxParamStrLen, "%f", *params[index]);
145 } 150 }
146 151
147 void 152 void
148 Devuvuzelator::getParameterName(VstInt32 index, char *label) 153 Devuvuzelator::getParameterName(VstInt32 index, char *label)
149 { 154 {
186 m_fundamental = 220; 191 m_fundamental = 220;
187 m_bandwidth = 60; 192 m_bandwidth = 60;
188 m_harmonics = 3; 193 m_harmonics = 3;
189 m_reduction = 10; 194 m_reduction = 10;
190 195
191 setUniqueID("qmvz"); 196 setUniqueID('qmvz');
192 setNumInputs(1); 197 setNumInputs(1);
193 setNumOutputs(1); 198 setNumOutputs(1);
194 canProcessReplacing(true); 199 canProcessReplacing(true);
195 canDoubleReplacing(false); 200 canDoubleReplacing(false);
196 201
224 { 229 {
225 if (!m_input || !m_output) return; 230 if (!m_input || !m_output) return;
226 231
227 int ii = 0; 232 int ii = 0;
228 int oi = 0; 233 int oi = 0;
229 234 const int sc = sampleCount;
230 while (ii < sampleCount) { 235
236 while (ii < sc) {
231 237
232 m_output[oi++] = m_outacc[m_read++] / 1.5f; 238 m_output[oi++] = m_outacc[m_read++] / 1.5f;
233 239
234 if (m_fill == m_fftsize) { 240 if (m_fill == m_fftsize) {
235 241