commit d47eb77b031f5fa91d2d061fa7638a54ec917dbd
parent f1c67f0f87d9a16122f937f0355daf65b652da33
Author: fundamental <[email protected]>
Date: Sun, 7 Aug 2011 10:01:01 -0400
Removing REALTYPE
- The original intention of realtype was to allow for changes of processing from
float to double.
- As such, it would likely not work due to varioius implicit assumptions that it
was floating point data.
- With this in mind, it has been removed
Diffstat:
99 files changed, 1184 insertions(+), 1187 deletions(-)
diff --git a/ExternalPrograms/Controller/ControllerUI.fl b/ExternalPrograms/Controller/ControllerUI.fl
@@ -20,7 +20,7 @@ class Pad {: {public Fl_Box}
}
Function {temp_draw()} {} {
code {/*int ox=x(),oy=y(),lx=w(),ly=h(),i,ix,iy,oiy;
-REALTYPE freqx;
+float freqx;
fl_color(FL_BLACK);
fl_rectf(ox,oy,lx,ly);
diff --git a/src/DSP/AnalogFilter.cpp b/src/DSP/AnalogFilter.cpp
@@ -29,8 +29,8 @@
#include "AnalogFilter.h"
AnalogFilter::AnalogFilter(unsigned char Ftype,
- REALTYPE Ffreq,
- REALTYPE Fq,
+ float Ffreq,
+ float Fq,
unsigned char Fstages)
{
stages = Fstages;
@@ -73,11 +73,11 @@ void AnalogFilter::cleanup()
void AnalogFilter::computefiltercoefs()
{
- REALTYPE tmp;
+ float tmp;
bool zerocoefs = false; //this is used if the freq is too high
//do not allow frequencies bigger than samplerate/2
- REALTYPE freq = this->freq;
+ float freq = this->freq;
if(freq > (SAMPLE_RATE / 2 - 500.0)) {
freq = SAMPLE_RATE / 2 - 500.0;
zerocoefs = true;
@@ -87,7 +87,7 @@ void AnalogFilter::computefiltercoefs()
//do not allow bogus Q
if(q < 0.0)
q = 0.0;
- REALTYPE tmpq, tmpgain;
+ float tmpq, tmpgain;
if(stages == 0) {
tmpq = q;
tmpgain = gain;
@@ -98,13 +98,13 @@ void AnalogFilter::computefiltercoefs()
}
//Alias Terms
- REALTYPE *c = coeff.c;
- REALTYPE *d = coeff.d;
+ float *c = coeff.c;
+ float *d = coeff.d;
//General Constants
- const REALTYPE omega = 2 * PI * freq / SAMPLE_RATE;
- const REALTYPE sn = sin(omega), cs = cos(omega);
- REALTYPE alpha, beta;
+ const float omega = 2 * PI * freq / SAMPLE_RATE;
+ const float sn = sin(omega), cs = cos(omega);
+ float alpha, beta;
//most of theese are implementations of
//the "Cookbook formulae for audio EQ" by Robert Bristow-Johnson
@@ -297,11 +297,11 @@ void AnalogFilter::computefiltercoefs()
}
-void AnalogFilter::setfreq(REALTYPE frequency)
+void AnalogFilter::setfreq(float frequency)
{
if(frequency < 0.1)
frequency = 0.1;
- REALTYPE rap = freq / frequency;
+ float rap = freq / frequency;
if(rap < 1.0)
rap = 1.0 / rap;
@@ -324,13 +324,13 @@ void AnalogFilter::setfreq(REALTYPE frequency)
firsttime = false;
}
-void AnalogFilter::setfreq_and_q(REALTYPE frequency, REALTYPE q_)
+void AnalogFilter::setfreq_and_q(float frequency, float q_)
{
q = q_;
setfreq(frequency);
}
-void AnalogFilter::setq(REALTYPE q_)
+void AnalogFilter::setq(float q_)
{
q = q_;
computefiltercoefs();
@@ -342,7 +342,7 @@ void AnalogFilter::settype(int type_)
computefiltercoefs();
}
-void AnalogFilter::setgain(REALTYPE dBgain)
+void AnalogFilter::setgain(float dBgain)
{
gain = dB2rap(dBgain);
computefiltercoefs();
@@ -357,12 +357,12 @@ void AnalogFilter::setstages(int stages_)
computefiltercoefs();
}
-void AnalogFilter::singlefilterout(REALTYPE *smp, fstage &hist,
+void AnalogFilter::singlefilterout(float *smp, fstage &hist,
const Coeff &coeff)
{
if(order == 1) { //First order filter
for(int i = 0; i < SOUND_BUFFER_SIZE; i++) {
- REALTYPE y0 = smp[i]*coeff.c[0] + hist.x1*coeff.c[1]
+ float y0 = smp[i]*coeff.c[0] + hist.x1*coeff.c[1]
+ hist.y1*coeff.d[1];
hist.y1 = y0;
hist.x1 = smp[i];
@@ -371,7 +371,7 @@ void AnalogFilter::singlefilterout(REALTYPE *smp, fstage &hist,
}
if(order == 2) { //Second order filter
for(int i = 0; i < SOUND_BUFFER_SIZE; i++) {
- REALTYPE y0 = smp[i]*coeff.c[0] + hist.x1*coeff.c[1]
+ float y0 = smp[i]*coeff.c[0] + hist.x1*coeff.c[1]
+ hist.x2*coeff.c[2] + hist.y1*coeff.d[1]
+ hist.y2*coeff.d[2];
hist.y2 = hist.y1;
@@ -382,21 +382,21 @@ void AnalogFilter::singlefilterout(REALTYPE *smp, fstage &hist,
}
}
}
-void AnalogFilter::filterout(REALTYPE *smp)
+void AnalogFilter::filterout(float *smp)
{
for(int i = 0; i < stages + 1; i++)
singlefilterout(smp, history[i], coeff);
if(needsinterpolation) {
//Merge Filter at old coeff with new coeff
- REALTYPE *ismp = getTmpBuffer();
- memcpy(ismp, smp, sizeof(REALTYPE) * SOUND_BUFFER_SIZE);
+ float *ismp = getTmpBuffer();
+ memcpy(ismp, smp, sizeof(float) * SOUND_BUFFER_SIZE);
for(int i = 0; i < stages + 1; i++)
singlefilterout(ismp, oldHistory[i], oldCoeff);
for(int i = 0; i < SOUND_BUFFER_SIZE; i++) {
- REALTYPE x = i / (REALTYPE) SOUND_BUFFER_SIZE;
+ float x = i / (float) SOUND_BUFFER_SIZE;
smp[i] = ismp[i] * (1.0 - x) + smp[i] * x;
}
returnTmpBuffer(ismp);
@@ -407,15 +407,15 @@ void AnalogFilter::filterout(REALTYPE *smp)
smp[i] *= outgain;
}
-REALTYPE AnalogFilter::H(REALTYPE freq)
+float AnalogFilter::H(float freq)
{
- REALTYPE fr = freq / SAMPLE_RATE * PI * 2.0;
- REALTYPE x = coeff.c[0], y = 0.0;
+ float fr = freq / SAMPLE_RATE * PI * 2.0;
+ float x = coeff.c[0], y = 0.0;
for(int n = 1; n < 3; n++) {
x += cos(n * fr) * coeff.c[n];
y -= sin(n * fr) * coeff.c[n];
}
- REALTYPE h = x * x + y * y;
+ float h = x * x + y * y;
x = 1.0;
y = 0.0;
for(int n = 1; n < 3; n++) {
diff --git a/src/DSP/AnalogFilter.h b/src/DSP/AnalogFilter.h
@@ -35,44 +35,44 @@ class AnalogFilter:public Filter_
{
public:
AnalogFilter(unsigned char Ftype,
- REALTYPE Ffreq,
- REALTYPE Fq,
+ float Ffreq,
+ float Fq,
unsigned char Fstages);
~AnalogFilter();
- void filterout(REALTYPE *smp);
- void setfreq(REALTYPE frequency);
- void setfreq_and_q(REALTYPE frequency, REALTYPE q_);
- void setq(REALTYPE q_);
+ void filterout(float *smp);
+ void setfreq(float frequency);
+ void setfreq_and_q(float frequency, float q_);
+ void setq(float q_);
void settype(int type_);
- void setgain(REALTYPE dBgain);
+ void setgain(float dBgain);
void setstages(int stages_);
void cleanup();
- REALTYPE H(REALTYPE freq); //Obtains the response for a given frequency
+ float H(float freq); //Obtains the response for a given frequency
private:
struct fstage {
- REALTYPE x1, x2;//Input History
- REALTYPE y1, y2;//Output History
+ float x1, x2;//Input History
+ float y1, y2;//Output History
} history[MAX_FILTER_STAGES + 1], oldHistory[MAX_FILTER_STAGES + 1];
struct Coeff {
- REALTYPE c[3], //Feed Forward
+ float c[3], //Feed Forward
d[3]; //Feed Back
} coeff, oldCoeff;
//old coeffs are used for interpolation when paremeters change quickly
//Apply IIR filter to Samples, with coefficients, and past history
- void singlefilterout(REALTYPE *smp, fstage &hist, const Coeff &coeff);
+ void singlefilterout(float *smp, fstage &hist, const Coeff &coeff);
//Update coeff and order
void computefiltercoefs();
int type; //The type of the filter (LPF1,HPF1,LPF2,HPF2...)
int stages; //how many times the filter is applied (0->1,1->2,etc.)
- REALTYPE freq; //Frequency given in Hz
- REALTYPE q; //Q factor (resonance or Q factor)
- REALTYPE gain; //the gain of the filter (if are shelf/peak) filters
+ float freq; //Frequency given in Hz
+ float q; //Q factor (resonance or Q factor)
+ float gain; //the gain of the filter (if are shelf/peak) filters
int order; //the order of the filter (number of poles)
diff --git a/src/DSP/FFTwrapper.cpp b/src/DSP/FFTwrapper.cpp
@@ -52,7 +52,7 @@ FFTwrapper::~FFTwrapper()
/*
* do the Fast Fourier Transform
*/
-void FFTwrapper::smps2freqs(REALTYPE *smps, FFTFREQS freqs)
+void FFTwrapper::smps2freqs(float *smps, FFTFREQS freqs)
{
for(int i = 0; i < fftsize; i++)
tmpfftdata1[i] = smps[i];
@@ -68,7 +68,7 @@ void FFTwrapper::smps2freqs(REALTYPE *smps, FFTFREQS freqs)
/*
* do the Inverse Fast Fourier Transform
*/
-void FFTwrapper::freqs2smps(FFTFREQS freqs, REALTYPE *smps)
+void FFTwrapper::freqs2smps(FFTFREQS freqs, float *smps)
{
tmpfftdata2[fftsize / 2] = 0.0;
for(int i = 0; i < fftsize / 2; i++) {
@@ -83,8 +83,8 @@ void FFTwrapper::freqs2smps(FFTFREQS freqs, REALTYPE *smps)
void newFFTFREQS(FFTFREQS *f, int size)
{
- f->c = new REALTYPE[size];
- f->s = new REALTYPE[size];
+ f->c = new float[size];
+ f->s = new float[size];
for(int i = 0; i < size; i++) {
f->c[i] = 0.0;
f->s[i] = 0.0;
diff --git a/src/DSP/FFTwrapper.h b/src/DSP/FFTwrapper.h
@@ -41,8 +41,8 @@ class FFTwrapper
/**Convert Samples to Frequencies using Fourier Transform
* @param smps Pointer to Samples to be converted; has length fftsize_
* @param freqs Structure FFTFREQS which stores the frequencies*/
- void smps2freqs(REALTYPE *smps, FFTFREQS freqs);
- void freqs2smps(FFTFREQS freqs, REALTYPE *smps);
+ void smps2freqs(float *smps, FFTFREQS freqs);
+ void freqs2smps(FFTFREQS freqs, float *smps);
private:
int fftsize;
fftw_real *tmpfftdata1, *tmpfftdata2;
diff --git a/src/DSP/Filter.cpp b/src/DSP/Filter.cpp
@@ -57,27 +57,27 @@ Filter::~Filter()
delete (filter);
}
-void Filter::filterout(REALTYPE *smp)
+void Filter::filterout(float *smp)
{
filter->filterout(smp);
}
-void Filter::setfreq(REALTYPE frequency)
+void Filter::setfreq(float frequency)
{
filter->setfreq(frequency);
}
-void Filter::setfreq_and_q(REALTYPE frequency, REALTYPE q_)
+void Filter::setfreq_and_q(float frequency, float q_)
{
filter->setfreq_and_q(frequency, q_);
}
-void Filter::setq(REALTYPE q_)
+void Filter::setq(float q_)
{
filter->setq(q_);
}
-REALTYPE Filter::getrealfreq(REALTYPE freqpitch)
+float Filter::getrealfreq(float freqpitch)
{
if((category == 0) || (category == 2))
return pow(2.0, freqpitch + 9.96578428); //log2(1000)=9.95748
diff --git a/src/DSP/Filter.h b/src/DSP/Filter.h
@@ -36,12 +36,12 @@ class Filter
public:
Filter(FilterParams *pars);
~Filter();
- void filterout(REALTYPE *smp);
- void setfreq(REALTYPE frequency);
- void setfreq_and_q(REALTYPE frequency, REALTYPE q_);
- void setq(REALTYPE q_);
+ void filterout(float *smp);
+ void setfreq(float frequency);
+ void setfreq_and_q(float frequency, float q_);
+ void setq(float q_);
- REALTYPE getrealfreq(REALTYPE freqpitch);
+ float getrealfreq(float freqpitch);
private:
Filter_ *filter;
unsigned char category;
diff --git a/src/DSP/Filter_.h b/src/DSP/Filter_.h
@@ -29,12 +29,12 @@ class Filter_
{
public:
virtual ~Filter_() {}
- virtual void filterout(REALTYPE *smp) = 0;
- virtual void setfreq(REALTYPE frequency) = 0;
- virtual void setfreq_and_q(REALTYPE frequency, REALTYPE q_) = 0;
- virtual void setq(REALTYPE q_) = 0;
- virtual void setgain(REALTYPE dBgain) = 0;
- REALTYPE outgain;
+ virtual void filterout(float *smp) = 0;
+ virtual void setfreq(float frequency) = 0;
+ virtual void setfreq_and_q(float frequency, float q_) = 0;
+ virtual void setq(float q_) = 0;
+ virtual void setgain(float dBgain) = 0;
+ float outgain;
private:
};
diff --git a/src/DSP/FormantFilter.cpp b/src/DSP/FormantFilter.cpp
@@ -84,7 +84,7 @@ void FormantFilter::cleanup()
formant[i]->cleanup();
}
-void FormantFilter::setpos(REALTYPE input)
+void FormantFilter::setpos(float input)
{
int p1, p2;
@@ -104,7 +104,7 @@ void FormantFilter::setpos(REALTYPE input)
oldinput = input;
- REALTYPE pos = fmod(input * sequencestretch, 1.0);
+ float pos = fmod(input * sequencestretch, 1.0);
if(pos < 0.0)
pos += 1.0;
@@ -173,38 +173,38 @@ void FormantFilter::setpos(REALTYPE input)
oldQfactor = Qfactor;
}
-void FormantFilter::setfreq(REALTYPE frequency)
+void FormantFilter::setfreq(float frequency)
{
setpos(frequency);
}
-void FormantFilter::setq(REALTYPE q_)
+void FormantFilter::setq(float q_)
{
Qfactor = q_;
for(int i = 0; i < numformants; i++)
formant[i]->setq(Qfactor * currentformants[i].q);
}
-void FormantFilter::setgain(REALTYPE /*dBgain*/)
+void FormantFilter::setgain(float /*dBgain*/)
{}
-void FormantFilter::setfreq_and_q(REALTYPE frequency, REALTYPE q_)
+void FormantFilter::setfreq_and_q(float frequency, float q_)
{
Qfactor = q_;
setpos(frequency);
}
-void FormantFilter::filterout(REALTYPE *smp)
+void FormantFilter::filterout(float *smp)
{
- REALTYPE *inbuffer = getTmpBuffer();
+ float *inbuffer = getTmpBuffer();
- memcpy(inbuffer, smp, sizeof(REALTYPE) * SOUND_BUFFER_SIZE);
- memset(smp, 0, sizeof(REALTYPE) * SOUND_BUFFER_SIZE);
+ memcpy(inbuffer, smp, sizeof(float) * SOUND_BUFFER_SIZE);
+ memset(smp, 0, sizeof(float) * SOUND_BUFFER_SIZE);
for(int j = 0; j < numformants; j++) {
- REALTYPE *tmpbuf = getTmpBuffer();
+ float *tmpbuf = getTmpBuffer();
for(int i = 0; i < SOUND_BUFFER_SIZE; i++)
tmpbuf[i] = inbuffer[i] * outgain;
formant[j]->filterout(tmpbuf);
diff --git a/src/DSP/FormantFilter.h b/src/DSP/FormantFilter.h
@@ -34,18 +34,18 @@ class FormantFilter:public Filter_
public:
FormantFilter(FilterParams *pars);
~FormantFilter();
- void filterout(REALTYPE *smp);
- void setfreq(REALTYPE frequency);
- void setfreq_and_q(REALTYPE frequency, REALTYPE q_);
- void setq(REALTYPE q_);
- void setgain(REALTYPE dBgain);
+ void filterout(float *smp);
+ void setfreq(float frequency);
+ void setfreq_and_q(float frequency, float q_);
+ void setq(float q_);
+ void setgain(float dBgain);
void cleanup();
private:
AnalogFilter *formant[FF_MAX_FORMANTS];
struct {
- REALTYPE freq, amp, q; //frequency,amplitude,Q
+ float freq, amp, q; //frequency,amplitude,Q
} formantpar[FF_MAX_VOWELS][FF_MAX_FORMANTS],
currentformants[FF_MAX_FORMANTS];
@@ -53,14 +53,14 @@ class FormantFilter:public Filter_
unsigned char nvowel;
} sequence [FF_MAX_SEQUENCE];
- REALTYPE oldformantamp[FF_MAX_FORMANTS];
+ float oldformantamp[FF_MAX_FORMANTS];
int sequencesize, numformants, firsttime;
- REALTYPE oldinput, slowinput;
- REALTYPE Qfactor, formantslowness, oldQfactor;
- REALTYPE vowelclearness, sequencestretch;
+ float oldinput, slowinput;
+ float Qfactor, formantslowness, oldQfactor;
+ float vowelclearness, sequencestretch;
- void setpos(REALTYPE input);
+ void setpos(float input);
};
diff --git a/src/DSP/SVFilter.cpp b/src/DSP/SVFilter.cpp
@@ -29,8 +29,8 @@
#include "SVFilter.h"
SVFilter::SVFilter(unsigned char Ftype,
- REALTYPE Ffreq,
- REALTYPE Fq,
+ float Ffreq,
+ float Fq,
unsigned char Fstages)
{
assert(Ftype<4);
@@ -74,11 +74,11 @@ void SVFilter::computefiltercoefs()
}
-void SVFilter::setfreq(REALTYPE frequency)
+void SVFilter::setfreq(float frequency)
{
if(frequency < 0.1)
frequency = 0.1;
- REALTYPE rap = freq / frequency;
+ float rap = freq / frequency;
if(rap < 1.0)
rap = 1.0 / rap;
@@ -98,13 +98,13 @@ void SVFilter::setfreq(REALTYPE frequency)
firsttime = false;
}
-void SVFilter::setfreq_and_q(REALTYPE frequency, REALTYPE q_)
+void SVFilter::setfreq_and_q(float frequency, float q_)
{
q = q_;
setfreq(frequency);
}
-void SVFilter::setq(REALTYPE q_)
+void SVFilter::setq(float q_)
{
q = q_;
computefiltercoefs();
@@ -116,7 +116,7 @@ void SVFilter::settype(int type_)
computefiltercoefs();
}
-void SVFilter::setgain(REALTYPE dBgain)
+void SVFilter::setgain(float dBgain)
{
gain = dB2rap(dBgain);
computefiltercoefs();
@@ -131,9 +131,9 @@ void SVFilter::setstages(int stages_)
computefiltercoefs();
}
-void SVFilter::singlefilterout(REALTYPE *smp, fstage &x, parameters &par)
+void SVFilter::singlefilterout(float *smp, fstage &x, parameters &par)
{
- REALTYPE *out = NULL;
+ float *out = NULL;
switch(type) {
case 0:
out = &x.low;
@@ -161,20 +161,20 @@ void SVFilter::singlefilterout(REALTYPE *smp, fstage &x, parameters &par)
}
}
-void SVFilter::filterout(REALTYPE *smp)
+void SVFilter::filterout(float *smp)
{
for(int i = 0; i < stages + 1; i++)
singlefilterout(smp, st[i], par);
if(needsinterpolation) {
- REALTYPE *ismp = getTmpBuffer();
- memcpy(ismp, smp, sizeof(REALTYPE) * SOUND_BUFFER_SIZE);
+ float *ismp = getTmpBuffer();
+ memcpy(ismp, smp, sizeof(float) * SOUND_BUFFER_SIZE);
for(int i = 0; i < stages + 1; i++)
singlefilterout(ismp, st[i], ipar);
for(int i = 0; i < SOUND_BUFFER_SIZE; i++) {
- REALTYPE x = i / (REALTYPE) SOUND_BUFFER_SIZE;
+ float x = i / (float) SOUND_BUFFER_SIZE;
smp[i] = ismp[i] * (1.0 - x) + smp[i] * x;
}
returnTmpBuffer(ismp);
diff --git a/src/DSP/SVFilter.h b/src/DSP/SVFilter.h
@@ -29,37 +29,37 @@ class SVFilter:public Filter_
{
public:
SVFilter(unsigned char Ftype,
- REALTYPE Ffreq,
- REALTYPE Fq,
+ float Ffreq,
+ float Fq,
unsigned char Fstages);
~SVFilter();
- void filterout(REALTYPE *smp);
- void setfreq(REALTYPE frequency);
- void setfreq_and_q(REALTYPE frequency, REALTYPE q_);
- void setq(REALTYPE q_);
+ void filterout(float *smp);
+ void setfreq(float frequency);
+ void setfreq_and_q(float frequency, float q_);
+ void setq(float q_);
void settype(int type_);
- void setgain(REALTYPE dBgain);
+ void setgain(float dBgain);
void setstages(int stages_);
void cleanup();
private:
struct fstage {
- REALTYPE low, high, band, notch;
+ float low, high, band, notch;
} st[MAX_FILTER_STAGES + 1];
struct parameters {
- REALTYPE f, q, q_sqrt;
+ float f, q, q_sqrt;
} par, ipar;
- void singlefilterout(REALTYPE *smp, fstage &x, parameters &par);
+ void singlefilterout(float *smp, fstage &x, parameters &par);
void computefiltercoefs();
int type; //The type of the filter (LPF1,HPF1,LPF2,HPF2...)
int stages; //how many times the filter is applied (0->1,1->2,etc.)
- REALTYPE freq; //Frequency given in Hz
- REALTYPE q; //Q factor (resonance or Q factor)
- REALTYPE gain; //the gain of the filter (if are shelf/peak) filters
+ float freq; //Frequency given in Hz
+ float q; //Q factor (resonance or Q factor)
+ float gain; //the gain of the filter (if are shelf/peak) filters
bool abovenq, //if the frequency is above the nyquist
oldabovenq;
diff --git a/src/DSP/Unison.cpp b/src/DSP/Unison.cpp
@@ -23,17 +23,17 @@
#include <stdio.h>
#include "Unison.h"
-Unison::Unison(int update_period_samples_, REALTYPE max_delay_sec_) {
+Unison::Unison(int update_period_samples_, float max_delay_sec_) {
update_period_samples = update_period_samples_;
- max_delay = (int)(max_delay_sec_ * (REALTYPE)SAMPLE_RATE + 1);
+ max_delay = (int)(max_delay_sec_ * (float)SAMPLE_RATE + 1);
if(max_delay < 10)
max_delay = 10;
- delay_buffer = new REALTYPE[max_delay];
+ delay_buffer = new float[max_delay];
delay_k = 0;
base_freq = 1.0;
unison_bandwidth_cents = 10.0;
- ZERO_REALTYPE(delay_buffer, max_delay);
+ ZERO_float(delay_buffer, max_delay);
uv = NULL;
update_period_sample_k = 0;
@@ -59,12 +59,12 @@ void Unison::set_size(int new_size) {
update_parameters();
}
-void Unison::set_base_frequency(REALTYPE freq) {
+void Unison::set_base_frequency(float freq) {
base_freq = freq;
update_parameters();
}
-void Unison::set_bandwidth(REALTYPE bandwidth) {
+void Unison::set_bandwidth(float bandwidth) {
if(bandwidth < 0)
bandwidth = 0.0;
if(bandwidth > 1200.0)
@@ -80,21 +80,21 @@ void Unison::set_bandwidth(REALTYPE bandwidth) {
void Unison::update_parameters() {
if(!uv)
return;
- REALTYPE increments_per_second = SAMPLE_RATE
- / (REALTYPE) update_period_samples;
+ float increments_per_second = SAMPLE_RATE
+ / (float) update_period_samples;
// printf("#%g, %g\n",increments_per_second,base_freq);
for(int i = 0; i < unison_size; i++) {
- REALTYPE base = pow(UNISON_FREQ_SPAN, RND * 2.0 - 1.0);
+ float base = pow(UNISON_FREQ_SPAN, RND * 2.0 - 1.0);
uv[i].relative_amplitude = base;
- REALTYPE period = base / base_freq;
- REALTYPE m = 4.0 / (period * increments_per_second);
+ float period = base / base_freq;
+ float m = 4.0 / (period * increments_per_second);
if(RND < 0.5)
m = -m;
uv[i].step = m;
// printf("%g %g\n",uv[i].relative_amplitude,period);
}
- REALTYPE max_speed = pow(2.0, unison_bandwidth_cents / 1200.0);
+ float max_speed = pow(2.0, unison_bandwidth_cents / 1200.0);
unison_amplitude_samples = 0.125
* (max_speed - 1.0) * SAMPLE_RATE / base_freq;
printf("unison_amplitude_samples %g\n", unison_amplitude_samples);
@@ -107,15 +107,15 @@ void Unison::update_parameters() {
update_unison_data();
}
-void Unison::process(int bufsize, REALTYPE *inbuf, REALTYPE *outbuf) {
+void Unison::process(int bufsize, float *inbuf, float *outbuf) {
if(!uv)
return;
if(!outbuf)
outbuf = inbuf;
- REALTYPE volume = 1.0 / sqrt(unison_size);
- REALTYPE xpos_step = 1.0 / (REALTYPE) update_period_samples;
- REALTYPE xpos = (REALTYPE) update_period_sample_k * xpos_step;
+ float volume = 1.0 / sqrt(unison_size);
+ float xpos_step = 1.0 / (float) update_period_samples;
+ float xpos = (float) update_period_sample_k * xpos_step;
for(int i = 0; i < bufsize; i++) {
if((update_period_sample_k++) >= update_period_samples) {
update_unison_data();
@@ -123,15 +123,15 @@ void Unison::process(int bufsize, REALTYPE *inbuf, REALTYPE *outbuf) {
xpos = 0.0;
}
xpos += xpos_step;
- REALTYPE in = inbuf[i], out = 0.0;
+ float in = inbuf[i], out = 0.0;
- REALTYPE sign = 1.0;
+ float sign = 1.0;
for(int k = 0; k < unison_size; k++) {
- REALTYPE vpos = uv[k].realpos1
+ float vpos = uv[k].realpos1
* (1.0 - xpos) + uv[k].realpos2 * xpos; //optimize
- REALTYPE pos = delay_k + max_delay - vpos - 1.0; //optimize
+ float pos = delay_k + max_delay - vpos - 1.0; //optimize
int posi;
- REALTYPE posf;
+ float posf;
F2I(pos, posi); //optimize!
if(posi >= max_delay)
posi -= max_delay;
@@ -155,8 +155,8 @@ void Unison::update_unison_data() {
return;
for(int k = 0; k < unison_size; k++) {
- REALTYPE pos = uv[k].position;
- REALTYPE step = uv[k].step;
+ float pos = uv[k].position;
+ float step = uv[k].step;
pos += step;
if(pos <= -1.0) {
pos = -1.0;
@@ -166,12 +166,12 @@ void Unison::update_unison_data() {
pos = 1.0;
step = -step;
}
- REALTYPE vibratto_val = (pos - 0.333333333 * pos * pos * pos) * 1.5; //make the vibratto lfo smoother
+ float vibratto_val = (pos - 0.333333333 * pos * pos * pos) * 1.5; //make the vibratto lfo smoother
#warning \
I will use relative amplitude, so the delay might be bigger than the whole buffer
#warning \
I have to enlarge (reallocate) the buffer to make place for the whole delay
- REALTYPE newval = 1.0 + 0.5
+ float newval = 1.0 + 0.5
* (vibratto_val
+ 1.0) * unison_amplitude_samples
* uv[k].relative_amplitude;
diff --git a/src/DSP/Unison.h b/src/DSP/Unison.h
@@ -30,26 +30,26 @@
class Unison
{
public:
- Unison(int update_period_samples_, REALTYPE max_delay_sec_);
+ Unison(int update_period_samples_, float max_delay_sec_);
~Unison();
void set_size(int new_size);
- void set_base_frequency(REALTYPE freq);
- void set_bandwidth(REALTYPE bandwidth_cents);
+ void set_base_frequency(float freq);
+ void set_bandwidth(float bandwidth_cents);
- void process(int bufsize, REALTYPE *inbuf, REALTYPE *outbuf = NULL);
+ void process(int bufsize, float *inbuf, float *outbuf = NULL);
private:
void update_parameters();
void update_unison_data();
int unison_size;
- REALTYPE base_freq;
+ float base_freq;
struct UnisonVoice {
- REALTYPE step, position; //base LFO
- REALTYPE realpos1, realpos2; //the position regarding samples
- REALTYPE relative_amplitude;
- REALTYPE lin_fpos, lin_ffreq;
+ float step, position; //base LFO
+ float realpos1, realpos2; //the position regarding samples
+ float relative_amplitude;
+ float lin_fpos, lin_ffreq;
UnisonVoice() {
position = RND * 1.8 - 0.9;
realpos1 = 0.0;
@@ -61,9 +61,9 @@ class Unison
int update_period_samples, update_period_sample_k;
int max_delay, delay_k;
bool first_time;
- REALTYPE *delay_buffer;
- REALTYPE unison_amplitude_samples;
- REALTYPE unison_bandwidth_cents;
+ float *delay_buffer;
+ float unison_amplitude_samples;
+ float unison_bandwidth_cents;
};
#endif
diff --git a/src/Effects/Alienwah.cpp b/src/Effects/Alienwah.cpp
@@ -24,14 +24,14 @@
#include "Alienwah.h"
Alienwah::Alienwah(const int &insertion_,
- REALTYPE *const efxoutl_,
- REALTYPE *const efxoutr_)
+ float *const efxoutl_,
+ float *const efxoutr_)
:Effect(insertion_, efxoutl_, efxoutr_, NULL, 0), oldl(NULL), oldr(NULL)
{
setpreset(Ppreset);
cleanup();
- oldclfol = complex<REALTYPE>(fb, 0.0);
- oldclfor = complex<REALTYPE>(fb, 0.0);
+ oldclfol = complex<float>(fb, 0.0);
+ oldclfor = complex<float>(fb, 0.0);
}
Alienwah::~Alienwah()
@@ -48,29 +48,29 @@ Alienwah::~Alienwah()
*/
void Alienwah::out(const Stereo<float *> &smp)
{
- REALTYPE lfol, lfor; //Left/Right LFOs
- complex<REALTYPE> clfol, clfor;
+ float lfol, lfor; //Left/Right LFOs
+ complex<float> clfol, clfor;
/**\todo Rework, as optimization can be used when the new complex type is
* utilized.
- * Before all calculations needed to be done with individual REALTYPE,
+ * Before all calculations needed to be done with individual float,
* but now they can be done together*/
lfo.effectlfoout(&lfol, &lfor);
lfol *= depth * PI * 2.0;
lfor *= depth * PI * 2.0;
- clfol = complex<REALTYPE>(cos(lfol + phase) * fb, sin(lfol + phase) * fb); //rework
- clfor = complex<REALTYPE>(cos(lfor + phase) * fb, sin(lfor + phase) * fb); //rework
+ clfol = complex<float>(cos(lfol + phase) * fb, sin(lfol + phase) * fb); //rework
+ clfor = complex<float>(cos(lfor + phase) * fb, sin(lfor + phase) * fb); //rework
for(int i = 0; i < SOUND_BUFFER_SIZE; i++) {
- REALTYPE x = ((REALTYPE) i) / SOUND_BUFFER_SIZE;
- REALTYPE x1 = 1.0 - x;
+ float x = ((float) i) / SOUND_BUFFER_SIZE;
+ float x1 = 1.0 - x;
//left
- complex<REALTYPE> tmp = clfol * x + oldclfol * x1;
+ complex<float> tmp = clfol * x + oldclfol * x1;
- complex<REALTYPE>out = tmp * oldl[oldk];
+ complex<float>out = tmp * oldl[oldk];
out.real() += (1 - fabs(fb)) * smp.l[i] * (1.0 - panning);
oldl[oldk] = out;
- REALTYPE l = out.real() * 10.0 * (fb + 0.1);
+ float l = out.real() * 10.0 * (fb + 0.1);
//right
tmp = clfor * x + oldclfor * x1;
@@ -79,7 +79,7 @@ void Alienwah::out(const Stereo<float *> &smp)
out.real() += (1 - fabs(fb)) * smp.r[i] * (1.0 - panning);
oldr[oldk] = out;
- REALTYPE r = out.real() * 10.0 * (fb + 0.1);
+ float r = out.real() * 10.0 * (fb + 0.1);
if(++oldk >= Pdelay)
@@ -99,8 +99,8 @@ void Alienwah::out(const Stereo<float *> &smp)
void Alienwah::cleanup()
{
for(int i = 0; i < Pdelay; i++) {
- oldl[i] = complex<REALTYPE>(0.0, 0.0);
- oldr[i] = complex<REALTYPE>(0.0, 0.0);
+ oldl[i] = complex<float>(0.0, 0.0);
+ oldr[i] = complex<float>(0.0, 0.0);
}
oldk = 0;
}
@@ -165,8 +165,8 @@ void Alienwah::setdelay(unsigned char Pdelay)
this->Pdelay = MAX_ALIENWAH_DELAY;
else
this->Pdelay = Pdelay;
- oldl = new complex<REALTYPE>[Pdelay];
- oldr = new complex<REALTYPE>[Pdelay];
+ oldl = new complex<float>[Pdelay];
+ oldr = new complex<float>[Pdelay];
cleanup();
}
diff --git a/src/Effects/Alienwah.h b/src/Effects/Alienwah.h
@@ -43,8 +43,8 @@ class Alienwah:public Effect
* @return Initialized Alienwah
*/
Alienwah(const int &insetion_,
- REALTYPE *const efxoutl_,
- REALTYPE *const efxoutr_);
+ float *const efxoutl_,
+ float *const efxoutr_);
~Alienwah();
void out(const Stereo<float *> &smp);
@@ -75,9 +75,9 @@ class Alienwah:public Effect
void setphase(unsigned char Pphase);
//Internal Values
- REALTYPE panning, fb, depth, lrcross, phase;
- complex<REALTYPE> *oldl, *oldr;
- complex<REALTYPE> oldclfol, oldclfor;
+ float panning, fb, depth, lrcross, phase;
+ complex<float> *oldl, *oldr;
+ complex<float> oldclfol, oldclfor;
int oldk;
};
diff --git a/src/Effects/Chorus.cpp b/src/Effects/Chorus.cpp
@@ -27,8 +27,8 @@
using namespace std;
Chorus::Chorus(const int &insertion_,
- REALTYPE *const efxoutl_,
- REALTYPE *const efxoutr_)
+ float *const efxoutl_,
+ float *const efxoutr_)
:Effect(insertion_, efxoutl_, efxoutr_, NULL, 0),
maxdelay((int)(MAX_CHORUS_DELAY / 1000.0 * SAMPLE_RATE)),
delaySample(maxdelay)
@@ -49,9 +49,9 @@ Chorus::~Chorus() {}
/*
* get the delay value in samples; xlfo is the current lfo value
*/
-REALTYPE Chorus::getdelay(REALTYPE xlfo)
+float Chorus::getdelay(float xlfo)
{
- REALTYPE result;
+ float result;
if(Pflangemode == 0)
result = (delay + xlfo * depth) * SAMPLE_RATE;
else
@@ -70,7 +70,7 @@ REALTYPE Chorus::getdelay(REALTYPE xlfo)
void Chorus::out(const Stereo<float *> &input)
{
- const REALTYPE one = 1.0;
+ const float one = 1.0;
dl1 = dl2;
dr1 = dr2;
lfo.effectlfoout(&lfol, &lfor);
@@ -79,11 +79,11 @@ void Chorus::out(const Stereo<float *> &input)
dr2 = getdelay(lfor);
for(int i = 0; i < SOUND_BUFFER_SIZE; i++) {
- REALTYPE inl = input.l[i];
- REALTYPE inr = input.r[i];
+ float inl = input.l[i];
+ float inr = input.r[i];
//LRcross
- Stereo<REALTYPE> tmpc(inl, inr);
- //REALTYPE r=inr;
+ Stereo<float> tmpc(inl, inr);
+ //float r=inr;
inl = tmpc.l * (1.0 - lrcross) + tmpc.r * lrcross;
inr = tmpc.r * (1.0 - lrcross) + tmpc.l * lrcross;
@@ -93,7 +93,7 @@ void Chorus::out(const Stereo<float *> &input)
mdel = (dl1 * (SOUND_BUFFER_SIZE - i) + dl2 * i) / SOUND_BUFFER_SIZE;
if(++dlk >= maxdelay)
dlk = 0;
- REALTYPE tmp = dlk - mdel + maxdelay * 2.0; //where should I get the sample from
+ float tmp = dlk - mdel + maxdelay * 2.0; //where should I get the sample from
F2I(tmp, dlhi);
dlhi %= maxdelay;
diff --git a/src/Effects/Chorus.h b/src/Effects/Chorus.h
@@ -34,7 +34,7 @@
class Chorus:public Effect
{
public:
- Chorus(const int &insetion_, REALTYPE *efxoutl_, REALTYPE *efxoutr_);
+ Chorus(const int &insetion_, float *efxoutl_, float *efxoutr_);
/**Destructor*/
~Chorus();
void out(const Stereo<float *> &input);
@@ -101,13 +101,13 @@ class Chorus:public Effect
void setlrcross(unsigned char Plrcross);
//Internal Values
- REALTYPE depth, delay, fb, lrcross, panning;
- REALTYPE dl1, dl2, dr1, dr2, lfol, lfor;
+ float depth, delay, fb, lrcross, panning;
+ float dl1, dl2, dr1, dr2, lfol, lfor;
int maxdelay;
Stereo<Sample> delaySample;
int dlk, drk, dlhi, dlhi2;
- REALTYPE getdelay(REALTYPE xlfo);
- REALTYPE dllo, mdel;
+ float getdelay(float xlfo);
+ float dllo, mdel;
};
#endif
diff --git a/src/Effects/Distorsion.cpp b/src/Effects/Distorsion.cpp
@@ -29,13 +29,13 @@
*/
void waveshapesmps(int n,
- REALTYPE *smps,
+ float *smps,
unsigned char type,
unsigned char drive)
{
int i;
- REALTYPE ws = drive / 127.0;
- REALTYPE tmpv;
+ float ws = drive / 127.0;
+ float tmpv;
switch(type) {
case 1:
@@ -92,7 +92,7 @@ void waveshapesmps(int n,
case 7:
ws = pow(2.0, -ws * ws * 8.0); //Limiter
for(i = 0; i < n; i++) {
- REALTYPE tmp = smps[i];
+ float tmp = smps[i];
if(fabs(tmp) > ws) {
if(tmp >= 0.0)
smps[i] = 1.0;
@@ -106,7 +106,7 @@ void waveshapesmps(int n,
case 8:
ws = pow(2.0, -ws * ws * 8.0); //Upper Limiter
for(i = 0; i < n; i++) {
- REALTYPE tmp = smps[i];
+ float tmp = smps[i];
if(tmp > ws)
smps[i] = ws;
smps[i] *= 2.0;
@@ -115,7 +115,7 @@ void waveshapesmps(int n,
case 9:
ws = pow(2.0, -ws * ws * 8.0); //Lower Limiter
for(i = 0; i < n; i++) {
- REALTYPE tmp = smps[i];
+ float tmp = smps[i];
if(tmp < -ws)
smps[i] = -ws;
smps[i] *= 2.0;
@@ -124,7 +124,7 @@ void waveshapesmps(int n,
case 10:
ws = (pow(2.0, ws * 6.0) - 1.0) / pow(2.0, 6.0); //Inverse Limiter
for(i = 0; i < n; i++) {
- REALTYPE tmp = smps[i];
+ float tmp = smps[i];
if(fabs(tmp) > ws) {
if(tmp >= 0.0)
smps[i] = tmp - ws;
@@ -149,7 +149,7 @@ void waveshapesmps(int n,
else
tmpv = 1.0;
for(i = 0; i < n; i++) {
- REALTYPE tmp = smps[i] * ws;
+ float tmp = smps[i] * ws;
if((tmp > -2.0) && (tmp < 1.0))
smps[i] = tmp * (1.0 - tmp) * (tmp + 2.0) / tmpv;
else
@@ -163,7 +163,7 @@ void waveshapesmps(int n,
else
tmpv = 1.0;
for(i = 0; i < n; i++) {
- REALTYPE tmp = smps[i] * ws;
+ float tmp = smps[i] * ws;
if((tmp > -1.0) && (tmp < 1.618034))
smps[i] = tmp * (1.0 - tmp) / tmpv;
else
@@ -180,7 +180,7 @@ void waveshapesmps(int n,
else
tmpv = 0.5 - 1.0 / (exp(ws) + 1.0);
for(i = 0; i < n; i++) {
- REALTYPE tmp = smps[i] * ws;
+ float tmp = smps[i] * ws;
if(tmp < -10.0)
tmp = -10.0;
else
@@ -196,8 +196,8 @@ void waveshapesmps(int n,
Distorsion::Distorsion(const int &insertion_,
- REALTYPE *efxoutl_,
- REALTYPE *efxoutr_)
+ float *efxoutl_,
+ float *efxoutr_)
:Effect(insertion_, efxoutl_, efxoutr_, NULL, 0)
{
lpfl = new AnalogFilter(2, 22000, 1, 0);
@@ -246,7 +246,7 @@ void Distorsion::cleanup()
* Apply the filters
*/
-void Distorsion::applyfilters(REALTYPE *efxoutl, REALTYPE *efxoutr)
+void Distorsion::applyfilters(float *efxoutl, float *efxoutr)
{
lpfl->filterout(efxoutl);
hpfl->filterout(efxoutl);
@@ -263,9 +263,9 @@ void Distorsion::applyfilters(REALTYPE *efxoutl, REALTYPE *efxoutr)
void Distorsion::out(const Stereo<float *> &smp)
{
int i;
- REALTYPE l, r, lout, rout;
+ float l, r, lout, rout;
- REALTYPE inputvol = pow(5.0, (Pdrive - 32.0) / 127.0);
+ float inputvol = pow(5.0, (Pdrive - 32.0) / 127.0);
if(Pnegate != 0)
inputvol *= -1.0;
@@ -297,7 +297,7 @@ void Distorsion::out(const Stereo<float *> &smp)
for(i = 0; i < SOUND_BUFFER_SIZE; i++)
efxoutr[i] = efxoutl[i];
- REALTYPE level = dB2rap(60.0 * Plevel / 127.0 - 40.0);
+ float level = dB2rap(60.0 * Plevel / 127.0 - 40.0);
for(i = 0; i < SOUND_BUFFER_SIZE; i++) {
lout = efxoutl[i];
rout = efxoutr[i];
@@ -346,7 +346,7 @@ void Distorsion::setlrcross(unsigned char Plrcross)
void Distorsion::setlpf(unsigned char Plpf)
{
this->Plpf = Plpf;
- REALTYPE fr = exp(pow(Plpf / 127.0, 0.5) * log(25000.0)) + 40;
+ float fr = exp(pow(Plpf / 127.0, 0.5) * log(25000.0)) + 40;
lpfl->setfreq(fr);
lpfr->setfreq(fr);
}
@@ -354,7 +354,7 @@ void Distorsion::setlpf(unsigned char Plpf)
void Distorsion::sethpf(unsigned char Phpf)
{
this->Phpf = Phpf;
- REALTYPE fr = exp(pow(Phpf / 127.0, 0.5) * log(25000.0)) + 20.0;
+ float fr = exp(pow(Phpf / 127.0, 0.5) * log(25000.0)) + 20.0;
hpfl->setfreq(fr);
hpfr->setfreq(fr);
}
diff --git a/src/Effects/Distorsion.h b/src/Effects/Distorsion.h
@@ -29,21 +29,21 @@
//Waveshaping(called by Distorsion effect and waveshape from OscilGen)
void waveshapesmps(int n,
- REALTYPE *smps,
+ float *smps,
unsigned char type,
unsigned char drive);
/**Distortion Effect*/
class Distorsion:public Effect
{
public:
- Distorsion(const int &insertion, REALTYPE *efxoutl_, REALTYPE *efxoutr_);
+ Distorsion(const int &insertion, float *efxoutl_, float *efxoutr_);
~Distorsion();
void out(const Stereo<float *> &smp);
void setpreset(unsigned char npreset);
void changepar(int npar, unsigned char value);
unsigned char getpar(int npar) const;
void cleanup();
- void applyfilters(REALTYPE *efxoutl, REALTYPE *efxoutr);
+ void applyfilters(float *efxoutl, float *efxoutr);
private:
//Parametrii
@@ -66,7 +66,7 @@ class Distorsion:public Effect
void sethpf(unsigned char Phpf);
//Real Parameters
- REALTYPE panning, lrcross;
+ float panning, lrcross;
AnalogFilter *lpfl, *lpfr, *hpfl, *hpfr;
};
diff --git a/src/Effects/DynamicFilter.cpp b/src/Effects/DynamicFilter.cpp
@@ -24,8 +24,8 @@
#include "DynamicFilter.h"
DynamicFilter::DynamicFilter(int insertion_,
- REALTYPE *efxoutl_,
- REALTYPE *efxoutr_)
+ float *efxoutl_,
+ float *efxoutr_)
:Effect(insertion_, efxoutl_, efxoutr_, new FilterParams(0, 64, 64), 0),
Pvolume(110), Ppanning(64), Pdepth(0), Pampsns(90),
Pampsnsinv(0), Pampsmooth(60),
@@ -53,29 +53,29 @@ void DynamicFilter::out(const Stereo<float *> &smp)
cleanup();
}
- REALTYPE lfol, lfor;
+ float lfol, lfor;
lfo.effectlfoout(&lfol, &lfor);
lfol *= depth * 5.0;
lfor *= depth * 5.0;
- const REALTYPE freq = filterpars->getfreq();
- const REALTYPE q = filterpars->getq();
+ const float freq = filterpars->getfreq();
+ const float q = filterpars->getq();
for(int i = 0; i < SOUND_BUFFER_SIZE; i++) {
efxoutl[i] = smp.l[i];
efxoutr[i] = smp.r[i];
- const REALTYPE x = (fabs(smp.l[i]) + fabs(smp.l[i])) * 0.5;
+ const float x = (fabs(smp.l[i]) + fabs(smp.l[i])) * 0.5;
ms1 = ms1 * (1.0 - ampsmooth) + x * ampsmooth + 1e-10;
}
- const REALTYPE ampsmooth2 = pow(ampsmooth, 0.2) * 0.3;
+ const float ampsmooth2 = pow(ampsmooth, 0.2) * 0.3;
ms2 = ms2 * (1.0 - ampsmooth2) + ms1 * ampsmooth2;
ms3 = ms3 * (1.0 - ampsmooth2) + ms2 * ampsmooth2;
ms4 = ms4 * (1.0 - ampsmooth2) + ms3 * ampsmooth2;
- const REALTYPE rms = (sqrt(ms4)) * ampsns;
+ const float rms = (sqrt(ms4)) * ampsns;
- const REALTYPE frl = filterl->getrealfreq(freq + lfol + rms);
- const REALTYPE frr = filterr->getrealfreq(freq + lfor + rms);
+ const float frl = filterl->getrealfreq(freq + lfol + rms);
+ const float frr = filterr->getrealfreq(freq + lfor + rms);
filterl->setfreq_and_q(frl, q);
filterr->setfreq_and_q(frr, q);
diff --git a/src/Effects/DynamicFilter.h b/src/Effects/DynamicFilter.h
@@ -31,7 +31,7 @@
class DynamicFilter:public Effect
{
public:
- DynamicFilter(int insetion_, REALTYPE *efxoutl_, REALTYPE *efxoutr_);
+ DynamicFilter(int insetion_, float *efxoutl_, float *efxoutr_);
~DynamicFilter();
void out(const Stereo<float *> &smp);
@@ -59,11 +59,11 @@ class DynamicFilter:public Effect
void reinitfilter();
//Internal Values
- REALTYPE panning, depth, ampsns, ampsmooth;
+ float panning, depth, ampsns, ampsmooth;
Filter *filterl, *filterr;
- REALTYPE ms1, ms2, ms3, ms4; //mean squares
+ float ms1, ms2, ms3, ms4; //mean squares
};
#endif
diff --git a/src/Effects/EQ.cpp b/src/Effects/EQ.cpp
@@ -23,7 +23,7 @@
#include <cmath>
#include "EQ.h"
-EQ::EQ(const int &insertion_, REALTYPE *efxoutl_, REALTYPE *efxoutr_)
+EQ::EQ(const int &insertion_, float *efxoutl_, float *efxoutr_)
:Effect(insertion_, efxoutl_, efxoutr_, NULL, 0)
{
for(int i = 0; i < MAX_EQ_BANDS; i++) {
@@ -120,7 +120,7 @@ void EQ::changepar(int npar, unsigned char value)
return;
int bp = npar % 5; //band paramenter
- REALTYPE tmp;
+ float tmp;
switch(bp) {
case 0:
filter[nb].Ptype = value;
@@ -198,9 +198,9 @@ unsigned char EQ::getpar(int npar) const
-REALTYPE EQ::getfreqresponse(REALTYPE freq)
+float EQ::getfreqresponse(float freq)
{
- REALTYPE resp = 1.0;
+ float resp = 1.0;
for(int i = 0; i < MAX_EQ_BANDS; i++) {
if(filter[i].Ptype == 0)
diff --git a/src/Effects/EQ.h b/src/Effects/EQ.h
@@ -31,14 +31,14 @@
class EQ:public Effect
{
public:
- EQ(const int &insertion_, REALTYPE *efxoutl_, REALTYPE *efxoutr_);
+ EQ(const int &insertion_, float *efxoutl_, float *efxoutr_);
~EQ();
void out(const Stereo<float *> &smp);
void setpreset(unsigned char npreset);
void changepar(int npar, unsigned char value);
unsigned char getpar(int npar) const;
void cleanup();
- REALTYPE getfreqresponse(REALTYPE freq);
+ float getfreqresponse(float freq);
private:
//Parameters
unsigned char Pvolume; /**<Volume*/
diff --git a/src/Effects/Echo.cpp b/src/Effects/Echo.cpp
@@ -28,14 +28,14 @@
#define MAX_DELAY 2
Echo::Echo(const int &insertion_,
- REALTYPE *const efxoutl_,
- REALTYPE *const efxoutr_)
+ float *const efxoutl_,
+ float *const efxoutr_)
:Effect(insertion_, efxoutl_, efxoutr_, NULL, 0),
Pvolume(50), Ppanning(64), Pdelay(60),
Plrdelay(100), Plrcross(100), Pfb(40), Phidamp(60),
delayTime(1), lrdelay(0), avgDelay(0),
- delay(new REALTYPE[(int)(MAX_DELAY * SAMPLE_RATE)],
- new REALTYPE[(int)(MAX_DELAY * SAMPLE_RATE)]),
+ delay(new float[(int)(MAX_DELAY * SAMPLE_RATE)],
+ new float[(int)(MAX_DELAY * SAMPLE_RATE)]),
old(0.0), pos(0), delta(1), ndelta(1)
{
initdelays();
@@ -53,9 +53,9 @@ Echo::~Echo()
*/
void Echo::cleanup()
{
- memset(delay.l,0,MAX_DELAY*SAMPLE_RATE*sizeof(REALTYPE));
- memset(delay.r,0,MAX_DELAY*SAMPLE_RATE*sizeof(REALTYPE));
- old = Stereo<REALTYPE>(0.0);
+ memset(delay.l,0,MAX_DELAY*SAMPLE_RATE*sizeof(float));
+ memset(delay.r,0,MAX_DELAY*SAMPLE_RATE*sizeof(float));
+ old = Stereo<float>(0.0);
}
inline int max(int a, int b)
@@ -81,7 +81,7 @@ void Echo::initdelays()
void Echo::out(const Stereo<float *> &input)
{
- REALTYPE ldl, rdl;
+ float ldl, rdl;
for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) {
ldl = delay.l[pos.l];
@@ -147,7 +147,7 @@ void Echo::setdelay(unsigned char Pdelay)
void Echo::setlrdelay(unsigned char Plrdelay)
{
- REALTYPE tmp;
+ float tmp;
this->Plrdelay = Plrdelay;
tmp =
(pow(2, fabs(Plrdelay - 64.0) / 64.0 * 9) - 1.0) / 1000.0;
diff --git a/src/Effects/Echo.h b/src/Effects/Echo.h
@@ -42,8 +42,8 @@ class Echo:public Effect
* @return An initialized Echo Object
*/
Echo(const int &insertion_,
- REALTYPE *const efxoutl_,
- REALTYPE *const efxoutr_);
+ float *const efxoutl_,
+ float *const efxoutr_);
/**
* The destructor
@@ -116,16 +116,16 @@ class Echo:public Effect
void sethidamp(unsigned char Phidamp);
//Real Parameters
- REALTYPE panning, lrcross, fb, hidamp;
+ float panning, lrcross, fb, hidamp;
//Left/Right delay lengths
Stereo<int> delayTime;
- REALTYPE lrdelay;
- REALTYPE avgDelay;
+ float lrdelay;
+ float avgDelay;
void initdelays();
//2 channel ring buffer
- Stereo<REALTYPE *> delay;
- Stereo<REALTYPE> old;
+ Stereo<float *> delay;
+ Stereo<float> old;
//position of reading/writing from delaysample
Stereo<int> pos;
diff --git a/src/Effects/Effect.cpp b/src/Effects/Effect.cpp
@@ -23,14 +23,14 @@
#include "Effect.h"
#include "../Params/FilterParams.h"
-Effect::Effect(bool insertion_, REALTYPE *const efxoutl_,
- REALTYPE *const efxoutr_, FilterParams *filterpars_,
+Effect::Effect(bool insertion_, float *const efxoutl_,
+ float *const efxoutr_, FilterParams *filterpars_,
const unsigned char &Ppreset_)
:Ppreset(Ppreset_), efxoutl(efxoutl_), efxoutr(efxoutr_),
filterpars(filterpars_), insertion(insertion_)
{}
-void Effect::out(REALTYPE *const smpsl, REALTYPE *const smpsr)
+void Effect::out(float *const smpsl, float *const smpsr)
{
out(Stereo<float *>(smpsl,smpsr));
};
diff --git a/src/Effects/Effect.h b/src/Effects/Effect.h
@@ -43,8 +43,8 @@ class Effect
* @param filterpars_ pointer to FilterParams array
* @param Ppreset_ chosen preset
* @return Initialized Effect object*/
- Effect(bool insertion_, REALTYPE *const efxoutl_,
- REALTYPE *const efxoutr_, FilterParams *filterpars_,
+ Effect(bool insertion_, float *const efxoutl_,
+ float *const efxoutr_, FilterParams *filterpars_,
const unsigned char &Ppreset_);
/**Deconstructor
*
@@ -73,27 +73,27 @@ class Effect
* @param smpsl Input buffer for the Left channel
* @param smpsr Input buffer for the Right channel
*/
- void out(REALTYPE *const smpsl, REALTYPE *const smpsr);
+ void out(float *const smpsl, float *const smpsr);
virtual void out(const Stereo<float *> &smp) = 0;
/**Reset the state of the effect*/
virtual void cleanup() {}
/**This is only used for EQ (for user interface)*/
- virtual REALTYPE getfreqresponse(REALTYPE freq) {
+ virtual float getfreqresponse(float freq) {
return freq;
}
unsigned char Ppreset; /**<Currently used preset*/
- REALTYPE *const efxoutl; /**<Effect out Left Channel*/
- REALTYPE *const efxoutr; /**<Effect out Right Channel*/
+ float *const efxoutl; /**<Effect out Left Channel*/
+ float *const efxoutr; /**<Effect out Right Channel*/
/**\todo make efxoutl and efxoutr private and replace them with a Stereo<float*>*/
- REALTYPE outvolume;/**<This is the volume of effect and is public because
+ float outvolume;/**<This is the volume of effect and is public because
* it is needed in system effects.
* The out volume of such effects are always 1.0, so
* this setting tells me how is the volume to the
* Master Output only.*/
- REALTYPE volume;
+ float volume;
FilterParams *filterpars; /**<Parameters for filters used by Effect*/
protected:
diff --git a/src/Effects/EffectLFO.cpp b/src/Effects/EffectLFO.cpp
@@ -52,8 +52,8 @@ EffectLFO::~EffectLFO()
*/
void EffectLFO::updateparams()
{
- REALTYPE lfofreq = (pow(2, Pfreq / 127.0 * 10.0) - 1.0) * 0.03;
- incx = fabs(lfofreq) * (REALTYPE)SOUND_BUFFER_SIZE / (REALTYPE)SAMPLE_RATE;
+ float lfofreq = (pow(2, Pfreq / 127.0 * 10.0) - 1.0) * 0.03;
+ incx = fabs(lfofreq) * (float)SOUND_BUFFER_SIZE / (float)SAMPLE_RATE;
if(incx > 0.49999999)
incx = 0.499999999; //Limit the Frequency
@@ -75,9 +75,9 @@ void EffectLFO::updateparams()
/*
* Compute the shape of the LFO
*/
-REALTYPE EffectLFO::getlfoshape(REALTYPE x)
+float EffectLFO::getlfoshape(float x)
{
- REALTYPE out;
+ float out;
switch(lfotype) {
case 1: //EffectLFO_TRIANGLE
if((x > 0.0) && (x < 0.25))
@@ -98,9 +98,9 @@ REALTYPE EffectLFO::getlfoshape(REALTYPE x)
/*
* LFO output
*/
-void EffectLFO::effectlfoout(REALTYPE *outl, REALTYPE *outr)
+void EffectLFO::effectlfoout(float *outl, float *outr)
{
- REALTYPE out;
+ float out;
out = getlfoshape(xl);
if((lfotype == 0) || (lfotype == 1))
diff --git a/src/Effects/EffectLFO.h b/src/Effects/EffectLFO.h
@@ -31,20 +31,20 @@ class EffectLFO
public:
EffectLFO();
~EffectLFO();
- void effectlfoout(REALTYPE *outl, REALTYPE *outr);
+ void effectlfoout(float *outl, float *outr);
void updateparams();
unsigned char Pfreq;
unsigned char Prandomness;
unsigned char PLFOtype;
unsigned char Pstereo; //"64"=0
private:
- REALTYPE getlfoshape(REALTYPE x);
+ float getlfoshape(float x);
- REALTYPE xl, xr;
- REALTYPE incx;
- REALTYPE ampl1, ampl2, ampr1, ampr2; //necessary for "randomness"
- REALTYPE lfointensity;
- REALTYPE lfornd;
+ float xl, xr;
+ float incx;
+ float ampl1, ampl2, ampr1, ampr2; //necessary for "randomness"
+ float lfointensity;
+ float lfornd;
char lfotype; /**\todo GET RID OF CHAR (replace with short or enum)*/
};
diff --git a/src/Effects/EffectMgr.cpp b/src/Effects/EffectMgr.cpp
@@ -36,8 +36,8 @@ using namespace std;
EffectMgr::EffectMgr(int insertion_, pthread_mutex_t *mutex_)
:insertion(insertion_),
- efxoutl(new REALTYPE[SOUND_BUFFER_SIZE]),
- efxoutr(new REALTYPE[SOUND_BUFFER_SIZE]),
+ efxoutl(new float[SOUND_BUFFER_SIZE]),
+ efxoutr(new float[SOUND_BUFFER_SIZE]),
filterpars(NULL), nefx(0), efx(NULL), mutex(mutex_), dryonly(false)
{
setpresettype("Peffect"); /**\todo Figure out what this is doing
@@ -46,8 +46,8 @@ EffectMgr::EffectMgr(int insertion_, pthread_mutex_t *mutex_)
// nefx=0;
// insertion=insertion_;
// mutex=mutex_;
-// efxoutl=new REALTYPE[SOUND_BUFFER_SIZE];
-// efxoutr=new REALTYPE[SOUND_BUFFER_SIZE];
+// efxoutl=new float[SOUND_BUFFER_SIZE];
+// efxoutr=new float[SOUND_BUFFER_SIZE];
for(int i = 0; i < SOUND_BUFFER_SIZE; i++) {
efxoutl[i] = 0.0;
efxoutr[i] = 0.0;
@@ -207,7 +207,7 @@ unsigned char EffectMgr::geteffectpar(int npar)
/*
* Apply the effect
*/
-void EffectMgr::out(REALTYPE *smpsl, REALTYPE *smpsr)
+void EffectMgr::out(float *smpsl, float *smpsr)
{
int i;
if(efx == NULL) {
@@ -229,7 +229,7 @@ void EffectMgr::out(REALTYPE *smpsl, REALTYPE *smpsr)
}
efx->out(smpsl, smpsr);
- REALTYPE volume = efx->volume;
+ float volume = efx->volume;
if(nefx == 7) { //this is need only for the EQ effect
/**\todo figure out why*/
@@ -242,7 +242,7 @@ void EffectMgr::out(REALTYPE *smpsl, REALTYPE *smpsr)
//Insertion effect
if(insertion != 0) {
- REALTYPE v1, v2;
+ float v1, v2;
if(volume < 0.5) {
v1 = 1.0;
v2 = volume * 2.0;
@@ -282,7 +282,7 @@ void EffectMgr::out(REALTYPE *smpsl, REALTYPE *smpsr)
/*
* Get the effect volume for the system effect
*/
-REALTYPE EffectMgr::sysefxgetvolume()
+float EffectMgr::sysefxgetvolume()
{
if(efx == NULL)
return 1.0;
@@ -294,7 +294,7 @@ REALTYPE EffectMgr::sysefxgetvolume()
/*
* Get the EQ response
*/
-REALTYPE EffectMgr::getEQfreqresponse(REALTYPE freq)
+float EffectMgr::getEQfreqresponse(float freq)
{
if(nefx == 7)
return efx->getfreqresponse(freq);
diff --git a/src/Effects/EffectMgr.h b/src/Effects/EffectMgr.h
@@ -50,12 +50,12 @@ class EffectMgr:public Presets
void defaults();
void getfromXML(XMLwrapper *xml);
- void out(REALTYPE *smpsl, REALTYPE *smpsr);
+ void out(float *smpsl, float *smpsr);
void setdryonly(bool value);
/**get the output(to speakers) volume of the systemeffect*/
- REALTYPE sysefxgetvolume();
+ float sysefxgetvolume();
void cleanup(); /**<cleanup the effect*/
@@ -85,11 +85,11 @@ class EffectMgr:public Presets
void seteffectpar_nolock(int npar, unsigned char value);
unsigned char geteffectpar(int npar);
const bool insertion; /**<1 if the effect is connected as insertion effect*/
- REALTYPE *efxoutl, *efxoutr;
+ float *efxoutl, *efxoutr;
/**used by UI
* \todo needs to be decoupled*/
- REALTYPE getEQfreqresponse(REALTYPE freq);
+ float getEQfreqresponse(float freq);
FilterParams *filterpars;
diff --git a/src/Effects/Phaser.cpp b/src/Effects/Phaser.cpp
@@ -39,7 +39,7 @@ using namespace std;
#define ONE_ 0.99999f // To prevent LFO ever reaching 1.0 for filter stability purposes
#define ZERO_ 0.00001f // Same idea as above.
-Phaser::Phaser(const int &insertion_, REALTYPE *efxoutl_, REALTYPE *efxoutr_)
+Phaser::Phaser(const int &insertion_, float *efxoutl_, float *efxoutr_)
:Effect(insertion_, efxoutl_, efxoutr_, NULL, 0), old(NULL), xn1(NULL),
yn1(NULL), diff(0.0), oldgain(0.0), fb(0.0)
{
@@ -91,7 +91,7 @@ Phaser::~Phaser()
/*
* Effect output
*/
-void Phaser::out(const Stereo<REALTYPE *> &input)
+void Phaser::out(const Stereo<float *> &input)
{
if(Panalog)
AnalogPhase(input);
@@ -99,9 +99,9 @@ void Phaser::out(const Stereo<REALTYPE *> &input)
normalPhase(input);
}
-void Phaser::AnalogPhase(const Stereo<REALTYPE *> &input)
+void Phaser::AnalogPhase(const Stereo<float *> &input)
{
- Stereo<REALTYPE> gain(0.0), lfoVal(0.0), mod(0.0), g(0.0), b(0.0), hpf(0.0);
+ Stereo<float> gain(0.0), lfoVal(0.0), mod(0.0), g(0.0), b(0.0), hpf(0.0);
lfo.effectlfoout(&lfoVal.l, &lfoVal.r);
mod.l = lfoVal.l*width + (depth - 0.5f);
@@ -132,7 +132,7 @@ void Phaser::AnalogPhase(const Stereo<REALTYPE *> &input)
g.l += diff.l;// Linear interpolation between LFO samples
g.r += diff.r;
- Stereo<REALTYPE> xn(input.l[i] * panning,
+ Stereo<float> xn(input.l[i] * panning,
input.r[i] * (1.0f - panning));
if (barber) {
@@ -156,8 +156,8 @@ void Phaser::AnalogPhase(const Stereo<REALTYPE *> &input)
}
}
-REALTYPE Phaser::applyPhase(REALTYPE x, REALTYPE g, REALTYPE fb,
- REALTYPE &hpf, REALTYPE *yn1, REALTYPE *xn1)
+float Phaser::applyPhase(float x, float g, float fb,
+ float &hpf, float *yn1, float *xn1)
{
for(int j = 0; j < Pstages; j++) { //Phasing routine
mis = 1.0f + offsetpct*offset[j];
@@ -184,9 +184,9 @@ REALTYPE Phaser::applyPhase(REALTYPE x, REALTYPE g, REALTYPE fb,
}
return x;
}
-void Phaser::normalPhase(const Stereo<REALTYPE *> &input)
+void Phaser::normalPhase(const Stereo<float *> &input)
{
- Stereo<REALTYPE> gain(0.0), lfoVal(0.0);
+ Stereo<float> gain(0.0), lfoVal(0.0);
lfo.effectlfoout(&lfoVal.l, &lfoVal.r);
gain.l = (exp(lfoVal.l * PHASER_LFO_SHAPE) - 1) / (exp(PHASER_LFO_SHAPE) - 1.0);
@@ -199,13 +199,13 @@ void Phaser::normalPhase(const Stereo<REALTYPE *> &input)
gain.r = limit(gain.r, ZERO_, ONE_);
for(int i = 0; i < SOUND_BUFFER_SIZE; i++) {
- REALTYPE x = (REALTYPE) i / SOUND_BUFFER_SIZE;
- REALTYPE x1 = 1.0 - x;
+ float x = (float) i / SOUND_BUFFER_SIZE;
+ float x1 = 1.0 - x;
//TODO think about making panning an external feature
- Stereo<REALTYPE> xn(input.l[i] * panning + fb.l,
+ Stereo<float> xn(input.l[i] * panning + fb.l,
input.r[i] * (1.0 - panning) + fb.r);
- Stereo<REALTYPE> g(gain.l * x + oldgain.l * x1,
+ Stereo<float> g(gain.l * x + oldgain.l * x1,
gain.r * x + oldgain.r * x1);
xn.l = applyPhase(xn.l, g.l, old.l);
@@ -228,10 +228,10 @@ void Phaser::normalPhase(const Stereo<REALTYPE *> &input)
}
}
-REALTYPE Phaser::applyPhase(REALTYPE x, REALTYPE g, REALTYPE *old)
+float Phaser::applyPhase(float x, float g, float *old)
{
for(int j = 0; j < Pstages * 2; j++) { //Phasing routine
- REALTYPE tmp = old[j];
+ float tmp = old[j];
old[j] = g * tmp + x;
x = tmp - g *old[j];
}
@@ -243,7 +243,7 @@ REALTYPE Phaser::applyPhase(REALTYPE x, REALTYPE g, REALTYPE *old)
*/
void Phaser::cleanup()
{
- fb = oldgain = Stereo<REALTYPE>(0.0);
+ fb = oldgain = Stereo<float>(0.0);
for(int i = 0; i < Pstages * 2; i++) {
old.l[i] = 0.0;
old.r[i] = 0.0;
@@ -319,14 +319,14 @@ void Phaser::setstages(unsigned char Pstages)
this->Pstages = min(MAX_PHASER_STAGES, (int)Pstages);
- old = Stereo<REALTYPE *>(new REALTYPE[Pstages * 2],
- new REALTYPE[Pstages * 2]);
+ old = Stereo<float *>(new float[Pstages * 2],
+ new float[Pstages * 2]);
- xn1 = Stereo<REALTYPE *>(new REALTYPE[Pstages],
- new REALTYPE[Pstages]);
+ xn1 = Stereo<float *>(new float[Pstages],
+ new float[Pstages]);
- yn1 = Stereo<REALTYPE *>(new REALTYPE[Pstages],
- new REALTYPE[Pstages]);
+ yn1 = Stereo<float *>(new float[Pstages],
+ new float[Pstages]);
cleanup();
}
diff --git a/src/Effects/Phaser.h b/src/Effects/Phaser.h
@@ -35,9 +35,9 @@
class Phaser:public Effect
{
public:
- Phaser(const int &insertion_, REALTYPE *efxoutl_, REALTYPE *efxoutr_);
+ Phaser(const int &insertion_, float *efxoutl_, float *efxoutr_);
~Phaser();
- void out(const Stereo<REALTYPE *> &input);
+ void out(const Stereo<float *> &input);
void setpreset(unsigned char npreset);
void changepar(int npar, unsigned char value);
unsigned char getpar(int npar) const;
@@ -74,12 +74,12 @@ class Phaser:public Effect
//Internal Variables
bool barber; //Barber pole phasing flag
- REALTYPE distortion, width, offsetpct;
- REALTYPE panning, feedback, depth, lrcross, phase;
- Stereo<REALTYPE *> old, xn1, yn1;
- Stereo<REALTYPE> diff, oldgain, fb;
- REALTYPE invperiod;
- REALTYPE offset[12];
+ float distortion, width, offsetpct;
+ float panning, feedback, depth, lrcross, phase;
+ Stereo<float *> old, xn1, yn1;
+ Stereo<float> diff, oldgain, fb;
+ float invperiod;
+ float offset[12];
float mis;
float Rmin; // 3N5457 typical on resistance at Vgs = 0
@@ -90,13 +90,13 @@ class Phaser:public Effect
float CFs; // A constant derived from capacitor and resistor relationships
void analog_setup();
- void AnalogPhase(const Stereo<REALTYPE *> &input);
+ void AnalogPhase(const Stereo<float *> &input);
//analog case
- REALTYPE applyPhase(REALTYPE x, REALTYPE g, REALTYPE fb,
- REALTYPE &hpf, REALTYPE *yn1, REALTYPE *xn1);
+ float applyPhase(float x, float g, float fb,
+ float &hpf, float *yn1, float *xn1);
- void normalPhase(const Stereo<REALTYPE *> &input);
- REALTYPE applyPhase(REALTYPE x, REALTYPE g, REALTYPE *old);
+ void normalPhase(const Stereo<float *> &input);
+ float applyPhase(float x, float g, float *old);
};
#endif
diff --git a/src/Effects/Reverb.cpp b/src/Effects/Reverb.cpp
@@ -26,7 +26,7 @@
/**\todo: EarlyReflections,Prdelay,Perbalance */
-Reverb::Reverb(const int &insertion_, REALTYPE *efxoutl_, REALTYPE *efxoutr_)
+Reverb::Reverb(const int &insertion_, float *efxoutl_, float *efxoutr_)
:Effect(insertion_, efxoutl_, efxoutr_, NULL, 0)
{
bandwidth = NULL;
@@ -119,16 +119,16 @@ void Reverb::cleanup()
/*
* Process one channel; 0=left,1=right
*/
-void Reverb::processmono(int ch, REALTYPE *output, REALTYPE *inputbuf)
+void Reverb::processmono(int ch, float *output, float *inputbuf)
{
/**\todo: implement the high part from lohidamp*/
for(int j = REV_COMBS * ch; j < REV_COMBS * (ch + 1); j++) {
int &ck = combk[j];
const int comblength = comblen[j];
- REALTYPE &lpcombj = lpcomb[j];
+ float &lpcombj = lpcomb[j];
for(int i = 0; i < SOUND_BUFFER_SIZE; i++) {
- REALTYPE fbout = comb[j][ck] * combfb[j];
+ float fbout = comb[j][ck] * combfb[j];
fbout = fbout * (1.0 - lohifb) + lpcombj * lohifb;
lpcombj = fbout;
@@ -144,7 +144,7 @@ void Reverb::processmono(int ch, REALTYPE *output, REALTYPE *inputbuf)
int &ak = apk[j];
const int aplength = aplen[j];
for(int i = 0; i < SOUND_BUFFER_SIZE; i++) {
- REALTYPE tmp = ap[j][ak];
+ float tmp = ap[j][ak];
ap[j][ak] = 0.7 * tmp + output[i];
output[i] = tmp - 0.7 * ap[j][ak];
if((++ak) >= aplength)
@@ -161,14 +161,14 @@ void Reverb::out(const Stereo<float *> &smp)
if((Pvolume == 0) && (insertion != 0))
return;
- REALTYPE *inputbuf = getTmpBuffer();
+ float *inputbuf = getTmpBuffer();
for(int i = 0; i < SOUND_BUFFER_SIZE; i++)
inputbuf[i] = (smp.l[i] + smp.r[i]) / 2.0;
if(idelay != NULL) {
for(int i = 0; i < SOUND_BUFFER_SIZE; i++) {
//Initial delay r
- REALTYPE tmp = inputbuf[i] + idelay[idelayk] * idelayfb;
+ float tmp = inputbuf[i] + idelay[idelayk] * idelayfb;
inputbuf[i] = idelay[idelayk];
idelay[idelayk] = tmp;
idelayk++;
@@ -189,8 +189,8 @@ void Reverb::out(const Stereo<float *> &smp)
processmono(1, efxoutr, inputbuf); //right
returnTmpBuffer(inputbuf);
- REALTYPE lvol = rs / REV_COMBS * pan;
- REALTYPE rvol = rs / REV_COMBS * (1.0 - pan);
+ float lvol = rs / REV_COMBS * pan;
+ float rvol = rs / REV_COMBS * (1.0 - pan);
if(insertion != 0) {
lvol *= 2;
rvol *= 2;
@@ -222,19 +222,19 @@ void Reverb::setvolume(unsigned char Pvolume)
void Reverb::setpan(unsigned char Ppan)
{
this->Ppan = Ppan;
- pan = (REALTYPE)Ppan / 127.0;
+ pan = (float)Ppan / 127.0;
}
void Reverb::settime(unsigned char Ptime)
{
int i;
- REALTYPE t;
+ float t;
this->Ptime = Ptime;
- t = pow(60.0, (REALTYPE)Ptime / 127.0) - 0.97;
+ t = pow(60.0, (float)Ptime / 127.0) - 0.97;
for(i = 0; i < REV_COMBS * 2; i++)
combfb[i] =
- -exp((REALTYPE)comblen[i] / (REALTYPE)SAMPLE_RATE * log(0.001) / t);
+ -exp((float)comblen[i] / (float)SAMPLE_RATE * log(0.001) / t);
//the feedback is negative because it removes the DC
}
@@ -253,14 +253,14 @@ void Reverb::setlohidamp(unsigned char Plohidamp)
lohidamptype = 1;
if(Plohidamp > 64)
lohidamptype = 2;
- REALTYPE x = fabs((REALTYPE)(Plohidamp - 64) / 64.1);
+ float x = fabs((float)(Plohidamp - 64) / 64.1);
lohifb = x * x;
}
}
void Reverb::setidelay(unsigned char Pidelay)
{
- REALTYPE delay;
+ float delay;
this->Pidelay = Pidelay;
delay = pow(50 * Pidelay / 127.0, 2) - 1.0;
@@ -271,7 +271,7 @@ void Reverb::setidelay(unsigned char Pidelay)
idelaylen = (int) (SAMPLE_RATE * delay / 1000);
if(idelaylen > 1) {
idelayk = 0;
- idelay = new REALTYPE[idelaylen];
+ idelay = new float[idelaylen];
for(int i = 0; i < idelaylen; i++)
idelay[i] = 0.0;
}
@@ -292,7 +292,7 @@ void Reverb::sethpf(unsigned char Phpf)
hpf = NULL;
}
else {
- REALTYPE fr = exp(pow(Phpf / 127.0, 0.5) * log(10000.0)) + 20.0;
+ float fr = exp(pow(Phpf / 127.0, 0.5) * log(10000.0)) + 20.0;
if(hpf == NULL)
hpf = new AnalogFilter(3, fr, 1, 0);
else
@@ -309,7 +309,7 @@ void Reverb::setlpf(unsigned char Plpf)
lpf = NULL;
}
else {
- REALTYPE fr = exp(pow(Plpf / 127.0, 0.5) * log(25000.0)) + 40;
+ float fr = exp(pow(Plpf / 127.0, 0.5) * log(25000.0)) + 40;
if(lpf == NULL)
lpf = new AnalogFilter(2, fr, 1, 0);
else
@@ -341,7 +341,7 @@ void Reverb::settype(unsigned char Ptype)
Ptype = NUM_TYPES - 1;
this->Ptype = Ptype;
- REALTYPE tmp;
+ float tmp;
for(int i = 0; i < REV_COMBS * 2; i++) {
if(Ptype == 0)
tmp = 800.0 + (int)(RND * 1400.0);
@@ -359,7 +359,7 @@ void Reverb::settype(unsigned char Ptype)
lpcomb[i] = 0;
if(comb[i] != NULL)
delete [] comb[i];
- comb[i] = new REALTYPE[comblen[i]];
+ comb[i] = new float[comblen[i]];
}
for(int i = 0; i < REV_APS * 2; i++) {
@@ -377,7 +377,7 @@ void Reverb::settype(unsigned char Ptype)
apk[i] = 0;
if(ap[i] != NULL)
delete [] ap[i];
- ap[i] = new REALTYPE[aplen[i]];
+ ap[i] = new float[aplen[i]];
}
settime(Ptime);
cleanup();
@@ -407,7 +407,7 @@ void Reverb::setroomsize(unsigned char Proomsize)
void Reverb::setbandwidth(unsigned char Pbandwidth) {
this->Pbandwidth = Pbandwidth;
- REALTYPE v = Pbandwidth / 127.0;
+ float v = Pbandwidth / 127.0;
if(bandwidth)
bandwidth->set_bandwidth(pow(v, 2.0) * 200.0);
}
diff --git a/src/Effects/Reverb.h b/src/Effects/Reverb.h
@@ -38,7 +38,7 @@
class Reverb:public Effect
{
public:
- Reverb(const int &insertion_, REALTYPE *efxoutl_, REALTYPE *efxoutr_);
+ Reverb(const int &insertion_, float *efxoutl_, float *efxoutr_);
~Reverb();
void out(const Stereo<float *> &smp);
void cleanup();
@@ -102,32 +102,32 @@ class Reverb:public Effect
void setroomsize(unsigned char Proomsize);
void setbandwidth(unsigned char Pbandwidth);
- REALTYPE pan, erbalance;
+ float pan, erbalance;
//Parameters
int lohidamptype; /**<0=disable,1=highdamp(lowpass),2=lowdamp(highpass)*/
int idelaylen, rdelaylen;
int idelayk;
- REALTYPE lohifb, idelayfb, roomsize, rs; //rs is used to "normalise" the volume according to the roomsize
+ float lohifb, idelayfb, roomsize, rs; //rs is used to "normalise" the volume according to the roomsize
int comblen[REV_COMBS * 2];
int aplen[REV_APS * 2];
Unison *bandwidth;
//Internal Variables
- REALTYPE *comb[REV_COMBS * 2];
+ float *comb[REV_COMBS * 2];
int combk[REV_COMBS * 2];
- REALTYPE combfb[REV_COMBS * 2]; /**<feedback-ul fiecarui filtru "comb"*/
- REALTYPE lpcomb[REV_COMBS * 2]; /**<pentru Filtrul LowPass*/
+ float combfb[REV_COMBS * 2]; /**<feedback-ul fiecarui filtru "comb"*/
+ float lpcomb[REV_COMBS * 2]; /**<pentru Filtrul LowPass*/
- REALTYPE *ap[REV_APS * 2];
+ float *ap[REV_APS * 2];
int apk[REV_APS * 2];
- REALTYPE *idelay;
+ float *idelay;
AnalogFilter *lpf, *hpf; //filters
- void processmono(int ch, REALTYPE *output, REALTYPE *inputbuf);
+ void processmono(int ch, float *output, float *inputbuf);
};
#endif
diff --git a/src/Misc/Master.cpp b/src/Misc/Master.cpp
@@ -189,7 +189,7 @@ void Master::setController(char chan, int type, int par)
}
}
-void Master::vuUpdate(const REALTYPE *outl, const REALTYPE *outr)
+void Master::vuUpdate(const float *outl, const float *outr)
{
//Peak computation (for vumeters)
vu.outpeakl = 1e-12;
@@ -221,10 +221,10 @@ void Master::vuUpdate(const REALTYPE *outl, const REALTYPE *outr)
for(int npart = 0; npart < NUM_MIDI_PARTS; npart++) {
vuoutpeakpart[npart] = 1.0e-12;
if(part[npart]->Penabled != 0) {
- REALTYPE *outl = part[npart]->partoutl,
+ float *outl = part[npart]->partoutl,
*outr = part[npart]->partoutr;
for(int i = 0; i < SOUND_BUFFER_SIZE; i++) {
- REALTYPE tmp = fabs(outl[i] + outr[i]);
+ float tmp = fabs(outl[i] + outr[i]);
if(tmp > vuoutpeakpart[npart])
vuoutpeakpart[npart] = tmp;
}
@@ -262,15 +262,15 @@ void Master::partonoff(int npart, int what)
/*
* Master audio out (the final sound)
*/
-void Master::AudioOut(REALTYPE *outl, REALTYPE *outr)
+void Master::AudioOut(float *outl, float *outr)
{
//Swaps the Left channel with Right Channel
if(swaplr)
swap(outl,outr);
//clean up the output samples (should not be needed?)
- memset(outl, 0, sizeof(REALTYPE) * SOUND_BUFFER_SIZE);
- memset(outr, 0, sizeof(REALTYPE) * SOUND_BUFFER_SIZE);
+ memset(outl, 0, sizeof(float) * SOUND_BUFFER_SIZE);
+ memset(outr, 0, sizeof(float) * SOUND_BUFFER_SIZE);
//Compute part samples and store them part[npart]->partoutl,partoutr
for(int npart = 0; npart < NUM_MIDI_PARTS; npart++)
@@ -293,11 +293,11 @@ void Master::AudioOut(REALTYPE *outl, REALTYPE *outr)
if(part[npart]->Penabled == 0)
continue;
- Stereo<REALTYPE> newvol(part[npart]->volume),
+ Stereo<float> newvol(part[npart]->volume),
oldvol(part[npart]->oldvolumel,
part[npart]->oldvolumer);
- REALTYPE pan = part[npart]->panning;
+ float pan = part[npart]->panning;
if(pan < 0.5)
newvol.l *= pan * 2.0;
else
@@ -307,7 +307,7 @@ void Master::AudioOut(REALTYPE *outl, REALTYPE *outr)
if(ABOVE_AMPLITUDE_THRESHOLD(oldvol.l, newvol.l)
|| ABOVE_AMPLITUDE_THRESHOLD(oldvol.r, newvol.r)) {
for(int i = 0; i < SOUND_BUFFER_SIZE; i++) {
- Stereo<REALTYPE> vol(INTERPOLATE_AMPLITUDE(oldvol.l, newvol.l,
+ Stereo<float> vol(INTERPOLATE_AMPLITUDE(oldvol.l, newvol.l,
i, SOUND_BUFFER_SIZE),
INTERPOLATE_AMPLITUDE(oldvol.r, newvol.r,
i, SOUND_BUFFER_SIZE));
@@ -331,11 +331,11 @@ void Master::AudioOut(REALTYPE *outl, REALTYPE *outr)
if(sysefx[nefx]->geteffect() == 0)
continue; //the effect is disabled
- REALTYPE *tmpmixl = getTmpBuffer();
- REALTYPE *tmpmixr = getTmpBuffer();
+ float *tmpmixl = getTmpBuffer();
+ float *tmpmixr = getTmpBuffer();
//Clean up the samples used by the system effects
- memset(tmpmixl, 0, sizeof(REALTYPE) * SOUND_BUFFER_SIZE);
- memset(tmpmixr, 0, sizeof(REALTYPE) * SOUND_BUFFER_SIZE);
+ memset(tmpmixl, 0, sizeof(float) * SOUND_BUFFER_SIZE);
+ memset(tmpmixr, 0, sizeof(float) * SOUND_BUFFER_SIZE);
//Mix the channels according to the part settings about System Effect
for(int npart = 0; npart < NUM_MIDI_PARTS; npart++) {
@@ -348,7 +348,7 @@ void Master::AudioOut(REALTYPE *outl, REALTYPE *outr)
continue;
//the output volume of each part to system effect
- const REALTYPE vol = sysefxvol[nefx][npart];
+ const float vol = sysefxvol[nefx][npart];
for(int i = 0; i < SOUND_BUFFER_SIZE; i++) {
tmpmixl[i] += part[npart]->partoutl[i] * vol;
tmpmixr[i] += part[npart]->partoutr[i] * vol;
@@ -358,7 +358,7 @@ void Master::AudioOut(REALTYPE *outl, REALTYPE *outr)
// system effect send to next ones
for(int nefxfrom = 0; nefxfrom < nefx; nefxfrom++) {
if(Psysefxsend[nefxfrom][nefx] != 0) {
- const REALTYPE vol = sysefxsend[nefxfrom][nefx];
+ const float vol = sysefxsend[nefxfrom][nefx];
for(int i = 0; i < SOUND_BUFFER_SIZE; i++) {
tmpmixl[i] += sysefx[nefxfrom]->efxoutl[i] * vol;
tmpmixr[i] += sysefx[nefxfrom]->efxoutr[i] * vol;
@@ -369,7 +369,7 @@ void Master::AudioOut(REALTYPE *outl, REALTYPE *outr)
sysefx[nefx]->out(tmpmixl, tmpmixr);
//Add the System Effect to sound output
- const REALTYPE outvol = sysefx[nefx]->sysefxgetvolume();
+ const float outvol = sysefx[nefx]->sysefxgetvolume();
for(int i = 0; i < SOUND_BUFFER_SIZE; i++) {
outl[i] += tmpmixl[i] * outvol;
outr[i] += tmpmixr[i] * outvol;
@@ -409,8 +409,8 @@ void Master::AudioOut(REALTYPE *outl, REALTYPE *outr)
//Shutup if it is asked (with fade-out)
if(shutup) {
for(int i = 0; i < SOUND_BUFFER_SIZE; i++) {
- REALTYPE tmp =
- (SOUND_BUFFER_SIZE - i) / (REALTYPE) SOUND_BUFFER_SIZE;
+ float tmp =
+ (SOUND_BUFFER_SIZE - i) / (float) SOUND_BUFFER_SIZE;
outl[i] *= tmp;
outr[i] *= tmp;
}
diff --git a/src/Misc/Master.h b/src/Misc/Master.h
@@ -38,7 +38,7 @@ typedef enum { MUTEX_TRYLOCK, MUTEX_LOCK, MUTEX_UNLOCK } lockset;
extern Dump dump;
typedef struct vuData_t {
- REALTYPE outpeakl, outpeakr, maxoutpeakl, maxoutpeakr,
+ float outpeakl, outpeakr, maxoutpeakl, maxoutpeakr,
rmspeakl, rmspeakr;
int clipped;
} vuData;
@@ -95,15 +95,15 @@ class Master
void ShutUp();
int shutup;
- void vuUpdate(const REALTYPE *outl, const REALTYPE *outr);
+ void vuUpdate(const float *outl, const float *outr);
/**Audio Output*/
- void AudioOut(REALTYPE *outl, REALTYPE *outr);
+ void AudioOut(float *outl, float *outr);
/**Audio Output (for callback mode). This allows the program to be controled by an external program*/
void GetAudioOutSamples(int nsamples,
int samplerate,
- REALTYPE *outl,
- REALTYPE *outr);
+ float *outl,
+ float *outr);
void partonoff(int npart, int what);
@@ -142,7 +142,7 @@ class Master
//peaks for part VU-meters
/**\todo synchronize this with a mutex*/
- REALTYPE vuoutpeakpart[NUM_MIDI_PARTS];
+ float vuoutpeakpart[NUM_MIDI_PARTS];
unsigned char fakepeakpart[NUM_MIDI_PARTS]; //this is used to compute the "peak" when the part is disabled
Controller ctl;
@@ -160,9 +160,9 @@ class Master
private:
bool nullRun;
vuData vu;
- REALTYPE volume;
- REALTYPE sysefxvol[NUM_SYS_EFX][NUM_MIDI_PARTS];
- REALTYPE sysefxsend[NUM_SYS_EFX][NUM_SYS_EFX];
+ float volume;
+ float sysefxvol[NUM_SYS_EFX][NUM_MIDI_PARTS];
+ float sysefxsend[NUM_SYS_EFX][NUM_SYS_EFX];
int keyshift;
};
diff --git a/src/Misc/Microtonal.cpp b/src/Misc/Microtonal.cpp
@@ -95,7 +95,7 @@ unsigned char Microtonal::getoctavesize() const
/*
* Get the frequency according the note number
*/
-REALTYPE Microtonal::getnotefreq(int note, int keyshift) const
+float Microtonal::getnotefreq(int note, int keyshift) const
{
// in this function will appears many times things like this:
// var=(a+b*100)%b
@@ -106,7 +106,7 @@ REALTYPE Microtonal::getnotefreq(int note, int keyshift) const
note = (int) Pinvertupdowncenter * 2 - note;
//compute global fine detune
- REALTYPE globalfinedetunerap = pow(2.0, (Pglobalfinedetune - 64.0) / 1200.0); //-64.0 .. 63.0 cents
+ float globalfinedetunerap = pow(2.0, (Pglobalfinedetune - 64.0) / 1200.0); //-64.0 .. 63.0 cents
if(Penabled == 0)
return pow(2.0,
@@ -117,7 +117,7 @@ REALTYPE Microtonal::getnotefreq(int note, int keyshift) const
((int)Pscaleshift - 64 + (int) octavesize * 100) % octavesize;
//compute the keyshift
- REALTYPE rap_keyshift = 1.0;
+ float rap_keyshift = 1.0;
if(keyshift != 0) {
int kskey = (keyshift + (int)octavesize * 100) % octavesize;
int ksoct = (keyshift + (int)octavesize * 100) / octavesize - 100;
@@ -140,7 +140,7 @@ REALTYPE Microtonal::getnotefreq(int note, int keyshift) const
for(int i = 0; i < tmp; i++)
if(Pmapping[i % Pmapsize] >= 0)
deltanote++;
- REALTYPE rap_anote_middlenote =
+ float rap_anote_middlenote =
(deltanote ==
0) ? (1.0) : (octave[(deltanote - 1) % octavesize].tuning);
if(deltanote != 0)
@@ -169,7 +169,7 @@ REALTYPE Microtonal::getnotefreq(int note, int keyshift) const
degoct += degkey / octavesize;
degkey %= octavesize;
- REALTYPE freq = (degkey == 0) ? (1.0) : octave[degkey - 1].tuning;
+ float freq = (degkey == 0) ? (1.0) : octave[degkey - 1].tuning;
freq *= pow(octave[octavesize - 1].tuning, degoct);
freq *= PAfreq / rap_anote_middlenote;
freq *= globalfinedetunerap;
@@ -182,8 +182,8 @@ REALTYPE Microtonal::getnotefreq(int note, int keyshift) const
int ntkey = (nt + (int)octavesize * 100) % octavesize;
int ntoct = (nt - ntkey) / octavesize;
- REALTYPE oct = octave[octavesize - 1].tuning;
- REALTYPE freq =
+ float oct = octave[octavesize - 1].tuning;
+ float freq =
octave[(ntkey + octavesize - 1) % octavesize].tuning *pow(oct,
ntoct)
* PAfreq;
@@ -255,7 +255,7 @@ bool Microtonal::operator!=(const Microtonal µ) const
int Microtonal::linetotunings(unsigned int nline, const char *line)
{
int x1 = -1, x2 = -1, type = -1;
- REALTYPE x = -1.0, tmp, tuning = 1.0;
+ float x = -1.0, tmp, tuning = 1.0;
if(strstr(line, "/") == NULL) {
if(strstr(line, ".") == NULL) { // M case (M=M/1)
sscanf(line, "%d", &x1);
@@ -285,7 +285,7 @@ int Microtonal::linetotunings(unsigned int nline, const char *line)
if((type == 2)
&& ((x1 > (128 * 128 * 128 - 1)) || (x2 > (128 * 128 * 128 - 1)))) {
type = 1;
- x = ((REALTYPE) x1) / x2;
+ x = ((float) x1) / x2;
}
switch(type) {
case 1:
@@ -295,7 +295,7 @@ int Microtonal::linetotunings(unsigned int nline, const char *line)
tuning = pow(2.0, x / 1200.0);
break;
case 2:
- x = ((REALTYPE)x1) / x2;
+ x = ((float)x1) / x2;
tuning = x;
break;
}
@@ -514,7 +514,7 @@ int Microtonal::loadkbm(const char *filename)
//loads the reference freq.
if(loadline(file, &tmp[0]) != 0)
return 2;
- REALTYPE tmpPAfreq = 440.0;
+ float tmpPAfreq = 440.0;
if(sscanf(&tmp[0], "%f", &tmpPAfreq) == 0)
return 2;
PAfreq = tmpPAfreq;
diff --git a/src/Misc/Microtonal.h b/src/Misc/Microtonal.h
@@ -43,7 +43,7 @@ class Microtonal
void defaults();
/**Calculates the frequency for a given note
*/
- REALTYPE getnotefreq(int note, int keyshift) const;
+ float getnotefreq(int note, int keyshift) const;
//Parameters
@@ -60,7 +60,7 @@ class Microtonal
unsigned char PAnote;
/**the frequency of the "A" note*/
- REALTYPE PAfreq;
+ float PAfreq;
/**if the scale is "tuned" to a note, you can tune to other note*/
unsigned char Pscaleshift;
@@ -124,7 +124,7 @@ class Microtonal
// the real tuning (eg. +1.05946 for one halftone)
// or 2.0 for one octave
- REALTYPE tuning;
+ float tuning;
//the real tunning is x1/x2
unsigned int x1, x2;
diff --git a/src/Misc/Part.cpp b/src/Misc/Part.cpp
@@ -40,8 +40,8 @@ Part::Part(Microtonal *microtonal_, FFTwrapper *fft_, pthread_mutex_t *mutex_)
microtonal = microtonal_;
fft = fft_;
mutex = mutex_;
- partoutl = new REALTYPE [SOUND_BUFFER_SIZE];
- partoutr = new REALTYPE [SOUND_BUFFER_SIZE];
+ partoutl = new float [SOUND_BUFFER_SIZE];
+ partoutr = new float [SOUND_BUFFER_SIZE];
for(int n = 0; n < NUM_KIT_ITEMS; n++) {
kit[n].Pname = new unsigned char [PART_MAX_NAME_LEN];
@@ -61,8 +61,8 @@ Part::Part(Microtonal *microtonal_, FFTwrapper *fft_, pthread_mutex_t *mutex_)
}
for(int n = 0; n < NUM_PART_EFX + 1; n++) {
- partfxinputl[n] = new REALTYPE [SOUND_BUFFER_SIZE];
- partfxinputr[n] = new REALTYPE [SOUND_BUFFER_SIZE];
+ partfxinputl[n] = new float [SOUND_BUFFER_SIZE];
+ partfxinputr[n] = new float [SOUND_BUFFER_SIZE];
}
killallnotes = 0;
@@ -302,7 +302,7 @@ void Part::NoteOn(unsigned char note,
}
//this computes the velocity sensing of the part
- REALTYPE vel = VelF(velocity / 127.0, Pvelsns);
+ float vel = VelF(velocity / 127.0, Pvelsns);
//compute the velocity offset
vel += (Pveloffs - 64.0) / 64.0;
@@ -317,7 +317,7 @@ void Part::NoteOn(unsigned char note,
int keyshift = masterkeyshift + partkeyshift;
//initialise note frequency
- REALTYPE notebasefreq;
+ float notebasefreq;
if(Pdrummode == 0) {
notebasefreq = microtonal->getnotefreq(note, keyshift);
if(notebasefreq < 0.0)
@@ -820,8 +820,8 @@ void Part::RunNote(unsigned int k)
continue;
noteplay++;
- REALTYPE *tmpoutr = getTmpBuffer();
- REALTYPE *tmpoutl = getTmpBuffer();
+ float *tmpoutr = getTmpBuffer();
+ float *tmpoutl = getTmpBuffer();
(*note)->noteout(&tmpoutl[0], &tmpoutr[0]);
if((*note)->finished()) {
@@ -888,8 +888,8 @@ void Part::ComputePartSmps()
//Kill All Notes if killallnotes!=0
if(killallnotes != 0) {
for(int i = 0; i < SOUND_BUFFER_SIZE; i++) {
- REALTYPE tmp =
- (SOUND_BUFFER_SIZE - i) / (REALTYPE) SOUND_BUFFER_SIZE;
+ float tmp =
+ (SOUND_BUFFER_SIZE - i) / (float) SOUND_BUFFER_SIZE;
partoutl[i] *= tmp;
partoutr[i] *= tmp;
}
diff --git a/src/Misc/Part.h b/src/Misc/Part.h
@@ -128,18 +128,18 @@ class Part
} info;
- REALTYPE *partoutl; //Left channel output of the part
- REALTYPE *partoutr; //Right channel output of the part
+ float *partoutl; //Left channel output of the part
+ float *partoutr; //Right channel output of the part
- REALTYPE *partfxinputl[NUM_PART_EFX + 1], //Left and right signal that pass thru part effects;
+ float *partfxinputl[NUM_PART_EFX + 1], //Left and right signal that pass thru part effects;
*partfxinputr[NUM_PART_EFX + 1]; //partfxinput l/r [NUM_PART_EFX] is for "no effect" buffer
enum NoteStatus {
KEY_OFF, KEY_PLAYING, KEY_RELASED_AND_SUSTAINED, KEY_RELASED
};
- REALTYPE volume, oldvolumel, oldvolumer; //this is applied by Master
- REALTYPE panning; //this is applied by Master, too
+ float volume, oldvolumel, oldvolumer; //this is applied by Master
+ float panning; //this is applied by Master, too
Controller ctl; //Part controllers
@@ -189,7 +189,7 @@ class Part
PartNotes partnote[POLIPHONY];
- REALTYPE oldfreq; //this is used for portamento
+ float oldfreq; //this is used for portamento
Microtonal *microtonal;
FFTwrapper *fft;
};
diff --git a/src/Misc/Util.cpp b/src/Misc/Util.cpp
@@ -39,15 +39,15 @@ int SOUND_BUFFER_SIZE = 256;
int OSCIL_SIZE = 1024;
Config config;
-REALTYPE *denormalkillbuf;
+float *denormalkillbuf;
/*
* Transform the velocity according the scaling parameter (velocity sensing)
*/
-REALTYPE VelF(REALTYPE velocity, unsigned char scaling)
+float VelF(float velocity, unsigned char scaling)
{
- REALTYPE x;
+ float x;
x = pow(VELOCITY_MAX_SCALE, (64.0 - scaling) / 64.0);
if((scaling == 127) || (velocity > 0.99))
return 1.0;
@@ -58,11 +58,11 @@ REALTYPE VelF(REALTYPE velocity, unsigned char scaling)
/*
* Get the detune in cents
*/
-REALTYPE getdetune(unsigned char type,
+float getdetune(unsigned char type,
unsigned short int coarsedetune,
unsigned short int finedetune)
{
- REALTYPE det = 0.0, octdet = 0.0, cdet = 0.0, findet = 0.0;
+ float det = 0.0, octdet = 0.0, cdet = 0.0, findet = 0.0;
//Get Octave
int octave = coarsedetune / 1024;
if(octave >= 8)
@@ -141,16 +141,16 @@ std::string legalizeFilename(std::string filename)
return filename;
}
-void invSignal(REALTYPE *sig, size_t len)
+void invSignal(float *sig, size_t len)
{
for(size_t i = 0; i < len; i++)
sig[i] *= -1.0f;
}
-void crossover(REALTYPE &a, REALTYPE &b, REALTYPE crossover)
+void crossover(float &a, float &b, float crossover)
{
- REALTYPE tmpa = a;
- REALTYPE tmpb = b;
+ float tmpa = a;
+ float tmpb = b;
a = tmpa * (1.0 - crossover) + tmpb * crossover;
b = tmpb * (1.0 - crossover) + tmpa * crossover;
}
@@ -160,14 +160,14 @@ void crossover(REALTYPE &a, REALTYPE &b, REALTYPE crossover)
struct pool_entry{
bool free;
- REALTYPE *dat;
+ float *dat;
};
typedef std::vector<pool_entry> pool_t;
typedef pool_t::iterator pool_itr_t;
pool_t pool;
-REALTYPE *getTmpBuffer()
+float *getTmpBuffer()
{
for(pool_itr_t itr = pool.begin(); itr != pool.end(); ++itr) {
if(itr->free) { //Use Pool
@@ -177,13 +177,13 @@ REALTYPE *getTmpBuffer()
}
pool_entry p; //Extend Pool
p.free = false;
- p.dat = new REALTYPE[SOUND_BUFFER_SIZE];
+ p.dat = new float[SOUND_BUFFER_SIZE];
pool.push_back(p);
return p.dat;
}
-void returnTmpBuffer(REALTYPE *buf)
+void returnTmpBuffer(float *buf)
{
for(pool_itr_t itr = pool.begin(); itr != pool.end(); ++itr) {
if(itr->dat == buf) { //Return to Pool
diff --git a/src/Misc/Util.h b/src/Misc/Util.h
@@ -29,12 +29,12 @@
#include "../globals.h"
//Velocity Sensing function
-extern REALTYPE VelF(REALTYPE velocity, unsigned char scaling);
+extern float VelF(float velocity, unsigned char scaling);
bool fileexists(const char *filename);
#define N_DETUNE_TYPES 4 //the number of detune types
-extern REALTYPE getdetune(unsigned char type,
+extern float getdetune(unsigned char type,
unsigned short int coarsedetune,
unsigned short int finedetune);
@@ -49,19 +49,19 @@ void os_sleep(long length);
std::string legalizeFilename(std::string filename);
-extern REALTYPE *denormalkillbuf; /**<the buffer to add noise in order to avoid denormalisation*/
+extern float *denormalkillbuf; /**<the buffer to add noise in order to avoid denormalisation*/
extern class Config config;
-void invSignal(REALTYPE *sig, size_t len);
+void invSignal(float *sig, size_t len);
-void crossover(REALTYPE &a, REALTYPE &b, REALTYPE crossover);
+void crossover(float &a, float &b, float crossover);
//Memory pool for temporary buffers
//No allocation in *normal* case
//All should be sized to SOUND_BUFFER_SIZE
-REALTYPE *getTmpBuffer();
-void returnTmpBuffer(REALTYPE *buf);
+float *getTmpBuffer();
+void returnTmpBuffer(float *buf);
template<class T>
std::string stringFrom(T x)
diff --git a/src/Misc/XMLwrapper.cpp b/src/Misc/XMLwrapper.cpp
@@ -249,10 +249,10 @@ void XMLwrapper::addpar(const string &name, int val)
val).c_str());
}
-void XMLwrapper::addparreal(const string &name, REALTYPE val)
+void XMLwrapper::addparreal(const string &name, float val)
{
addparams("par_real", 2, "name", name.c_str(), "value",
- stringFrom<REALTYPE>(val).c_str());
+ stringFrom<float>(val).c_str());
}
void XMLwrapper::addparbool(const string &name, int val)
@@ -559,7 +559,7 @@ string XMLwrapper::getparstr(const string &name,
return defaultpar;
}
-REALTYPE XMLwrapper::getparreal(const char *name, REALTYPE defaultpar) const
+float XMLwrapper::getparreal(const char *name, float defaultpar) const
{
const mxml_node_t *tmp = mxmlFindElement(node,
node,
@@ -574,15 +574,15 @@ REALTYPE XMLwrapper::getparreal(const char *name, REALTYPE defaultpar) const
if(strval == NULL)
return defaultpar;
- return stringTo<REALTYPE>(strval);
+ return stringTo<float>(strval);
}
-REALTYPE XMLwrapper::getparreal(const char *name,
- REALTYPE defaultpar,
- REALTYPE min,
- REALTYPE max) const
+float XMLwrapper::getparreal(const char *name,
+ float defaultpar,
+ float min,
+ float max) const
{
- REALTYPE result = getparreal(name, defaultpar);
+ float result = getparreal(name, defaultpar);
if(result < min)
result = min;
diff --git a/src/Misc/XMLwrapper.h b/src/Misc/XMLwrapper.h
@@ -24,8 +24,8 @@
#include <mxml.h>
#include <string>
-#ifndef REALTYPE
-#define REALTYPE float
+#ifndef float
+#define float float
#endif
#ifndef XML_WRAPPER_H
@@ -68,9 +68,9 @@ class XMLwrapper
/**
* Adds a realtype parameter.
* @param name The name of the mXML node.
- * @param val The REALTYPE value of the node.
+ * @param val The float value of the node.
*/
- void addparreal(const std::string &name, REALTYPE val);
+ void addparreal(const std::string &name, float val);
/**
* Add boolean parameter.
@@ -195,7 +195,7 @@ class XMLwrapper
* @param name The parameter name.
* @param defaultpar The default value if the real value is not found.
*/
- REALTYPE getparreal(const char *name, REALTYPE defaultpar) const;
+ float getparreal(const char *name, float defaultpar) const;
/**
* Returns the real value stored in the node.
@@ -204,10 +204,10 @@ class XMLwrapper
* @param min The minimum value
* @param max The maximum value
*/
- REALTYPE getparreal(const char *name,
- REALTYPE defaultpar,
- REALTYPE min,
- REALTYPE max) const;
+ float getparreal(const char *name,
+ float defaultpar,
+ float min,
+ float max) const;
bool minimal; /**<false if all parameters will be stored (used only for clipboard)*/
diff --git a/src/Nio/AlsaEngine.cpp b/src/Nio/AlsaEngine.cpp
@@ -233,7 +233,7 @@ void AlsaEngine::stopMidi()
snd_seq_close(handle);
}
-short *AlsaEngine::interleave(const Stereo<REALTYPE *> &smps)
+short *AlsaEngine::interleave(const Stereo<float *> &smps)
{
/**\todo TODO fix repeated allocation*/
short *shortInterleaved = audio.buffer;
diff --git a/src/Nio/AlsaEngine.h b/src/Nio/AlsaEngine.h
@@ -57,7 +57,7 @@ class AlsaEngine : public AudioOut, MidiIn
bool openAudio();
void stopAudio();
- short *interleave(const Stereo<REALTYPE *> &smps);
+ short *interleave(const Stereo<float *> &smps);
struct {
std::string device;
diff --git a/src/Nio/AudioOut.cpp b/src/Nio/AudioOut.cpp
@@ -53,7 +53,7 @@ void AudioOut::setBufferSize(int _bufferSize)
bufferSize = _bufferSize;
}
-const Stereo<REALTYPE *> AudioOut::getNext()
+const Stereo<float *> AudioOut::getNext()
{
return OutMgr::getInstance().tick(bufferSize);
}
diff --git a/src/Nio/AudioOut.h b/src/Nio/AudioOut.h
@@ -52,7 +52,7 @@ class AudioOut : public virtual Engine
protected:
/**Get the next sample for output.
* (has nsamples sampled at a rate of samplerate)*/
- const Stereo<REALTYPE *> getNext();
+ const Stereo<float *> getNext();
int samplerate;
int bufferSize;
diff --git a/src/Nio/JackEngine.cpp b/src/Nio/JackEngine.cpp
@@ -283,11 +283,11 @@ bool JackEngine::processAudio(jack_nframes_t nframes)
}
}
- Stereo<REALTYPE *> smp = getNext();
+ Stereo<float *> smp = getNext();
//Assumes size of smp.l == nframes
- memcpy(audio.portBuffs[0], smp.l, bufferSize*sizeof(REALTYPE));
- memcpy(audio.portBuffs[1], smp.r, bufferSize*sizeof(REALTYPE));
+ memcpy(audio.portBuffs[0], smp.l, bufferSize*sizeof(float));
+ memcpy(audio.portBuffs[1], smp.r, bufferSize*sizeof(float));
return true;
}
diff --git a/src/Nio/OssEngine.cpp b/src/Nio/OssEngine.cpp
@@ -209,9 +209,9 @@ void *OssEngine::thread()
{
if(getAudioEn())
{
- const Stereo<REALTYPE *> smps = getNext();
+ const Stereo<float *> smps = getNext();
- REALTYPE l, r;
+ float l, r;
for(int i = 0; i < SOUND_BUFFER_SIZE; i++) {
l = smps.l[i];
r = smps.r[i];
diff --git a/src/Nio/OutMgr.cpp b/src/Nio/OutMgr.cpp
@@ -20,15 +20,15 @@ OutMgr &OutMgr::getInstance()
OutMgr::OutMgr()
:wave(new WavEngine()),
- priBuf(new REALTYPE[4096],new REALTYPE[4096]),priBuffCurrent(priBuf),master(Master::getInstance())
+ priBuf(new float[4096],new float[4096]),priBuffCurrent(priBuf),master(Master::getInstance())
{
currentOut = NULL;
stales = 0;
master = Master::getInstance();
//init samples
- outr = new REALTYPE[SOUND_BUFFER_SIZE];
- outl = new REALTYPE[SOUND_BUFFER_SIZE];
+ outr = new float[SOUND_BUFFER_SIZE];
+ outl = new float[SOUND_BUFFER_SIZE];
};
OutMgr::~OutMgr()
@@ -51,7 +51,7 @@ OutMgr::~OutMgr()
* 8) Lets return those samples to the primary and secondary outputs
* 9) Lets wait for another tick
*/
-const Stereo<REALTYPE *> OutMgr::tick(unsigned int frameSize)
+const Stereo<float *> OutMgr::tick(unsigned int frameSize)
{
pthread_mutex_lock(&(master.mutex));
InMgr::getInstance().flush();
@@ -64,7 +64,7 @@ const Stereo<REALTYPE *> OutMgr::tick(unsigned int frameSize)
pthread_mutex_unlock(&(master.mutex));
addSmps(outl,outr);
}
- Stereo<REALTYPE *> ans = priBuffCurrent;
+ Stereo<float *> ans = priBuffCurrent;
ans.l -= frameSize;
ans.r -= frameSize;
//cout << storedSmps() << '=' << frameSize << endl;
@@ -114,22 +114,22 @@ string OutMgr::getSink() const
return "ERROR";
}
-void OutMgr::addSmps(REALTYPE *l, REALTYPE *r)
+void OutMgr::addSmps(float *l, float *r)
{
//allow wave file to syphon off stream
- wave->push(Stereo<REALTYPE *>(l,r),SOUND_BUFFER_SIZE);
+ wave->push(Stereo<float *>(l,r),SOUND_BUFFER_SIZE);
if(currentOut->getSampleRate() != SAMPLE_RATE) { //we need to resample
//cout << "BAD RESAMPLING" << endl;
Stereo<Sample> smps(Sample(SOUND_BUFFER_SIZE, l), Sample(SOUND_BUFFER_SIZE, r));
smps.l.resample(SAMPLE_RATE,currentOut->getSampleRate());
smps.r.resample(SAMPLE_RATE,currentOut->getSampleRate());
- memcpy(priBuffCurrent.l, smps.l.c_buf(), SOUND_BUFFER_SIZE*sizeof(REALTYPE));
- memcpy(priBuffCurrent.r, smps.r.c_buf(), SOUND_BUFFER_SIZE*sizeof(REALTYPE));
+ memcpy(priBuffCurrent.l, smps.l.c_buf(), SOUND_BUFFER_SIZE*sizeof(float));
+ memcpy(priBuffCurrent.r, smps.r.c_buf(), SOUND_BUFFER_SIZE*sizeof(float));
}
else { //just copy the samples
- memcpy(priBuffCurrent.l, l, SOUND_BUFFER_SIZE*sizeof(REALTYPE));
- memcpy(priBuffCurrent.r, r, SOUND_BUFFER_SIZE*sizeof(REALTYPE));
+ memcpy(priBuffCurrent.l, l, SOUND_BUFFER_SIZE*sizeof(float));
+ memcpy(priBuffCurrent.r, r, SOUND_BUFFER_SIZE*sizeof(float));
}
priBuffCurrent.l += SOUND_BUFFER_SIZE;
priBuffCurrent.r += SOUND_BUFFER_SIZE;
@@ -142,8 +142,8 @@ void OutMgr::removeStaleSmps()
return;
//memset is possibly unneeded
- memset(priBuf.l, '0', 4096*sizeof(REALTYPE));
- memset(priBuf.r, '0', 4096*sizeof(REALTYPE));
+ memset(priBuf.l, '0', 4096*sizeof(float));
+ memset(priBuf.r, '0', 4096*sizeof(float));
priBuffCurrent = priBuf;
stales = 0;
}
diff --git a/src/Nio/OutMgr.h b/src/Nio/OutMgr.h
@@ -16,7 +16,7 @@ class OutMgr
~OutMgr();
/**Execute a tick*/
- const Stereo<REALTYPE *> tick(unsigned int frameSize);
+ const Stereo<float *> tick(unsigned int frameSize);
/**Request a new set of samples
* @param n number of requested samples (defaults to 1)
@@ -43,7 +43,7 @@ class OutMgr
friend class EngineMgr;
private:
OutMgr();
- void addSmps(REALTYPE *l, REALTYPE *r);
+ void addSmps(float *l, float *r);
unsigned int storedSmps() const {return priBuffCurrent.l - priBuf.l;};
void removeStaleSmps();
@@ -52,11 +52,11 @@ class OutMgr
sem_t requested;
/**Buffer*/
- Stereo<REALTYPE *> priBuf; //buffer for primary drivers
- Stereo<REALTYPE *> priBuffCurrent; //current array accessor
+ Stereo<float *> priBuf; //buffer for primary drivers
+ Stereo<float *> priBuffCurrent; //current array accessor
- REALTYPE *outl;
- REALTYPE *outr;
+ float *outl;
+ float *outr;
class Master &master;
int stales;
diff --git a/src/Nio/PaEngine.cpp b/src/Nio/PaEngine.cpp
@@ -94,7 +94,7 @@ int PaEngine::PAprocess(const void *inputBuffer, void *outputBuffer,
int PaEngine::process(float *out, unsigned long framesPerBuffer)
{
- const Stereo<REALTYPE *> smp = getNext();
+ const Stereo<float *> smp = getNext();
//if(framesPerBuffer != smp.l.size())
// cerr << "Bug: PaEngine::process SOUND_BUFFER_SIZE!=framesPerBuffer"
diff --git a/src/Nio/WavEngine.cpp b/src/Nio/WavEngine.cpp
@@ -70,7 +70,7 @@ void WavEngine::Stop()
delete pThread;
}
-void WavEngine::push(Stereo<REALTYPE *> smps, size_t len)
+void WavEngine::push(Stereo<float *> smps, size_t len)
{
if(!pThread)
return;
diff --git a/src/Nio/WavEngine.h b/src/Nio/WavEngine.h
@@ -42,7 +42,7 @@ class WavEngine: public AudioOut
void setAudioEn(bool /*nval*/){};
bool getAudioEn() const{return true;};
- void push(Stereo<REALTYPE *> smps, size_t len);
+ void push(Stereo<float *> smps, size_t len);
void newFile(WavFile *_file);
void destroyFile();
diff --git a/src/Output/DSSIaudiooutput.cpp b/src/Output/DSSIaudiooutput.cpp
@@ -599,7 +599,7 @@ DSSIaudiooutput::DSSIaudiooutput(unsigned long sampleRate)
config.init();
srand(time(NULL));
- denormalkillbuf=new REALTYPE [SOUND_BUFFER_SIZE];
+ denormalkillbuf=new float [SOUND_BUFFER_SIZE];
for (int i=0;i<SOUND_BUFFER_SIZE;i++) denormalkillbuf[i]=(RND-0.5)*1e-16;
this->master = new Master();
diff --git a/src/Params/ADnoteParameters.cpp b/src/Params/ADnoteParameters.cpp
@@ -220,9 +220,9 @@ void ADnoteVoiceParam::enable(FFTwrapper *fft, Resonance *Reson)
/*
* Get the Multiplier of the fine detunes of the voices
*/
-REALTYPE ADnoteParameters::getBandwidthDetuneMultiplier()
+float ADnoteParameters::getBandwidthDetuneMultiplier()
{
- REALTYPE bw = (GlobalPar.PBandwidth - 64.0) / 64.0;
+ float bw = (GlobalPar.PBandwidth - 64.0) / 64.0;
bw = pow(2.0, bw * pow(fabs(bw), 0.2) * 5.0);
return bw;
@@ -232,8 +232,8 @@ REALTYPE ADnoteParameters::getBandwidthDetuneMultiplier()
* Get the unison spread in cents for a voice
*/
-REALTYPE ADnoteParameters::getUnisonFrequencySpreadCents(int nvoice) {
- REALTYPE unison_spread = VoicePar[nvoice].Unison_frequency_spread / 127.0;
+float ADnoteParameters::getUnisonFrequencySpreadCents(int nvoice) {
+ float unison_spread = VoicePar[nvoice].Unison_frequency_spread / 127.0;
unison_spread = pow(unison_spread * 2.0, 2.0) * 50.0; //cents
return unison_spread;
}
diff --git a/src/Params/ADnoteParameters.h b/src/Params/ADnoteParameters.h
@@ -298,8 +298,8 @@ class ADnoteParameters : public PresetsArray
void add2XML(XMLwrapper *xml);
void getfromXML(XMLwrapper *xml);
- REALTYPE getBandwidthDetuneMultiplier();
- REALTYPE getUnisonFrequencySpreadCents(int nvoice);
+ float getBandwidthDetuneMultiplier();
+ float getUnisonFrequencySpreadCents(int nvoice);
int get_unison_size_index(int nvoice);
void set_unison_size_index(int nvoice, int index);
private:
diff --git a/src/Params/Controller.cpp b/src/Params/Controller.cpp
@@ -92,7 +92,7 @@ void Controller::resetall()
void Controller::setpitchwheel(int value)
{
pitchwheel.data = value;
- REALTYPE cents = value / 8192.0;
+ float cents = value / 8192.0;
cents *= pitchwheel.bendrange;
pitchwheel.relfreq = pow(2, cents / 1200.0);
//fprintf(stderr,"%ld %ld -> %.3f\n",pitchwheel.bendrange,pitchwheel.data,pitchwheel.relfreq);fflush(stderr);
@@ -135,7 +135,7 @@ void Controller::setbandwidth(int value)
{
bandwidth.data = value;
if(bandwidth.exponential == 0) {
- REALTYPE tmp = pow(25.0, pow(bandwidth.depth / 127.0, 1.5)) - 1.0;
+ float tmp = pow(25.0, pow(bandwidth.depth / 127.0, 1.5)) - 1.0;
if((value < 64) && (bandwidth.depth >= 64))
tmp = 1.0;
bandwidth.relbw = (value / 64.0 - 1.0) * tmp + 1.0;
@@ -152,7 +152,7 @@ void Controller::setmodwheel(int value)
{
modwheel.data = value;
if(modwheel.exponential == 0) {
- REALTYPE tmp = pow(25.0, pow(modwheel.depth / 127.0, 1.5) * 2.0) / 25.0;
+ float tmp = pow(25.0, pow(modwheel.depth / 127.0, 1.5) * 2.0) / 25.0;
if((value < 64) && (modwheel.depth >= 64))
tmp = 1.0;
modwheel.relmod = (value / 64.0 - 1.0) * tmp + 1.0;
@@ -199,8 +199,8 @@ void Controller::setportamento(int value)
portamento.portamento = ((value < 64) ? 0 : 1);
}
-int Controller::initportamento(REALTYPE oldfreq,
- REALTYPE newfreq,
+int Controller::initportamento(float oldfreq,
+ float newfreq,
bool legatoflag)
{
portamento.x = 0.0;
@@ -214,7 +214,7 @@ int Controller::initportamento(REALTYPE oldfreq,
return 0;
;
- REALTYPE portamentotime = pow(100.0, portamento.time / 127.0) / 50.0; //portamento time in seconds
+ float portamentotime = pow(100.0, portamento.time / 127.0) / 50.0; //portamento time in seconds
if(portamento.proportional) {
//If there is a min(float,float) and a max(float,float) then they
@@ -246,11 +246,11 @@ int Controller::initportamento(REALTYPE oldfreq,
portamento.dx = SOUND_BUFFER_SIZE / (portamentotime * SAMPLE_RATE);
portamento.origfreqrap = oldfreq / newfreq;
- REALTYPE tmprap = ((portamento.origfreqrap > 1.0) ?
+ float tmprap = ((portamento.origfreqrap > 1.0) ?
(portamento.origfreqrap) :
(1.0 / portamento.origfreqrap));
- REALTYPE thresholdrap = pow(2.0, portamento.pitchthresh / 12.0);
+ float thresholdrap = pow(2.0, portamento.pitchthresh / 12.0);
if((portamento.pitchthreshtype == 0) && (tmprap - 0.00001 > thresholdrap))
return 0;
if((portamento.pitchthreshtype == 1) && (tmprap + 0.00001 < thresholdrap))
diff --git a/src/Params/Controller.h b/src/Params/Controller.h
@@ -68,7 +68,7 @@ class Controller
* @param newfreq Ending frequency of the portamento (Hz)
* @param legatoflag true when legato is in progress, false otherwise
* @returns 1 if properly initialized, 0 otherwise*/
- int initportamento(REALTYPE oldfreq, REALTYPE newfreq, bool legatoflag);
+ int initportamento(float oldfreq, float newfreq, bool legatoflag);
/**Update portamento's freqrap to next value based upon dx*/
void updateportamento();
@@ -76,57 +76,57 @@ class Controller
struct { //Pitch Wheel
int data;
short int bendrange; //bendrange is in cents
- REALTYPE relfreq; //the relative frequency (default is 1.0)
+ float relfreq; //the relative frequency (default is 1.0)
} pitchwheel;
struct { //Expression
int data;
- REALTYPE relvolume;
+ float relvolume;
unsigned char receive;
} expression;
struct { //Panning
int data;
- REALTYPE pan;
+ float pan;
unsigned char depth;
} panning;
struct { //Filter cutoff
int data;
- REALTYPE relfreq;
+ float relfreq;
unsigned char depth;
} filtercutoff;
struct { //Filter Q
int data;
- REALTYPE relq;
+ float relq;
unsigned char depth;
} filterq;
struct { //Bandwidth
int data;
- REALTYPE relbw;
+ float relbw;
unsigned char depth;
unsigned char exponential;
} bandwidth;
struct { //Modulation Wheel
int data;
- REALTYPE relmod;
+ float relmod;
unsigned char depth;
unsigned char exponential;
} modwheel;
struct { //FM amplitude
int data;
- REALTYPE relamp;
+ float relamp;
unsigned char receive;
} fmamp;
struct { //Volume
int data;
- REALTYPE volume;
+ float volume;
unsigned char receive;
} volume;
@@ -177,7 +177,7 @@ class Controller
* This is a multiplyer to change the frequency of the newer
* frequency to fit the profile of the portamento.
* This will be linear with respect to x.*/
- REALTYPE freqrap;
+ float freqrap;
/**this is used by the Part for knowing which note uses the portamento*/
int noteusing;
/**if a the portamento is used by a note
@@ -187,22 +187,22 @@ class Controller
//Internal data
/**x is from 0.0 (start portamento) to 1.0 (finished portamento)*/
- REALTYPE x;
+ float x;
/**dx is the increment to x when updateportamento is called*/
- REALTYPE dx;
+ float dx;
/** this is used for computing oldfreq value from x*/
- REALTYPE origfreqrap;
+ float origfreqrap;
} portamento;
struct { //Resonance Center Frequency
int data;
- REALTYPE relcenter;
+ float relcenter;
unsigned char depth;
} resonancecenter;
struct { //Resonance Bandwidth
int data;
- REALTYPE relbw;
+ float relbw;
unsigned char depth;
} resonancebandwidth;
diff --git a/src/Params/EnvelopeParams.cpp b/src/Params/EnvelopeParams.cpp
@@ -58,9 +58,9 @@ EnvelopeParams::EnvelopeParams(unsigned char Penvstretch_,
EnvelopeParams::~EnvelopeParams()
{}
-REALTYPE EnvelopeParams::getdt(char i)
+float EnvelopeParams::getdt(char i)
{
- REALTYPE result = (pow(2.0, Penvdt[(int)i] / 127.0 * 12.0) - 1.0) * 10.0; //miliseconds
+ float result = (pow(2.0, Penvdt[(int)i] / 127.0 * 12.0) - 1.0) * 10.0; //miliseconds
return result;
}
diff --git a/src/Params/EnvelopeParams.h b/src/Params/EnvelopeParams.h
@@ -52,7 +52,7 @@ class EnvelopeParams:public Presets
void defaults();
void getfromXML(XMLwrapper *xml);
- REALTYPE getdt(char i);
+ float getdt(char i);
/* MIDI Parameters */
unsigned char Pfreemode; //1 daca este in modul free sau 0 daca este in mod ADSR,ASR,...
diff --git a/src/Params/FilterParams.cpp b/src/Params/FilterParams.cpp
@@ -127,21 +127,21 @@ void FilterParams::getfromFilterParams(FilterParams *pars)
/*
* Parameter control
*/
-REALTYPE FilterParams::getfreq()
+float FilterParams::getfreq()
{
return (Pfreq / 64.0 - 1.0) * 5.0;
}
-REALTYPE FilterParams::getq()
+float FilterParams::getq()
{
- return exp(pow((REALTYPE) Pq / 127.0, 2) * log(1000.0)) - 0.9;
+ return exp(pow((float) Pq / 127.0, 2) * log(1000.0)) - 0.9;
}
-REALTYPE FilterParams::getfreqtracking(REALTYPE notefreq)
+float FilterParams::getfreqtracking(float notefreq)
{
return log(notefreq / 440.0) * (Pfreqtrack - 64.0) / (64.0 * LOG_2);
}
-REALTYPE FilterParams::getgain()
+float FilterParams::getgain()
{
return (Pgain / 64.0 - 1.0) * 30.0; //-30..30dB
}
@@ -149,7 +149,7 @@ REALTYPE FilterParams::getgain()
/*
* Get the center frequency of the formant's graph
*/
-REALTYPE FilterParams::getcenterfreq()
+float FilterParams::getcenterfreq()
{
return 10000.0 * pow(10, -(1.0 - Pcenterfreq / 127.0) * 2.0);
}
@@ -157,7 +157,7 @@ REALTYPE FilterParams::getcenterfreq()
/*
* Get the number of octave that the formant functions applies to
*/
-REALTYPE FilterParams::getoctavesfreq()
+float FilterParams::getoctavesfreq()
{
return 0.25 + 10.0 * Poctavesfreq / 127.0;
}
@@ -165,18 +165,18 @@ REALTYPE FilterParams::getoctavesfreq()
/*
* Get the frequency from x, where x is [0..1]
*/
-REALTYPE FilterParams::getfreqx(REALTYPE x)
+float FilterParams::getfreqx(float x)
{
if(x > 1.0)
x = 1.0;
- REALTYPE octf = pow(2.0, getoctavesfreq());
+ float octf = pow(2.0, getoctavesfreq());
return getcenterfreq() / sqrt(octf) * pow(octf, x);
}
/*
* Get the x coordinate from frequency (used by the UI)
*/
-REALTYPE FilterParams::getfreqpos(REALTYPE freq)
+float FilterParams::getfreqpos(float freq)
{
return (log(freq) - log(getfreqx(0.0))) / log(2.0) / getoctavesfreq();
}
@@ -185,11 +185,11 @@ REALTYPE FilterParams::getfreqpos(REALTYPE freq)
/*
* Get the freq. response of the formant filter
*/
-void FilterParams::formantfilterH(int nvowel, int nfreqs, REALTYPE *freqs)
+void FilterParams::formantfilterH(int nvowel, int nfreqs, float *freqs)
{
- REALTYPE c[3], d[3];
- REALTYPE filter_freq, filter_q, filter_amp;
- REALTYPE omega, sn, cs, alpha;
+ float c[3], d[3];
+ float filter_freq, filter_q, filter_amp;
+ float omega, sn, cs, alpha;
for(int i = 0; i < nfreqs; i++)
freqs[i] = 0.0;
@@ -211,7 +211,7 @@ void FilterParams::formantfilterH(int nvowel, int nfreqs, REALTYPE *freqs)
sn = sin(omega);
cs = cos(omega);
alpha = sn / (2 * filter_q);
- REALTYPE tmp = 1 + alpha;
+ float tmp = 1 + alpha;
c[0] = alpha / tmp *sqrt(filter_q + 1);
c[1] = 0;
c[2] = -alpha / tmp *sqrt(filter_q + 1);
@@ -223,19 +223,19 @@ void FilterParams::formantfilterH(int nvowel, int nfreqs, REALTYPE *freqs)
for(int i = 0; i < nfreqs; i++) {
- REALTYPE freq = getfreqx(i / (REALTYPE) nfreqs);
+ float freq = getfreqx(i / (float) nfreqs);
if(freq > SAMPLE_RATE / 2) {
for(int tmp = i; tmp < nfreqs; tmp++)
freqs[tmp] = 0.0;
break;
}
- REALTYPE fr = freq / SAMPLE_RATE * PI * 2.0;
- REALTYPE x = c[0], y = 0.0;
+ float fr = freq / SAMPLE_RATE * PI * 2.0;
+ float x = c[0], y = 0.0;
for(int n = 1; n < 3; n++) {
x += cos(n * fr) * c[n];
y -= sin(n * fr) * c[n];
}
- REALTYPE h = x * x + y * y;
+ float h = x * x + y * y;
x = 1.0;
y = 0.0;
for(int n = 1; n < 3; n++) {
@@ -258,22 +258,22 @@ void FilterParams::formantfilterH(int nvowel, int nfreqs, REALTYPE *freqs)
/*
* Transforms a parameter to the real value
*/
-REALTYPE FilterParams::getformantfreq(unsigned char freq)
+float FilterParams::getformantfreq(unsigned char freq)
{
- REALTYPE result = getfreqx(freq / 127.0);
+ float result = getfreqx(freq / 127.0);
return result;
}
-REALTYPE FilterParams::getformantamp(unsigned char amp)
+float FilterParams::getformantamp(unsigned char amp)
{
- REALTYPE result = pow(0.1, (1.0 - amp / 127.0) * 4.0);
+ float result = pow(0.1, (1.0 - amp / 127.0) * 4.0);
return result;
}
-REALTYPE FilterParams::getformantq(unsigned char q)
+float FilterParams::getformantq(unsigned char q)
{
//temp
- REALTYPE result = pow(25.0, (q - 32.0) / 64.0);
+ float result = pow(25.0, (q - 32.0) / 64.0);
return result;
}
diff --git a/src/Params/FilterParams.h b/src/Params/FilterParams.h
@@ -44,10 +44,10 @@ class FilterParams : public PresetsArray
void getfromFilterParams(FilterParams *pars);
- REALTYPE getfreq();
- REALTYPE getq();
- REALTYPE getfreqtracking(REALTYPE notefreq);
- REALTYPE getgain();
+ float getfreq();
+ float getq();
+ float getfreqtracking(float notefreq);
+ float getgain();
unsigned char Pcategory; //Filter category (Analog/Formant/StVar)
unsigned char Ptype; // Filter type (for analog lpf,hpf,bpf..)
@@ -77,16 +77,16 @@ class FilterParams : public PresetsArray
unsigned char nvowel; //the vowel from the position
} Psequence[FF_MAX_SEQUENCE];
- REALTYPE getcenterfreq();
- REALTYPE getoctavesfreq();
- REALTYPE getfreqpos(REALTYPE freq);
- REALTYPE getfreqx(REALTYPE x);
+ float getcenterfreq();
+ float getoctavesfreq();
+ float getfreqpos(float freq);
+ float getfreqx(float x);
- void formantfilterH(int nvowel, int nfreqs, REALTYPE *freqs); //used by UI
+ void formantfilterH(int nvowel, int nfreqs, float *freqs); //used by UI
- REALTYPE getformantfreq(unsigned char freq);
- REALTYPE getformantamp(unsigned char amp);
- REALTYPE getformantq(unsigned char q);
+ float getformantfreq(unsigned char freq);
+ float getformantamp(unsigned char amp);
+ float getformantq(unsigned char q);
bool changed;
diff --git a/src/Params/LFOParams.h b/src/Params/LFOParams.h
@@ -45,7 +45,7 @@ class LFOParams:public Presets
void getfromXML(XMLwrapper *xml);
/* MIDI Parameters*/
- REALTYPE Pfreq; /**<frequency*/
+ float Pfreq; /**<frequency*/
unsigned char Pintensity; /**<intensity*/
unsigned char Pstartphase; /**<start phase (0=random)*/
unsigned char PLFOtype; /**<LFO type (sin,triangle,square,ramp,...)*/
diff --git a/src/Params/PADnoteParameters.cpp b/src/Params/PADnoteParameters.cpp
@@ -155,30 +155,30 @@ void PADnoteParameters::deletesamples()
/*
* Get the harmonic profile (i.e. the frequency distributio of a single harmonic)
*/
-REALTYPE PADnoteParameters::getprofile(REALTYPE *smp, int size)
+float PADnoteParameters::getprofile(float *smp, int size)
{
for(int i = 0; i < size; i++)
smp[i] = 0.0;
const int supersample = 16;
- REALTYPE basepar = pow(2.0, (1.0 - Php.base.par1 / 127.0) * 12.0);
- REALTYPE freqmult = floor(pow(2.0,
+ float basepar = pow(2.0, (1.0 - Php.base.par1 / 127.0) * 12.0);
+ float freqmult = floor(pow(2.0,
Php.freqmult / 127.0 * 5.0) + 0.000001);
- REALTYPE modfreq = floor(pow(2.0,
+ float modfreq = floor(pow(2.0,
Php.modulator.freq / 127.0
* 5.0) + 0.000001);
- REALTYPE modpar1 = pow(Php.modulator.par1 / 127.0, 4.0) * 5.0 / sqrt(
+ float modpar1 = pow(Php.modulator.par1 / 127.0, 4.0) * 5.0 / sqrt(
modfreq);
- REALTYPE amppar1 =
+ float amppar1 =
pow(2.0, pow(Php.amp.par1 / 127.0, 2.0) * 10.0) - 0.999;
- REALTYPE amppar2 = (1.0 - Php.amp.par2 / 127.0) * 0.998 + 0.001;
- REALTYPE width = pow(150.0 / (Php.width + 22.0), 2.0);
+ float amppar2 = (1.0 - Php.amp.par2 / 127.0) * 0.998 + 0.001;
+ float width = pow(150.0 / (Php.width + 22.0), 2.0);
for(int i = 0; i < size * supersample; i++) {
bool makezero = false;
- REALTYPE x = i * 1.0 / (size * (REALTYPE) supersample);
+ float x = i * 1.0 / (size * (float) supersample);
- REALTYPE origx = x;
+ float origx = x;
//do the sizing (width)
x = (x - 0.5) * width + 0.5;
@@ -203,7 +203,7 @@ REALTYPE PADnoteParameters::getprofile(REALTYPE *smp, int size)
break;
}
- REALTYPE x_before_freq_mult = x;
+ float x_before_freq_mult = x;
//do the frequency multiplier
x *= freqmult;
@@ -214,7 +214,7 @@ REALTYPE PADnoteParameters::getprofile(REALTYPE *smp, int size)
//this is the base function of the profile
- REALTYPE f;
+ float f;
switch(Php.base.type) {
case 1:
f = exp(-(x * x) * basepar);
@@ -233,7 +233,7 @@ REALTYPE PADnoteParameters::getprofile(REALTYPE *smp, int size)
if(makezero)
f = 0.0;
- REALTYPE amp = 1.0;
+ float amp = 1.0;
origx = origx * 2.0 - 1.0;
//compute the amplitude multiplier
@@ -250,7 +250,7 @@ REALTYPE PADnoteParameters::getprofile(REALTYPE *smp, int size)
}
//apply the amplitude multiplier
- REALTYPE finalsmp = f;
+ float finalsmp = f;
if(Php.amp.type != 0)
switch(Php.amp.mode) {
case 0:
@@ -272,7 +272,7 @@ REALTYPE PADnoteParameters::getprofile(REALTYPE *smp, int size)
}
//normalize the profile (make the max. to be equal to 1.0)
- REALTYPE max = 0.0;
+ float max = 0.0;
for(int i = 0; i < size; i++) {
if(smp[i] < 0.0)
smp[i] = 0.0;
@@ -288,7 +288,7 @@ REALTYPE PADnoteParameters::getprofile(REALTYPE *smp, int size)
return 0.5;
//compute the estimated perceived bandwidth
- REALTYPE sum = 0.0;
+ float sum = 0.0;
int i;
for(i = 0; i < size / 2 - 2; i++) {
sum += smp[i] * smp[i] + smp[size - i - 1] * smp[size - i - 1];
@@ -296,7 +296,7 @@ REALTYPE PADnoteParameters::getprofile(REALTYPE *smp, int size)
break;
}
- REALTYPE result = 1.0 - 2.0 * i / (REALTYPE) size;
+ float result = 1.0 - 2.0 * i / (float) size;
return result;
}
@@ -304,10 +304,10 @@ REALTYPE PADnoteParameters::getprofile(REALTYPE *smp, int size)
* Compute the real bandwidth in cents and returns it
* Also, sets the bandwidth parameter
*/
-REALTYPE PADnoteParameters::setPbandwidth(int Pbandwidth)
+float PADnoteParameters::setPbandwidth(int Pbandwidth)
{
this->Pbandwidth = Pbandwidth;
- REALTYPE result = pow(Pbandwidth / 1000.0, 1.1);
+ float result = pow(Pbandwidth / 1000.0, 1.1);
result = pow(10.0, result * 4.0) * 0.25;
return result;
}
@@ -315,14 +315,14 @@ REALTYPE PADnoteParameters::setPbandwidth(int Pbandwidth)
/*
* Get the harmonic(overtone) position
*/
-REALTYPE PADnoteParameters::getNhr(int n)
+float PADnoteParameters::getNhr(int n)
{
- REALTYPE result = 1.0;
- REALTYPE par1 = pow(10.0, -(1.0 - Phrpos.par1 / 255.0) * 3.0);
- REALTYPE par2 = Phrpos.par2 / 255.0;
+ float result = 1.0;
+ float par1 = pow(10.0, -(1.0 - Phrpos.par1 / 255.0) * 3.0);
+ float par2 = Phrpos.par2 / 255.0;
- REALTYPE n0 = n - 1.0;
- REALTYPE tmp = 0.0;
+ float n0 = n - 1.0;
+ float tmp = 0.0;
int thresh = 0;
switch(Phrpos.type) {
case 1:
@@ -362,10 +362,10 @@ REALTYPE PADnoteParameters::getNhr(int n)
break;
}
- REALTYPE par3 = Phrpos.par3 / 255.0;
+ float par3 = Phrpos.par3 / 255.0;
- REALTYPE iresult = floor(result + 0.5);
- REALTYPE dresult = result - iresult;
+ float iresult = floor(result + 0.5);
+ float dresult = result - iresult;
result = iresult + (1.0 - par3) * dresult;
@@ -375,24 +375,24 @@ REALTYPE PADnoteParameters::getNhr(int n)
/*
* Generates the long spectrum for Bandwidth mode (only amplitudes are generated; phases will be random)
*/
-void PADnoteParameters::generatespectrum_bandwidthMode(REALTYPE *spectrum,
+void PADnoteParameters::generatespectrum_bandwidthMode(float *spectrum,
int size,
- REALTYPE basefreq,
- REALTYPE *profile,
+ float basefreq,
+ float *profile,
int profilesize,
- REALTYPE bwadjust)
+ float bwadjust)
{
for(int i = 0; i < size; i++)
spectrum[i] = 0.0;
- REALTYPE harmonics[OSCIL_SIZE / 2];
+ float harmonics[OSCIL_SIZE / 2];
for(int i = 0; i < OSCIL_SIZE / 2; i++)
harmonics[i] = 0.0;
//get the harmonic structure from the oscillator (I am using the frequency amplitudes, only)
oscilgen->get(harmonics, basefreq, false);
//normalize
- REALTYPE max = 0.0;
+ float max = 0.0;
for(int i = 0; i < OSCIL_SIZE / 2; i++)
if(harmonics[i] > max)
max = harmonics[i];
@@ -402,7 +402,7 @@ void PADnoteParameters::generatespectrum_bandwidthMode(REALTYPE *spectrum,
harmonics[i] /= max;
for(int nh = 1; nh < OSCIL_SIZE / 2; nh++) { //for each harmonic
- REALTYPE realfreq = getNhr(nh) * basefreq;
+ float realfreq = getNhr(nh) * basefreq;
if(realfreq > SAMPLE_RATE * 0.49999)
break;
if(realfreq < 20.0)
@@ -411,10 +411,10 @@ void PADnoteParameters::generatespectrum_bandwidthMode(REALTYPE *spectrum,
continue;
//compute the bandwidth of each harmonic
- REALTYPE bandwidthcents = setPbandwidth(Pbandwidth);
- REALTYPE bw =
+ float bandwidthcents = setPbandwidth(Pbandwidth);
+ float bw =
(pow(2.0, bandwidthcents / 1200.0) - 1.0) * basefreq / bwadjust;
- REALTYPE power = 1.0;
+ float power = 1.0;
switch(Pbwscale) {
case 0:
power = 1.0;
@@ -444,12 +444,12 @@ void PADnoteParameters::generatespectrum_bandwidthMode(REALTYPE *spectrum,
bw = bw * pow(realfreq / basefreq, power);
int ibw = (int)((bw / (SAMPLE_RATE * 0.5) * size)) + 1;
- REALTYPE amp = harmonics[nh - 1];
+ float amp = harmonics[nh - 1];
if(resonance->Penabled)
amp *= resonance->getfreqresponse(realfreq);
if(ibw > profilesize) { //if the bandwidth is larger than the profilesize
- REALTYPE rap = sqrt((REALTYPE)profilesize / (REALTYPE)ibw);
+ float rap = sqrt((float)profilesize / (float)ibw);
int cfreq =
(int) (realfreq / (SAMPLE_RATE * 0.5) * size) - ibw / 2;
for(int i = 0; i < ibw; i++) {
@@ -463,13 +463,13 @@ void PADnoteParameters::generatespectrum_bandwidthMode(REALTYPE *spectrum,
}
}
else { //if the bandwidth is smaller than the profilesize
- REALTYPE rap = sqrt((REALTYPE)ibw / (REALTYPE)profilesize);
- REALTYPE ibasefreq = realfreq / (SAMPLE_RATE * 0.5) * size;
+ float rap = sqrt((float)ibw / (float)profilesize);
+ float ibasefreq = realfreq / (SAMPLE_RATE * 0.5) * size;
for(int i = 0; i < profilesize; i++) {
- REALTYPE idfreq = i / (REALTYPE)profilesize - 0.5;
+ float idfreq = i / (float)profilesize - 0.5;
idfreq *= ibw;
int spfreq = (int) (idfreq + ibasefreq);
- REALTYPE fspfreq = fmod(idfreq + ibasefreq, 1.0);
+ float fspfreq = fmod(idfreq + ibasefreq, 1.0);
if(spfreq <= 0)
continue;
if(spfreq >= size - 1)
@@ -484,21 +484,21 @@ void PADnoteParameters::generatespectrum_bandwidthMode(REALTYPE *spectrum,
/*
* Generates the long spectrum for non-Bandwidth modes (only amplitudes are generated; phases will be random)
*/
-void PADnoteParameters::generatespectrum_otherModes(REALTYPE *spectrum,
+void PADnoteParameters::generatespectrum_otherModes(float *spectrum,
int size,
- REALTYPE basefreq)
+ float basefreq)
{
for(int i = 0; i < size; i++)
spectrum[i] = 0.0;
- REALTYPE harmonics[OSCIL_SIZE / 2];
+ float harmonics[OSCIL_SIZE / 2];
for(int i = 0; i < OSCIL_SIZE / 2; i++)
harmonics[i] = 0.0;
//get the harmonic structure from the oscillator (I am using the frequency amplitudes, only)
oscilgen->get(harmonics, basefreq, false);
//normalize
- REALTYPE max = 0.0;
+ float max = 0.0;
for(int i = 0; i < OSCIL_SIZE / 2; i++)
if(harmonics[i] > max)
max = harmonics[i];
@@ -508,7 +508,7 @@ void PADnoteParameters::generatespectrum_otherModes(REALTYPE *spectrum,
harmonics[i] /= max;
for(int nh = 1; nh < OSCIL_SIZE / 2; nh++) { //for each harmonic
- REALTYPE realfreq = getNhr(nh) * basefreq;
+ float realfreq = getNhr(nh) * basefreq;
///sa fac aici interpolarea si sa am grija daca frecv descresc
@@ -519,7 +519,7 @@ void PADnoteParameters::generatespectrum_otherModes(REALTYPE *spectrum,
// if (harmonics[nh-1]<1e-4) continue;
- REALTYPE amp = harmonics[nh - 1];
+ float amp = harmonics[nh - 1];
if(resonance->Penabled)
amp *= resonance->getfreqresponse(realfreq);
int cfreq = (int) (realfreq / (SAMPLE_RATE * 0.5) * size);
@@ -532,11 +532,11 @@ void PADnoteParameters::generatespectrum_otherModes(REALTYPE *spectrum,
for(int k = 1; k < size; k++) {
if((spectrum[k] > 1e-10) || (k == (size - 1))) {
int delta = k - old;
- REALTYPE val1 = spectrum[old];
- REALTYPE val2 = spectrum[k];
- REALTYPE idelta = 1.0 / delta;
+ float val1 = spectrum[old];
+ float val2 = spectrum[k];
+ float idelta = 1.0 / delta;
for(int i = 0; i < delta; i++) {
- REALTYPE x = idelta * i;
+ float x = idelta * i;
spectrum[old + i] = val1 * (1.0 - x) + val2 * x;
}
old = k;
@@ -552,14 +552,14 @@ void PADnoteParameters::applyparameters(bool lockmutex)
{
const int samplesize = (((int) 1) << (Pquality.samplesize + 14));
int spectrumsize = samplesize / 2;
- REALTYPE spectrum[spectrumsize];
+ float spectrum[spectrumsize];
int profilesize = 512;
- REALTYPE profile[profilesize];
+ float profile[profilesize];
- REALTYPE bwadjust = getprofile(profile, profilesize);
+ float bwadjust = getprofile(profile, profilesize);
// for (int i=0;i<profilesize;i++) profile[i]*=profile[i];
- REALTYPE basefreq = 65.406 * pow(2.0, Pquality.basenote / 2);
+ float basefreq = 65.406 * pow(2.0, Pquality.basenote / 2);
if(Pquality.basenote % 2 == 1)
basefreq *= 1.5;
@@ -581,12 +581,12 @@ void PADnoteParameters::applyparameters(bool lockmutex)
FFTFREQS fftfreqs;
newFFTFREQS(&fftfreqs, samplesize / 2);
- REALTYPE adj[samplemax]; //this is used to compute frequency relation to the base frequency
+ float adj[samplemax]; //this is used to compute frequency relation to the base frequency
for(int nsample = 0; nsample < samplemax; nsample++)
- adj[nsample] = (Pquality.oct + 1.0) * (REALTYPE)nsample / samplemax;
+ adj[nsample] = (Pquality.oct + 1.0) * (float)nsample / samplemax;
for(int nsample = 0; nsample < samplemax; nsample++) {
- REALTYPE tmp = adj[nsample] - adj[samplemax - 1] * 0.5;
- REALTYPE basefreqadjust = pow(2.0, tmp);
+ float tmp = adj[nsample] - adj[samplemax - 1] * 0.5;
+ float basefreqadjust = pow(2.0, tmp);
if(Pmode == 0)
generatespectrum_bandwidthMode(spectrum,
@@ -600,11 +600,11 @@ void PADnoteParameters::applyparameters(bool lockmutex)
basefreq * basefreqadjust);
const int extra_samples = 5; //the last samples contains the first samples (used for linear/cubic interpolation)
- newsample.smp = new REALTYPE[samplesize + extra_samples];
+ newsample.smp = new float[samplesize + extra_samples];
newsample.smp[0] = 0.0;
for(int i = 1; i < spectrumsize; i++) { //randomize the phases
- REALTYPE phase = RND * 6.29;
+ float phase = RND * 6.29;
fftfreqs.c[i] = spectrum[i] * cos(phase);
fftfreqs.s[i] = spectrum[i] * sin(phase);
}
@@ -612,7 +612,7 @@ void PADnoteParameters::applyparameters(bool lockmutex)
//normalize(rms)
- REALTYPE rms = 0.0;
+ float rms = 0.0;
for(int i = 0; i < samplesize; i++)
rms += newsample.smp[i] * newsample.smp[i];
rms = sqrt(rms);
diff --git a/src/Params/PADnoteParameters.h b/src/Params/PADnoteParameters.h
@@ -48,7 +48,7 @@ class PADnoteParameters:public Presets
void getfromXML(XMLwrapper *xml);
//returns a value between 0.0-1.0 that represents the estimation perceived bandwidth
- REALTYPE getprofile(REALTYPE *smp, int size);
+ float getprofile(float *smp, int size);
//parameters
@@ -142,8 +142,8 @@ class PADnoteParameters:public Presets
- REALTYPE setPbandwidth(int Pbandwidth); //returns the BandWidth in cents
- REALTYPE getNhr(int n); //gets the n-th overtone position relatively to N harmonic
+ float setPbandwidth(int Pbandwidth); //returns the BandWidth in cents
+ float getNhr(int n); //gets the n-th overtone position relatively to N harmonic
void applyparameters(bool lockmutex);
void export2wav(std::string basefilename);
@@ -153,20 +153,20 @@ class PADnoteParameters:public Presets
struct {
int size;
- REALTYPE basefreq;
- REALTYPE *smp;
+ float basefreq;
+ float *smp;
} sample[PAD_MAX_SAMPLES], newsample;
private:
- void generatespectrum_bandwidthMode(REALTYPE *spectrum,
+ void generatespectrum_bandwidthMode(float *spectrum,
int size,
- REALTYPE basefreq,
- REALTYPE *profile,
+ float basefreq,
+ float *profile,
int profilesize,
- REALTYPE bwadjust);
- void generatespectrum_otherModes(REALTYPE *spectrum,
+ float bwadjust);
+ void generatespectrum_otherModes(float *spectrum,
int size,
- REALTYPE basefreq);
+ float basefreq);
void deletesamples();
void deletesample(int n);
diff --git a/src/Samples/Sample.cpp b/src/Samples/Sample.cpp
@@ -30,7 +30,7 @@ using namespace std;
/**\TODO start using pointer math here as these will be Frequency called
* functions throughout the code*/
Sample::Sample()
- :bufferSize(1),buffer(new REALTYPE[1])
+ :bufferSize(1),buffer(new float[1])
{
buffer[0] = 0.0;
}
@@ -38,28 +38,28 @@ Sample::Sample()
Sample::Sample(const Sample &smp)
:bufferSize(smp.bufferSize)
{
- buffer = new REALTYPE[bufferSize];
+ buffer = new float[bufferSize];
memcpy(buffer, smp.buffer, bufferSize * sizeof(float));
}
-Sample::Sample(int length, REALTYPE fill)
+Sample::Sample(int length, float fill)
:bufferSize(length)
{
if(length < 1)
bufferSize = 1;
- buffer = new REALTYPE[bufferSize];
+ buffer = new float[bufferSize];
memset(buffer, fill, bufferSize * sizeof(float));
}
-Sample::Sample(int length, const REALTYPE *input)
+Sample::Sample(int length, const float *input)
:bufferSize(length)
{
if(length > 0) {
- buffer = new REALTYPE[length];
+ buffer = new float[length];
memcpy(buffer, input, bufferSize * sizeof(float));
}
else {
- buffer = new REALTYPE[1];
+ buffer = new float[1];
bufferSize = 1;
*buffer = 0;
}
@@ -80,7 +80,7 @@ void Sample::operator=(const Sample &smp)
{
if(bufferSize != smp.bufferSize) {
delete[] buffer;
- buffer = new REALTYPE[smp.bufferSize];
+ buffer = new float[smp.bufferSize];
bufferSize = smp.bufferSize;
}
memcpy(buffer, smp.buffer, bufferSize * sizeof(float));
@@ -169,27 +169,27 @@ Sample Sample::subSample(int a, int b) const
return Sample(b-a, buffer+a);
}
-REALTYPE Sample::max() const
+float Sample::max() const
{
- REALTYPE max = -1500; //a good low considering that samples should store values -1.0 to 1.0
+ float max = -1500; //a good low considering that samples should store values -1.0 to 1.0
for(int i = 0; i < bufferSize; ++i)
if(buffer[i] > max)
max = buffer[i];
return max;
}
-REALTYPE Sample::min() const
+float Sample::min() const
{
- REALTYPE min = 1500; //a good high considering that samples should store values -1.0 to 1.0
+ float min = 1500; //a good high considering that samples should store values -1.0 to 1.0
for(int i = 0; i < bufferSize; ++i)
if(buffer[i] < min)
min = buffer[i];
return min;
}
-REALTYPE Sample::absMax() const
+float Sample::absMax() const
{
- REALTYPE max = 0;
+ float max = 0;
for(int i = 0; i < bufferSize; ++i)
if(fabs(buffer[i]) > max)
max = fabs(buffer[i]);
diff --git a/src/Samples/Sample.h b/src/Samples/Sample.h
@@ -29,8 +29,8 @@ class Sample
public:
Sample();
Sample(const Sample &smp);
- Sample(int length, REALTYPE fill = 0);
- Sample(int length, const REALTYPE *fill);
+ Sample(int length, float fill = 0);
+ Sample(int length, const float *fill);
~Sample();
/**Fills the buffer with zeros*/
void clear();
@@ -40,11 +40,11 @@ class Sample
return bufferSize;
}
/**Provides the indexing operator for non const Samples*/
- REALTYPE &operator[](int index) {
+ float &operator[](int index) {
return *(buffer + index % bufferSize);
}
/**Provides the indexing operator for const Samples*/
- const REALTYPE &operator[](int index) const {
+ const float &operator[](int index) const {
return *(buffer + index % bufferSize);
}
/**Provides the assignment operator*/
@@ -56,7 +56,7 @@ class Sample
*
* This method is like c_str() from the string class and should be used
* sparingly*/
- const REALTYPE *c_buf() const {return buffer;}
+ const float *c_buf() const {return buffer;}
/**Change the sampling rate of the Sample*/
void resample(const unsigned int rate, const unsigned int nrate);
@@ -68,9 +68,9 @@ class Sample
/**Gets a subsample from a to b*/
Sample subSample(int a, int b) const;
- REALTYPE max() const;
- REALTYPE min() const;
- REALTYPE absMax() const;
+ float max() const;
+ float min() const;
+ float absMax() const;
private:
int bufferSize;
float *buffer;
diff --git a/src/Synth/ADnote.cpp b/src/Synth/ADnote.cpp
@@ -32,18 +32,18 @@
ADnote::ADnote(ADnoteParameters *pars,
Controller *ctl_,
- REALTYPE freq,
- REALTYPE velocity,
+ float freq,
+ float velocity,
int portamento_,
int midinote_,
bool besilent)
:SynthNote(freq, velocity, portamento_, midinote, besilent)
{
- tmpwavel = new REALTYPE [SOUND_BUFFER_SIZE];
- tmpwaver = new REALTYPE [SOUND_BUFFER_SIZE];
- bypassl = new REALTYPE [SOUND_BUFFER_SIZE];
- bypassr = new REALTYPE [SOUND_BUFFER_SIZE];
+ tmpwavel = new float [SOUND_BUFFER_SIZE];
+ tmpwaver = new float [SOUND_BUFFER_SIZE];
+ bypassl = new float [SOUND_BUFFER_SIZE];
+ bypassr = new float [SOUND_BUFFER_SIZE];
partparams = pars;
ctl = ctl_;
@@ -82,9 +82,9 @@ ADnote::ADnote(ADnoteParameters *pars,
((pow(10, 1.5 * pars->GlobalPar.PPunchStrength / 127.0) - 1.0)
* VelF(velocity,
pars->GlobalPar.PPunchVelocitySensing));
- REALTYPE time =
+ float time =
pow(10, 3.0 * pars->GlobalPar.PPunchTime / 127.0) / 10000.0; //0.1 .. 100 ms
- REALTYPE stretch = pow(440.0 / freq,
+ float stretch = pow(440.0 / freq,
pars->GlobalPar.PPunchStretch / 64.0);
NoteGlobalPar.Punch.dt = 1.0 / (time * SAMPLE_RATE * stretch);
}
@@ -114,13 +114,13 @@ ADnote::ADnote(ADnoteParameters *pars,
//compute unison
unison_size[nvoice] = unison;
- unison_base_freq_rap[nvoice] = new REALTYPE[unison];
- unison_freq_rap[nvoice] = new REALTYPE[unison];
+ unison_base_freq_rap[nvoice] = new float[unison];
+ unison_freq_rap[nvoice] = new float[unison];
unison_invert_phase[nvoice] = new bool[unison];
- REALTYPE unison_spread = pars->getUnisonFrequencySpreadCents(
+ float unison_spread = pars->getUnisonFrequencySpreadCents(
nvoice);
- REALTYPE unison_real_spread = pow(2.0, (unison_spread * 0.5) / 1200.0);
- REALTYPE unison_vibratto_a = pars->VoicePar[nvoice].Unison_vibratto
+ float unison_real_spread = pow(2.0, (unison_spread * 0.5) / 1200.0);
+ float unison_vibratto_a = pars->VoicePar[nvoice].Unison_vibratto
/ 127.0; //0.0 .. 1.0
@@ -134,14 +134,14 @@ ADnote::ADnote(ADnoteParameters *pars,
};
break;
default: { //unison for more than 2 subvoices
- REALTYPE unison_values[unison];
- REALTYPE min = -1e-6, max = 1e-6;
+ float unison_values[unison];
+ float min = -1e-6, max = 1e-6;
for(int k = 0; k < unison; k++) {
- REALTYPE step = (k / (REALTYPE) (unison - 1)) * 2.0 - 1.0; //this makes the unison spread more uniform
- REALTYPE val = step + (RND * 2.0 - 1.0) / (unison - 1);
+ float step = (k / (float) (unison - 1)) * 2.0 - 1.0; //this makes the unison spread more uniform
+ float val = step + (RND * 2.0 - 1.0) / (unison - 1);
unison_values[k] = limit(val, min, max);
}
- REALTYPE diff = max - min;
+ float diff = max - min;
for(int k = 0; k < unison; k++) {
unison_values[k] =
(unison_values[k] - (max + min) * 0.5) / diff; //the lowest value will be -1 and the highest will be 1
@@ -158,14 +158,14 @@ ADnote::ADnote(ADnoteParameters *pars,
+ (unison_base_freq_rap[nvoice][k] - 1.0)
* (1.0 - unison_vibratto_a);
}
- unison_vibratto[nvoice].step = new REALTYPE[unison];
- unison_vibratto[nvoice].position = new REALTYPE[unison];
+ unison_vibratto[nvoice].step = new float[unison];
+ unison_vibratto[nvoice].position = new float[unison];
unison_vibratto[nvoice].amplitude =
(unison_real_spread - 1.0) * unison_vibratto_a;
- REALTYPE increments_per_second = SAMPLE_RATE
- / (REALTYPE)SOUND_BUFFER_SIZE;
- REALTYPE vibratto_base_period = 0.25
+ float increments_per_second = SAMPLE_RATE
+ / (float)SOUND_BUFFER_SIZE;
+ float vibratto_base_period = 0.25
* pow(2.0,
(1.0
- pars->VoicePar[nvoice].
@@ -173,10 +173,10 @@ ADnote::ADnote(ADnoteParameters *pars,
for(int k = 0; k < unison; k++) {
unison_vibratto[nvoice].position[k] = RND * 1.8 - 0.9;
//make period to vary randomly from 50% to 200% vibratto base period
- REALTYPE vibratto_period = vibratto_base_period
+ float vibratto_period = vibratto_base_period
* pow(2.0, RND * 2.0 - 1.0);
- REALTYPE m = 4.0 / (vibratto_period * increments_per_second);
+ float m = 4.0 / (vibratto_period * increments_per_second);
if(RND < 0.5)
m = -m;
unison_vibratto[nvoice].step[k] = m;
@@ -208,13 +208,13 @@ ADnote::ADnote(ADnoteParameters *pars,
oscfreqhi[nvoice] = new int[unison];
- oscfreqlo[nvoice] = new REALTYPE[unison];
+ oscfreqlo[nvoice] = new float[unison];
oscfreqhiFM[nvoice] = new unsigned int[unison];
- oscfreqloFM[nvoice] = new REALTYPE[unison];
+ oscfreqloFM[nvoice] = new float[unison];
oscposhi[nvoice] = new int[unison];
- oscposlo[nvoice] = new REALTYPE[unison];
+ oscposlo[nvoice] = new float[unison];
oscposhiFM[nvoice] = new unsigned int[unison];
- oscposloFM[nvoice] = new REALTYPE[unison];
+ oscposloFM[nvoice] = new float[unison];
NoteVoicePar[nvoice].Enabled = ON;
NoteVoicePar[nvoice].fixedfreq = pars->VoicePar[nvoice].Pfixedfreq;
@@ -267,7 +267,7 @@ ADnote::ADnote(ADnoteParameters *pars,
//the extra points contains the first point
NoteVoicePar[nvoice].OscilSmp =
- new REALTYPE[OSCIL_SIZE + OSCIL_SMP_EXTRA_SAMPLES];
+ new float[OSCIL_SIZE + OSCIL_SMP_EXTRA_SAMPLES];
//Get the voice's oscil or external's voice oscil
int vc = nvoice;
@@ -337,7 +337,7 @@ ADnote::ADnote(ADnoteParameters *pars,
NoteVoicePar[nvoice].FMAmpEnvelope = NULL;
//Compute the Voice's modulator volume (incl. damping)
- REALTYPE fmvoldamp = pow(440.0 / getvoicebasefreq(
+ float fmvoldamp = pow(440.0 / getvoicebasefreq(
nvoice),
pars->VoicePar[nvoice].PFMVolumeDamp / 64.0
- 1.0);
@@ -369,7 +369,7 @@ ADnote::ADnote(ADnoteParameters *pars,
VelF(velocity,
partparams->VoicePar[nvoice].PFMVelocityScaleFunction);
- FMoldsmp[nvoice] = new REALTYPE [unison];
+ FMoldsmp[nvoice] = new float [unison];
for(int k = 0; k < unison; k++)
FMoldsmp[nvoice][k] = 0.0; //this is for FM (integration)
@@ -386,10 +386,10 @@ ADnote::ADnote(ADnoteParameters *pars,
max_unison = unison_size[nvoice];
- tmpwave_unison = new REALTYPE *[max_unison];
+ tmpwave_unison = new float *[max_unison];
for(int k = 0; k < max_unison; k++) {
- tmpwave_unison[k] = new REALTYPE[SOUND_BUFFER_SIZE];
- memset(tmpwave_unison[k], 0, SOUND_BUFFER_SIZE * sizeof(REALTYPE));
+ tmpwave_unison[k] = new float[SOUND_BUFFER_SIZE];
+ memset(tmpwave_unison[k], 0, SOUND_BUFFER_SIZE * sizeof(float));
}
initparameters();
@@ -399,7 +399,7 @@ ADnote::ADnote(ADnoteParameters *pars,
// initparameters() stuck together with some lines removed so that it
// only alter the already playing note (to perform legato). It is
// possible I left stuff that is not required for this.
-void ADnote::legatonote(REALTYPE freq, REALTYPE velocity, int portamento_,
+void ADnote::legatonote(float freq, float velocity, int portamento_,
int midinote_, bool externcall)
{
ADnoteParameters *pars = partparams;
@@ -499,7 +499,7 @@ void ADnote::legatonote(REALTYPE freq, REALTYPE velocity, int portamento_,
NoteVoicePar[nvoice].FMVoice = pars->VoicePar[nvoice].PFMVoice;
//Compute the Voice's modulator volume (incl. damping)
- REALTYPE fmvoldamp = pow(440.0 / getvoicebasefreq(nvoice),
+ float fmvoldamp = pow(440.0 / getvoicebasefreq(nvoice),
pars->VoicePar[nvoice].PFMVolumeDamp / 64.0
- 1.0);
@@ -777,7 +777,7 @@ void ADnote::initparameters()
/* Voice Modulation Parameters Init */
if((vce.FMEnabled != NONE) && (vce.FMVoice < 0)) {
param.FMSmp->newrandseed(rand());
- vce.FMSmp = new REALTYPE[OSCIL_SIZE + OSCIL_SMP_EXTRA_SAMPLES];
+ vce.FMSmp = new float[OSCIL_SIZE + OSCIL_SMP_EXTRA_SAMPLES];
//Perform Anti-aliasing only on MORPH or RING MODULATION
@@ -785,7 +785,7 @@ void ADnote::initparameters()
if(param.PextFMoscil != -1)
vc = param.PextFMoscil;
- REALTYPE tmp = 1.0;
+ float tmp = 1.0;
if((partparams->VoicePar[vc].FMSmp->Padaptiveharmonics != 0)
|| (vce.FMEnabled == MORPH)
|| (vce.FMEnabled == RING_MOD))
@@ -826,12 +826,12 @@ void ADnote::initparameters()
tmp[i] = 0;
for(int i = nvoice + 1; i < NUM_VOICES; i++)
if((NoteVoicePar[i].FMVoice == nvoice) && (tmp[i] == 0)) {
- NoteVoicePar[nvoice].VoiceOut = new REALTYPE[SOUND_BUFFER_SIZE];
+ NoteVoicePar[nvoice].VoiceOut = new float[SOUND_BUFFER_SIZE];
tmp[i] = 1;
}
if(NoteVoicePar[nvoice].VoiceOut)
- memset(NoteVoicePar[nvoice].VoiceOut, 0, SOUND_BUFFER_SIZE * sizeof(REALTYPE));
+ memset(NoteVoicePar[nvoice].VoiceOut, 0, SOUND_BUFFER_SIZE * sizeof(float));
}
}
@@ -845,10 +845,10 @@ void ADnote::compute_unison_freq_rap(int nvoice) {
unison_freq_rap[nvoice][0] = 1.0;
return;
}
- REALTYPE relbw = ctl->bandwidth.relbw * bandwidthDetuneMultiplier;
+ float relbw = ctl->bandwidth.relbw * bandwidthDetuneMultiplier;
for(int k = 0; k < unison_size[nvoice]; k++) {
- REALTYPE pos = unison_vibratto[nvoice].position[k];
- REALTYPE step = unison_vibratto[nvoice].step[k];
+ float pos = unison_vibratto[nvoice].position[k];
+ float step = unison_vibratto[nvoice].step[k];
pos += step;
if(pos <= -1.0) {
pos = -1.0;
@@ -858,7 +858,7 @@ void ADnote::compute_unison_freq_rap(int nvoice) {
pos = 1.0;
step = -step;
}
- REALTYPE vibratto_val = (pos - 0.333333333 * pos * pos * pos) * 1.5; //make the vibratto lfo smoother
+ float vibratto_val = (pos - 0.333333333 * pos * pos * pos) * 1.5; //make the vibratto lfo smoother
unison_freq_rap[nvoice][k] = 1.0
+ ((unison_base_freq_rap[nvoice][k]
- 1.0) + vibratto_val
@@ -874,11 +874,11 @@ void ADnote::compute_unison_freq_rap(int nvoice) {
/*
* Computes the frequency of an oscillator
*/
-void ADnote::setfreq(int nvoice, REALTYPE in_freq)
+void ADnote::setfreq(int nvoice, float in_freq)
{
for(int k = 0; k < unison_size[nvoice]; k++) {
- REALTYPE freq = fabs(in_freq) * unison_freq_rap[nvoice][k];
- REALTYPE speed = freq * REALTYPE(OSCIL_SIZE) / (REALTYPE) SAMPLE_RATE;
+ float freq = fabs(in_freq) * unison_freq_rap[nvoice][k];
+ float speed = freq * float(OSCIL_SIZE) / (float) SAMPLE_RATE;
if(speed > OSCIL_SIZE)
speed = OSCIL_SIZE;
@@ -890,11 +890,11 @@ void ADnote::setfreq(int nvoice, REALTYPE in_freq)
/*
* Computes the frequency of an modullator oscillator
*/
-void ADnote::setfreqFM(int nvoice, REALTYPE in_freq)
+void ADnote::setfreqFM(int nvoice, float in_freq)
{
for(int k = 0; k < unison_size[nvoice]; k++) {
- REALTYPE freq = fabs(in_freq) * unison_freq_rap[nvoice][k];
- REALTYPE speed = freq * REALTYPE(OSCIL_SIZE) / (REALTYPE) SAMPLE_RATE;
+ float freq = fabs(in_freq) * unison_freq_rap[nvoice][k];
+ float speed = freq * float(OSCIL_SIZE) / (float) SAMPLE_RATE;
if(speed > OSCIL_SIZE)
speed = OSCIL_SIZE;
@@ -906,9 +906,9 @@ void ADnote::setfreqFM(int nvoice, REALTYPE in_freq)
/*
* Get Voice base frequency
*/
-REALTYPE ADnote::getvoicebasefreq(int nvoice) const
+float ADnote::getvoicebasefreq(int nvoice) const
{
- REALTYPE detune = NoteVoicePar[nvoice].Detune / 100.0
+ float detune = NoteVoicePar[nvoice].Detune / 100.0
+ NoteVoicePar[nvoice].FineDetune / 100.0
* ctl->bandwidth.relbw * bandwidthDetuneMultiplier
+ NoteGlobalPar.Detune / 100.0;
@@ -916,10 +916,10 @@ REALTYPE ADnote::getvoicebasefreq(int nvoice) const
if(NoteVoicePar[nvoice].fixedfreq == 0)
return this->basefreq * pow(2, detune / 12.0);
else { //the fixed freq is enabled
- REALTYPE fixedfreq = 440.0;
+ float fixedfreq = 440.0;
int fixedfreqET = NoteVoicePar[nvoice].fixedfreqET;
if(fixedfreqET != 0) { //if the frequency varies according the keyboard note
- REALTYPE tmp =
+ float tmp =
(midinote
- 69.0) / 12.0 * (pow(2.0, (fixedfreqET - 1) / 63.0) - 1.0);
if(fixedfreqET <= 64)
@@ -934,9 +934,9 @@ REALTYPE ADnote::getvoicebasefreq(int nvoice) const
/*
* Get Voice's Modullator base frequency
*/
-REALTYPE ADnote::getFMvoicebasefreq(int nvoice) const
+float ADnote::getFMvoicebasefreq(int nvoice) const
{
- REALTYPE detune = NoteVoicePar[nvoice].FMDetune / 100.0;
+ float detune = NoteVoicePar[nvoice].FMDetune / 100.0;
return getvoicebasefreq(nvoice) * pow(2, detune / 12.0);
}
@@ -946,7 +946,7 @@ REALTYPE ADnote::getFMvoicebasefreq(int nvoice) const
void ADnote::computecurrentparameters()
{
int nvoice;
- REALTYPE voicefreq, voicepitch, filterpitch, filterfreq, FMfreq,
+ float voicefreq, voicepitch, filterpitch, filterfreq, FMfreq,
FMrelativepitch, globalpitch, globalfilterpitch;
globalpitch = 0.01 * (NoteGlobalPar.FreqEnvelope->envout()
+ NoteGlobalPar.FreqLfo->lfoout()
@@ -960,18 +960,18 @@ void ADnote::computecurrentparameters()
+ NoteGlobalPar.FilterLfo->lfoout()
+ NoteGlobalPar.FilterCenterPitch;
- REALTYPE tmpfilterfreq = globalfilterpitch + ctl->filtercutoff.relfreq
+ float tmpfilterfreq = globalfilterpitch + ctl->filtercutoff.relfreq
+ NoteGlobalPar.FilterFreqTracking;
tmpfilterfreq = NoteGlobalPar.GlobalFilterL->getrealfreq(tmpfilterfreq);
- REALTYPE globalfilterq = NoteGlobalPar.FilterQ * ctl->filterq.relq;
+ float globalfilterq = NoteGlobalPar.FilterQ * ctl->filterq.relq;
NoteGlobalPar.GlobalFilterL->setfreq_and_q(tmpfilterfreq, globalfilterq);
if(stereo != 0)
NoteGlobalPar.GlobalFilterR->setfreq_and_q(tmpfilterfreq, globalfilterq);
//compute the portamento, if it is used by this note
- REALTYPE portamentofreqrap = 1.0;
+ float portamentofreqrap = 1.0;
if(portamento != 0) { //this voice use portamento
portamentofreqrap = ctl->portamento.freqrap;
if(ctl->portamento.used == 0) //the portamento has finished
@@ -1061,21 +1061,21 @@ void ADnote::computecurrentparameters()
}
}
}
- time += (REALTYPE)SOUND_BUFFER_SIZE / (REALTYPE)SAMPLE_RATE;
+ time += (float)SOUND_BUFFER_SIZE / (float)SAMPLE_RATE;
}
/*
* Fadein in a way that removes clicks but keep sound "punchy"
*/
-inline void ADnote::fadein(REALTYPE *smps) const
+inline void ADnote::fadein(float *smps) const
{
int zerocrossings = 0;
for(int i = 1; i < SOUND_BUFFER_SIZE; i++)
if((smps[i - 1] < 0.0) && (smps[i] > 0.0))
zerocrossings++; //this is only the possitive crossings
- REALTYPE tmp = (SOUND_BUFFER_SIZE - 1.0) / (zerocrossings + 1) / 3.0;
+ float tmp = (SOUND_BUFFER_SIZE - 1.0) / (zerocrossings + 1) / 3.0;
if(tmp < 8.0)
tmp = 8.0;
@@ -1084,7 +1084,7 @@ inline void ADnote::fadein(REALTYPE *smps) const
if(n > SOUND_BUFFER_SIZE)
n = SOUND_BUFFER_SIZE;
for(int i = 0; i < n; i++) { //fade-in
- REALTYPE tmp = 0.5 - cos((REALTYPE)i / (REALTYPE) n * PI) * 0.5;
+ float tmp = 0.5 - cos((float)i / (float) n * PI) * 0.5;
smps[i] *= tmp;
}
}
@@ -1095,15 +1095,15 @@ inline void ADnote::fadein(REALTYPE *smps) const
inline void ADnote::ComputeVoiceOscillator_LinearInterpolation(int nvoice)
{
int i, poshi;
- REALTYPE poslo;
+ float poslo;
for(int k = 0; k < unison_size[nvoice]; k++) {
poshi = oscposhi[nvoice][k];
poslo = oscposlo[nvoice][k];
int freqhi = oscfreqhi[nvoice][k];
- REALTYPE freqlo = oscfreqlo[nvoice][k];
- REALTYPE *smps = NoteVoicePar[nvoice].OscilSmp;
- REALTYPE *tw = tmpwave_unison[k];
+ float freqlo = oscfreqlo[nvoice][k];
+ float *smps = NoteVoicePar[nvoice].OscilSmp;
+ float *tw = tmpwave_unison[k];
for(i = 0; i < SOUND_BUFFER_SIZE; i++) {
tw[i] = smps[poshi] * (1.0 - poslo) + smps[poshi + 1] * poslo;
poslo += freqlo;
@@ -1127,12 +1127,12 @@ inline void ADnote::ComputeVoiceOscillator_LinearInterpolation(int nvoice)
The differences from the Linear are to little to deserve to be used. This is because I am using a large OSCIL_SIZE (>512)
inline void ADnote::ComputeVoiceOscillator_CubicInterpolation(int nvoice){
int i,poshi;
- REALTYPE poslo;
+ float poslo;
poshi=oscposhi[nvoice];
poslo=oscposlo[nvoice];
- REALTYPE *smps=NoteVoicePar[nvoice].OscilSmp;
- REALTYPE xm1,x0,x1,x2,a,b,c;
+ float *smps=NoteVoicePar[nvoice].OscilSmp;
+ float xm1,x0,x1,x2,a,b,c;
for (i=0;i<SOUND_BUFFER_SIZE;i++){
xm1=smps[poshi];
x0=smps[poshi+1];
@@ -1162,7 +1162,7 @@ inline void ADnote::ComputeVoiceOscillator_CubicInterpolation(int nvoice){
inline void ADnote::ComputeVoiceOscillatorMorph(int nvoice)
{
int i;
- REALTYPE amp;
+ float amp;
ComputeVoiceOscillator_LinearInterpolation(nvoice);
if(FMnewamplitude[nvoice] > 1.0)
FMnewamplitude[nvoice] = 1.0;
@@ -1173,7 +1173,7 @@ inline void ADnote::ComputeVoiceOscillatorMorph(int nvoice)
//if I use VoiceOut[] as modullator
int FMVoice = NoteVoicePar[nvoice].FMVoice;
for(int k = 0; k < unison_size[nvoice]; k++) {
- REALTYPE *tw = tmpwave_unison[k];
+ float *tw = tmpwave_unison[k];
for(i = 0; i < SOUND_BUFFER_SIZE; i++) {
amp = INTERPOLATE_AMPLITUDE(FMoldamplitude[nvoice],
FMnewamplitude[nvoice],
@@ -1187,10 +1187,10 @@ inline void ADnote::ComputeVoiceOscillatorMorph(int nvoice)
else {
for(int k = 0; k < unison_size[nvoice]; k++) {
int poshiFM = oscposhiFM[nvoice][k];
- REALTYPE posloFM = oscposloFM[nvoice][k];
+ float posloFM = oscposloFM[nvoice][k];
int freqhiFM = oscfreqhiFM[nvoice][k];
- REALTYPE freqloFM = oscfreqloFM[nvoice][k];
- REALTYPE *tw = tmpwave_unison[k];
+ float freqloFM = oscfreqloFM[nvoice][k];
+ float *tw = tmpwave_unison[k];
for(i = 0; i < SOUND_BUFFER_SIZE; i++) {
amp = INTERPOLATE_AMPLITUDE(FMoldamplitude[nvoice],
@@ -1220,7 +1220,7 @@ inline void ADnote::ComputeVoiceOscillatorMorph(int nvoice)
inline void ADnote::ComputeVoiceOscillatorRingModulation(int nvoice)
{
int i;
- REALTYPE amp;
+ float amp;
ComputeVoiceOscillator_LinearInterpolation(nvoice);
if(FMnewamplitude[nvoice] > 1.0)
FMnewamplitude[nvoice] = 1.0;
@@ -1229,7 +1229,7 @@ inline void ADnote::ComputeVoiceOscillatorRingModulation(int nvoice)
if(NoteVoicePar[nvoice].FMVoice >= 0) {
// if I use VoiceOut[] as modullator
for(int k = 0; k < unison_size[nvoice]; k++) {
- REALTYPE *tw = tmpwave_unison[k];
+ float *tw = tmpwave_unison[k];
for(i = 0; i < SOUND_BUFFER_SIZE; i++) {
amp = INTERPOLATE_AMPLITUDE(FMoldamplitude[nvoice],
FMnewamplitude[nvoice],
@@ -1243,10 +1243,10 @@ inline void ADnote::ComputeVoiceOscillatorRingModulation(int nvoice)
else {
for(int k = 0; k < unison_size[nvoice]; k++) {
int poshiFM = oscposhiFM[nvoice][k];
- REALTYPE posloFM = oscposloFM[nvoice][k];
+ float posloFM = oscposloFM[nvoice][k];
int freqhiFM = oscfreqhiFM[nvoice][k];
- REALTYPE freqloFM = oscfreqloFM[nvoice][k];
- REALTYPE *tw = tmpwave_unison[k];
+ float freqloFM = oscfreqloFM[nvoice][k];
+ float *tw = tmpwave_unison[k];
for(i = 0; i < SOUND_BUFFER_SIZE; i++) {
amp = INTERPOLATE_AMPLITUDE(FMoldamplitude[nvoice],
@@ -1281,24 +1281,24 @@ inline void ADnote::ComputeVoiceOscillatorFrequencyModulation(int nvoice,
{
int carposhi = 0;
int i, FMmodfreqhi = 0;
- REALTYPE FMmodfreqlo = 0, carposlo = 0;
+ float FMmodfreqlo = 0, carposlo = 0;
if(NoteVoicePar[nvoice].FMVoice >= 0) {
//if I use VoiceOut[] as modulator
for(int k = 0; k < unison_size[nvoice]; k++) {
- REALTYPE *tw = tmpwave_unison[k];
+ float *tw = tmpwave_unison[k];
memcpy(tw, NoteVoicePar[NoteVoicePar[nvoice].FMVoice].VoiceOut,
- SOUND_BUFFER_SIZE * sizeof(REALTYPE));
+ SOUND_BUFFER_SIZE * sizeof(float));
}
}
else {
//Compute the modulator and store it in tmpwave_unison[][]
for(int k = 0; k < unison_size[nvoice]; k++) {
int poshiFM = oscposhiFM[nvoice][k];
- REALTYPE posloFM = oscposloFM[nvoice][k];
+ float posloFM = oscposloFM[nvoice][k];
int freqhiFM = oscfreqhiFM[nvoice][k];
- REALTYPE freqloFM = oscfreqloFM[nvoice][k];
- REALTYPE *tw = tmpwave_unison[k];
+ float freqloFM = oscfreqloFM[nvoice][k];
+ float *tw = tmpwave_unison[k];
for(i = 0; i < SOUND_BUFFER_SIZE; i++) {
tw[i] =
@@ -1320,7 +1320,7 @@ inline void ADnote::ComputeVoiceOscillatorFrequencyModulation(int nvoice,
if(ABOVE_AMPLITUDE_THRESHOLD(FMoldamplitude[nvoice],
FMnewamplitude[nvoice])) {
for(int k = 0; k < unison_size[nvoice]; k++) {
- REALTYPE *tw = tmpwave_unison[k];
+ float *tw = tmpwave_unison[k];
for(i = 0; i < SOUND_BUFFER_SIZE; i++)
tw[i] *= INTERPOLATE_AMPLITUDE(FMoldamplitude[nvoice],
FMnewamplitude[nvoice],
@@ -1331,7 +1331,7 @@ inline void ADnote::ComputeVoiceOscillatorFrequencyModulation(int nvoice,
}
else {
for(int k = 0; k < unison_size[nvoice]; k++) {
- REALTYPE *tw = tmpwave_unison[k];
+ float *tw = tmpwave_unison[k];
for(i = 0; i < SOUND_BUFFER_SIZE; i++)
tw[i] *= FMnewamplitude[nvoice];
}
@@ -1340,11 +1340,11 @@ inline void ADnote::ComputeVoiceOscillatorFrequencyModulation(int nvoice,
//normalize: makes all sample-rates, oscil_sizes to produce same sound
if(FMmode != 0) { //Frequency modulation
- REALTYPE normalize = OSCIL_SIZE / 262144.0 * 44100.0
- / (REALTYPE)SAMPLE_RATE;
+ float normalize = OSCIL_SIZE / 262144.0 * 44100.0
+ / (float)SAMPLE_RATE;
for(int k = 0; k < unison_size[nvoice]; k++) {
- REALTYPE *tw = tmpwave_unison[k];
- REALTYPE fmold = FMoldsmp[nvoice][k];
+ float *tw = tmpwave_unison[k];
+ float fmold = FMoldsmp[nvoice][k];
for(i = 0; i < SOUND_BUFFER_SIZE; i++) {
fmold = fmod(fmold + tw[i] * normalize, OSCIL_SIZE);
tw[i] = fmold;
@@ -1353,9 +1353,9 @@ inline void ADnote::ComputeVoiceOscillatorFrequencyModulation(int nvoice,
}
}
else { //Phase modulation
- REALTYPE normalize = OSCIL_SIZE / 262144.0;
+ float normalize = OSCIL_SIZE / 262144.0;
for(int k = 0; k < unison_size[nvoice]; k++) {
- REALTYPE *tw = tmpwave_unison[k];
+ float *tw = tmpwave_unison[k];
for(i = 0; i < SOUND_BUFFER_SIZE; i++)
tw[i] *= normalize;
}
@@ -1363,11 +1363,11 @@ inline void ADnote::ComputeVoiceOscillatorFrequencyModulation(int nvoice,
//do the modulation
for(int k = 0; k < unison_size[nvoice]; k++) {
- REALTYPE *tw = tmpwave_unison[k];
+ float *tw = tmpwave_unison[k];
int poshi = oscposhi[nvoice][k];
- REALTYPE poslo = oscposlo[nvoice][k];
+ float poslo = oscposlo[nvoice][k];
int freqhi = oscfreqhi[nvoice][k];
- REALTYPE freqlo = oscfreqlo[nvoice][k];
+ float freqlo = oscfreqlo[nvoice][k];
for(i = 0; i < SOUND_BUFFER_SIZE; i++) {
F2I(tw[i], FMmodfreqhi);
@@ -1417,7 +1417,7 @@ inline void ADnote::ComputeVoiceOscillatorPitchModulation(int /*nvoice*/)
inline void ADnote::ComputeVoiceNoise(int nvoice)
{
for(int k = 0; k < unison_size[nvoice]; k++) {
- REALTYPE *tw = tmpwave_unison[k];
+ float *tw = tmpwave_unison[k];
for(int i = 0; i < SOUND_BUFFER_SIZE; i++)
tw[i] = RND * 2.0 - 1.0;
}
@@ -1429,16 +1429,16 @@ inline void ADnote::ComputeVoiceNoise(int nvoice)
* Compute the ADnote samples
* Returns 0 if the note is finished
*/
-int ADnote::noteout(REALTYPE *outl, REALTYPE *outr)
+int ADnote::noteout(float *outl, float *outr)
{
- memcpy(outl, denormalkillbuf, SOUND_BUFFER_SIZE * sizeof(REALTYPE));
- memcpy(outr, denormalkillbuf, SOUND_BUFFER_SIZE * sizeof(REALTYPE));
+ memcpy(outl, denormalkillbuf, SOUND_BUFFER_SIZE * sizeof(float));
+ memcpy(outr, denormalkillbuf, SOUND_BUFFER_SIZE * sizeof(float));
if(NoteEnabled == OFF)
return 0;
- memset(bypassl, 0, SOUND_BUFFER_SIZE * sizeof(REALTYPE));
- memset(bypassr, 0, SOUND_BUFFER_SIZE * sizeof(REALTYPE));
+ memset(bypassl, 0, SOUND_BUFFER_SIZE * sizeof(float));
+ memset(bypassr, 0, SOUND_BUFFER_SIZE * sizeof(float));
computecurrentparameters();
for(unsigned nvoice = 0; nvoice < NUM_VOICES; nvoice++) {
@@ -1470,20 +1470,20 @@ int ADnote::noteout(REALTYPE *outl, REALTYPE *outr)
//mix subvoices into voice
- memset(tmpwavel, 0, SOUND_BUFFER_SIZE * sizeof(REALTYPE));
+ memset(tmpwavel, 0, SOUND_BUFFER_SIZE * sizeof(float));
if(stereo)
- memset(tmpwaver, 0, SOUND_BUFFER_SIZE * sizeof(REALTYPE));
+ memset(tmpwaver, 0, SOUND_BUFFER_SIZE * sizeof(float));
for(int k = 0; k < unison_size[nvoice]; k++) {
- REALTYPE *tw = tmpwave_unison[k];
+ float *tw = tmpwave_unison[k];
if(stereo) {
- REALTYPE stereo_pos = 0;
+ float stereo_pos = 0;
if(unison_size[nvoice] > 1)
stereo_pos = k
- / (REALTYPE)(unison_size[nvoice]
+ / (float)(unison_size[nvoice]
- 1) * 2.0 - 1.0;
- REALTYPE stereo_spread = unison_stereo_spread[nvoice] * 2.0; //between 0 and 2.0
+ float stereo_spread = unison_stereo_spread[nvoice] * 2.0; //between 0 and 2.0
if(stereo_spread > 1.0) {
- REALTYPE stereo_pos_1 = (stereo_pos >= 0.0) ? 1.0 : -1.0;
+ float stereo_pos_1 = (stereo_pos >= 0.0) ? 1.0 : -1.0;
stereo_pos =
(2.0
- stereo_spread) * stereo_pos
@@ -1494,14 +1494,14 @@ int ADnote::noteout(REALTYPE *outl, REALTYPE *outr)
if(unison_size[nvoice] == 1)
stereo_pos = 0.0;
- REALTYPE panning = (stereo_pos + 1.0) * 0.5;
+ float panning = (stereo_pos + 1.0) * 0.5;
- REALTYPE lvol = (1.0 - panning) * 2.0;
+ float lvol = (1.0 - panning) * 2.0;
if(lvol > 1.0)
lvol = 1.0;
- REALTYPE rvol = panning * 2.0;
+ float rvol = panning * 2.0;
if(rvol > 1.0)
rvol = 1.0;
@@ -1522,10 +1522,10 @@ int ADnote::noteout(REALTYPE *outl, REALTYPE *outr)
}
- REALTYPE unison_amplitude = 1.0 / sqrt(unison_size[nvoice]); //reduce the amplitude for large unison sizes
+ float unison_amplitude = 1.0 / sqrt(unison_size[nvoice]); //reduce the amplitude for large unison sizes
// Amplitude
- REALTYPE oldam = oldamplitude[nvoice] * unison_amplitude;
- REALTYPE newam = newamplitude[nvoice] * unison_amplitude;
+ float oldam = oldamplitude[nvoice] * unison_amplitude;
+ float newam = newamplitude[nvoice] * unison_amplitude;
if(ABOVE_AMPLITUDE_THRESHOLD(oldam, newam)) {
int rest = SOUND_BUFFER_SIZE;
@@ -1542,7 +1542,7 @@ int ADnote::noteout(REALTYPE *outl, REALTYPE *outr)
}
// Amplitude interpolation
for(int i = 0; i < rest; i++) {
- REALTYPE amp = INTERPOLATE_AMPLITUDE(oldam, newam, i, rest);
+ float amp = INTERPOLATE_AMPLITUDE(oldam, newam, i, rest);
tmpwavel[i + (SOUND_BUFFER_SIZE - rest)] *= amp;
if(stereo)
tmpwaver[i + (SOUND_BUFFER_SIZE - rest)] *= amp;
@@ -1575,12 +1575,12 @@ int ADnote::noteout(REALTYPE *outl, REALTYPE *outr)
if(NoteVoicePar[nvoice].AmpEnvelope != NULL) {
if(NoteVoicePar[nvoice].AmpEnvelope->finished() != 0) {
for(int i = 0; i < SOUND_BUFFER_SIZE; i++)
- tmpwavel[i] *= 1.0 - (REALTYPE)i
- / (REALTYPE)SOUND_BUFFER_SIZE;
+ tmpwavel[i] *= 1.0 - (float)i
+ / (float)SOUND_BUFFER_SIZE;
if(stereo)
for(int i = 0; i < SOUND_BUFFER_SIZE; i++)
- tmpwaver[i] *= 1.0 - (REALTYPE)i
- / (REALTYPE)SOUND_BUFFER_SIZE;
+ tmpwaver[i] *= 1.0 - (float)i
+ / (float)SOUND_BUFFER_SIZE;
}
//the voice is killed later
}
@@ -1640,8 +1640,8 @@ int ADnote::noteout(REALTYPE *outl, REALTYPE *outr)
NoteGlobalPar.GlobalFilterL->filterout(&outl[0]);
if(stereo == 0) { //set the right channel=left channel
- memcpy(outr, outl, SOUND_BUFFER_SIZE * sizeof(REALTYPE));
- memcpy(bypassr, bypassl, SOUND_BUFFER_SIZE * sizeof(REALTYPE));
+ memcpy(outr, outl, SOUND_BUFFER_SIZE * sizeof(float));
+ memcpy(bypassr, bypassl, SOUND_BUFFER_SIZE * sizeof(float));
}
else
NoteGlobalPar.GlobalFilterR->filterout(&outr[0]);
@@ -1654,7 +1654,7 @@ int ADnote::noteout(REALTYPE *outl, REALTYPE *outr)
if(ABOVE_AMPLITUDE_THRESHOLD(globaloldamplitude, globalnewamplitude)) {
// Amplitude Interpolation
for(int i = 0; i < SOUND_BUFFER_SIZE; i++) {
- REALTYPE tmpvol = INTERPOLATE_AMPLITUDE(globaloldamplitude,
+ float tmpvol = INTERPOLATE_AMPLITUDE(globaloldamplitude,
globalnewamplitude,
i,
SOUND_BUFFER_SIZE);
@@ -1672,7 +1672,7 @@ int ADnote::noteout(REALTYPE *outl, REALTYPE *outr)
//Apply the punch
if(NoteGlobalPar.Punch.Enabled != 0) {
for(int i = 0; i < SOUND_BUFFER_SIZE; i++) {
- REALTYPE punchamp = NoteGlobalPar.Punch.initialvalue
+ float punchamp = NoteGlobalPar.Punch.initialvalue
* NoteGlobalPar.Punch.t + 1.0;
outl[i] *= punchamp;
outr[i] *= punchamp;
@@ -1693,7 +1693,7 @@ int ADnote::noteout(REALTYPE *outl, REALTYPE *outr)
// If it does, disable the note
if(NoteGlobalPar.AmpEnvelope->finished()) {
for(int i = 0; i < SOUND_BUFFER_SIZE; i++) { //fade-out
- REALTYPE tmp = 1.0 - (REALTYPE)i / (REALTYPE)SOUND_BUFFER_SIZE;
+ float tmp = 1.0 - (float)i / (float)SOUND_BUFFER_SIZE;
outl[i] *= tmp;
outr[i] *= tmp;
}
@@ -1765,7 +1765,7 @@ void ADnote::Voice::kill()
}
if(VoiceOut)
- memset(VoiceOut, 0, SOUND_BUFFER_SIZE * sizeof(REALTYPE));
+ memset(VoiceOut, 0, SOUND_BUFFER_SIZE * sizeof(float));
//do not delete, yet: perhaps is used by another voice
Enabled = OFF;
@@ -1784,7 +1784,7 @@ void ADnote::Global::kill()
}
void ADnote::Global::initparameters(const ADnoteGlobalParam ¶m,
- REALTYPE basefreq, REALTYPE velocity,
+ float basefreq, float velocity,
bool stereo)
{
FreqEnvelope = new Envelope(param.FreqEnvelope, basefreq);
diff --git a/src/Synth/ADnote.h b/src/Synth/ADnote.h
@@ -49,17 +49,17 @@ class ADnote :public SynthNote
* @param portamento_ 1 if the note has portamento
* @param midinote_ The midi number of the note
* @param besilent Start silent note if true*/
- ADnote(ADnoteParameters *pars, Controller *ctl_, REALTYPE freq,
- REALTYPE velocity, int portamento_, int midinote_,
+ ADnote(ADnoteParameters *pars, Controller *ctl_, float freq,
+ float velocity, int portamento_, int midinote_,
bool besilent);
/**Destructor*/
~ADnote();
/**Alters the playing note for legato effect*/
- void legatonote(REALTYPE freq, REALTYPE velocity, int portamento_,
+ void legatonote(float freq, float velocity, int portamento_,
int midinote_, bool externcall);
- int noteout(REALTYPE *outl, REALTYPE *outr);
+ int noteout(float *outl, float *outr);
void relasekey();
int finished() const;
private:
@@ -67,9 +67,9 @@ class ADnote :public SynthNote
/**Changes the frequency of an oscillator.
* @param nvoice voice to run computations on
* @param in_freq new frequency*/
- void setfreq(int nvoice, REALTYPE in_freq);
+ void setfreq(int nvoice, float in_freq);
/**Set the frequency of the modulator oscillator*/
- void setfreqFM(int nvoice, REALTYPE in_freq);
+ void setfreqFM(int nvoice, float in_freq);
/**Computes relative frequency for unison and unison's vibratto.
* Note: Must be called before setfreq* functions.*/
void compute_unison_freq_rap(int nvoice);
@@ -82,9 +82,9 @@ class ADnote :public SynthNote
/**Deallocate Note resources and voice resources*/
void KillNote();
/**Get the Voice's base frequency*/
- inline REALTYPE getvoicebasefreq(int nvoice) const;
+ inline float getvoicebasefreq(int nvoice) const;
/**Get modulator's base frequency*/
- inline REALTYPE getFMvoicebasefreq(int nvoice) const;
+ inline float getFMvoicebasefreq(int nvoice) const;
/**Compute the Oscillator's samples.
* Affects tmpwave_unison and updates oscposhi/oscposlo*/
inline void ComputeVoiceOscillator_LinearInterpolation(int nvoice);
@@ -109,14 +109,14 @@ class ADnote :public SynthNote
inline void ComputeVoiceNoise(int nvoice);
/**Fadein in a way that removes clicks but keep sound "punchy"*/
- inline void fadein(REALTYPE *smps) const;
+ inline void fadein(float *smps) const;
//GLOBALS
ADnoteParameters *partparams;
unsigned char stereo; //if the note is stereo (allows note Panning)
int midinote;
- REALTYPE velocity, basefreq;
+ float velocity, basefreq;
ONOFFTYPE NoteEnabled;
Controller *ctl;
@@ -128,12 +128,12 @@ class ADnote :public SynthNote
struct Global {
void kill();
void initparameters(const ADnoteGlobalParam ¶m,
- REALTYPE basefreq, REALTYPE velocity,
+ float basefreq, float velocity,
bool stereo);
/******************************************
* FREQUENCY GLOBAL PARAMETERS *
******************************************/
- REALTYPE Detune; //cents
+ float Detune; //cents
Envelope *FreqEnvelope;
LFO *FreqLfo;
@@ -141,16 +141,16 @@ class ADnote :public SynthNote
/********************************************
* AMPLITUDE GLOBAL PARAMETERS *
********************************************/
- REALTYPE Volume; // [ 0 .. 1 ]
+ float Volume; // [ 0 .. 1 ]
- REALTYPE Panning; // [ 0 .. 1 ]
+ float Panning; // [ 0 .. 1 ]
Envelope *AmpEnvelope;
LFO *AmpLfo;
struct {
int Enabled;
- REALTYPE initialvalue, dt, t;
+ float initialvalue, dt, t;
} Punch;
/******************************************
@@ -158,9 +158,9 @@ class ADnote :public SynthNote
******************************************/
Filter *GlobalFilterL, *GlobalFilterR;
- REALTYPE FilterCenterPitch; //octaves
- REALTYPE FilterQ;
- REALTYPE FilterFreqTracking;
+ float FilterCenterPitch; //octaves
+ float FilterQ;
+ float FilterFreqTracking;
Envelope *FilterEnvelope;
@@ -188,7 +188,7 @@ class ADnote :public SynthNote
int DelayTicks;
/* Waveform of the Voice */
- REALTYPE *OscilSmp;
+ float *OscilSmp;
/************************************
* FREQUENCY PARAMETERS *
@@ -197,7 +197,7 @@ class ADnote :public SynthNote
int fixedfreqET; //if the "fixed" frequency varies according to the note (ET)
// cents = basefreq*VoiceDetune
- REALTYPE Detune, FineDetune;
+ float Detune, FineDetune;
Envelope *FreqEnvelope;
LFO *FreqLfo;
@@ -208,8 +208,8 @@ class ADnote :public SynthNote
***************************/
/* Panning 0.0=left, 0.5 - center, 1.0 = right */
- REALTYPE Panning;
- REALTYPE Volume; // [-1.0 .. 1.0]
+ float Panning;
+ float Volume; // [-1.0 .. 1.0]
Envelope *AmpEnvelope;
LFO *AmpLfo;
@@ -221,8 +221,8 @@ class ADnote :public SynthNote
Filter *VoiceFilterL;
Filter *VoiceFilterR;
- REALTYPE FilterCenterPitch; /* Filter center Pitch*/
- REALTYPE FilterFreqTracking;
+ float FilterCenterPitch; /* Filter center Pitch*/
+ float FilterFreqTracking;
Envelope *FilterEnvelope;
LFO *FilterLfo;
@@ -237,13 +237,13 @@ class ADnote :public SynthNote
int FMVoice;
// Voice Output used by other voices if use this as modullator
- REALTYPE *VoiceOut;
+ float *VoiceOut;
/* Wave of the Voice */
- REALTYPE *FMSmp;
+ float *FMSmp;
- REALTYPE FMVolume;
- REALTYPE FMDetune; //in cents
+ float FMVolume;
+ float FMDetune; //in cents
Envelope *FMFreqEnvelope;
Envelope *FMAmpEnvelope;
@@ -255,37 +255,37 @@ class ADnote :public SynthNote
/********************************************************/
//time from the start of the note
- REALTYPE time;
+ float time;
//the size of unison for a single voice
int unison_size[NUM_VOICES];
//the stereo spread of the unison subvoices (0.0=mono,1.0=max)
- REALTYPE unison_stereo_spread[NUM_VOICES];
+ float unison_stereo_spread[NUM_VOICES];
//fractional part (skip)
- REALTYPE *oscposlo[NUM_VOICES], *oscfreqlo[NUM_VOICES];
+ float *oscposlo[NUM_VOICES], *oscfreqlo[NUM_VOICES];
//integer part (skip)
int *oscposhi[NUM_VOICES], *oscfreqhi[NUM_VOICES];
//fractional part (skip) of the Modullator
- REALTYPE *oscposloFM[NUM_VOICES], *oscfreqloFM[NUM_VOICES];
+ float *oscposloFM[NUM_VOICES], *oscfreqloFM[NUM_VOICES];
//the unison base_value
- REALTYPE *unison_base_freq_rap[NUM_VOICES];
+ float *unison_base_freq_rap[NUM_VOICES];
//how the unison subvoice's frequency is changed (1.0 for no change)
- REALTYPE *unison_freq_rap[NUM_VOICES];
+ float *unison_freq_rap[NUM_VOICES];
//which subvoice has phase inverted
bool *unison_invert_phase[NUM_VOICES];
//unison vibratto
struct {
- REALTYPE amplitude; //amplitude which be added to unison_freq_rap
- REALTYPE *step; //value which increments the position
- REALTYPE *position; //between -1.0 and 1.0
+ float amplitude; //amplitude which be added to unison_freq_rap
+ float *step; //value which increments the position
+ float *position; //between -1.0 and 1.0
} unison_vibratto[NUM_VOICES];
@@ -293,25 +293,25 @@ class ADnote :public SynthNote
unsigned int *oscposhiFM[NUM_VOICES], *oscfreqhiFM[NUM_VOICES];
//used to compute and interpolate the amplitudes of voices and modullators
- REALTYPE oldamplitude[NUM_VOICES],
+ float oldamplitude[NUM_VOICES],
newamplitude[NUM_VOICES],
FMoldamplitude[NUM_VOICES],
FMnewamplitude[NUM_VOICES];
//used by Frequency Modulation (for integration)
- REALTYPE *FMoldsmp[NUM_VOICES];
+ float *FMoldsmp[NUM_VOICES];
//temporary buffer
- REALTYPE *tmpwavel;
- REALTYPE *tmpwaver;
+ float *tmpwavel;
+ float *tmpwaver;
int max_unison;
- REALTYPE **tmpwave_unison;
+ float **tmpwave_unison;
//Filter bypass samples
- REALTYPE *bypassl, *bypassr;
+ float *bypassl, *bypassr;
//interpolate the amplitudes
- REALTYPE globaloldamplitude, globalnewamplitude;
+ float globaloldamplitude, globalnewamplitude;
//1 - if it is the fitst tick (used to fade in the sound)
char firsttick[NUM_VOICES];
@@ -320,7 +320,7 @@ class ADnote :public SynthNote
int portamento;
//how the fine detunes are made bigger or smaller
- REALTYPE bandwidthDetuneMultiplier;
+ float bandwidthDetuneMultiplier;
};
#endif
diff --git a/src/Synth/Envelope.cpp b/src/Synth/Envelope.cpp
@@ -24,7 +24,7 @@
#include "Envelope.h"
#include "../Params/EnvelopeParams.h"
-Envelope::Envelope(EnvelopeParams *envpars, REALTYPE basefreq)
+Envelope::Envelope(EnvelopeParams *envpars, float basefreq)
{
int i;
envpoints = envpars->Penvpoints;
@@ -38,7 +38,7 @@ Envelope::Envelope(EnvelopeParams *envpars, REALTYPE basefreq)
if(envpars->Pfreemode == 0)
envpars->converttofree();
- REALTYPE bufferdt = SOUND_BUFFER_SIZE / (REALTYPE)SAMPLE_RATE;
+ float bufferdt = SOUND_BUFFER_SIZE / (float)SAMPLE_RATE;
int mode = envpars->Envmode;
@@ -49,7 +49,7 @@ Envelope::Envelope(EnvelopeParams *envpars, REALTYPE basefreq)
mode = 1; //change to linear
for(i = 0; i < MAX_ENVELOPE_POINTS; i++) {
- REALTYPE tmp = envpars->getdt(i) / 1000.0 * envstretch;
+ float tmp = envpars->getdt(i) / 1000.0 * envstretch;
if(tmp > bufferdt)
envdt[i] = bufferdt / tmp;
else
@@ -106,9 +106,9 @@ void Envelope::relasekey()
/*
* Envelope Output
*/
-REALTYPE Envelope::envout()
+float Envelope::envout()
{
- REALTYPE out;
+ float out;
if(envfinish) { //if the envelope is finished
envoutval = envval[envpoints - 1];
@@ -161,15 +161,15 @@ REALTYPE Envelope::envout()
/*
* Envelope Output (dB)
*/
-REALTYPE Envelope::envout_dB()
+float Envelope::envout_dB()
{
- REALTYPE out;
+ float out;
if(linearenvelope != 0)
return envout();
if((currentpoint == 1) && (!keyreleased || (forcedrelase == 0))) { //first point is always lineary interpolated
- REALTYPE v1 = dB2rap(envval[0]);
- REALTYPE v2 = dB2rap(envval[1]);
+ float v1 = dB2rap(envval[0]);
+ float v2 = dB2rap(envval[1]);
out = v1 + (v2 - v1) * t;
t += inct;
diff --git a/src/Synth/Envelope.h b/src/Synth/Envelope.h
@@ -32,30 +32,30 @@ class Envelope
public:
/**Constructor*/
- Envelope(class EnvelopeParams *envpars, REALTYPE basefreq);
+ Envelope(class EnvelopeParams *envpars, float basefreq);
/**Destructor*/
~Envelope();
void relasekey();
- REALTYPE envout();
- REALTYPE envout_dB();
+ float envout();
+ float envout_dB();
/**Determines the status of the Envelope
* @return returns 1 if the envelope is finished*/
bool finished() const;
private:
int envpoints;
int envsustain; //"-1" means disabled
- REALTYPE envdt[MAX_ENVELOPE_POINTS]; //millisecons
- REALTYPE envval[MAX_ENVELOPE_POINTS]; // [0.0 .. 1.0]
- REALTYPE envstretch;
+ float envdt[MAX_ENVELOPE_POINTS]; //millisecons
+ float envval[MAX_ENVELOPE_POINTS]; // [0.0 .. 1.0]
+ float envstretch;
int linearenvelope;
int currentpoint; //current envelope point (starts from 1)
int forcedrelase;
bool keyreleased; //if the key was released
bool envfinish;
- REALTYPE t; // the time from the last point
- REALTYPE inct; // the time increment
- REALTYPE envoutval; //used to do the forced release
+ float t; // the time from the last point
+ float inct; // the time increment
+ float envoutval; //used to do the forced release
};
diff --git a/src/Synth/LFO.cpp b/src/Synth/LFO.cpp
@@ -27,16 +27,16 @@
#include "LFO.h"
-LFO::LFO(LFOParams *lfopars, REALTYPE basefreq)
+LFO::LFO(LFOParams *lfopars, float basefreq)
{
if(lfopars->Pstretch == 0)
lfopars->Pstretch = 1;
- REALTYPE lfostretch = pow(basefreq / 440.0,
+ float lfostretch = pow(basefreq / 440.0,
(lfopars->Pstretch - 64.0) / 63.0); //max 2x/octave
- REALTYPE lfofreq =
+ float lfofreq =
(pow(2, lfopars->Pfreq * 10.0) - 1.0) / 12.0 * lfostretch;
- incx = fabs(lfofreq) * (REALTYPE)SOUND_BUFFER_SIZE / (REALTYPE)SAMPLE_RATE;
+ incx = fabs(lfofreq) * (float)SOUND_BUFFER_SIZE / (float)SAMPLE_RATE;
if(lfopars->Pcontinous == 0) {
if(lfopars->Pstartphase == 0)
@@ -45,7 +45,7 @@ LFO::LFO(LFOParams *lfopars, REALTYPE basefreq)
x = fmod((lfopars->Pstartphase - 64.0) / 127.0 + 1.0, 1.0);
}
else {
- REALTYPE tmp = fmod(lfopars->time * incx, 1.0);
+ float tmp = fmod(lfopars->time * incx, 1.0);
x = fmod((lfopars->Pstartphase - 64.0) / 127.0 + 1.0 + tmp, 1.0);
}
@@ -93,9 +93,9 @@ LFO::~LFO()
/*
* LFO out
*/
-REALTYPE LFO::lfoout()
+float LFO::lfoout()
{
- REALTYPE out;
+ float out;
switch(lfotype) {
case 1: //LFO_TRIANGLE
if((x >= 0.0) && (x < 0.25))
@@ -154,16 +154,16 @@ REALTYPE LFO::lfoout()
}
}
else
- lfodelay -= (REALTYPE)SOUND_BUFFER_SIZE / (REALTYPE)SAMPLE_RATE;
+ lfodelay -= (float)SOUND_BUFFER_SIZE / (float)SAMPLE_RATE;
return out;
}
/*
* LFO out (for amplitude)
*/
-REALTYPE LFO::amplfoout()
+float LFO::amplfoout()
{
- REALTYPE out;
+ float out;
out = 1.0 - lfointensity + lfoout();
if(out < -1.0)
out = -1.0;
diff --git a/src/Synth/LFO.h b/src/Synth/LFO.h
@@ -35,18 +35,18 @@ class LFO
* @param lfopars pointer to a LFOParams object
* @param basefreq base frequency of LFO
*/
- LFO(LFOParams *lfopars, REALTYPE basefreq);
+ LFO(LFOParams *lfopars, float basefreq);
/**Deconstructor*/
~LFO();
- REALTYPE lfoout();
- REALTYPE amplfoout();
+ float lfoout();
+ float amplfoout();
private:
- REALTYPE x;
- REALTYPE incx, incrnd, nextincrnd;
- REALTYPE amp1, amp2; // used for randomness
- REALTYPE lfointensity;
- REALTYPE lfornd, lfofreqrnd;
- REALTYPE lfodelay;
+ float x;
+ float incx, incrnd, nextincrnd;
+ float amp1, amp2; // used for randomness
+ float lfointensity;
+ float lfornd, lfofreqrnd;
+ float lfodelay;
/**\todo see if an enum would be better here*/
char lfotype;
int freqrndenabled;
diff --git a/src/Synth/OscilGen.cpp b/src/Synth/OscilGen.cpp
@@ -35,7 +35,7 @@ OscilGen::OscilGen(FFTwrapper *fft_, Resonance *res_):Presets()
fft = fft_;
res = res_;
- tmpsmps = new REALTYPE[OSCIL_SIZE];
+ tmpsmps = new float[OSCIL_SIZE];
newFFTFREQS(&outoscilFFTfreqs, OSCIL_SIZE / 2);
newFFTFREQS(&oscilFFTfreqs, OSCIL_SIZE / 2);
newFFTFREQS(&basefuncFFTfreqs, OSCIL_SIZE / 2);
@@ -132,8 +132,8 @@ void OscilGen::defaults()
void OscilGen::convert2sine()
{
- REALTYPE mag[MAX_AD_HARMONICS], phase[MAX_AD_HARMONICS];
- REALTYPE oscil[OSCIL_SIZE];
+ float mag[MAX_AD_HARMONICS], phase[MAX_AD_HARMONICS];
+ float oscil[OSCIL_SIZE];
FFTFREQS freqs;
newFFTFREQS(&freqs, OSCIL_SIZE / 2);
@@ -142,7 +142,7 @@ void OscilGen::convert2sine()
fft->smps2freqs(oscil, freqs);
delete (fft);
- REALTYPE max = 0.0;
+ float max = 0.0;
mag[0] = 0;
phase[0] = 0;
@@ -158,8 +158,8 @@ void OscilGen::convert2sine()
defaults();
for(int i = 0; i < MAX_AD_HARMONICS - 1; i++) {
- REALTYPE newmag = mag[i] / max;
- REALTYPE newphase = phase[i];
+ float newmag = mag[i] / max;
+ float newphase = phase[i];
Phmag[i] = (int) ((newmag) * 64.0) + 64;
@@ -177,14 +177,14 @@ void OscilGen::convert2sine()
/*
* Get the base function
*/
-void OscilGen::getbasefunction(REALTYPE *smps)
+void OscilGen::getbasefunction(float *smps)
{
int i;
- REALTYPE par = (Pbasefuncpar + 0.5) / 128.0;
+ float par = (Pbasefuncpar + 0.5) / 128.0;
if(Pbasefuncpar == 64)
par = 0.5;
- REALTYPE basefuncmodulationpar1 = Pbasefuncmodulationpar1 / 127.0,
+ float basefuncmodulationpar1 = Pbasefuncmodulationpar1 / 127.0,
basefuncmodulationpar2 = Pbasefuncmodulationpar2 / 127.0,
basefuncmodulationpar3 = Pbasefuncmodulationpar3 / 127.0;
@@ -216,7 +216,7 @@ void OscilGen::getbasefunction(REALTYPE *smps)
base_func func = getBaseFunction(Pcurrentbasefunc);
for(i = 0; i < OSCIL_SIZE; i++) {
- REALTYPE t = i * 1.0 / OSCIL_SIZE;
+ float t = i * 1.0 / OSCIL_SIZE;
switch(Pbasefuncmodulation) {
case 1:
@@ -253,17 +253,17 @@ void OscilGen::oscilfilter()
if(Pfiltertype == 0)
return;
- const REALTYPE par = 1.0 - Pfilterpar1 / 128.0;
- const REALTYPE par2 = Pfilterpar2 / 127.0;
- REALTYPE max = 0.0;
+ const float par = 1.0 - Pfilterpar1 / 128.0;
+ const float par2 = Pfilterpar2 / 127.0;
+ float max = 0.0;
filter_func filter = getFilter(Pfiltertype);
for(int i = 1; i < OSCIL_SIZE / 2; i++) {
- REALTYPE gain = filter(i,par,par2);
+ float gain = filter(i,par,par2);
oscilFFTfreqs.s[i] *= gain;
oscilFFTfreqs.c[i] *= gain;
- REALTYPE magnitude = oscilFFTfreqs.s[i] * oscilFFTfreqs.s[i]
+ float magnitude = oscilFFTfreqs.s[i] * oscilFFTfreqs.s[i]
+ oscilFFTfreqs.c[i] * oscilFFTfreqs.c[i];
if(max < magnitude)
max = magnitude;
@@ -273,7 +273,7 @@ void OscilGen::oscilfilter()
max = sqrt(max);
if(max < 1e-10)
max = 1.0;
- REALTYPE imax = 1.0 / max;
+ float imax = 1.0 / max;
//Normalize signal
for(int i = 1; i < OSCIL_SIZE / 2; i++) {
@@ -324,14 +324,14 @@ void OscilGen::waveshape()
oscilFFTfreqs.c[0] = 0.0; //remove the DC
//reduce the amplitude of the freqs near the nyquist
for(i = 1; i < OSCIL_SIZE / 8; i++) {
- REALTYPE tmp = i / (OSCIL_SIZE / 8.0);
+ float tmp = i / (OSCIL_SIZE / 8.0);
oscilFFTfreqs.s[OSCIL_SIZE / 2 - i] *= tmp;
oscilFFTfreqs.c[OSCIL_SIZE / 2 - i] *= tmp;
}
fft->freqs2smps(oscilFFTfreqs, tmpsmps);
//Normalize
- REALTYPE max = 0.0;
+ float max = 0.0;
for(i = 0; i < OSCIL_SIZE; i++)
if(max < fabs(tmpsmps[i]))
max = fabs(tmpsmps[i]);
@@ -363,7 +363,7 @@ void OscilGen::modulation()
return;
- REALTYPE modulationpar1 = Pmodulationpar1 / 127.0,
+ float modulationpar1 = Pmodulationpar1 / 127.0,
modulationpar2 = 0.5 - Pmodulationpar2 / 127.0,
modulationpar3 = Pmodulationpar3 / 127.0;
@@ -387,16 +387,16 @@ void OscilGen::modulation()
oscilFFTfreqs.c[0] = 0.0; //remove the DC
//reduce the amplitude of the freqs near the nyquist
for(i = 1; i < OSCIL_SIZE / 8; i++) {
- REALTYPE tmp = i / (OSCIL_SIZE / 8.0);
+ float tmp = i / (OSCIL_SIZE / 8.0);
oscilFFTfreqs.s[OSCIL_SIZE / 2 - i] *= tmp;
oscilFFTfreqs.c[OSCIL_SIZE / 2 - i] *= tmp;
}
fft->freqs2smps(oscilFFTfreqs, tmpsmps);
int extra_points = 2;
- REALTYPE *in = new REALTYPE[OSCIL_SIZE + extra_points];
+ float *in = new float[OSCIL_SIZE + extra_points];
//Normalize
- REALTYPE max = 0.0;
+ float max = 0.0;
for(i = 0; i < OSCIL_SIZE; i++)
if(max < fabs(tmpsmps[i]))
max = fabs(tmpsmps[i]);
@@ -410,7 +410,7 @@ void OscilGen::modulation()
//Do the modulation
for(i = 0; i < OSCIL_SIZE; i++) {
- REALTYPE t = i * 1.0 / OSCIL_SIZE;
+ float t = i * 1.0 / OSCIL_SIZE;
switch(Pmodulation) {
case 1:
@@ -432,7 +432,7 @@ void OscilGen::modulation()
t = (t - floor(t)) * OSCIL_SIZE;
int poshi = (int) t;
- REALTYPE poslo = t - floor(t);
+ float poslo = t - floor(t);
tmpsmps[i] = in[poshi] * (1.0 - poslo) + in[poshi + 1] * poslo;
}
@@ -450,7 +450,7 @@ void OscilGen::spectrumadjust()
{
if(Psatype == 0)
return;
- REALTYPE par = Psapar / 127.0;
+ float par = Psapar / 127.0;
switch(Psatype) {
case 1:
par = 1.0 - par * 2.0;
@@ -468,9 +468,9 @@ void OscilGen::spectrumadjust()
}
- REALTYPE max = 0.0;
+ float max = 0.0;
for(int i = 0; i < OSCIL_SIZE / 2; i++) {
- REALTYPE tmp = pow(oscilFFTfreqs.c[i], 2) + pow(oscilFFTfreqs.s[i], 2.0);
+ float tmp = pow(oscilFFTfreqs.c[i], 2) + pow(oscilFFTfreqs.s[i], 2.0);
if(max < tmp)
max = tmp;
}
@@ -480,10 +480,10 @@ void OscilGen::spectrumadjust()
for(int i = 0; i < OSCIL_SIZE / 2; i++) {
- REALTYPE mag =
+ float mag =
sqrt(pow(oscilFFTfreqs.s[i],
2) + pow(oscilFFTfreqs.c[i], 2.0)) / max;
- REALTYPE phase = atan2(oscilFFTfreqs.s[i], oscilFFTfreqs.c[i]);
+ float phase = atan2(oscilFFTfreqs.s[i], oscilFFTfreqs.c[i]);
switch(Psatype) {
case 1:
@@ -509,7 +509,7 @@ void OscilGen::shiftharmonics()
if(Pharmonicshift == 0)
return;
- REALTYPE hc, hs;
+ float hc, hs;
int harmonicshift = -Pharmonicshift;
if(harmonicshift > 0) {
@@ -557,7 +557,7 @@ void OscilGen::shiftharmonics()
void OscilGen::prepare()
{
int i, j, k;
- REALTYPE a, b, c, d, hmagnew;
+ float a, b, c, d, hmagnew;
if((oldbasepar != Pbasefuncpar) || (oldbasefunc != Pcurrentbasefunc)
|| (oldbasefuncmodulation != Pbasefuncmodulation)
@@ -652,7 +652,7 @@ void OscilGen::prepare()
oscilprepared = 1;
}
-void OscilGen::adaptiveharmonic(FFTFREQS f, REALTYPE freq)
+void OscilGen::adaptiveharmonic(FFTFREQS f, float freq)
{
if(Padaptiveharmonics == 0 /*||(freq<1.0)*/)
return;
@@ -670,11 +670,11 @@ void OscilGen::adaptiveharmonic(FFTFREQS f, REALTYPE freq)
inf.c[0] = 0.0;
inf.s[0] = 0.0;
- REALTYPE hc = 0.0, hs = 0.0;
- REALTYPE basefreq = 30.0 * pow(10.0, Padaptiveharmonicsbasefreq / 128.0);
- REALTYPE power = (Padaptiveharmonicspower + 1.0) / 101.0;
+ float hc = 0.0, hs = 0.0;
+ float basefreq = 30.0 * pow(10.0, Padaptiveharmonicsbasefreq / 128.0);
+ float power = (Padaptiveharmonicspower + 1.0) / 101.0;
- REALTYPE rap = freq / basefreq;
+ float rap = freq / basefreq;
rap = pow(rap, power);
@@ -685,9 +685,9 @@ void OscilGen::adaptiveharmonic(FFTFREQS f, REALTYPE freq)
}
for(int i = 0; i < OSCIL_SIZE / 2 - 2; i++) {
- REALTYPE h = i * rap;
+ float h = i * rap;
int high = (int)(i * rap);
- REALTYPE low = fmod(h, 1.0);
+ float low = fmod(h, 1.0);
if(high >= (OSCIL_SIZE / 2 - 2))
break;
@@ -725,12 +725,12 @@ void OscilGen::adaptiveharmonic(FFTFREQS f, REALTYPE freq)
deleteFFTFREQS(&inf);
}
-void OscilGen::adaptiveharmonicpostprocess(REALTYPE *f, int size)
+void OscilGen::adaptiveharmonicpostprocess(float *f, int size)
{
if(Padaptiveharmonics <= 1)
return;
- REALTYPE *inf = new REALTYPE[size];
- REALTYPE par = Padaptiveharmonicspar * 0.01;
+ float *inf = new float[size];
+ float par = Padaptiveharmonicspar * 0.01;
par = 1.0 - pow((1.0 - par), 1.5);
for(int i = 0; i < size; i++) {
@@ -772,7 +772,7 @@ void OscilGen::newrandseed(unsigned int randseed)
/*
* Get the oscillator function
*/
-short int OscilGen::get(REALTYPE *smps, REALTYPE freqHz, int resonance)
+short int OscilGen::get(float *smps, float freqHz, int resonance)
{
int i;
int nyquist, outpos;
@@ -812,7 +812,7 @@ short int OscilGen::get(REALTYPE *smps, REALTYPE freqHz, int resonance)
prepare();
outpos =
- (int)((RND * 2.0 - 1.0) * (REALTYPE) OSCIL_SIZE * (Prand - 64.0) / 64.0);
+ (int)((RND * 2.0 - 1.0) * (float) OSCIL_SIZE * (Prand - 64.0) / 64.0);
outpos = (outpos + 2 * OSCIL_SIZE) % OSCIL_SIZE;
@@ -852,7 +852,7 @@ short int OscilGen::get(REALTYPE *smps, REALTYPE freqHz, int resonance)
// Randomness (each harmonic), the block type is computed
// in ADnote by setting start position according to this setting
if((Prand > 64) && (freqHz >= 0.0) && (!ADvsPAD)) {
- REALTYPE rnd, angle, a, b, c, d;
+ float rnd, angle, a, b, c, d;
rnd = PI * pow((Prand - 64.0) / 64.0, 2.0);
for(i = 1; i < nyquist - 1; i++) { //to Nyquist only for AntiAliasing
angle = rnd * i * RND;
@@ -869,14 +869,14 @@ short int OscilGen::get(REALTYPE *smps, REALTYPE freqHz, int resonance)
if((freqHz > 0.1) && (!ADvsPAD)) {
unsigned int realrnd = rand();
srand(randseed);
- REALTYPE power = Pamprandpower / 127.0;
- REALTYPE normalize = 1.0 / (1.2 - power);
+ float power = Pamprandpower / 127.0;
+ float normalize = 1.0 / (1.2 - power);
switch(Pamprandtype) {
case 1:
power = power * 2.0 - 0.5;
power = pow(15.0, power);
for(i = 1; i < nyquist - 1; i++) {
- REALTYPE amp = pow(RND, power) * normalize;
+ float amp = pow(RND, power) * normalize;
outoscilFFTfreqs.c[i] *= amp;
outoscilFFTfreqs.s[i] *= amp;
}
@@ -884,9 +884,9 @@ short int OscilGen::get(REALTYPE *smps, REALTYPE freqHz, int resonance)
case 2:
power = power * 2.0 - 0.5;
power = pow(15.0, power) * 2.0;
- REALTYPE rndfreq = 2 * PI * RND;
+ float rndfreq = 2 * PI * RND;
for(i = 1; i < nyquist - 1; i++) {
- REALTYPE amp = pow(fabs(sin(i * rndfreq)), power) * normalize;
+ float amp = pow(fabs(sin(i * rndfreq)), power) * normalize;
outoscilFFTfreqs.c[i] *= amp;
outoscilFFTfreqs.s[i] *= amp;
}
@@ -899,9 +899,9 @@ short int OscilGen::get(REALTYPE *smps, REALTYPE freqHz, int resonance)
res->applyres(nyquist - 1, outoscilFFTfreqs, freqHz);
//Full RMS normalize
- REALTYPE sum = 0;
+ float sum = 0;
for(int j = 1; j < OSCIL_SIZE / 2; j++) {
- REALTYPE term = outoscilFFTfreqs.c[j] * outoscilFFTfreqs.c[j]
+ float term = outoscilFFTfreqs.c[j] * outoscilFFTfreqs.c[j]
+ outoscilFFTfreqs.s[j] * outoscilFFTfreqs.s[j];
sum += term;
}
@@ -934,7 +934,7 @@ short int OscilGen::get(REALTYPE *smps, REALTYPE freqHz, int resonance)
/*
* Get the spectrum of the oscillator for the UI
*/
-void OscilGen::getspectrum(int n, REALTYPE *spc, int what)
+void OscilGen::getspectrum(int n, float *spc, int what)
{
if(n > OSCIL_SIZE / 2)
n = OSCIL_SIZE / 2;
@@ -987,7 +987,7 @@ void OscilGen::useasbase()
/*
* Get the base function for UI
*/
-void OscilGen::getcurrentbasefunction(REALTYPE *smps)
+void OscilGen::getcurrentbasefunction(float *smps)
{
if(Pcurrentbasefunc != 0)
fft->freqs2smps(basefuncFFTfreqs, smps);
@@ -1046,7 +1046,7 @@ void OscilGen::add2XML(XMLwrapper *xml)
xml->endbranch();
if(Pcurrentbasefunc == 127) {
- REALTYPE max = 0.0;
+ float max = 0.0;
for(int i = 0; i < OSCIL_SIZE / 2; i++) {
if(max < fabs(basefuncFFTfreqs.c[i]))
@@ -1059,8 +1059,8 @@ void OscilGen::add2XML(XMLwrapper *xml)
xml->beginbranch("BASE_FUNCTION");
for(int i = 1; i < OSCIL_SIZE / 2; i++) {
- REALTYPE xc = basefuncFFTfreqs.c[i] / max;
- REALTYPE xs = basefuncFFTfreqs.s[i] / max;
+ float xc = basefuncFFTfreqs.c[i] / max;
+ float xs = basefuncFFTfreqs.s[i] / max;
if((fabs(xs) > 0.00001) && (fabs(xs) > 0.00001)) {
xml->beginbranch("BF_HARMONIC", i);
xml->addparreal("cos", xc);
@@ -1163,7 +1163,7 @@ void OscilGen::getfromXML(XMLwrapper *xml)
}
xml->exitbranch();
- REALTYPE max = 0.0;
+ float max = 0.0;
basefuncFFTfreqs.c[0] = 0.0;
for(int i = 0; i < OSCIL_SIZE / 2; i++) {
@@ -1185,7 +1185,7 @@ void OscilGen::getfromXML(XMLwrapper *xml)
}
//Define basic functions
-#define FUNC(b) REALTYPE basefunc_##b(REALTYPE x, REALTYPE a)
+#define FUNC(b) float basefunc_##b(float x, float a)
FUNC(pulse)
{
@@ -1289,7 +1289,7 @@ FUNC(stretchsine)
if(a > 0.0)
a *= 2;
a = pow(3.0, a);
- REALTYPE b = pow(fabs(x), a);
+ float b = pow(fabs(x), a);
if(x < 0)
b = -b;
return -sin(b * PI);
@@ -1310,7 +1310,7 @@ FUNC(absstretchsine)
x = fmod(x + 0.5, 1) * 2.0 - 1.0;
a = (a - 0.5) * 9;
a = pow(3.0, a);
- REALTYPE b = pow(fabs(x), a);
+ float b = pow(fabs(x), a);
if(x < 0)
b = -b;
return -pow(sin(b * PI), 2);
@@ -1328,7 +1328,7 @@ FUNC(sqr)
return -atan(sin(x * 2.0 * PI) * a);
}
-typedef REALTYPE(*base_func)(REALTYPE,REALTYPE);
+typedef float(*base_func)(float,float);
base_func getBaseFunction(unsigned char func)
{
if(!func)
@@ -1358,11 +1358,11 @@ base_func getBaseFunction(unsigned char func)
//And filters
-#define FILTER(x) REALTYPE osc_##x(unsigned int i, REALTYPE par, REALTYPE par2)
+#define FILTER(x) float osc_##x(unsigned int i, float par, float par2)
FILTER(lp)
{
- REALTYPE gain = pow(1.0 - par * par * par * 0.99, i);
- REALTYPE tmp = par2 * par2 * par2 * par2 * 0.5 + 0.0001;
+ float gain = pow(1.0 - par * par * par * 0.99, i);
+ float tmp = par2 * par2 * par2 * par2 * 0.5 + 0.0001;
if(gain < tmp)
gain = pow(gain, 10.0) / pow(tmp, 9.0);
return gain;
@@ -1370,7 +1370,7 @@ FILTER(lp)
FILTER(hp1)
{
- REALTYPE gain = 1.0 - pow(1.0 - par * par, i + 1);
+ float gain = 1.0 - pow(1.0 - par * par, i + 1);
return pow(gain, par2 * 2.0 + 0.1);
}
@@ -1378,16 +1378,16 @@ FILTER(hp1b)
{
if(par < 0.2)
par = par * 0.25 + 0.15;
- REALTYPE gain = 1.0 - pow(1.0 - par * par * 0.999 + 0.001, i * 0.05 * i + 1.0);
- REALTYPE tmp = pow(5.0, par2 * 2.0);
+ float gain = 1.0 - pow(1.0 - par * par * 0.999 + 0.001, i * 0.05 * i + 1.0);
+ float tmp = pow(5.0, par2 * 2.0);
return pow(gain, tmp);
}
FILTER(bp1)
{
- REALTYPE gain = i + 1 - pow(2, (1.0 - par) * 7.5);
+ float gain = i + 1 - pow(2, (1.0 - par) * 7.5);
gain = 1.0 / (1.0 + gain * gain / (i + 1.0));
- REALTYPE tmp = pow(5.0, par2 * 2.0);
+ float tmp = pow(5.0, par2 * 2.0);
gain = pow(gain, tmp);
if(gain < 1e-5)
gain = 1e-5;
@@ -1396,7 +1396,7 @@ FILTER(bp1)
FILTER(bs1)
{
- REALTYPE gain = i + 1 - pow(2, (1.0 - par) * 7.5);
+ float gain = i + 1 - pow(2, (1.0 - par) * 7.5);
gain = pow(atan(gain / (i / 10.0 + 1)) / 1.57, 6);
return pow(gain, par2 * par2 * 3.9 + 0.1);
}
@@ -1431,50 +1431,50 @@ bool floatEq(float a, float b)
FILTER(cos)
{
- REALTYPE tmp = pow(5.0, par2 * 2.0 - 1.0);
+ float tmp = pow(5.0, par2 * 2.0 - 1.0);
tmp = pow(i / 32.0, tmp) * 32.0;
if(floatEq(par2 * 127.0, 64.0))
tmp = i;
- REALTYPE gain = cos(par * par * PI / 2.0 * tmp);
+ float gain = cos(par * par * PI / 2.0 * tmp);
gain *= gain;
return gain;
}
FILTER(sin)
{
- REALTYPE tmp = pow(5.0, par2 * 2.0 - 1.0);
+ float tmp = pow(5.0, par2 * 2.0 - 1.0);
tmp = pow(i / 32.0, tmp) * 32.0;
if(floatEq(par2 * 127.0, 64.0))
tmp = i;
- REALTYPE gain = sin(par * par * PI / 2.0 * tmp);
+ float gain = sin(par * par * PI / 2.0 * tmp);
gain *= gain;
return gain;
}
FILTER(low_shelf)
{
- REALTYPE p2 = 1.0 - par + 0.2;
- REALTYPE x = i / (64.0 * p2 * p2);
+ float p2 = 1.0 - par + 0.2;
+ float x = i / (64.0 * p2 * p2);
if(x < 0.0)
x = 0.0;
else
if(x > 1.0)
x = 1.0;
- REALTYPE tmp = pow(1.0 - par2, 2.0);
+ float tmp = pow(1.0 - par2, 2.0);
return cos(x * PI) * (1.0 - tmp) + 1.01 + tmp;
}
FILTER(s)
{
unsigned int tmp = (int) (pow(2.0, (1.0 - par) * 7.2));
- REALTYPE gain = 1.0;
+ float gain = 1.0;
if(i == tmp)
gain = pow(2.0, par2 * par2 * 8.0);
return gain;
}
#undef FILTER
-typedef REALTYPE(*filter_func)(unsigned int, REALTYPE, REALTYPE);
+typedef float(*filter_func)(unsigned int, float, float);
filter_func getFilter(unsigned char func)
{
if(!func)
diff --git a/src/Synth/OscilGen.h b/src/Synth/OscilGen.h
@@ -40,14 +40,14 @@ class OscilGen:public Presets
/**do the antialiasing(cut off higher freqs.),apply randomness and do a IFFT*/
//returns where should I start getting samples, used in block type randomness
- short get(REALTYPE *smps, REALTYPE freqHz, int resonance=0);
+ short get(float *smps, float freqHz, int resonance=0);
//if freqHz is smaller than 0, return the "un-randomized" sample for UI
- void getbasefunction(REALTYPE *smps);
+ void getbasefunction(float *smps);
//called by UI
- void getspectrum(int n, REALTYPE *spc, int what); //what=0 pt. oscil,1 pt. basefunc
- void getcurrentbasefunction(REALTYPE *smps);
+ void getspectrum(int n, float *spc, int what); //what=0 pt. oscil,1 pt. basefunc
+ void getcurrentbasefunction(float *smps);
/**convert oscil to base function*/
void useasbase();
@@ -112,10 +112,10 @@ class OscilGen:public Presets
private:
//This array stores some termporary data and it has OSCIL_SIZE elements
- REALTYPE *tmpsmps;
+ float *tmpsmps;
FFTFREQS outoscilFFTfreqs;
- REALTYPE hmag[MAX_AD_HARMONICS], hphase[MAX_AD_HARMONICS]; //the magnituides and the phases of the sine/nonsine harmonics
+ float hmag[MAX_AD_HARMONICS], hphase[MAX_AD_HARMONICS]; //the magnituides and the phases of the sine/nonsine harmonics
// private:
FFTwrapper *fft;
//computes the basefunction and make the FFT; newbasefunc<0 = same basefunc
@@ -136,13 +136,13 @@ class OscilGen:public Presets
void modulation();
//Do the adaptive harmonic stuff
- void adaptiveharmonic(FFTFREQS f, REALTYPE freq);
+ void adaptiveharmonic(FFTFREQS f, float freq);
//Do the adaptive harmonic postprocessing (2n+1,2xS,2xA,etc..)
//this function is called even for the user interface
//this can be called for the sine and components, and for the spectrum
//(that's why the sine and cosine components should be processed with a separate call)
- void adaptiveharmonicpostprocess(REALTYPE *f, int size);
+ void adaptiveharmonicpostprocess(float *f, int size);
//Internal Data
unsigned char oldbasefunc, oldbasepar, oldhmagtype,
@@ -163,9 +163,9 @@ class OscilGen:public Presets
unsigned int randseed;
};
-typedef REALTYPE(*filter_func)(unsigned int, REALTYPE, REALTYPE);
+typedef float(*filter_func)(unsigned int, float, float);
filter_func getFilter(unsigned char func);
-typedef REALTYPE(*base_func)(REALTYPE,REALTYPE);
+typedef float(*base_func)(float,float);
base_func getBaseFunction(unsigned char func);
diff --git a/src/Synth/PADnote.cpp b/src/Synth/PADnote.cpp
@@ -24,8 +24,8 @@
PADnote::PADnote(PADnoteParameters *parameters,
Controller *ctl_,
- REALTYPE freq,
- REALTYPE velocity,
+ float freq,
+ float velocity,
int portamento_,
int midinote,
bool besilent)
@@ -39,7 +39,7 @@ PADnote::PADnote(PADnoteParameters *parameters,
}
-void PADnote::setup(REALTYPE freq, REALTYPE velocity,int portamento_, int midinote, bool legato)
+void PADnote::setup(float freq, float velocity,int portamento_, int midinote, bool legato)
{
portamento = portamento_;
this->velocity = velocity;
@@ -52,7 +52,7 @@ void PADnote::setup(REALTYPE freq, REALTYPE velocity,int portamento_, int midino
basefreq = 440.0;
int fixedfreqET = pars->PfixedfreqET;
if(fixedfreqET != 0) { //if the frequency varies according the keyboard note
- REALTYPE tmp =
+ float tmp =
(midinote
- 69.0) / 12.0 * (pow(2.0, (fixedfreqET - 1) / 63.0) - 1.0);
if(fixedfreqET <= 64)
@@ -71,13 +71,13 @@ void PADnote::setup(REALTYPE freq, REALTYPE velocity,int portamento_, int midino
//find out the closest note
- REALTYPE logfreq = log(basefreq * pow(2.0, NoteGlobalPar.Detune / 1200.0));
- REALTYPE mindist = fabs(logfreq - log(pars->sample[0].basefreq + 0.0001));
+ float logfreq = log(basefreq * pow(2.0, NoteGlobalPar.Detune / 1200.0));
+ float mindist = fabs(logfreq - log(pars->sample[0].basefreq + 0.0001));
nsample = 0;
for(int i = 1; i < PAD_MAX_SAMPLES; i++) {
if(pars->sample[i].smp == NULL)
break;
- REALTYPE dist = fabs(logfreq - log(pars->sample[i].basefreq + 0.0001));
+ float dist = fabs(logfreq - log(pars->sample[i].basefreq + 0.0001));
if(dist < mindist) {
nsample = i;
@@ -120,8 +120,8 @@ void PADnote::setup(REALTYPE freq, REALTYPE velocity,int portamento_, int midino
((pow(10, 1.5 * pars->PPunchStrength / 127.0) - 1.0)
* VelF(velocity,
pars->PPunchVelocitySensing));
- REALTYPE time = pow(10, 3.0 * pars->PPunchTime / 127.0) / 10000.0; //0.1 .. 100 ms
- REALTYPE stretch = pow(440.0 / freq, pars->PPunchStretch / 64.0);
+ float time = pow(10, 3.0 * pars->PPunchTime / 127.0) / 10000.0; //0.1 .. 100 ms
+ float stretch = pow(440.0 / freq, pars->PPunchStretch / 64.0);
NoteGlobalPar.Punch.dt = 1.0 / (time * SAMPLE_RATE * stretch);
}
else
@@ -161,8 +161,8 @@ void PADnote::setup(REALTYPE freq, REALTYPE velocity,int portamento_, int midino
}
}
-void PADnote::legatonote(REALTYPE freq,
- REALTYPE velocity,
+void PADnote::legatonote(float freq,
+ float velocity,
int portamento_,
int midinote,
bool externcall)
@@ -188,14 +188,14 @@ PADnote::~PADnote()
}
-inline void PADnote::fadein(REALTYPE *smps)
+inline void PADnote::fadein(float *smps)
{
int zerocrossings = 0;
for(int i = 1; i < SOUND_BUFFER_SIZE; i++)
if((smps[i - 1] < 0.0) && (smps[i] > 0.0))
zerocrossings++; //this is only the possitive crossings
- REALTYPE tmp = (SOUND_BUFFER_SIZE - 1.0) / (zerocrossings + 1) / 3.0;
+ float tmp = (SOUND_BUFFER_SIZE - 1.0) / (zerocrossings + 1) / 3.0;
if(tmp < 8.0)
tmp = 8.0;
@@ -204,7 +204,7 @@ inline void PADnote::fadein(REALTYPE *smps)
if(n > SOUND_BUFFER_SIZE)
n = SOUND_BUFFER_SIZE;
for(int i = 0; i < n; i++) { //fade-in
- REALTYPE tmp = 0.5 - cos((REALTYPE)i / (REALTYPE) n * PI) * 0.5;
+ float tmp = 0.5 - cos((float)i / (float) n * PI) * 0.5;
smps[i] *= tmp;
}
}
@@ -212,7 +212,7 @@ inline void PADnote::fadein(REALTYPE *smps)
void PADnote::computecurrentparameters()
{
- REALTYPE globalpitch, globalfilterpitch;
+ float globalpitch, globalfilterpitch;
globalpitch = 0.01 * (NoteGlobalPar.FreqEnvelope->envout()
+ NoteGlobalPar.FreqLfo->lfoout()
* ctl->modwheel.relmod + NoteGlobalPar.Detune);
@@ -225,17 +225,17 @@ void PADnote::computecurrentparameters()
+ NoteGlobalPar.FilterLfo->lfoout()
+ NoteGlobalPar.FilterCenterPitch;
- REALTYPE tmpfilterfreq = globalfilterpitch + ctl->filtercutoff.relfreq
+ float tmpfilterfreq = globalfilterpitch + ctl->filtercutoff.relfreq
+ NoteGlobalPar.FilterFreqTracking;
tmpfilterfreq = NoteGlobalPar.GlobalFilterL->getrealfreq(tmpfilterfreq);
- REALTYPE globalfilterq = NoteGlobalPar.FilterQ * ctl->filterq.relq;
+ float globalfilterq = NoteGlobalPar.FilterQ * ctl->filterq.relq;
NoteGlobalPar.GlobalFilterL->setfreq_and_q(tmpfilterfreq, globalfilterq);
NoteGlobalPar.GlobalFilterR->setfreq_and_q(tmpfilterfreq, globalfilterq);
//compute the portamento, if it is used by this note
- REALTYPE portamentofreqrap = 1.0;
+ float portamentofreqrap = 1.0;
if(portamento != 0) { //this voice use portamento
portamentofreqrap = ctl->portamento.freqrap;
if(ctl->portamento.used == 0) //the portamento has finished
@@ -248,12 +248,12 @@ void PADnote::computecurrentparameters()
}
-int PADnote::Compute_Linear(REALTYPE *outl,
- REALTYPE *outr,
+int PADnote::Compute_Linear(float *outl,
+ float *outr,
int freqhi,
- REALTYPE freqlo)
+ float freqlo)
{
- REALTYPE *smps = pars->sample[nsample].smp;
+ float *smps = pars->sample[nsample].smp;
if(smps == NULL) {
finished_ = true;
return 1;
@@ -278,18 +278,18 @@ int PADnote::Compute_Linear(REALTYPE *outl,
}
return 1;
}
-int PADnote::Compute_Cubic(REALTYPE *outl,
- REALTYPE *outr,
+int PADnote::Compute_Cubic(float *outl,
+ float *outr,
int freqhi,
- REALTYPE freqlo)
+ float freqlo)
{
- REALTYPE *smps = pars->sample[nsample].smp;
+ float *smps = pars->sample[nsample].smp;
if(smps == NULL) {
finished_ = true;
return 1;
}
int size = pars->sample[nsample].size;
- REALTYPE xm1, x0, x1, x2, a, b, c;
+ float xm1, x0, x1, x2, a, b, c;
for(int i = 0; i < SOUND_BUFFER_SIZE; i++) {
poshi_l += freqhi;
poshi_r += freqhi;
@@ -328,10 +328,10 @@ int PADnote::Compute_Cubic(REALTYPE *outl,
}
-int PADnote::noteout(REALTYPE *outl, REALTYPE *outr)
+int PADnote::noteout(float *outl, float *outr)
{
computecurrentparameters();
- REALTYPE *smps = pars->sample[nsample].smp;
+ float *smps = pars->sample[nsample].smp;
if(smps == NULL) {
for(int i = 0; i < SOUND_BUFFER_SIZE; i++) {
outl[i] = 0.0;
@@ -339,12 +339,12 @@ int PADnote::noteout(REALTYPE *outl, REALTYPE *outr)
}
return 1;
}
- REALTYPE smpfreq = pars->sample[nsample].basefreq;
+ float smpfreq = pars->sample[nsample].basefreq;
- REALTYPE freqrap = realfreq / smpfreq;
+ float freqrap = realfreq / smpfreq;
int freqhi = (int) (floor(freqrap));
- REALTYPE freqlo = freqrap - floor(freqrap);
+ float freqlo = freqrap - floor(freqrap);
if(config.cfg.Interpolation)
@@ -365,7 +365,7 @@ int PADnote::noteout(REALTYPE *outl, REALTYPE *outr)
//Apply the punch
if(NoteGlobalPar.Punch.Enabled != 0) {
for(int i = 0; i < SOUND_BUFFER_SIZE; i++) {
- REALTYPE punchamp = NoteGlobalPar.Punch.initialvalue
+ float punchamp = NoteGlobalPar.Punch.initialvalue
* NoteGlobalPar.Punch.t + 1.0;
outl[i] *= punchamp;
outr[i] *= punchamp;
@@ -380,7 +380,7 @@ int PADnote::noteout(REALTYPE *outl, REALTYPE *outr)
if(ABOVE_AMPLITUDE_THRESHOLD(globaloldamplitude, globalnewamplitude)) {
// Amplitude Interpolation
for(int i = 0; i < SOUND_BUFFER_SIZE; i++) {
- REALTYPE tmpvol = INTERPOLATE_AMPLITUDE(globaloldamplitude,
+ float tmpvol = INTERPOLATE_AMPLITUDE(globaloldamplitude,
globalnewamplitude,
i,
SOUND_BUFFER_SIZE);
@@ -403,7 +403,7 @@ int PADnote::noteout(REALTYPE *outl, REALTYPE *outr)
// If it does, disable the note
if(NoteGlobalPar.AmpEnvelope->finished() != 0) {
for(int i = 0; i < SOUND_BUFFER_SIZE; i++) { //fade-out
- REALTYPE tmp = 1.0 - (REALTYPE)i / (REALTYPE)SOUND_BUFFER_SIZE;
+ float tmp = 1.0 - (float)i / (float)SOUND_BUFFER_SIZE;
outl[i] *= tmp;
outr[i] *= tmp;
}
diff --git a/src/Synth/PADnote.h b/src/Synth/PADnote.h
@@ -36,50 +36,50 @@ class PADnote :public SynthNote
public:
PADnote(PADnoteParameters *parameters,
Controller *ctl_,
- REALTYPE freq,
- REALTYPE velocity,
+ float freq,
+ float velocity,
int portamento_,
int midinote,
bool besilent);
~PADnote();
- void legatonote(REALTYPE freq, REALTYPE velocity, int portamento_,
+ void legatonote(float freq, float velocity, int portamento_,
int midinote, bool externcall);
- int noteout(REALTYPE *outl, REALTYPE *outr);
+ int noteout(float *outl, float *outr);
int finished() const;
void relasekey();
private:
- void setup(REALTYPE freq, REALTYPE velocity,int portamento_,
+ void setup(float freq, float velocity,int portamento_,
int midinote, bool legato=false);
- void fadein(REALTYPE *smps);
+ void fadein(float *smps);
void computecurrentparameters();
bool finished_;
PADnoteParameters *pars;
int poshi_l, poshi_r;
- REALTYPE poslo;
+ float poslo;
- REALTYPE basefreq;
+ float basefreq;
bool firsttime, released;
int nsample, portamento;
- int Compute_Linear(REALTYPE *outl,
- REALTYPE *outr,
+ int Compute_Linear(float *outl,
+ float *outr,
int freqhi,
- REALTYPE freqlo);
- int Compute_Cubic(REALTYPE *outl,
- REALTYPE *outr,
+ float freqlo);
+ int Compute_Cubic(float *outl,
+ float *outr,
int freqhi,
- REALTYPE freqlo);
+ float freqlo);
struct {
/******************************************
* FREQUENCY GLOBAL PARAMETERS *
******************************************/
- REALTYPE Detune; //cents
+ float Detune; //cents
Envelope *FreqEnvelope;
LFO *FreqLfo;
@@ -87,16 +87,16 @@ class PADnote :public SynthNote
/********************************************
* AMPLITUDE GLOBAL PARAMETERS *
********************************************/
- REALTYPE Volume; // [ 0 .. 1 ]
+ float Volume; // [ 0 .. 1 ]
- REALTYPE Panning; // [ 0 .. 1 ]
+ float Panning; // [ 0 .. 1 ]
Envelope *AmpEnvelope;
LFO *AmpLfo;
struct {
int Enabled;
- REALTYPE initialvalue, dt, t;
+ float initialvalue, dt, t;
} Punch;
/******************************************
@@ -104,9 +104,9 @@ class PADnote :public SynthNote
******************************************/
Filter *GlobalFilterL, *GlobalFilterR;
- REALTYPE FilterCenterPitch; //octaves
- REALTYPE FilterQ;
- REALTYPE FilterFreqTracking;
+ float FilterCenterPitch; //octaves
+ float FilterQ;
+ float FilterFreqTracking;
Envelope *FilterEnvelope;
@@ -114,7 +114,7 @@ class PADnote :public SynthNote
} NoteGlobalPar;
- REALTYPE globaloldamplitude, globalnewamplitude, velocity, realfreq;
+ float globaloldamplitude, globalnewamplitude, velocity, realfreq;
Controller *ctl;
};
diff --git a/src/Synth/Resonance.cpp b/src/Synth/Resonance.cpp
@@ -62,11 +62,11 @@ void Resonance::setpoint(int n, unsigned char p)
/*
* Apply the resonance to FFT data
*/
-void Resonance::applyres(int n, FFTFREQS fftdata, REALTYPE freq)
+void Resonance::applyres(int n, FFTFREQS fftdata, float freq)
{
if(Penabled == 0)
return; //if the resonance is disabled
- REALTYPE sum = 0.0,
+ float sum = 0.0,
l1 = log(getfreqx(0.0) * ctlcenter),
l2 = log(2.0) * getoctavesfreq() * ctlbw;
@@ -77,12 +77,12 @@ void Resonance::applyres(int n, FFTFREQS fftdata, REALTYPE freq)
sum = 1.0;
for(int i = 1; i < n; i++) {
- REALTYPE x = (log(freq * i) - l1) / l2; //compute where the n-th hamonics fits to the graph
+ float x = (log(freq * i) - l1) / l2; //compute where the n-th hamonics fits to the graph
if(x < 0.0)
x = 0.0;
x *= N_RES_POINTS;
- REALTYPE dx = x - floor(x);
+ float dx = x - floor(x);
x = floor(x);
int kx1 = (int)x;
if(kx1 >= N_RES_POINTS)
@@ -90,7 +90,7 @@ void Resonance::applyres(int n, FFTFREQS fftdata, REALTYPE freq)
int kx2 = kx1 + 1;
if(kx2 >= N_RES_POINTS)
kx2 = N_RES_POINTS - 1;
- REALTYPE y =
+ float y =
(Prespoints[kx1]
* (1.0 - dx) + Prespoints[kx2] * dx) / 127.0 - sum / 127.0;
@@ -108,9 +108,9 @@ void Resonance::applyres(int n, FFTFREQS fftdata, REALTYPE freq)
* Gets the response at the frequency "freq"
*/
-REALTYPE Resonance::getfreqresponse(REALTYPE freq)
+float Resonance::getfreqresponse(float freq)
{
- REALTYPE l1 = log(getfreqx(0.0) * ctlcenter),
+ float l1 = log(getfreqx(0.0) * ctlcenter),
l2 = log(2.0) * getoctavesfreq() * ctlbw, sum = 0.0;
for(int i = 0; i < N_RES_POINTS; i++)
@@ -119,11 +119,11 @@ REALTYPE Resonance::getfreqresponse(REALTYPE freq)
if(sum < 1.0)
sum = 1.0;
- REALTYPE x = (log(freq) - l1) / l2; //compute where the n-th hamonics fits to the graph
+ float x = (log(freq) - l1) / l2; //compute where the n-th hamonics fits to the graph
if(x < 0.0)
x = 0.0;
x *= N_RES_POINTS;
- REALTYPE dx = x - floor(x);
+ float dx = x - floor(x);
x = floor(x);
int kx1 = (int)x;
if(kx1 >= N_RES_POINTS)
@@ -131,7 +131,7 @@ REALTYPE Resonance::getfreqresponse(REALTYPE freq)
int kx2 = kx1 + 1;
if(kx2 >= N_RES_POINTS)
kx2 = N_RES_POINTS - 1;
- REALTYPE result =
+ float result =
(Prespoints[kx1]
* (1.0 - dx) + Prespoints[kx2] * dx) / 127.0 - sum / 127.0;
result = pow(10.0, result * PmaxdB / 20.0);
@@ -144,7 +144,7 @@ REALTYPE Resonance::getfreqresponse(REALTYPE freq)
*/
void Resonance::smooth()
{
- REALTYPE old = Prespoints[0];
+ float old = Prespoints[0];
for(int i = 0; i < N_RES_POINTS; i++) {
old = old * 0.4 + Prespoints[i] * 0.6;
Prespoints[i] = (int) old;
@@ -200,18 +200,18 @@ void Resonance::interpolatepeaks(int type)
/*
* Get the frequency from x, where x is [0..1]; x is the x coordinate
*/
-REALTYPE Resonance::getfreqx(REALTYPE x)
+float Resonance::getfreqx(float x)
{
if(x > 1.0)
x = 1.0;
- REALTYPE octf = pow(2.0, getoctavesfreq());
+ float octf = pow(2.0, getoctavesfreq());
return getcenterfreq() / sqrt(octf) * pow(octf, x);
}
/*
* Get the x coordinate from frequency (used by the UI)
*/
-REALTYPE Resonance::getfreqpos(REALTYPE freq)
+float Resonance::getfreqpos(float freq)
{
return (log(freq) - log(getfreqx(0.0))) / log(2.0) / getoctavesfreq();
}
@@ -219,7 +219,7 @@ REALTYPE Resonance::getfreqpos(REALTYPE freq)
/*
* Get the center frequency of the resonance graph
*/
-REALTYPE Resonance::getcenterfreq()
+float Resonance::getcenterfreq()
{
return 10000.0 * pow(10, -(1.0 - Pcenterfreq / 127.0) * 2.0);
}
@@ -227,12 +227,12 @@ REALTYPE Resonance::getcenterfreq()
/*
* Get the number of octave that the resonance functions applies to
*/
-REALTYPE Resonance::getoctavesfreq()
+float Resonance::getoctavesfreq()
{
return 0.25 + 10.0 * Poctavesfreq / 127.0;
}
-void Resonance::sendcontroller(MidiControllers ctl, REALTYPE par)
+void Resonance::sendcontroller(MidiControllers ctl, float par)
{
if(ctl == C_resonance_center)
ctlcenter = par;
diff --git a/src/Synth/Resonance.h b/src/Synth/Resonance.h
@@ -35,7 +35,7 @@ class Resonance:public Presets
Resonance();
~Resonance();
void setpoint(int n, unsigned char p);
- void applyres(int n, FFTFREQS fftdata, REALTYPE freq);
+ void applyres(int n, FFTFREQS fftdata, float freq);
void smooth();
void interpolatepeaks(int type);
void randomize(int type);
@@ -45,12 +45,12 @@ class Resonance:public Presets
void getfromXML(XMLwrapper *xml);
- REALTYPE getfreqpos(REALTYPE freq);
- REALTYPE getfreqx(REALTYPE x);
- REALTYPE getfreqresponse(REALTYPE freq);
- REALTYPE getcenterfreq();
- REALTYPE getoctavesfreq();
- void sendcontroller(MidiControllers ctl, REALTYPE par);
+ float getfreqpos(float freq);
+ float getfreqx(float x);
+ float getfreqresponse(float freq);
+ float getcenterfreq();
+ float getoctavesfreq();
+ void sendcontroller(MidiControllers ctl, float par);
//parameters
unsigned char Penabled; //if the ressonance is enabled
@@ -60,8 +60,8 @@ class Resonance:public Presets
unsigned char Pprotectthefundamental; //the fundamental (1-st harmonic) is not damped, even it resonance function is low
//controllers
- REALTYPE ctlcenter; //center frequency(relative)
- REALTYPE ctlbw; //bandwidth(relative)
+ float ctlcenter; //center frequency(relative)
+ float ctlbw; //bandwidth(relative)
private:
};
diff --git a/src/Synth/SUBnote.cpp b/src/Synth/SUBnote.cpp
@@ -29,8 +29,8 @@
SUBnote::SUBnote(SUBnoteParameters *parameters,
Controller *ctl_,
- REALTYPE freq,
- REALTYPE velocity,
+ float freq,
+ float velocity,
int portamento_,
int midinote,
bool besilent)
@@ -42,7 +42,7 @@ SUBnote::SUBnote(SUBnoteParameters *parameters,
setup(freq, velocity, portamento_, midinote);
}
-void SUBnote::setup(REALTYPE freq, REALTYPE velocity, int portamento_, int midinote, bool legato)
+void SUBnote::setup(float freq, float velocity, int portamento_, int midinote, bool legato)
{
portamento = portamento_;
NoteEnabled = ON;
@@ -66,7 +66,7 @@ void SUBnote::setup(REALTYPE freq, REALTYPE velocity, int portamento_, int midin
basefreq = 440.0;
int fixedfreqET = pars->PfixedfreqET;
if(fixedfreqET != 0) { //if the frequency varies according the keyboard note
- REALTYPE tmp =
+ float tmp =
(midinote
- 69.0) / 12.0 * (pow(2.0, (fixedfreqET - 1) / 63.0) - 1.0);
if(fixedfreqET <= 64)
@@ -75,7 +75,7 @@ void SUBnote::setup(REALTYPE freq, REALTYPE velocity, int portamento_, int midin
basefreq *= pow(3.0, tmp);
}
}
- REALTYPE detune = getdetune(pars->PDetuneType,
+ float detune = getdetune(pars->PDetuneType,
pars->PCoarseDetune,
pars->PDetune);
basefreq *= pow(2.0, detune / 1200.0); //detune
@@ -126,13 +126,13 @@ void SUBnote::setup(REALTYPE freq, REALTYPE velocity, int portamento_, int midin
}
//how much the amplitude is normalised (because the harmonics)
- REALTYPE reduceamp = 0.0;
+ float reduceamp = 0.0;
for(int n = 0; n < numharmonics; n++) {
- REALTYPE freq = basefreq * (pos[n] + 1);
+ float freq = basefreq * (pos[n] + 1);
//the bandwidth is not absolute(Hz); it is relative to frequency
- REALTYPE bw =
+ float bw =
pow(10, (pars->Pbandwidth - 127.0) / 127.0 * 4) * numstages;
//Bandwidth Scale
@@ -145,10 +145,10 @@ void SUBnote::setup(REALTYPE freq, REALTYPE velocity, int portamento_, int midin
bw = 25.0;
//try to keep same amplitude on all freqs and bw. (empirically)
- REALTYPE gain = sqrt(1500.0 / (bw * freq));
+ float gain = sqrt(1500.0 / (bw * freq));
- REALTYPE hmagnew = 1.0 - pars->Phmag[pos[n]] / 127.0;
- REALTYPE hgain;
+ float hmagnew = 1.0 - pars->Phmag[pos[n]] / 127.0;
+ float hgain;
switch(pars->Phmagtype) {
case 1:
@@ -170,7 +170,7 @@ void SUBnote::setup(REALTYPE freq, REALTYPE velocity, int portamento_, int midin
reduceamp += hgain;
for(int nph = 0; nph < numstages; nph++) {
- REALTYPE amp = 1.0;
+ float amp = 1.0;
if(nph == 0)
amp = gain;
initfilter(lfilter[nph + n * numstages], freq, bw, amp, hgain);
@@ -206,7 +206,7 @@ void SUBnote::setup(REALTYPE freq, REALTYPE velocity, int portamento_, int midin
oldamplitude = newamplitude;
}
-void SUBnote::legatonote(REALTYPE freq, REALTYPE velocity, int portamento_,
+void SUBnote::legatonote(float freq, float velocity, int portamento_,
int midinote, bool externcall)
{
// Manage legato stuff
@@ -247,18 +247,18 @@ void SUBnote::KillNote()
* Compute the filters coefficients
*/
void SUBnote::computefiltercoefs(bpfilter &filter,
- REALTYPE freq,
- REALTYPE bw,
- REALTYPE gain)
+ float freq,
+ float bw,
+ float gain)
{
if(freq > SAMPLE_RATE / 2.0 - 200.0)
freq = SAMPLE_RATE / 2.0 - 200.0;
- REALTYPE omega = 2.0 * PI * freq / SAMPLE_RATE;
- REALTYPE sn = sin(omega);
- REALTYPE cs = cos(omega);
- REALTYPE alpha = sn * sinh(LOG_2 / 2.0 * bw * omega / sn);
+ float omega = 2.0 * PI * freq / SAMPLE_RATE;
+ float sn = sin(omega);
+ float cs = cos(omega);
+ float alpha = sn * sinh(LOG_2 / 2.0 * bw * omega / sn);
if(alpha > 1)
alpha = 1;
@@ -276,10 +276,10 @@ void SUBnote::computefiltercoefs(bpfilter &filter,
* Initialise the filters
*/
void SUBnote::initfilter(bpfilter &filter,
- REALTYPE freq,
- REALTYPE bw,
- REALTYPE amp,
- REALTYPE mag)
+ float freq,
+ float bw,
+ float amp,
+ float mag)
{
filter.xn1 = 0.0;
filter.xn2 = 0.0;
@@ -289,8 +289,8 @@ void SUBnote::initfilter(bpfilter &filter,
filter.yn2 = 0.0;
}
else {
- REALTYPE a = 0.1 * mag; //empirically
- REALTYPE p = RND * 2.0 * PI;
+ float a = 0.1 * mag; //empirically
+ float p = RND * 2.0 * PI;
if(start == 1)
a *= RND;
filter.yn1 = a * cos(p);
@@ -313,10 +313,10 @@ void SUBnote::initfilter(bpfilter &filter,
/*
* Do the filtering
*/
-void SUBnote::filter(bpfilter &filter, REALTYPE *smps)
+void SUBnote::filter(bpfilter &filter, float *smps)
{
int i;
- REALTYPE out;
+ float out;
for(i = 0; i < SOUND_BUFFER_SIZE; i++) {
out = smps[i] * filter.b0 + filter.b2 * filter.xn2
- filter.a1 * filter.yn1 - filter.a2 * filter.yn2;
@@ -331,7 +331,7 @@ void SUBnote::filter(bpfilter &filter, REALTYPE *smps)
/*
* Init Parameters
*/
-void SUBnote::initparameters(REALTYPE freq)
+void SUBnote::initparameters(float freq)
{
AmpEnvelope = new Envelope(pars->AmpEnvelope, freq);
if(pars->PFreqEnvelopeEnabled != 0)
@@ -364,9 +364,9 @@ void SUBnote::computecurrentparameters()
|| (oldpitchwheel != ctl->pitchwheel.data)
|| (oldbandwidth != ctl->bandwidth.data)
|| (portamento != 0)) {
- REALTYPE envfreq = 1.0;
- REALTYPE envbw = 1.0;
- REALTYPE gain = 1.0;
+ float envfreq = 1.0;
+ float envbw = 1.0;
+ float gain = 1.0;
if(FreqEnvelope != NULL) {
envfreq = FreqEnvelope->envout() / 1200;
@@ -386,7 +386,7 @@ void SUBnote::computecurrentparameters()
}
envbw *= ctl->bandwidth.relbw; //bandwidth controller
- REALTYPE tmpgain = 1.0 / sqrt(envbw * envfreq);
+ float tmpgain = 1.0 / sqrt(envbw * envfreq);
for(int n = 0; n < numharmonics; n++) {
for(int nph = 0; nph < numstages; nph++) {
@@ -423,9 +423,9 @@ void SUBnote::computecurrentparameters()
//Filter
if(GlobalFilterL != NULL) {
- REALTYPE globalfilterpitch = GlobalFilterCenterPitch
+ float globalfilterpitch = GlobalFilterCenterPitch
+ GlobalFilterEnvelope->envout();
- REALTYPE filterfreq = globalfilterpitch + ctl->filtercutoff.relfreq
+ float filterfreq = globalfilterpitch + ctl->filtercutoff.relfreq
+ GlobalFilterFreqTracking;
filterfreq = GlobalFilterL->getrealfreq(filterfreq);
@@ -442,21 +442,21 @@ void SUBnote::computecurrentparameters()
/*
* Note Output
*/
-int SUBnote::noteout(REALTYPE *outl, REALTYPE *outr)
+int SUBnote::noteout(float *outl, float *outr)
{
- memcpy(outl, denormalkillbuf, SOUND_BUFFER_SIZE * sizeof(REALTYPE));
- memcpy(outr, denormalkillbuf, SOUND_BUFFER_SIZE * sizeof(REALTYPE));
+ memcpy(outl, denormalkillbuf, SOUND_BUFFER_SIZE * sizeof(float));
+ memcpy(outr, denormalkillbuf, SOUND_BUFFER_SIZE * sizeof(float));
if(NoteEnabled == OFF)
return 0;
- REALTYPE *tmprnd = getTmpBuffer();
- REALTYPE *tmpsmp = getTmpBuffer();
+ float *tmprnd = getTmpBuffer();
+ float *tmpsmp = getTmpBuffer();
//left channel
for(int i = 0; i < SOUND_BUFFER_SIZE; i++)
tmprnd[i] = RND * 2.0 - 1.0;
for(int n = 0; n < numharmonics; n++) {
- memcpy(tmpsmp, tmprnd, SOUND_BUFFER_SIZE * sizeof(REALTYPE));
+ memcpy(tmpsmp, tmprnd, SOUND_BUFFER_SIZE * sizeof(float));
for(int nph = 0; nph < numstages; nph++)
filter(lfilter[nph + n * numstages], tmpsmp);
for(int i = 0; i < SOUND_BUFFER_SIZE; i++)
@@ -471,7 +471,7 @@ int SUBnote::noteout(REALTYPE *outl, REALTYPE *outr)
for(int i = 0; i < SOUND_BUFFER_SIZE; i++)
tmprnd[i] = RND * 2.0 - 1.0;
for(int n = 0; n < numharmonics; n++) {
- memcpy(tmpsmp, tmprnd, SOUND_BUFFER_SIZE * sizeof(REALTYPE));
+ memcpy(tmpsmp, tmprnd, SOUND_BUFFER_SIZE * sizeof(float));
for(int nph = 0; nph < numstages; nph++)
filter(rfilter[nph + n * numstages], tmpsmp);
for(int i = 0; i < SOUND_BUFFER_SIZE; i++)
@@ -481,7 +481,7 @@ int SUBnote::noteout(REALTYPE *outl, REALTYPE *outr)
GlobalFilterR->filterout(&outr[0]);
}
else
- memcpy(outr, outl, SOUND_BUFFER_SIZE * sizeof(REALTYPE));
+ memcpy(outr, outl, SOUND_BUFFER_SIZE * sizeof(float));
returnTmpBuffer(tmprnd);
returnTmpBuffer(tmpsmp);
@@ -490,8 +490,8 @@ int SUBnote::noteout(REALTYPE *outl, REALTYPE *outr)
if(n > SOUND_BUFFER_SIZE)
n = SOUND_BUFFER_SIZE;
for(int i = 0; i < n; i++) {
- REALTYPE ampfadein = 0.5 - 0.5 * cos(
- (REALTYPE) i / (REALTYPE) n * PI);
+ float ampfadein = 0.5 - 0.5 * cos(
+ (float) i / (float) n * PI);
outl[i] *= ampfadein;
outr[i] *= ampfadein;
}
@@ -501,7 +501,7 @@ int SUBnote::noteout(REALTYPE *outl, REALTYPE *outr)
if(ABOVE_AMPLITUDE_THRESHOLD(oldamplitude, newamplitude)) {
// Amplitude interpolation
for(int i = 0; i < SOUND_BUFFER_SIZE; i++) {
- REALTYPE tmpvol = INTERPOLATE_AMPLITUDE(oldamplitude,
+ float tmpvol = INTERPOLATE_AMPLITUDE(oldamplitude,
newamplitude,
i,
SOUND_BUFFER_SIZE);
@@ -525,7 +525,7 @@ int SUBnote::noteout(REALTYPE *outl, REALTYPE *outr)
// Check if the note needs to be computed more
if(AmpEnvelope->finished() != 0) {
for(int i = 0; i < SOUND_BUFFER_SIZE; i++) { //fade-out
- REALTYPE tmp = 1.0 - (REALTYPE)i / (REALTYPE)SOUND_BUFFER_SIZE;
+ float tmp = 1.0 - (float)i / (float)SOUND_BUFFER_SIZE;
outl[i] *= tmp;
outr[i] *= tmp;
}
diff --git a/src/Synth/SUBnote.h b/src/Synth/SUBnote.h
@@ -33,21 +33,21 @@
class SUBnote :public SynthNote
{
public:
- SUBnote(SUBnoteParameters *parameters, Controller *ctl_, REALTYPE freq,
- REALTYPE velocity, int portamento_, int midinote, bool besilent);
+ SUBnote(SUBnoteParameters *parameters, Controller *ctl_, float freq,
+ float velocity, int portamento_, int midinote, bool besilent);
~SUBnote();
- void legatonote(REALTYPE freq, REALTYPE velocity, int portamento_,
+ void legatonote(float freq, float velocity, int portamento_,
int midinote, bool externcall);
- int noteout(REALTYPE *outl, REALTYPE *outr); //note output,return 0 if the note is finished
+ int noteout(float *outl, float *outr); //note output,return 0 if the note is finished
void relasekey();
int finished() const;
private:
- void setup(REALTYPE freq, REALTYPE velocity, int portamento_, int midinote, bool legato=false);
+ void setup(float freq, float velocity, int portamento_, int midinote, bool legato=false);
void computecurrentparameters();
- void initparameters(REALTYPE freq);
+ void initparameters(float freq);
void KillNote();
SUBnoteParameters *pars;
@@ -58,8 +58,8 @@ class SUBnote :public SynthNote
int numharmonics; //number of harmonics (after the too higher hamonics are removed)
int firstnumharmonics; //To keep track of the first note's numharmonics value, useful in legato mode.
int start; //how the harmonics start
- REALTYPE basefreq;
- REALTYPE panning;
+ float basefreq;
+ float panning;
Envelope *AmpEnvelope;
Envelope *FreqEnvelope;
Envelope *BandWidthEnvelope;
@@ -71,33 +71,33 @@ class SUBnote :public SynthNote
//internal values
ONOFFTYPE NoteEnabled;
int firsttick, portamento;
- REALTYPE volume, oldamplitude, newamplitude;
+ float volume, oldamplitude, newamplitude;
- REALTYPE GlobalFilterCenterPitch; //octaves
- REALTYPE GlobalFilterFreqTracking;
+ float GlobalFilterCenterPitch; //octaves
+ float GlobalFilterFreqTracking;
struct bpfilter {
- REALTYPE freq, bw, amp; //filter parameters
- REALTYPE a1, a2, b0, b2; //filter coefs. b1=0
- REALTYPE xn1, xn2, yn1, yn2; //filter internal values
+ float freq, bw, amp; //filter parameters
+ float a1, a2, b0, b2; //filter coefs. b1=0
+ float xn1, xn2, yn1, yn2; //filter internal values
};
void initfilter(bpfilter &filter,
- REALTYPE freq,
- REALTYPE bw,
- REALTYPE amp,
- REALTYPE mag);
+ float freq,
+ float bw,
+ float amp,
+ float mag);
void computefiltercoefs(bpfilter &filter,
- REALTYPE freq,
- REALTYPE bw,
- REALTYPE gain);
- inline void filter(bpfilter &filter, REALTYPE *smps);
+ float freq,
+ float bw,
+ float gain);
+ inline void filter(bpfilter &filter, float *smps);
bpfilter *lfilter, *rfilter;
Controller *ctl;
int oldpitchwheel, oldbandwidth;
- REALTYPE globalfiltercenterq;
+ float globalfiltercenterq;
};
#endif
diff --git a/src/Synth/SynthNote.cpp b/src/Synth/SynthNote.cpp
@@ -2,11 +2,11 @@
#include "../globals.h"
#include <cstring>
-SynthNote::SynthNote(REALTYPE freq, REALTYPE vel, int port, int note, bool quiet)
+SynthNote::SynthNote(float freq, float vel, int port, int note, bool quiet)
:legato(freq,vel,port,note,quiet)
{}
-SynthNote::Legato::Legato(REALTYPE freq, REALTYPE vel, int port,
+SynthNote::Legato::Legato(float freq, float vel, int port,
int note, bool quiet)
{
// Initialise some legato-specific vars
@@ -24,7 +24,7 @@ SynthNote::Legato::Legato(REALTYPE freq, REALTYPE vel, int port,
silent = quiet;
}
-int SynthNote::Legato::update(REALTYPE freq, REALTYPE velocity, int portamento_,
+int SynthNote::Legato::update(float freq, float velocity, int portamento_,
int midinote_, bool externcall)
{
if(externcall)
@@ -52,12 +52,12 @@ int SynthNote::Legato::update(REALTYPE freq, REALTYPE velocity, int portamento_,
return 0;
}
-void SynthNote::Legato::apply(SynthNote ¬e, REALTYPE *outl, REALTYPE *outr)
+void SynthNote::Legato::apply(SynthNote ¬e, float *outl, float *outr)
{
if(silent) // Silencer
if(msg != LM_FadeIn) {
- memset(outl, 0, SOUND_BUFFER_SIZE * sizeof(REALTYPE));
- memset(outr, 0, SOUND_BUFFER_SIZE * sizeof(REALTYPE));
+ memset(outl, 0, SOUND_BUFFER_SIZE * sizeof(float));
+ memset(outr, 0, SOUND_BUFFER_SIZE * sizeof(float));
}
switch(msg) {
case LM_CatchUp: // Continue the catch-up...
@@ -111,7 +111,7 @@ void SynthNote::Legato::apply(SynthNote ¬e, REALTYPE *outl, REALTYPE *outr)
//This freq should make this now silent note to catch-up/resync
//with the heard note for the same length it stayed at the
//previous freq during the fadeout.
- REALTYPE catchupfreq = param.freq * (param.freq / lastfreq);
+ float catchupfreq = param.freq * (param.freq / lastfreq);
note.legatonote(catchupfreq, param.vel, param.portamento,
param.midinote, false);
break;
diff --git a/src/Synth/SynthNote.h b/src/Synth/SynthNote.h
@@ -26,12 +26,12 @@
class SynthNote
{
public:
- SynthNote(REALTYPE freq, REALTYPE vel, int port, int note, bool quiet);
+ SynthNote(float freq, float vel, int port, int note, bool quiet);
virtual ~SynthNote() {}
/**Compute Output Samples
* @return 0 if note is finished*/
- virtual int noteout(REALTYPE *outl, REALTYPE *outr) = 0;
+ virtual int noteout(float *outl, float *outr) = 0;
//TODO fix this spelling error [noisey commit]
/**Release the key for the note and start release portion of envelopes.*/
@@ -41,30 +41,30 @@ class SynthNote
* @return finished=1 unfinished=0*/
virtual int finished() const = 0;
- virtual void legatonote(REALTYPE freq, REALTYPE velocity,
+ virtual void legatonote(float freq, float velocity,
int portamento_, int midinote_, bool externcall) = 0;
protected:
// Legato transitions
class Legato{
public:
- Legato(REALTYPE freq, REALTYPE vel, int port,
+ Legato(float freq, float vel, int port,
int note, bool quiet);
- void apply(SynthNote ¬e, REALTYPE *outl, REALTYPE *outr);
- int update(REALTYPE freq, REALTYPE velocity, int portamento_,
+ void apply(SynthNote ¬e, float *outl, float *outr);
+ int update(float freq, float velocity, int portamento_,
int midinote_, bool externalcall);
private:
bool silent;
- REALTYPE lastfreq;
+ float lastfreq;
LegatoMsg msg;
int decounter;
struct { // Fade In/Out vars
int length;
- REALTYPE m, step;
+ float m, step;
} fade;
struct { // Note parameters
- REALTYPE freq, vel;
+ float freq, vel;
int portamento, midinote;
} param;
} legato;
diff --git a/src/Tests/AdNoteTest.h b/src/Tests/AdNoteTest.h
@@ -36,7 +36,7 @@ class AdNoteTest:public CxxTest::TestSuite
//next the bad global variables that for some reason have not been properly placed in some
//initialization routine, but rather exist as cryptic oneliners in main.cpp:
- denormalkillbuf = new REALTYPE[SOUND_BUFFER_SIZE];
+ denormalkillbuf = new float[SOUND_BUFFER_SIZE];
for(int i = 0; i < SOUND_BUFFER_SIZE; i++)
denormalkillbuf[i] = 0;
@@ -72,7 +72,7 @@ class AdNoteTest:public CxxTest::TestSuite
//lets go with.... 50! as a nice note
testnote = 50;
- REALTYPE freq = 440.0 * pow(2.0, (testnote - 69.0) / 12.0);
+ float freq = 440.0 * pow(2.0, (testnote - 69.0) / 12.0);
note = new ADnote(defaultPreset,
controller,
diff --git a/src/Tests/EchoTest.h b/src/Tests/EchoTest.h
@@ -38,7 +38,7 @@ class EchoTest:public CxxTest::TestSuite
outR = new float[SOUND_BUFFER_SIZE];
for(int i = 0; i < SOUND_BUFFER_SIZE; ++i)
outR[i] = 0.0;
- input = new Stereo<REALTYPE *>(new REALTYPE[SOUND_BUFFER_SIZE],new REALTYPE[SOUND_BUFFER_SIZE]);
+ input = new Stereo<float *>(new float[SOUND_BUFFER_SIZE],new float[SOUND_BUFFER_SIZE]);
for(int i = 0; i < SOUND_BUFFER_SIZE; ++i)
input->l[i] = input->r[i] = 0.0f;
testFX = new Echo(true, outL, outR);
@@ -116,7 +116,7 @@ class EchoTest:public CxxTest::TestSuite
private:
- Stereo<REALTYPE *> *input;
+ Stereo<float *> *input;
float *outR, *outL;
Echo *testFX;
};
diff --git a/src/Tests/SubNoteTest.h b/src/Tests/SubNoteTest.h
@@ -37,7 +37,7 @@ class SubNoteTest:public CxxTest::TestSuite
//next the bad global variables that for some reason have not been properly placed in some
//initialization routine, but rather exist as cryptic oneliners in main.cpp:
- denormalkillbuf = new REALTYPE[SOUND_BUFFER_SIZE];
+ denormalkillbuf = new float[SOUND_BUFFER_SIZE];
for(int i = 0; i < SOUND_BUFFER_SIZE; i++)
denormalkillbuf[i] = 0;
@@ -59,7 +59,7 @@ class SubNoteTest:public CxxTest::TestSuite
//lets go with.... 50! as a nice note
testnote = 50;
- REALTYPE freq = 440.0 * pow(2.0, (testnote - 69.0) / 12.0);
+ float freq = 440.0 * pow(2.0, (testnote - 69.0) / 12.0);
note = new SUBnote(defaultPreset,
controller,
diff --git a/src/UI/EffUI.fl b/src/UI/EffUI.fl
@@ -47,9 +47,9 @@ maxdB=30;} {}
oldx=-1;
khzval=-1;} {}
}
- Function {draw_freq_line(REALTYPE freq,int type)} {} {
+ Function {draw_freq_line(float freq,int type)} {} {
code {fl_color(FL_GRAY);
-REALTYPE freqx=getfreqpos(freq);
+float freqx=getfreqpos(freq);
switch(type){
case 0:if (active_r()) fl_color(FL_WHITE);
else fl_color(205,205,205);
@@ -66,7 +66,7 @@ if ((freqx>0.0)&&(freqx<1.0))
}
Function {draw()} {} {
code {int ox=x(),oy=y(),lx=w(),ly=h(),i,iy,oiy;
-REALTYPE freqx;
+float freqx;
if (active_r()) fl_color(0,70,150);
else fl_color(80,120,160);
@@ -107,7 +107,7 @@ draw_freq_line(20000.0,1);
fl_line_style(FL_DOT);
int GY=6;if (ly<GY*3) GY=-1;
for (i=1;i<GY;i++){
- int tmp=(int)(ly/(REALTYPE)GY*i);
+ int tmp=(int)(ly/(float)GY*i);
fl_line(ox+2,oy+tmp,ox+lx-2,oy+tmp);
};
@@ -118,7 +118,7 @@ if (active_r()) fl_color(FL_YELLOW);
fl_line_style(FL_SOLID);
oiy=getresponse(ly,getfreqx(0.0));
for (i=1;i<lx;i++){
- REALTYPE frq=getfreqx(i/(REALTYPE) lx);
+ float frq=getfreqx(i/(float) lx);
if (frq>SAMPLE_RATE/2) break;
iy=getresponse(ly,frq);
if ((oiy>=0) && (oiy<ly) &&
@@ -127,9 +127,9 @@ for (i=1;i<lx;i++){
oiy=iy;
};} {}
}
- Function {getresponse(int maxy,REALTYPE freq)} {return_type int
+ Function {getresponse(int maxy,float freq)} {return_type int
} {
- code {REALTYPE dbresp=eff->getEQfreqresponse(freq);
+ code {float dbresp=eff->getEQfreqresponse(freq);
int idbresp=(int) ((dbresp/maxdB+1.0)*maxy/2.0);
@@ -138,18 +138,18 @@ int idbresp=(int) ((dbresp/maxdB+1.0)*maxy/2.0);
return(idbresp);} {}
}
- Function {getfreqx(REALTYPE x)} {return_type REALTYPE
+ Function {getfreqx(float x)} {return_type float
} {
code {if (x>1.0) x=1.0;
-return(20.0*pow((REALTYPE)1000.0,x));} {}
+return(20.0*pow((float)1000.0,x));} {}
}
- Function {getfreqpos(REALTYPE freq)} {return_type REALTYPE
+ Function {getfreqpos(float freq)} {return_type float
} {
code {if (freq<0.00001) freq=0.00001;
return(log(freq/20.0)/log(1000.0));} {}
}
decl {int oldx,oldy;} {}
- decl {REALTYPE khzval;} {public
+ decl {float khzval;} {public
}
decl {EffectMgr *eff;} {}
decl {int maxdB;} {}
diff --git a/src/UI/EnvelopeUI.fl b/src/UI/EnvelopeUI.fl
@@ -63,7 +63,7 @@ for (int i=1;i<npoints;i++) sum+=env->getdt(i)+1;
float sumbefore=0;//the sum of all points before the computed point
for (int i=1;i<=n;i++) sumbefore+=env->getdt(i)+1;
-return((int) (sumbefore/(REALTYPE) sum*lx));} {}
+return((int) (sumbefore/(float) sum*lx));} {}
}
Function {getpointy(int n)} {return_type int
} {
diff --git a/src/UI/FilterUI.fl b/src/UI/FilterUI.fl
@@ -51,10 +51,10 @@ graphpoints=NULL;} {}
nvowel=nvowel_;
nformant=nformant_;
oldx=-1;
-graphpoints=new REALTYPE [w()];} {}
+graphpoints=new float [w()];} {}
}
- Function {draw_freq_line(REALTYPE freq,int type)} {} {
- code {REALTYPE freqx=pars->getfreqpos(freq);
+ Function {draw_freq_line(float freq,int type)} {} {
+ code {float freqx=pars->getfreqpos(freq);
switch(type){
case 0:fl_line_style(FL_SOLID);break;
case 1:fl_line_style(FL_DOT);break;
@@ -70,7 +70,7 @@ if ((freqx>0.0)&&(freqx<1.0))
} {
code {int maxdB=30;
int ox=x(),oy=y(),lx=w(),ly=h(),i,oiy;
-REALTYPE freqx;
+float freqx;
fl_color(FL_BLACK);
fl_rectf(ox,oy,lx,ly);
@@ -107,7 +107,7 @@ draw_freq_line(20000.0,1);
fl_line_style(FL_DOT);
int GY=10;if (ly<GY*3) GY=-1;
for (i=1;i<GY;i++){
- int tmp=(int)(ly/(REALTYPE)GY*i);
+ int tmp=(int)(ly/(float)GY*i);
fl_line(ox+2,oy+tmp,ox+lx-2,oy+tmp);
};
@@ -148,7 +148,7 @@ for (i=1;i<lx;i++){
decl {FilterParams *pars;} {}
decl {int oldx,oldy;} {}
decl {int *nvowel,*nformant;} {}
- decl {REALTYPE *graphpoints;} {}
+ decl {float *graphpoints;} {}
}
class FilterUI {: {public Fl_Group,PresetsUI_}
diff --git a/src/UI/MasterUI.fl b/src/UI/MasterUI.fl
@@ -84,12 +84,12 @@ int ox=x(); int oy=y(); int lx=w(); int ly=h();
vuData data = master->getVuData();
//pthread_mutex_lock(&master->mutex);
-REALTYPE dbl=rap2dB(data.outpeakl);
-REALTYPE dbr=rap2dB(data.outpeakr);
-REALTYPE rmsdbl=rap2dB(data.rmspeakl);
-REALTYPE rmsdbr=rap2dB(data.rmspeakr);
-REALTYPE maxdbl=rap2dB(data.maxoutpeakl);
-REALTYPE maxdbr=rap2dB(data.maxoutpeakr);
+float dbl=rap2dB(data.outpeakl);
+float dbr=rap2dB(data.outpeakr);
+float rmsdbl=rap2dB(data.rmspeakl);
+float rmsdbr=rap2dB(data.rmspeakr);
+float maxdbl=rap2dB(data.maxoutpeakl);
+float maxdbr=rap2dB(data.maxoutpeakr);
int clipped=data.clipped;
//pthread_mutex_unlock(&master->mutex);
@@ -148,7 +148,7 @@ fl_rectf(ox+idbr,oy,VULENX-idbr,VULENY,0,0,0);
fl_rectf(ox+idbl,oy+ly/2,VULENX-idbl,VULENY,0,0,0);
//draw the scales
-REALTYPE tmp=VULENX*1.0/MIN_DB;
+float tmp=VULENX*1.0/MIN_DB;
for (int i=1;i<1-MIN_DB;i++){
int tx=VULENX+(int) (tmp*i);
fl_rectf(ox+tx,oy,1,VULENY+ly/2,0,160,200);
@@ -197,7 +197,7 @@ if (!active_r()){
//draw the vu lines
pthread_mutex_lock(&master->mutex);
- REALTYPE db=rap2dB(master->vuoutpeakpart[npart]);
+ float db=rap2dB(master->vuoutpeakpart[npart]);
pthread_mutex_unlock(&master->mutex);
db=(MIN_DB-db)/MIN_DB;
@@ -213,7 +213,7 @@ fl_rectf(ox,oy,lx,ly-idb,0,0,0);
//draw the scales
-REALTYPE tmp=ly*1.0/MIN_DB;
+float tmp=ly*1.0/MIN_DB;
for (int i=1;i<1-MIN_DB;i++){
int ty=ly+(int) (tmp*i);
if (i%5==0) fl_rectf(ox,oy+ly-ty,lx,1,0,160,200);
diff --git a/src/UI/OscilGenUI.fl b/src/UI/OscilGenUI.fl
@@ -67,8 +67,8 @@ int GX=2;
int n=lx/GX-1;
if (n>OSCIL_SIZE/2) n=OSCIL_SIZE/2;
-REALTYPE x;
-REALTYPE* spc=new REALTYPE[n];
+float x;
+float* spc=new float[n];
for (i=0;i<n;i++) spc[i]=0.0;
pthread_mutex_lock(&master->mutex);
@@ -77,7 +77,7 @@ if (oscbase==0) oscil->getspectrum(n,spc,0);
pthread_mutex_unlock(&master->mutex);
//normalize
-REALTYPE max=0;
+float max=0;
for (i=0;i<n;i++){
x=fabs(spc[i]);
if (max<x) max=x;
@@ -92,7 +92,7 @@ if (this->active_r()) fl_color(this->parent()->selection_color());
fl_line_style(FL_DOT);
for (i=1;i<maxdb/10;i++){
- int ky=(int)((REALTYPE)i*ly*10.0/maxdb)/2;
+ int ky=(int)((float)i*ly*10.0/maxdb)/2;
ky*=2;
fl_line(ox,oy+ky-1,ox+lx-2,oy+ky-1);
};
@@ -178,7 +178,7 @@ master=master_;} {}
}
Function {draw()} {} {
code {int ox=x(),oy=y(),lx=w(),ly=h()-1,i;
-REALTYPE smps[OSCIL_SIZE];
+float smps[OSCIL_SIZE];
pthread_mutex_lock(&master->mutex);
if (oscbase==0) oscil->get(smps,-1.0);
else oscil->getcurrentbasefunction(smps);
@@ -190,7 +190,7 @@ if (damage()!=1){
};
//normalize
-REALTYPE max=0;
+float max=0;
for (i=0;i<OSCIL_SIZE;i++)
if (max<fabs(smps[i])) max=fabs(smps[i]);
//fprintf(stderr,"%.4f\\n",max);
@@ -203,12 +203,12 @@ if (this->active_r()) fl_color(this->parent()->labelcolor());
else fl_color(this->parent()->color());
int GX=16;if (lx<GX*3) GX=-1;
for (i=1;i<GX;i++){
- int tmp=(int)(lx/(REALTYPE)GX*i);
+ int tmp=(int)(lx/(float)GX*i);
fl_line(ox+tmp,oy+2,ox+tmp,oy+ly-2);
};
int GY=8;if (ly<GY*3) GY=-1;
for (i=1;i<GY;i++){
- int tmp=(int)(ly/(REALTYPE)GY*i);
+ int tmp=(int)(ly/(float)GY*i);
fl_line(ox+2,oy+tmp,ox+lx-2,oy+tmp);
};
@@ -222,10 +222,10 @@ int lw=1;
fl_line_style(0,lw);
int ph=(int)((phase-64.0)/128.0*OSCIL_SIZE+OSCIL_SIZE);
for (i=1;i<lx;i++){
- int k1=(int)((REALTYPE)OSCIL_SIZE*(i-1)/lx)+ph;
- int k2=(int)((REALTYPE)OSCIL_SIZE*i/lx)+ph;
- REALTYPE y1=smps[k1%OSCIL_SIZE]/max;
- REALTYPE y2=smps[k2%OSCIL_SIZE]/max;
+ int k1=(int)((float)OSCIL_SIZE*(i-1)/lx)+ph;
+ int k2=(int)((float)OSCIL_SIZE*i/lx)+ph;
+ float y1=smps[k1%OSCIL_SIZE]/max;
+ float y2=smps[k2%OSCIL_SIZE]/max;
fl_line(i-1+ox,(int)(y1*ly/2.0)+oy+ly/2,i+ox,(int)(y2*ly/2.0)+oy+ly/2);
};} {}
}
diff --git a/src/UI/PADnoteUI.fl b/src/UI/PADnoteUI.fl
@@ -61,9 +61,9 @@ this->pars=pars;} {}
Function {draw()} {} {
code {int ox=x(),oy=y(),lx=w(),ly=h();
if (!visible()) return;
-REALTYPE smps[lx];
+float smps[lx];
-REALTYPE realbw=pars->getprofile(smps,lx);
+float realbw=pars->getprofile(smps,lx);
bool active=active_r();
//draw the equivalent bandwidth
@@ -140,14 +140,14 @@ for (int i=1;i<maxharmonic;i++){
fl_line_style(FL_DOT);
if (i%5==0) fl_line_style(0);
if (i%10==0) fl_color(160,160,160);
- int kx=(int)(lx/(REALTYPE)maxharmonic*i);
+ int kx=(int)(lx/(float)maxharmonic*i);
fl_line(ox+kx,oy,ox+kx,oy+ly);
};
int n=OSCIL_SIZE/2;
-REALTYPE spc[n];
+float spc[n];
for (int i=0;i<n;i++) spc[i]=0.0;
pthread_mutex_lock(&master->mutex);
@@ -156,21 +156,21 @@ pthread_mutex_unlock(&master->mutex);
//normalize
-REALTYPE max=0;
+float max=0;
for (int i=0;i<n;i++){
- REALTYPE x=fabs(spc[i]);
+ float x=fabs(spc[i]);
if (max<x) max=x;
}
if (max<0.000001) max=1.0;
max=max*1.05;
-REALTYPE spectrum[lx];
+float spectrum[lx];
for (int i=0;i<lx;i++) spectrum[i]=0;
for (int i=1;i<n;i++){
- REALTYPE nhr=pars->getNhr(i);
- int kx=(int)(lx/(REALTYPE)maxharmonic*nhr);
+ float nhr=pars->getNhr(i);
+ int kx=(int)(lx/(float)maxharmonic*nhr);
if ((kx<0)||(kx>lx)) continue;
spectrum[kx]=spc[i-1]/max+1e-9;
@@ -185,12 +185,12 @@ if (pars->Pmode==2){
for (int i=1;i<lx;i++){
if ((spectrum[i]>1e-10)||(i==(lx-1))){
int delta=i-old;
- REALTYPE val1=spectrum[old];
- REALTYPE val2=spectrum[i];
+ float val1=spectrum[old];
+ float val2=spectrum[i];
- REALTYPE idelta=1.0/delta;
+ float idelta=1.0/delta;
for (int j=0;j<delta;j++){
- REALTYPE x=idelta*j;
+ float x=idelta*j;
spectrum[old+j]=val1*(1.0-x)+val2*x;
};
old=i;
@@ -200,7 +200,7 @@ if (pars->Pmode==2){
};
for (int i=0;i<lx;i++){
- REALTYPE x=spectrum[i];
+ float x=spectrum[i];
if (x>dB2rap(-maxdb)) x=rap2dB(x)/maxdb+1;
else continue;
int yy=(int)(x*ly);
diff --git a/src/UI/ResonanceUI.fl b/src/UI/ResonanceUI.fl
@@ -46,8 +46,8 @@ dbvalue=dbvalue_;
oldx=-1;
khzval=-1;} {}
}
- Function {draw_freq_line(REALTYPE freq,int type)} {} {
- code {REALTYPE freqx=respar->getfreqpos(freq);
+ Function {draw_freq_line(float freq,int type)} {} {
+ code {float freqx=respar->getfreqpos(freq);
switch(type){
case 0:fl_line_style(FL_SOLID);break;
case 1:fl_line_style(FL_DOT);break;
@@ -61,7 +61,7 @@ if ((freqx>0.0)&&(freqx<1.0))
}
Function {draw()} {} {
code {int ox=x(),oy=y(),lx=w(),ly=h(),i,ix,iy,oiy;
-REALTYPE freqx;
+float freqx;
fl_color(FL_BLACK);
fl_rectf(ox,oy,lx,ly);
@@ -98,7 +98,7 @@ draw_freq_line(20000.0,1);
fl_line_style(FL_DOT);
int GY=10;if (ly<GY*3) GY=-1;
for (i=1;i<GY;i++){
- int tmp=(int)(ly/(REALTYPE)GY*i);
+ int tmp=(int)(ly/(float)GY*i);
fl_line(ox+2,oy+tmp,ox+lx-2,oy+tmp);
};
@@ -146,7 +146,7 @@ if ((event==FL_PUSH)||(event==FL_DRAG)){
};
for (int i=0;i<x2-x1;i++){
int sn=(int)((i+x1)*1.0/w()*N_RES_POINTS);
- REALTYPE yy=(y2-y1)*1.0/(x2-x1)*i;
+ float yy=(y2-y1)*1.0/(x2-x1)*i;
int sp=127-(int)((y1+yy)/h()*127);
if (leftbutton!=0) respar->setpoint(sn,sp);
else respar->setpoint(sn,64);
@@ -179,7 +179,7 @@ this->applybutton=applybutton;} {}
decl {Fl_Value_Output *dbvalue;} {}
decl {Resonance *respar;} {}
decl {int oldx,oldy;} {}
- decl {REALTYPE khzval;} {public
+ decl {float khzval;} {public
}
decl {Fl_Widget *cbwidget,*applybutton;} {}
}
diff --git a/src/globals.h b/src/globals.h
@@ -25,11 +25,8 @@
#ifndef GLOBALS_H
#define GLOBALS_H
-//What float type I use for internal sampledata
-#define REALTYPE float
-
struct FFTFREQS {
- REALTYPE *s, *c; //sine and cosine components
+ float *s, *c; //sine and cosine components
};
extern void newFFTFREQS(FFTFREQS *f, int size);
@@ -171,8 +168,8 @@ extern int OSCIL_SIZE;
*/
#define INTERPOLATE_AMPLITUDE(a, b, x, size) ((a) \
+ ((b) \
- - (a)) * (REALTYPE)(x) \
- / (REALTYPE) (size))
+ - (a)) * (float)(x) \
+ / (float) (size))
/*
@@ -190,7 +187,7 @@ extern int OSCIL_SIZE;
i < size; \
i++) \
data_[i] = 0;}
-#define ZERO_REALTYPE(data, size) {REALTYPE *data_ = (REALTYPE *) data; \
+#define ZERO_float(data, size) {float *data_ = (float *) data; \
for(int i = 0; \
i < size; \
i++) \
diff --git a/src/main.cpp b/src/main.cpp
@@ -196,7 +196,7 @@ int main(int argc, char *argv[])
srand(time(NULL));
//produce denormal buf
- denormalkillbuf = new REALTYPE [SOUND_BUFFER_SIZE];
+ denormalkillbuf = new float [SOUND_BUFFER_SIZE];
for(int i = 0; i < SOUND_BUFFER_SIZE; i++)
denormalkillbuf[i] = (RND - 0.5) * 1e-16;