# HG changeset patch
# User Chris Cannam
# Date 1276253085 -3600
# Node ID e621e794011fb24f3d14971c5d55a6806ffded45
# Parent 0d2126c323093aa377ee7936d5ff4d80804702c1
* VST build fixes
diff -r 0d2126c32309 -r e621e794011f Devuvuzelator.vcproj
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Devuvuzelator.vcproj Fri Jun 11 11:44:45 2010 +0100
@@ -0,0 +1,229 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r 0d2126c32309 -r e621e794011f devuvuzelator-vst.cpp
--- a/devuvuzelator-vst.cpp Fri Jun 11 10:31:29 2010 +0100
+++ b/devuvuzelator-vst.cpp Fri Jun 11 11:44:45 2010 +0100
@@ -1,10 +1,16 @@
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
-#include
+#define _USE_MATH_DEFINES
+
#include
#include
+#include
+#include
-#include
+#include "public.sdk/source/vst2.x/audioeffect.h"
+
+#define snprintf _snprintf
+#define alloca _alloca
#define FFTSIZE 1024
@@ -60,7 +66,7 @@
static void fft(unsigned int n, bool inverse,
double *ri, double *ii, double *ro, double *io);
- int m_sampleRate;
+ float m_sampleRate;
float *m_input;
float *m_output;
@@ -68,7 +74,7 @@
float m_high;
float m_fundamental;
float m_bandwidth;
- float m_harmonics;
+ int m_harmonics;
float m_reduction;
const int m_fftsize;
@@ -105,9 +111,10 @@
case 1: return (m_high + 80) / 80;
case 2: return (m_fundamental - 110) / 440;
case 3: return (m_bandwidth - 20) / 80;
- case 4: return (m_harmonics / 6.0);
+ case 4: return (m_harmonics / 6.f);
case 5: return m_reduction / 20;
}
+ return 0;
}
// NB! The max name length for VST parameter names, labels
@@ -132,16 +139,14 @@
void
Devuvuzelator::getParameterDisplay(VstInt32 index, char *label)
{
- float *params[NumParams] = {
- m_low,
- m_high,
- m_fundamental,
- m_bandwidth,
- m_harmonics,
- m_reduction,
- };
-
- snprintf(label, kVstMaxParamStrLen, "%f", *params[index]);
+ switch (index) {
+ case 0: snprintf(label, kVstMaxParamStrLen, "%f", m_low); break;
+ case 1: snprintf(label, kVstMaxParamStrLen, "%f", m_high); break;
+ case 2: snprintf(label, kVstMaxParamStrLen, "%f", m_fundamental); break;
+ case 3: snprintf(label, kVstMaxParamStrLen, "%f", m_bandwidth); break;
+ case 4: snprintf(label, kVstMaxParamStrLen, "%d", m_harmonics); break;
+ case 5: snprintf(label, kVstMaxParamStrLen, "%f", m_reduction); break;
+ }
}
void
@@ -188,7 +193,7 @@
m_harmonics = 3;
m_reduction = 10;
- setUniqueID("qmvz");
+ setUniqueID('qmvz');
setNumInputs(1);
setNumOutputs(1);
canProcessReplacing(true);
@@ -226,8 +231,9 @@
int ii = 0;
int oi = 0;
+ const int sc = sampleCount;
- while (ii < sampleCount) {
+ while (ii < sc) {
m_output[oi++] = m_outacc[m_read++] / 1.5f;
diff -r 0d2126c32309 -r e621e794011f devuvuzelator.cpp
--- a/devuvuzelator.cpp Fri Jun 11 10:31:29 2010 +0100
+++ b/devuvuzelator.cpp Fri Jun 11 11:44:45 2010 +0100
@@ -11,28 +11,10 @@
mags[i] = sqrt(m_real[i] * m_real[i] + m_imag[i] * m_imag[i]);
}
- double low = -35;
- double high = -20;
+ double lowfun = m_fundamental - m_bandwidth/2;
+ double highfun = m_fundamental + m_bandwidth/2;
- if (m_low) low = *m_low;
- if (m_high) high = *m_high;
-
- int harmonics = 3;
- if (m_harmonics) harmonics = int(*m_harmonics + 0.5);
-
- double fun = 200;
- if (m_fundamental) fun = *m_fundamental;
-
- double bw = 40;
- if (m_bandwidth) bw = *m_bandwidth;
-
- double lowfun = fun - bw/2;
- double highfun = fun + bw/2;
-
- double reduction = 10;
- if (m_reduction) reduction = *m_reduction;
-
- for (int h = 1; h <= harmonics; ++h) {
+ for (int h = 1; h <= m_harmonics; ++h) {
double lowfreq = lowfun * h;
double highfreq = highfun * h;
@@ -47,8 +29,8 @@
// std::cerr << "bin " << i << " freq " << (m_sampleRate * i) / m_fftsize << std::endl;
ratios[i] = 1.0;
double db = 10 * log10(mags[i]);
- if (db > low && db < high) {
- double r = reduction;
+ if (db > m_low && db < m_high) {
+ double r = m_reduction;
ratios[i] = pow(10, -r / 10);
}
}