zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit d44dc9b66d503405cac29b73cdd15c962f0098b2
parent e97c0d78b6dd9cf65dd54a2c7bfa5ce3288231dd
Author: fundamental <mark.d.mccurry@gmail.com>
Date:   Sat, 10 Sep 2011 17:34:24 -0400

FP: All code should prefer single precision now

To better match yoshimi single precision usage two large regular expressions
were applied. The performance difference according to tests is fairly minimal,
as hot spots already make heavy use of single precision variables.

Scripted Changes:
perl -pi -e "s/(\d+\.\d+)([^f^\d])/\1f\2/g" `find . |grep -E "(cpp|h)$"`
perl -pi -e "s/(exp|pow|log|sin|cos|tan)\(/\1f\(/g" `find . |grep -E "(cpp|h)$"`

Minor changes were made for a handful of values

Diffstat:
Msrc/DSP/AnalogFilter.cpp | 210++++++++++++++++++++++++++++++++++++++++----------------------------------------
Msrc/DSP/FFTwrapper.cpp | 4++--
Msrc/DSP/Filter.cpp | 8++++----
Msrc/DSP/FormantFilter.cpp | 70+++++++++++++++++++++++++++++++++++-----------------------------------
Msrc/DSP/SVFilter.cpp | 36++++++++++++++++++------------------
Msrc/DSP/Unison.cpp | 52++++++++++++++++++++++++++--------------------------
Msrc/DSP/Unison.h | 14+++++++-------
Msrc/Effects/Alienwah.cpp | 40++++++++++++++++++++--------------------
Msrc/Effects/Chorus.cpp | 38+++++++++++++++++++-------------------
Msrc/Effects/Chorus.h | 2+-
Msrc/Effects/Distorsion.cpp | 26+++++++++++++-------------
Msrc/Effects/DynamicFilter.cpp | 34+++++++++++++++++-----------------
Msrc/Effects/EQ.cpp | 16++++++++--------
Msrc/Effects/Echo.cpp | 32++++++++++++++++----------------
Msrc/Effects/Effect.cpp | 8++++----
Msrc/Effects/Effect.h | 2+-
Msrc/Effects/EffectLFO.cpp | 48++++++++++++++++++++++++------------------------
Msrc/Effects/EffectMgr.cpp | 38+++++++++++++++++++-------------------
Msrc/Effects/Phaser.cpp | 38+++++++++++++++++++-------------------
Msrc/Effects/Reverb.cpp | 72++++++++++++++++++++++++++++++++++++------------------------------------
Msrc/Misc/Config.cpp | 2+-
Msrc/Misc/Dump.cpp | 2+-
Msrc/Misc/Master.cpp | 18+++++++++---------
Msrc/Misc/Microtonal.cpp | 50+++++++++++++++++++++++++-------------------------
Msrc/Misc/Microtonal.h | 4++--
Msrc/Misc/Part.cpp | 50+++++++++++++++++++++++++-------------------------
Msrc/Misc/Util.cpp | 26+++++++++++++-------------
Msrc/Misc/WaveShapeSmps.cpp | 124++++++++++++++++++++++++++++++++++++++++----------------------------------------
Msrc/Misc/XMLwrapper.cpp | 6+++---
Msrc/Nio/AlsaEngine.cpp | 4++--
Msrc/Nio/OssEngine.cpp | 20++++++++++----------
Msrc/Nio/WavEngine.cpp | 4++--
Msrc/Output/DSSIaudiooutput.cpp | 2+-
Msrc/Params/ADnoteParameters.cpp | 8++++----
Msrc/Params/Controller.cpp | 86++++++++++++++++++++++++++++++++++++++++----------------------------------------
Msrc/Params/Controller.h | 6+++---
Msrc/Params/EnvelopeParams.cpp | 2+-
Msrc/Params/FilterParams.cpp | 64++++++++++++++++++++++++++++++++--------------------------------
Msrc/Params/LFOParams.cpp | 4++--
Msrc/Params/PADnoteParameters.cpp | 228++++++++++++++++++++++++++++++++++++++++----------------------------------------
Msrc/Params/PADnoteParameters.h | 2+-
Msrc/Params/SUBnoteParameters.h | 2+-
Msrc/Samples/Sample.cpp | 10+++++-----
Msrc/Synth/ADnote.cpp | 374++++++++++++++++++++++++++++++++++++++++----------------------------------------
Msrc/Synth/ADnote.h | 12++++++------
Msrc/Synth/Envelope.cpp | 44++++++++++++++++++++++----------------------
Msrc/Synth/Envelope.h | 2+-
Msrc/Synth/LFO.cpp | 88++++++++++++++++++++++++++++++++++++++++----------------------------------------
Msrc/Synth/OscilGen.cpp | 468++++++++++++++++++++++++++++++++++++++++----------------------------------------
Msrc/Synth/PADnote.cpp | 88++++++++++++++++++++++++++++++++++++++++----------------------------------------
Msrc/Synth/Resonance.cpp | 78+++++++++++++++++++++++++++++++++++++++---------------------------------------
Msrc/Synth/SUBnote.cpp | 128++++++++++++++++++++++++++++++++++++++++----------------------------------------
Msrc/Synth/SynthNote.cpp | 14+++++++-------
Msrc/Tests/AdNoteTest.h | 12++++++------
Msrc/Tests/ControllerTest.h | 24++++++++++++------------
Msrc/Tests/EchoTest.h | 26+++++++++++++-------------
Msrc/Tests/MicrotonalTest.h | 6+++---
Msrc/Tests/OscilGenTest.h | 26+++++++++++++-------------
Msrc/Tests/RandTest.h | 10+++++-----
Msrc/Tests/SampleTest.h | 10+++++-----
Msrc/Tests/SubNoteTest.h | 12++++++------
Msrc/Tests/XMLwrapperTest.h | 2+-
Msrc/UI/WidgetPDial.cpp | 24++++++++++++------------
Msrc/UI/WidgetPDial.h | 2+-
Msrc/globals.h | 28++++++++++++++--------------
Msrc/main.cpp | 8++++----
66 files changed, 1499 insertions(+), 1499 deletions(-)

diff --git a/src/DSP/AnalogFilter.cpp b/src/DSP/AnalogFilter.cpp @@ -35,15 +35,15 @@ AnalogFilter::AnalogFilter(unsigned char Ftype, { stages = Fstages; for(int i = 0; i < 3; ++i) { - coeff.c[i] = 0.0; - coeff.d[i] = 0.0; - oldCoeff.c[i] = 0.0; - oldCoeff.d[i] = 0.0; + coeff.c[i] = 0.0f; + coeff.d[i] = 0.0f; + oldCoeff.c[i] = 0.0f; + oldCoeff.d[i] = 0.0f; } type = Ftype; freq = Ffreq; q = Fq; - gain = 1.0; + gain = 1.0f; if(stages >= MAX_FILTER_STAGES) stages = MAX_FILTER_STAGES; cleanup(); @@ -53,7 +53,7 @@ AnalogFilter::AnalogFilter(unsigned char Ftype, setfreq_and_q(Ffreq, Fq); firsttime = true; coeff.d[0] = 0; //this is not used - outgain = 1.0; + outgain = 1.0f; } AnalogFilter::~AnalogFilter() @@ -62,10 +62,10 @@ AnalogFilter::~AnalogFilter() void AnalogFilter::cleanup() { for(int i = 0; i < MAX_FILTER_STAGES + 1; ++i) { - history[i].x1 = 0.0; - history[i].x2 = 0.0; - history[i].y1 = 0.0; - history[i].y2 = 0.0; + history[i].x1 = 0.0f; + history[i].x2 = 0.0f; + history[i].y1 = 0.0f; + history[i].y2 = 0.0f; oldHistory[i] = history[i]; } needsinterpolation = false; @@ -78,23 +78,23 @@ void AnalogFilter::computefiltercoefs() //do not allow frequencies bigger than samplerate/2 float freq = this->freq; - if(freq > (SAMPLE_RATE / 2 - 500.0)) { - freq = SAMPLE_RATE / 2 - 500.0; + if(freq > (SAMPLE_RATE / 2 - 500.0f)) { + freq = SAMPLE_RATE / 2 - 500.0f; zerocoefs = true; } - if(freq < 0.1) - freq = 0.1; + if(freq < 0.1f) + freq = 0.1f; //do not allow bogus Q - if(q < 0.0) - q = 0.0; + if(q < 0.0f) + q = 0.0f; float tmpq, tmpgain; if(stages == 0) { tmpq = q; tmpgain = gain; } else { - tmpq = (q > 1.0 ? pow(q, 1.0 / (stages + 1)) : q); - tmpgain = pow(gain, 1.0 / (stages + 1)); + tmpq = (q > 1.0f ? powf(q, 1.0f / (stages + 1)) : q); + tmpgain = powf(gain, 1.0f / (stages + 1)); } //Alias Terms @@ -103,7 +103,7 @@ void AnalogFilter::computefiltercoefs() //General Constants const float omega = 2 * PI * freq / SAMPLE_RATE; - const float sn = sin(omega), cs = cos(omega); + const float sn = sinf(omega), cs = cosf(omega); float alpha, beta; //most of theese are implementations of @@ -113,44 +113,44 @@ void AnalogFilter::computefiltercoefs() switch(type) { case 0: //LPF 1 pole if(!zerocoefs) - tmp = exp(-2.0 * PI * freq / SAMPLE_RATE); + tmp = expf(-2.0f * PI * freq / SAMPLE_RATE); else - tmp = 0.0; - c[0] = 1.0 - tmp; - c[1] = 0.0; - c[2] = 0.0; + tmp = 0.0f; + c[0] = 1.0f - tmp; + c[1] = 0.0f; + c[2] = 0.0f; d[1] = tmp; - d[2] = 0.0; + d[2] = 0.0f; order = 1; break; case 1: //HPF 1 pole if(!zerocoefs) - tmp = exp(-2.0 * PI * freq / SAMPLE_RATE); + tmp = expf(-2.0f * PI * freq / SAMPLE_RATE); else - tmp = 0.0; - c[0] = (1.0 + tmp) / 2.0; - c[1] = -(1.0 + tmp) / 2.0; - c[2] = 0.0; + tmp = 0.0f; + c[0] = (1.0f + tmp) / 2.0f; + c[1] = -(1.0f + tmp) / 2.0f; + c[2] = 0.0f; d[1] = tmp; - d[2] = 0.0; + d[2] = 0.0f; order = 1; break; case 2: //LPF 2 poles if(!zerocoefs) { alpha = sn / (2 * tmpq); tmp = 1 + alpha; - c[0] = (1.0 - cs) / 2.0 / tmp; - c[1] = (1.0 - cs) / tmp; - c[2] = (1.0 - cs) / 2.0 / tmp; + c[0] = (1.0f - cs) / 2.0f / tmp; + c[1] = (1.0f - cs) / tmp; + c[2] = (1.0f - cs) / 2.0f / tmp; d[1] = -2 * cs / tmp * (-1); d[2] = (1 - alpha) / tmp * (-1); } else { - c[0] = 1.0; - c[1] = 0.0; - c[2] = 0.0; - d[1] = 0.0; - d[2] = 0.0; + c[0] = 1.0f; + c[1] = 0.0f; + c[2] = 0.0f; + d[1] = 0.0f; + d[2] = 0.0f; } order = 2; break; @@ -158,18 +158,18 @@ void AnalogFilter::computefiltercoefs() if(!zerocoefs) { alpha = sn / (2 * tmpq); tmp = 1 + alpha; - c[0] = (1.0 + cs) / 2.0 / tmp; - c[1] = -(1.0 + cs) / tmp; - c[2] = (1.0 + cs) / 2.0 / tmp; + c[0] = (1.0f + cs) / 2.0f / tmp; + c[1] = -(1.0f + cs) / tmp; + c[2] = (1.0f + cs) / 2.0f / tmp; d[1] = -2 * cs / tmp * (-1); d[2] = (1 - alpha) / tmp * (-1); } else { - c[0] = 0.0; - c[1] = 0.0; - c[2] = 0.0; - d[1] = 0.0; - d[2] = 0.0; + c[0] = 0.0f; + c[1] = 0.0f; + c[2] = 0.0f; + d[1] = 0.0f; + d[2] = 0.0f; } order = 2; break; @@ -184,11 +184,11 @@ void AnalogFilter::computefiltercoefs() d[2] = (1 - alpha) / tmp * (-1); } else { - c[0] = 0.0; - c[1] = 0.0; - c[2] = 0.0; - d[1] = 0.0; - d[2] = 0.0; + c[0] = 0.0f; + c[1] = 0.0f; + c[2] = 0.0f; + d[1] = 0.0f; + d[2] = 0.0f; } order = 2; break; @@ -203,31 +203,31 @@ void AnalogFilter::computefiltercoefs() d[2] = (1 - alpha) / tmp * (-1); } else { - c[0] = 1.0; - c[1] = 0.0; - c[2] = 0.0; - d[1] = 0.0; - d[2] = 0.0; + c[0] = 1.0f; + c[1] = 0.0f; + c[2] = 0.0f; + d[1] = 0.0f; + d[2] = 0.0f; } order = 2; break; case 6: //PEAK (2 poles) if(!zerocoefs) { - tmpq *= 3.0; + tmpq *= 3.0f; alpha = sn / (2 * tmpq); tmp = 1 + alpha / tmpgain; - c[0] = (1.0 + alpha * tmpgain) / tmp; - c[1] = (-2.0 * cs) / tmp; - c[2] = (1.0 - alpha * tmpgain) / tmp; + c[0] = (1.0f + alpha * tmpgain) / tmp; + c[1] = (-2.0f * cs) / tmp; + c[2] = (1.0f - alpha * tmpgain) / tmp; d[1] = -2 * cs / tmp * (-1); d[2] = (1 - alpha / tmpgain) / tmp * (-1); } else { - c[0] = 1.0; - c[1] = 0.0; - c[2] = 0.0; - d[1] = 0.0; - d[2] = 0.0; + c[0] = 1.0f; + c[1] = 0.0f; + c[2] = 0.0f; + d[1] = 0.0f; + d[2] = 0.0f; } order = 2; break; @@ -236,27 +236,27 @@ void AnalogFilter::computefiltercoefs() tmpq = sqrt(tmpq); alpha = sn / (2 * tmpq); beta = sqrt(tmpgain) / tmpq; - tmp = (tmpgain + 1.0) + (tmpgain - 1.0) * cs + beta * sn; + tmp = (tmpgain + 1.0f) + (tmpgain - 1.0f) * cs + beta * sn; c[0] = tmpgain * ((tmpgain - + 1.0) - (tmpgain - 1.0) * cs + beta * sn) / tmp; - c[1] = 2.0 * tmpgain - * ((tmpgain - 1.0) - (tmpgain + 1.0) * cs) / tmp; + + 1.0f) - (tmpgain - 1.0f) * cs + beta * sn) / tmp; + c[1] = 2.0f * tmpgain + * ((tmpgain - 1.0f) - (tmpgain + 1.0f) * cs) / tmp; c[2] = tmpgain * ((tmpgain - + 1.0) - (tmpgain - 1.0) * cs - beta * sn) / tmp; - d[1] = -2.0 * ((tmpgain - 1.0) + (tmpgain + 1.0) * cs) / tmp * (-1); + + 1.0f) - (tmpgain - 1.0f) * cs - beta * sn) / tmp; + d[1] = -2.0f * ((tmpgain - 1.0f) + (tmpgain + 1.0f) * cs) / tmp * (-1); d[2] = ((tmpgain - + 1.0) + (tmpgain - 1.0) * cs - beta * sn) / tmp * (-1); + + 1.0f) + (tmpgain - 1.0f) * cs - beta * sn) / tmp * (-1); } else { c[0] = tmpgain; - c[1] = 0.0; - c[2] = 0.0; - d[1] = 0.0; - d[2] = 0.0; + c[1] = 0.0f; + c[2] = 0.0f; + d[1] = 0.0f; + d[2] = 0.0f; } order = 2; break; @@ -265,27 +265,27 @@ void AnalogFilter::computefiltercoefs() tmpq = sqrt(tmpq); alpha = sn / (2 * tmpq); beta = sqrt(tmpgain) / tmpq; - tmp = (tmpgain + 1.0) - (tmpgain - 1.0) * cs + beta * sn; + tmp = (tmpgain + 1.0f) - (tmpgain - 1.0f) * cs + beta * sn; c[0] = tmpgain * ((tmpgain - + 1.0) + (tmpgain - 1.0) * cs + beta * sn) / tmp; - c[1] = -2.0 * tmpgain - * ((tmpgain - 1.0) + (tmpgain + 1.0) * cs) / tmp; + + 1.0f) + (tmpgain - 1.0f) * cs + beta * sn) / tmp; + c[1] = -2.0f * tmpgain + * ((tmpgain - 1.0f) + (tmpgain + 1.0f) * cs) / tmp; c[2] = tmpgain * ((tmpgain - + 1.0) + (tmpgain - 1.0) * cs - beta * sn) / tmp; - d[1] = 2.0 * ((tmpgain - 1.0) - (tmpgain + 1.0) * cs) / tmp * (-1); + + 1.0f) + (tmpgain - 1.0f) * cs - beta * sn) / tmp; + d[1] = 2.0f * ((tmpgain - 1.0f) - (tmpgain + 1.0f) * cs) / tmp * (-1); d[2] = ((tmpgain - + 1.0) - (tmpgain - 1.0) * cs - beta * sn) / tmp * (-1); + + 1.0f) - (tmpgain - 1.0f) * cs - beta * sn) / tmp * (-1); } else { - c[0] = 1.0; - c[1] = 0.0; - c[2] = 0.0; - d[1] = 0.0; - d[2] = 0.0; + c[0] = 1.0f; + c[1] = 0.0f; + c[2] = 0.0f; + d[1] = 0.0f; + d[2] = 0.0f; } order = 2; break; @@ -299,20 +299,20 @@ void AnalogFilter::computefiltercoefs() void AnalogFilter::setfreq(float frequency) { - if(frequency < 0.1) - frequency = 0.1; + if(frequency < 0.1f) + frequency = 0.1f; float rap = freq / frequency; - if(rap < 1.0) - rap = 1.0 / rap; + if(rap < 1.0f) + rap = 1.0f / rap; oldabovenq = abovenq; - abovenq = frequency > (SAMPLE_RATE / 2 - 500.0); + abovenq = frequency > (SAMPLE_RATE / 2 - 500.0f); bool nyquistthresh = (abovenq ^ oldabovenq); //if the frequency is changed fast, it needs interpolation - if((rap > 3.0) || nyquistthresh) { //(now, filter and coeficients backup) + if((rap > 3.0f) || nyquistthresh) { //(now, filter and coeficients backup) oldCoeff = coeff; for(int i = 0; i < MAX_FILTER_STAGES + 1; ++i) oldHistory[i] = history[i]; @@ -397,7 +397,7 @@ void AnalogFilter::filterout(float *smp) for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) { float x = i / (float) SOUND_BUFFER_SIZE; - smp[i] = ismp[i] * (1.0 - x) + smp[i] * x; + smp[i] = ismp[i] * (1.0f - x) + smp[i] * x; } returnTmpBuffer(ismp); needsinterpolation = false; @@ -409,20 +409,20 @@ void AnalogFilter::filterout(float *smp) float AnalogFilter::H(float freq) { - float fr = freq / SAMPLE_RATE * PI * 2.0; - float x = coeff.c[0], y = 0.0; + float fr = freq / SAMPLE_RATE * PI * 2.0f; + float x = coeff.c[0], y = 0.0f; for(int n = 1; n < 3; ++n) { - x += cos(n * fr) * coeff.c[n]; - y -= sin(n * fr) * coeff.c[n]; + x += cosf(n * fr) * coeff.c[n]; + y -= sinf(n * fr) * coeff.c[n]; } float h = x * x + y * y; - x = 1.0; - y = 0.0; + x = 1.0f; + y = 0.0f; for(int n = 1; n < 3; ++n) { - x -= cos(n * fr) * coeff.d[n]; - y += sin(n * fr) * coeff.d[n]; + x -= cosf(n * fr) * coeff.d[n]; + y += sinf(n * fr) * coeff.d[n]; } h = h / (x * x + y * y); - return pow(h, (stages + 1.0) / 2.0); + return powf(h, (stages + 1.0f) / 2.0f); } diff --git a/src/DSP/FFTwrapper.cpp b/src/DSP/FFTwrapper.cpp @@ -68,8 +68,8 @@ void FFTwrapper::freqs2smps(const fft_t *freqs, float *smps) memcpy( (void*)fft, (const void*)freqs, fftsize*sizeof(double)); //clear unused freq channel - fft[fftsize/2][0] = 0.0; - fft[fftsize/2][1] = 0.0; + fft[fftsize/2][0] = 0.0f; + fft[fftsize/2][1] = 0.0f; //IDFT fftw_execute(planfftw_inv); diff --git a/src/DSP/Filter.cpp b/src/DSP/Filter.cpp @@ -40,13 +40,13 @@ Filter *Filter::generate(FilterParams *pars) filter = new FormantFilter(pars); break; case 2: - filter = new SVFilter(Ftype, 1000.0, pars->getq(), Fstages); + filter = new SVFilter(Ftype, 1000.0f, pars->getq(), Fstages); filter->outgain = dB2rap(pars->getgain()); - if(filter->outgain > 1.0) + if(filter->outgain > 1.0f) filter->outgain = sqrt(filter->outgain); break; default: - filter = new AnalogFilter(Ftype, 1000.0, pars->getq(), Fstages); + filter = new AnalogFilter(Ftype, 1000.0f, pars->getq(), Fstages); if((Ftype >= 6) && (Ftype <= 8)) filter->setgain(pars->getgain()); else @@ -58,6 +58,6 @@ Filter *Filter::generate(FilterParams *pars) float Filter::getrealfreq(float freqpitch) { - return pow(2.0, freqpitch + 9.96578428); //log2(1000)=9.95748 + return powf(2.0f, freqpitch + 9.96578428f); //log2(1000)=9.95748f } diff --git a/src/DSP/FormantFilter.cpp b/src/DSP/FormantFilter.cpp @@ -31,7 +31,7 @@ FormantFilter::FormantFilter(FilterParams *pars) { numformants = pars->Pnumformants; for(int i = 0; i < numformants; ++i) - formant[i] = new AnalogFilter(4 /*BPF*/, 1000.0, 10.0, pars->Pstages); + formant[i] = new AnalogFilter(4 /*BPF*/, 1000.0f, 10.0f, pars->Pstages); cleanup(); for(int j = 0; j < FF_MAX_VOWELS; ++j) @@ -45,14 +45,14 @@ FormantFilter::FormantFilter(FilterParams *pars) } for(int i = 0; i < FF_MAX_FORMANTS; ++i) - oldformantamp[i] = 1.0; + oldformantamp[i] = 1.0f; for(int i = 0; i < numformants; ++i) { - currentformants[i].freq = 1000.0; - currentformants[i].amp = 1.0; - currentformants[i].q = 2.0; + currentformants[i].freq = 1000.0f; + currentformants[i].amp = 1.0f; + currentformants[i].q = 2.0f; } - formantslowness = pow(1.0 - (pars->Pformantslowness / 128.0), 3.0); + formantslowness = powf(1.0f - (pars->Pformantslowness / 128.0f), 3.0f); sequencesize = pars->Psequencesize; if(sequencesize == 0) @@ -60,16 +60,16 @@ FormantFilter::FormantFilter(FilterParams *pars) for(int k = 0; k < sequencesize; ++k) sequence[k].nvowel = pars->Psequence[k].nvowel; - vowelclearness = pow(10.0, (pars->Pvowelclearness - 32.0) / 48.0); + vowelclearness = powf(10.0f, (pars->Pvowelclearness - 32.0f) / 48.0f); - sequencestretch = pow(0.1, (pars->Psequencestretch - 32.0) / 48.0); + sequencestretch = powf(0.1f, (pars->Psequencestretch - 32.0f) / 48.0f); if(pars->Psequencereversed) - sequencestretch *= -1.0; + sequencestretch *= -1.0f; outgain = dB2rap(pars->getgain()); - oldinput = -1.0; - Qfactor = 1.0; + oldinput = -1.0f; + Qfactor = 1.0f; oldQfactor = Qfactor; firsttime = 1; } @@ -94,10 +94,10 @@ void FormantFilter::setpos(float input) slowinput = input; else slowinput = slowinput - * (1.0 - formantslowness) + input * formantslowness; + * (1.0f - formantslowness) + input * formantslowness; - if((fabs(oldinput - input) < 0.001) && (fabs(slowinput - input) < 0.001) - && (fabs(Qfactor - oldQfactor) < 0.001)) { + if((fabs(oldinput - input) < 0.001f) && (fabs(slowinput - input) < 0.001f) + && (fabs(Qfactor - oldQfactor) < 0.001f)) { // oldinput=input; daca setez asta, o sa faca probleme la schimbari foarte lente firsttime = 0; return; @@ -106,24 +106,24 @@ void FormantFilter::setpos(float input) oldinput = input; - float pos = fmod(input * sequencestretch, 1.0); - if(pos < 0.0) - pos += 1.0; + float pos = fmod(input * sequencestretch, 1.0f); + if(pos < 0.0f) + pos += 1.0f; F2I(pos * sequencesize, p2); p1 = p2 - 1; if(p1 < 0) p1 += sequencesize; - pos = fmod(pos * sequencesize, 1.0); - if(pos < 0.0) - pos = 0.0; + pos = fmod(pos * sequencesize, 1.0f); + if(pos < 0.0f) + pos = 0.0f; else - if(pos > 1.0) - pos = 1.0; + if(pos > 1.0f) + pos = 1.0f; pos = - (atan((pos * 2.0 - - 1.0) * vowelclearness) / atan(vowelclearness) + 1.0) * 0.5; + (atanf((pos * 2.0f + - 1.0f) * vowelclearness) / atanf(vowelclearness) + 1.0f) * 0.5f; p1 = sequence[p1].nvowel; p2 = sequence[p2].nvowel; @@ -131,13 +131,13 @@ void FormantFilter::setpos(float input) if(firsttime != 0) { for(int i = 0; i < numformants; ++i) { currentformants[i].freq = formantpar[p1][i].freq - * (1.0 + * (1.0f - pos) + formantpar[p2][i].freq * pos; currentformants[i].amp = formantpar[p1][i].amp - * (1.0 + * (1.0f - pos) + formantpar[p2][i].amp * pos; currentformants[i].q = formantpar[p1][i].q - * (1.0 - pos) + formantpar[p2][i].q * pos; + * (1.0f - pos) + formantpar[p2][i].q * pos; formant[i]->setfreq_and_q(currentformants[i].freq, currentformants[i].q * Qfactor); oldformantamp[i] = currentformants[i].amp; @@ -147,23 +147,23 @@ void FormantFilter::setpos(float input) else { for(int i = 0; i < numformants; ++i) { currentformants[i].freq = currentformants[i].freq - * (1.0 - formantslowness) + * (1.0f - formantslowness) + (formantpar[p1][i].freq - * (1.0 + * (1.0f - pos) + formantpar[p2][i].freq * pos) * formantslowness; currentformants[i].amp = currentformants[i].amp - * (1.0 - formantslowness) + * (1.0f - formantslowness) + (formantpar[p1][i].amp - * (1.0 + * (1.0f - pos) + formantpar[p2][i].amp * pos) * formantslowness; currentformants[i].q = currentformants[i].q - * (1.0 - formantslowness) + * (1.0f - formantslowness) + (formantpar[p1][i].q - * (1.0 + * (1.0f - pos) + formantpar[p2][i].q * pos) * formantslowness; @@ -192,13 +192,13 @@ void FormantFilter::setgain(float /*dBgain*/) inline float log_2(float x) { - return log(x)/log(2.0); + return logf(x)/logf(2.0f); } void FormantFilter::setfreq_and_q(float frequency, float q_) { //Convert form real freq[Hz] - const float freq = log_2(frequency) - 9.96578428; //log2(1000)=9.95748. + const float freq = log_2(frequency) - 9.96578428f; //log2(1000)=9.95748f. Qfactor = q_; setpos(freq); diff --git a/src/DSP/SVFilter.cpp b/src/DSP/SVFilter.cpp @@ -38,8 +38,8 @@ SVFilter::SVFilter(unsigned char Ftype, type = Ftype; freq = Ffreq; q = Fq; - gain = 1.0; - outgain = 1.0; + gain = 1.0f; + outgain = 1.0f; needsinterpolation = false; firsttime = true; if(stages >= MAX_FILTER_STAGES) @@ -54,10 +54,10 @@ SVFilter::~SVFilter() void SVFilter::cleanup() { for(int i = 0; i < MAX_FILTER_STAGES + 1; ++i) { - st[i].low = 0.0; - st[i].high = 0.0; - st[i].band = 0.0; - st[i].notch = 0.0; + st[i].low = 0.0f; + st[i].high = 0.0f; + st[i].band = 0.0f; + st[i].notch = 0.0f; } oldabovenq = false; abovenq = false; @@ -65,30 +65,30 @@ void SVFilter::cleanup() void SVFilter::computefiltercoefs() { - par.f = freq / SAMPLE_RATE * 4.0; - if(par.f > 0.99999) - par.f = 0.99999; - par.q = 1.0 - atan(sqrt(q)) * 2.0 / PI; - par.q = pow(par.q, 1.0 / (stages + 1)); + par.f = freq / SAMPLE_RATE * 4.0f; + if(par.f > 0.99999f) + par.f = 0.99999f; + par.q = 1.0f - atanf(sqrt(q)) * 2.0f / PI; + par.q = powf(par.q, 1.0f / (stages + 1)); par.q_sqrt = sqrt(par.q); } void SVFilter::setfreq(float frequency) { - if(frequency < 0.1) - frequency = 0.1; + if(frequency < 0.1f) + frequency = 0.1f; float rap = freq / frequency; - if(rap < 1.0) - rap = 1.0 / rap; + if(rap < 1.0f) + rap = 1.0f / rap; oldabovenq = abovenq; - abovenq = frequency > (SAMPLE_RATE / 2 - 500.0); + abovenq = frequency > (SAMPLE_RATE / 2 - 500.0f); bool nyquistthresh = (abovenq ^ oldabovenq); //if the frequency is changed fast, it needs interpolation - if((rap > 3.0) || nyquistthresh) {//(now, filter and coeficients backup) + if((rap > 3.0f) || nyquistthresh) {//(now, filter and coeficients backup) ipar = par; if(!firsttime) needsinterpolation = true; @@ -175,7 +175,7 @@ void SVFilter::filterout(float *smp) for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) { float x = i / (float) SOUND_BUFFER_SIZE; - smp[i] = ismp[i] * (1.0 - x) + smp[i] * x; + smp[i] = ismp[i] * (1.0f - x) + smp[i] * x; } returnTmpBuffer(ismp); needsinterpolation = false; diff --git a/src/DSP/Unison.cpp b/src/DSP/Unison.cpp @@ -30,8 +30,8 @@ Unison::Unison(int update_period_samples_, float max_delay_sec_) { max_delay = 10; delay_buffer = new float[max_delay]; delay_k = 0; - base_freq = 1.0; - unison_bandwidth_cents = 10.0; + base_freq = 1.0f; + unison_bandwidth_cents = 10.0f; ZERO_float(delay_buffer, max_delay); @@ -66,9 +66,9 @@ void Unison::set_base_frequency(float freq) { void Unison::set_bandwidth(float bandwidth) { if(bandwidth < 0) - bandwidth = 0.0; - if(bandwidth > 1200.0) - bandwidth = 1200.0; + bandwidth = 0.0f; + if(bandwidth > 1200.0f) + bandwidth = 1200.0f; printf("bandwidth %g\n", bandwidth); #warning \ @@ -84,19 +84,19 @@ void Unison::update_parameters() { / (float) update_period_samples; // printf("#%g, %g\n",increments_per_second,base_freq); for(int i = 0; i < unison_size; ++i) { - float base = pow(UNISON_FREQ_SPAN, RND * 2.0 - 1.0); + float base = powf(UNISON_FREQ_SPAN, RND * 2.0f - 1.0f); uv[i].relative_amplitude = base; float period = base / base_freq; - float m = 4.0 / (period * increments_per_second); - if(RND < 0.5) + float m = 4.0f / (period * increments_per_second); + if(RND < 0.5f) m = -m; uv[i].step = m; // printf("%g %g\n",uv[i].relative_amplitude,period); } - float max_speed = pow(2.0, unison_bandwidth_cents / 1200.0); - unison_amplitude_samples = 0.125 - * (max_speed - 1.0) * SAMPLE_RATE / base_freq; + float max_speed = powf(2.0f, unison_bandwidth_cents / 1200.0f); + unison_amplitude_samples = 0.125f + * (max_speed - 1.0f) * SAMPLE_RATE / base_freq; printf("unison_amplitude_samples %g\n", unison_amplitude_samples); #warning \ @@ -113,23 +113,23 @@ void Unison::process(int bufsize, float *inbuf, float *outbuf) { if(!outbuf) outbuf = inbuf; - float volume = 1.0 / sqrt(unison_size); - float xpos_step = 1.0 / (float) update_period_samples; + float volume = 1.0f / sqrt(unison_size); + float xpos_step = 1.0f / (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(); update_period_sample_k = 0; - xpos = 0.0; + xpos = 0.0f; } xpos += xpos_step; - float in = inbuf[i], out = 0.0; + float in = inbuf[i], out = 0.0f; - float sign = 1.0; + float sign = 1.0f; for(int k = 0; k < unison_size; ++k) { float vpos = uv[k].realpos1 - * (1.0 - xpos) + uv[k].realpos2 * xpos; //optimize - float pos = delay_k + max_delay - vpos - 1.0; //optimize + * (1.0f - xpos) + uv[k].realpos2 * xpos; //optimize + float pos = delay_k + max_delay - vpos - 1.0f; //optimize int posi; float posf; F2I(pos, posi); //optimize! @@ -137,7 +137,7 @@ void Unison::process(int bufsize, float *inbuf, float *outbuf) { posi -= max_delay; posf = pos - floor(pos); out += - ((1.0 + ((1.0f - posf) * delay_buffer[posi] + posf * delay_buffer[posi + 1]) * sign; sign = -sign; @@ -158,22 +158,22 @@ void Unison::update_unison_data() { float pos = uv[k].position; float step = uv[k].step; pos += step; - if(pos <= -1.0) { - pos = -1.0; + if(pos <= -1.0f) { + pos = -1.0f; step = -step; } - if(pos >= 1.0) { - pos = 1.0; + if(pos >= 1.0f) { + pos = 1.0f; step = -step; } - float vibratto_val = (pos - 0.333333333 * pos * pos * pos) * 1.5; //make the vibratto lfo smoother + float vibratto_val = (pos - 0.333333333f * pos * pos * pos) * 1.5f; //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 - float newval = 1.0 + 0.5 + float newval = 1.0f + 0.5f * (vibratto_val - + 1.0) * unison_amplitude_samples + + 1.0f) * unison_amplitude_samples * uv[k].relative_amplitude; if(first_time) diff --git a/src/DSP/Unison.h b/src/DSP/Unison.h @@ -24,8 +24,8 @@ #include <stdlib.h> #include "../globals.h" -#define UNISON_FREQ_SPAN 2.0 -//how much the unison frequencies varies (always >= 1.0) +#define UNISON_FREQ_SPAN 2.0f +//how much the unison frequencies varies (always >= 1.0f) class Unison { @@ -51,11 +51,11 @@ class Unison float relative_amplitude; float lin_fpos, lin_ffreq; UnisonVoice() { - position = RND * 1.8 - 0.9; - realpos1 = 0.0; - realpos2 = 0.0; - step = 0.0; - relative_amplitude = 1.0; + position = RND * 1.8f - 0.9f; + realpos1 = 0.0f; + realpos2 = 0.0f; + step = 0.0f; + relative_amplitude = 1.0f; } } *uv; int update_period_samples, update_period_sample_k; diff --git a/src/Effects/Alienwah.cpp b/src/Effects/Alienwah.cpp @@ -30,8 +30,8 @@ Alienwah::Alienwah(const int &insertion_, { setpreset(Ppreset); cleanup(); - oldclfol = complex<float>(fb, 0.0); - oldclfor = complex<float>(fb, 0.0); + oldclfol = complex<float>(fb, 0.0f); + oldclfor = complex<float>(fb, 0.0f); } Alienwah::~Alienwah() @@ -55,14 +55,14 @@ void Alienwah::out(const Stereo<float *> &smp) * 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<float>(cos(lfol + phase) * fb, sin(lfol + phase) * fb); //rework - clfor = complex<float>(cos(lfor + phase) * fb, sin(lfor + phase) * fb); //rework + lfol *= depth * PI * 2.0f; + lfor *= depth * PI * 2.0f; + clfol = complex<float>(cosf(lfol + phase) * fb, sinf(lfol + phase) * fb); //rework + clfor = complex<float>(cosf(lfor + phase) * fb, sinf(lfor + phase) * fb); //rework for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) { float x = ((float) i) / SOUND_BUFFER_SIZE; - float x1 = 1.0 - x; + float x1 = 1.0f - x; //left complex<float> tmp = clfol * x + oldclfol * x1; @@ -70,7 +70,7 @@ void Alienwah::out(const Stereo<float *> &smp) out.real() += (1 - fabs(fb)) * smp.l[i] * pangainL; oldl[oldk] = out; - float l = out.real() * 10.0 * (fb + 0.1); + float l = out.real() * 10.0f * (fb + 0.1f); //right tmp = clfor * x + oldclfor * x1; @@ -79,14 +79,14 @@ void Alienwah::out(const Stereo<float *> &smp) out.real() += (1 - fabs(fb)) * smp.r[i] * pangainR; oldr[oldk] = out; - float r = out.real() * 10.0 * (fb + 0.1); + float r = out.real() * 10.0f * (fb + 0.1f); if(++oldk >= Pdelay) oldk = 0; //LRcross - efxoutl[i] = l * (1.0 - lrcross) + r * lrcross; - efxoutr[i] = r * (1.0 - lrcross) + l * lrcross; + efxoutl[i] = l * (1.0f - lrcross) + r * lrcross; + efxoutr[i] = r * (1.0f - lrcross) + l * lrcross; } oldclfol = clfol; @@ -99,8 +99,8 @@ void Alienwah::out(const Stereo<float *> &smp) void Alienwah::cleanup() { for(int i = 0; i < Pdelay; ++i) { - oldl[i] = complex<float>(0.0, 0.0); - oldr[i] = complex<float>(0.0, 0.0); + oldl[i] = complex<float>(0.0f, 0.0f); + oldr[i] = complex<float>(0.0f, 0.0f); } oldk = 0; } @@ -113,16 +113,16 @@ void Alienwah::cleanup() void Alienwah::setdepth(unsigned char Pdepth) { this->Pdepth = Pdepth; - depth = (Pdepth / 127.0); + depth = (Pdepth / 127.0f); } void Alienwah::setfb(unsigned char Pfb) { this->Pfb = Pfb; - fb = fabs((Pfb - 64.0) / 64.1); + fb = fabs((Pfb - 64.0f) / 64.1f); fb = sqrt(fb); - if(fb < 0.4) - fb = 0.4; + if(fb < 0.4f) + fb = 0.4f; if(Pfb < 64) fb = -fb; } @@ -130,9 +130,9 @@ void Alienwah::setfb(unsigned char Pfb) void Alienwah::setvolume(unsigned char Pvolume) { this->Pvolume = Pvolume; - outvolume = Pvolume / 127.0; + outvolume = Pvolume / 127.0f; if(insertion == 0) - volume = 1.0; + volume = 1.0f; else volume = outvolume; } @@ -140,7 +140,7 @@ void Alienwah::setvolume(unsigned char Pvolume) void Alienwah::setphase(unsigned char Pphase) { this->Pphase = Pphase; - phase = (Pphase - 64.0) / 64.0 * PI; + phase = (Pphase - 64.0f) / 64.0f * PI; } void Alienwah::setdelay(unsigned char Pdelay) diff --git a/src/Effects/Chorus.cpp b/src/Effects/Chorus.cpp @@ -30,7 +30,7 @@ Chorus::Chorus(const int &insertion_, float *const efxoutl_, float *const efxoutr_) :Effect(insertion_, efxoutl_, efxoutr_, NULL, 0), - maxdelay((int)(MAX_CHORUS_DELAY / 1000.0 * SAMPLE_RATE)), + maxdelay((int)(MAX_CHORUS_DELAY / 1000.0f * SAMPLE_RATE)), delaySample(maxdelay) { dlk = 0; @@ -59,18 +59,18 @@ float Chorus::getdelay(float xlfo) //check if it is too big delay(caused bu errornous setdelay() and setdepth() /**\todo fix setdelay() and setdepth(), so this error cannot occur*/ - if((result + 0.5) >= maxdelay) { + if((result + 0.5f) >= maxdelay) { cerr << "WARNING: Chorus.cpp::getdelay(..) too big delay (see setdelay and setdepth funcs.)\n"; - result = maxdelay - 1.0; + result = maxdelay - 1.0f; } return result; } void Chorus::out(const Stereo<float *> &input) { - const float one = 1.0; + const float one = 1.0f; dl1 = dl2; dr1 = dr2; lfo.effectlfoout(&lfol, &lfor); @@ -84,8 +84,8 @@ void Chorus::out(const Stereo<float *> &input) float inr = input.r[i]; //LRcross Stereo<float> tmpc(inl, inr); - inl = tmpc.l * (1.0 - lrcross) + tmpc.r * lrcross; - inr = tmpc.r * (1.0 - lrcross) + tmpc.l * lrcross; + inl = tmpc.l * (1.0f - lrcross) + tmpc.r * lrcross; + inr = tmpc.r * (1.0f - lrcross) + tmpc.l * lrcross; //Left channel @@ -93,15 +93,15 @@ void Chorus::out(const Stereo<float *> &input) mdel = (dl1 * (SOUND_BUFFER_SIZE - i) + dl2 * i) / SOUND_BUFFER_SIZE; if(++dlk >= maxdelay) dlk = 0; - float tmp = dlk - mdel + maxdelay * 2.0; //where should I get the sample from + float tmp = dlk - mdel + maxdelay * 2.0f; //where should I get the sample from F2I(tmp, dlhi); dlhi %= maxdelay; dlhi2 = (dlhi - 1 + maxdelay) % maxdelay; - dllo = 1.0 - fmod(tmp, one); + dllo = 1.0f - fmod(tmp, one); efxoutl[i] = delaySample.l[dlhi2] * dllo + delaySample.l[dlhi] - * (1.0 - dllo); + * (1.0f - dllo); delaySample.l[dlk] = inl + efxoutl[i] * fb; //Right channel @@ -110,22 +110,22 @@ void Chorus::out(const Stereo<float *> &input) mdel = (dr1 * (SOUND_BUFFER_SIZE - i) + dr2 * i) / SOUND_BUFFER_SIZE; if(++drk >= maxdelay) drk = 0; - tmp = drk * 1.0 - mdel + maxdelay * 2.0; //where should I get the sample from + tmp = drk * 1.0f - mdel + maxdelay * 2.0f; //where should I get the sample from F2I(tmp, dlhi); dlhi %= maxdelay; dlhi2 = (dlhi - 1 + maxdelay) % maxdelay; - dllo = 1.0 - fmod(tmp, one); + dllo = 1.0f - fmod(tmp, one); efxoutr[i] = delaySample.r[dlhi2] * dllo + delaySample.r[dlhi] - * (1.0 - dllo); + * (1.0f - dllo); delaySample.r[dlk] = inr + efxoutr[i] * fb; } if(Poutsub != 0) for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) { - efxoutl[i] *= -1.0; - efxoutr[i] *= -1.0; + efxoutl[i] *= -1.0f; + efxoutr[i] *= -1.0f; } for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) { @@ -149,26 +149,26 @@ void Chorus::cleanup() void Chorus::setdepth(unsigned char Pdepth) { this->Pdepth = Pdepth; - depth = (pow(8.0, (Pdepth / 127.0) * 2.0) - 1.0) / 1000.0; //seconds + depth = (powf(8.0f, (Pdepth / 127.0f) * 2.0f) - 1.0f) / 1000.0f; //seconds } void Chorus::setdelay(unsigned char Pdelay) { this->Pdelay = Pdelay; - delay = (pow(10.0, (Pdelay / 127.0) * 2.0) - 1.0) / 1000.0; //seconds + delay = (powf(10.0f, (Pdelay / 127.0f) * 2.0f) - 1.0f) / 1000.0f; //seconds } void Chorus::setfb(unsigned char Pfb) { this->Pfb = Pfb; - fb = (Pfb - 64.0) / 64.1; + fb = (Pfb - 64.0f) / 64.1f; } void Chorus::setvolume(unsigned char Pvolume) { this->Pvolume = Pvolume; - outvolume = Pvolume / 127.0; + outvolume = Pvolume / 127.0f; if(insertion == 0) - volume = 1.0; + volume = 1.0f; else volume = outvolume; } diff --git a/src/Effects/Chorus.h b/src/Effects/Chorus.h @@ -28,7 +28,7 @@ #include "../Samples/Sample.h" #include "../Misc/Stereo.h" -#define MAX_CHORUS_DELAY 250.0 //ms +#define MAX_CHORUS_DELAY 250.0f //ms /**Chorus and Flange effects*/ class Chorus:public Effect diff --git a/src/Effects/Distorsion.cpp b/src/Effects/Distorsion.cpp @@ -94,9 +94,9 @@ void Distorsion::out(const Stereo<float *> &smp) int i; float l, r, lout, rout; - float inputvol = pow(5.0, (Pdrive - 32.0) / 127.0); + float inputvol = powf(5.0f, (Pdrive - 32.0f) / 127.0f); if(Pnegate != 0) - inputvol *= -1.0; + inputvol *= -1.0f; if(Pstereo != 0) { //Stereo for(i = 0; i < SOUND_BUFFER_SIZE; ++i) { @@ -124,17 +124,17 @@ void Distorsion::out(const Stereo<float *> &smp) for(i = 0; i < SOUND_BUFFER_SIZE; ++i) efxoutr[i] = efxoutl[i]; - float level = dB2rap(60.0 * Plevel / 127.0 - 40.0); + float level = dB2rap(60.0f * Plevel / 127.0f - 40.0f); for(i = 0; i < SOUND_BUFFER_SIZE; ++i) { lout = efxoutl[i]; rout = efxoutr[i]; - l = lout * (1.0 - lrcross) + rout * lrcross; - r = rout * (1.0 - lrcross) + lout * lrcross; + l = lout * (1.0f - lrcross) + rout * lrcross; + r = rout * (1.0f - lrcross) + lout * lrcross; lout = l; rout = r; - efxoutl[i] = lout * 2.0 * level; - efxoutr[i] = rout * 2.0 * level; + efxoutl[i] = lout * 2.0f * level; + efxoutr[i] = rout * 2.0f * level; } } @@ -147,11 +147,11 @@ void Distorsion::setvolume(unsigned char Pvolume) this->Pvolume = Pvolume; if(insertion == 0) { - outvolume = pow(0.01, (1.0 - Pvolume / 127.0)) * 4.0; - volume = 1.0; + outvolume = powf(0.01f, (1.0f - Pvolume / 127.0f)) * 4.0f; + volume = 1.0f; } else - volume = outvolume = Pvolume / 127.0; + volume = outvolume = Pvolume / 127.0f; ; if(Pvolume == 0) cleanup(); @@ -160,7 +160,7 @@ void Distorsion::setvolume(unsigned char Pvolume) void Distorsion::setlpf(unsigned char Plpf) { this->Plpf = Plpf; - float fr = exp(pow(Plpf / 127.0, 0.5) * log(25000.0)) + 40; + float fr = expf(powf(Plpf / 127.0f, 0.5f) * logf(25000.0f)) + 40; lpfl->setfreq(fr); lpfr->setfreq(fr); } @@ -168,7 +168,7 @@ void Distorsion::setlpf(unsigned char Plpf) void Distorsion::sethpf(unsigned char Phpf) { this->Phpf = Phpf; - float fr = exp(pow(Phpf / 127.0, 0.5) * log(25000.0)) + 20.0; + float fr = expf(powf(Phpf / 127.0f, 0.5f) * logf(25000.0f)) + 20.0f; hpfl->setfreq(fr); hpfr->setfreq(fr); } @@ -199,7 +199,7 @@ void Distorsion::setpreset(unsigned char npreset) for(int n = 0; n < PRESET_SIZE; ++n) changepar(n, presets[npreset][n]); if(insertion == 0) - changepar(0, (int) (presets[npreset][0] / 1.5)); //lower the volume if this is system effect + changepar(0, (int) (presets[npreset][0] / 1.5f)); //lower the volume if this is system effect Ppreset = npreset; cleanup(); } diff --git a/src/Effects/DynamicFilter.cpp b/src/Effects/DynamicFilter.cpp @@ -56,8 +56,8 @@ void DynamicFilter::out(const Stereo<float *> &smp) float lfol, lfor; lfo.effectlfoout(&lfol, &lfor); - lfol *= depth * 5.0; - lfor *= depth * 5.0; + lfol *= depth * 5.0f; + lfor *= depth * 5.0f; const float freq = filterpars->getfreq(); const float q = filterpars->getq(); @@ -65,14 +65,14 @@ void DynamicFilter::out(const Stereo<float *> &smp) efxoutl[i] = smp.l[i]; efxoutr[i] = smp.r[i]; - const float x = (fabs(smp.l[i]) + fabs(smp.l[i])) * 0.5; - ms1 = ms1 * (1.0 - ampsmooth) + x * ampsmooth + 1e-10; + const float x = (fabs(smp.l[i]) + fabs(smp.l[i])) * 0.5f; + ms1 = ms1 * (1.0f - ampsmooth) + x * ampsmooth + 1e-10; } - 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 float ampsmooth2 = powf(ampsmooth, 0.2f) * 0.3f; + ms2 = ms2 * (1.0f - ampsmooth2) + ms1 * ampsmooth2; + ms3 = ms3 * (1.0f - ampsmooth2) + ms2 * ampsmooth2; + ms4 = ms4 * (1.0f - ampsmooth2) + ms3 * ampsmooth2; const float rms = (sqrt(ms4)) * ampsns; const float frl = Filter::getrealfreq(freq + lfol + rms); @@ -98,10 +98,10 @@ void DynamicFilter::out(const Stereo<float *> &smp) void DynamicFilter::cleanup() { reinitfilter(); - ms1 = 0.0; - ms2 = 0.0; - ms3 = 0.0; - ms4 = 0.0; + ms1 = 0.0f; + ms2 = 0.0f; + ms3 = 0.0f; + ms4 = 0.0f; } @@ -112,26 +112,26 @@ void DynamicFilter::cleanup() void DynamicFilter::setdepth(unsigned char Pdepth) { this->Pdepth = Pdepth; - depth = pow((Pdepth / 127.0), 2.0); + depth = powf((Pdepth / 127.0f), 2.0f); } void DynamicFilter::setvolume(unsigned char Pvolume) { this->Pvolume = Pvolume; - outvolume = Pvolume / 127.0; + outvolume = Pvolume / 127.0f; if(insertion == 0) - volume = 1.0; + volume = 1.0f; else volume = outvolume; } void DynamicFilter::setampsns(unsigned char Pampsns) { - ampsns = pow(Pampsns / 127.0, 2.5) * 10.0; + ampsns = powf(Pampsns / 127.0f, 2.5f) * 10.0f; if(Pampsnsinv != 0) ampsns = -ampsns; - ampsmooth = exp(-Pampsmooth / 127.0 * 10.0) * 0.99; + ampsmooth = expf(-Pampsmooth / 127.0f * 10.0f) * 0.99f; this->Pampsns = Pampsns; } diff --git a/src/Effects/EQ.cpp b/src/Effects/EQ.cpp @@ -33,8 +33,8 @@ EQ::EQ(const int &insertion_, float *efxoutl_, float *efxoutr_) filter[i].Pgain = 64; filter[i].Pq = 64; filter[i].Pstages = 0; - filter[i].l = new AnalogFilter(6, 1000.0, 1.0, 0); - filter[i].r = new AnalogFilter(6, 1000.0, 1.0, 0); + filter[i].l = new AnalogFilter(6, 1000.0f, 1.0f, 0); + filter[i].r = new AnalogFilter(6, 1000.0f, 1.0f, 0); } //default values Pvolume = 50; @@ -78,9 +78,9 @@ void EQ::setvolume(unsigned char Pvolume) { this->Pvolume = Pvolume; - outvolume = pow(0.005, (1.0 - Pvolume / 127.0)) * 10.0; + outvolume = powf(0.005f, (1.0f - Pvolume / 127.0f)) * 10.0f; if(insertion == 0) - volume = 1.0; + volume = 1.0f; else volume = outvolume; ; @@ -134,19 +134,19 @@ void EQ::changepar(int npar, unsigned char value) break; case 1: filter[nb].Pfreq = value; - tmp = 600.0 * pow(30.0, (value - 64.0) / 64.0); + tmp = 600.0f * powf(30.0f, (value - 64.0f) / 64.0f); filter[nb].l->setfreq(tmp); filter[nb].r->setfreq(tmp); break; case 2: filter[nb].Pgain = value; - tmp = 30.0 * (value - 64.0) / 64.0; + tmp = 30.0f * (value - 64.0f) / 64.0f; filter[nb].l->setgain(tmp); filter[nb].r->setgain(tmp); break; case 3: filter[nb].Pq = value; - tmp = pow(30.0, (value - 64.0) / 64.0); + tmp = powf(30.0f, (value - 64.0f) / 64.0f); filter[nb].l->setq(tmp); filter[nb].r->setq(tmp); break; @@ -201,7 +201,7 @@ unsigned char EQ::getpar(int npar) const float EQ::getfreqresponse(float freq) { - float resp = 1.0; + float resp = 1.0f; for(int i = 0; i < MAX_EQ_BANDS; ++i) { if(filter[i].Ptype == 0) diff --git a/src/Effects/Echo.cpp b/src/Effects/Echo.cpp @@ -36,7 +36,7 @@ Echo::Echo(const int &insertion_, delayTime(1), lrdelay(0), avgDelay(0), delay(new float[(int)(MAX_DELAY * SAMPLE_RATE)], new float[(int)(MAX_DELAY * SAMPLE_RATE)]), - old(0.0), pos(0), delta(1), ndelta(1) + old(0.0f), pos(0), delta(1), ndelta(1) { initdelays(); setpreset(Ppreset); @@ -55,7 +55,7 @@ void Echo::cleanup() { 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); + old = Stereo<float>(0.0f); } inline int max(int a, int b) @@ -86,18 +86,18 @@ void Echo::out(const Stereo<float *> &input) for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) { ldl = delay.l[pos.l]; rdl = delay.r[pos.r]; - ldl = ldl * (1.0 - lrcross) + rdl * lrcross; - rdl = rdl * (1.0 - lrcross) + ldl * lrcross; + ldl = ldl * (1.0f - lrcross) + rdl * lrcross; + rdl = rdl * (1.0f - lrcross) + ldl * lrcross; - efxoutl[i] = ldl * 2.0; - efxoutr[i] = rdl * 2.0; + efxoutl[i] = ldl * 2.0f; + efxoutr[i] = rdl * 2.0f; ldl = input.l[i] * pangainL - ldl * fb; rdl = input.r[i] * pangainR - rdl * fb; //LowPass Filter - old.l = delay.l[(pos.l+delta.l)%(MAX_DELAY * SAMPLE_RATE)] = ldl * hidamp + old.l * (1.0 - hidamp); - old.r = delay.r[(pos.r+delta.r)%(MAX_DELAY * SAMPLE_RATE)] = rdl * hidamp + old.r * (1.0 - hidamp); + old.l = delay.l[(pos.l+delta.l)%(MAX_DELAY * SAMPLE_RATE)] = ldl * hidamp + old.l * (1.0f - hidamp); + old.r = delay.r[(pos.r+delta.r)%(MAX_DELAY * SAMPLE_RATE)] = rdl * hidamp + old.r * (1.0f - hidamp); //increment ++pos.l;// += delta.l; @@ -122,11 +122,11 @@ void Echo::setvolume(unsigned char Pvolume) this->Pvolume = Pvolume; if(insertion == 0) { - outvolume = pow(0.01, (1.0 - Pvolume / 127.0)) * 4.0; - volume = 1.0; + outvolume = powf(0.01f, (1.0f - Pvolume / 127.0f)) * 4.0f; + volume = 1.0f; } else - volume = outvolume = Pvolume / 127.0; + volume = outvolume = Pvolume / 127.0f; if(Pvolume == 0) cleanup(); } @@ -134,7 +134,7 @@ void Echo::setvolume(unsigned char Pvolume) void Echo::setdelay(unsigned char Pdelay) { this->Pdelay=Pdelay; - avgDelay=(Pdelay/127.0*1.5);//0 .. 1.5 sec + avgDelay=(Pdelay/127.0f*1.5f);//0 .. 1.5f sec initdelays(); } @@ -143,8 +143,8 @@ void Echo::setlrdelay(unsigned char Plrdelay) float tmp; this->Plrdelay = Plrdelay; tmp = - (pow(2, fabs(Plrdelay - 64.0) / 64.0 * 9) - 1.0) / 1000.0; - if(Plrdelay < 64.0) + (powf(2, fabs(Plrdelay - 64.0f) / 64.0f * 9) - 1.0f) / 1000.0f; + if(Plrdelay < 64.0f) tmp = -tmp; lrdelay = tmp; initdelays(); @@ -153,13 +153,13 @@ void Echo::setlrdelay(unsigned char Plrdelay) void Echo::setfb(unsigned char Pfb) { this->Pfb = Pfb; - fb = Pfb / 128.0; + fb = Pfb / 128.0f; } void Echo::sethidamp(unsigned char Phidamp) { this->Phidamp = Phidamp; - hidamp = 1.0 - Phidamp / 127.0; + hidamp = 1.0f - Phidamp / 127.0f; } void Echo::setpreset(unsigned char npreset) diff --git a/src/Effects/Effect.cpp b/src/Effects/Effect.cpp @@ -41,16 +41,16 @@ void Effect::crossover(float &a, float &b, float crossover) { float tmpa = a; float tmpb = b; - a = tmpa * (1.0 - crossover) + tmpb * crossover; - b = tmpb * (1.0 - crossover) + tmpa * crossover; + a = tmpa * (1.0f - crossover) + tmpb * crossover; + b = tmpb * (1.0f - crossover) + tmpa * crossover; } void Effect::setpanning(char Ppanning_) { Ppanning = Ppanning_; float t = (Ppanning > 0) ? (float)(Ppanning - 1) / 126.0f : 0.0f; - pangainL = cos(t * PI / 2.0f); - pangainR = cos((1.0f - t) * PI / 2.0f); + pangainL = cosf(t * PI / 2.0f); + pangainR = cosf((1.0f - t) * PI / 2.0f); } void Effect::setlrcross(char Plrcross_) diff --git a/src/Effects/Effect.h b/src/Effects/Effect.h @@ -89,7 +89,7 @@ class Effect 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 + * The out volume of such effects are always 1.0f, so * this setting tells me how is the volume to the * Master Output only.*/ diff --git a/src/Effects/EffectLFO.cpp b/src/Effects/EffectLFO.cpp @@ -28,8 +28,8 @@ EffectLFO::EffectLFO() { - xl = 0.0; - xr = 0.0; + xl = 0.0f; + xr = 0.0f; Pfreq = 40; Prandomness = 0; PLFOtype = 0; @@ -52,23 +52,23 @@ EffectLFO::~EffectLFO() */ void EffectLFO::updateparams() { - float lfofreq = (pow(2, Pfreq / 127.0 * 10.0) - 1.0) * 0.03; + float lfofreq = (powf(2, Pfreq / 127.0f * 10.0f) - 1.0f) * 0.03f; incx = fabs(lfofreq) * (float)SOUND_BUFFER_SIZE / (float)SAMPLE_RATE; - if(incx > 0.49999999) - incx = 0.499999999; //Limit the Frequency + if(incx > 0.49999999f) + incx = 0.499999999f; //Limit the Frequency - lfornd = Prandomness / 127.0; - if(lfornd < 0.0) - lfornd = 0.0; + lfornd = Prandomness / 127.0f; + if(lfornd < 0.0f) + lfornd = 0.0f; else - if(lfornd > 1.0) - lfornd = 1.0; + if(lfornd > 1.0f) + lfornd = 1.0f; if(PLFOtype > 1) PLFOtype = 1; //this has to be updated if more lfo's are added lfotype = PLFOtype; - xr = fmod(xl + (Pstereo - 64.0) / 127.0 + 1.0, 1.0); + xr = fmod(xl + (Pstereo - 64.0f) / 127.0f + 1.0f, 1.0f); } @@ -80,17 +80,17 @@ float EffectLFO::getlfoshape(float x) float out; switch(lfotype) { case 1: //EffectLFO_TRIANGLE - if((x > 0.0) && (x < 0.25)) - out = 4.0 * x; + if((x > 0.0f) && (x < 0.25f)) + out = 4.0f * x; else - if((x > 0.25) && (x < 0.75)) + if((x > 0.25f) && (x < 0.75f)) out = 2 - 4 * x; else - out = 4.0 * x - 4.0; + out = 4.0f * x - 4.0f; break; /**\todo more to be added here; also ::updateparams() need to be updated (to allow more lfotypes)*/ default: - out = cos(x * 2 * PI); //EffectLFO_SINE + out = cosf(x * 2 * PI); //EffectLFO_SINE } return out; } @@ -106,22 +106,22 @@ void EffectLFO::effectlfoout(float *outl, float *outr) if((lfotype == 0) || (lfotype == 1)) out *= (ampl1 + xl * (ampl2 - ampl1)); xl += incx; - if(xl > 1.0) { - xl -= 1.0; + if(xl > 1.0f) { + xl -= 1.0f; ampl1 = ampl2; - ampl2 = (1.0 - lfornd) + lfornd * RND; + ampl2 = (1.0f - lfornd) + lfornd * RND; } - *outl = (out + 1.0) * 0.5; + *outl = (out + 1.0f) * 0.5f; out = getlfoshape(xr); if((lfotype == 0) || (lfotype == 1)) out *= (ampr1 + xr * (ampr2 - ampr1)); xr += incx; - if(xr > 1.0) { - xr -= 1.0; + if(xr > 1.0f) { + xr -= 1.0f; ampr1 = ampr2; - ampr2 = (1.0 - lfornd) + lfornd * RND; + ampr2 = (1.0f - lfornd) + lfornd * RND; } - *outr = (out + 1.0) * 0.5; + *outr = (out + 1.0f) * 0.5f; } diff --git a/src/Effects/EffectMgr.cpp b/src/Effects/EffectMgr.cpp @@ -49,8 +49,8 @@ EffectMgr::EffectMgr(int insertion_, pthread_mutex_t *mutex_) // 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; + efxoutl[i] = 0.0f; + efxoutr[i] = 0.0f; } // filterpars=NULL; // dryonly=false; @@ -82,8 +82,8 @@ void EffectMgr::changeeffect(int nefx_) return; nefx = nefx_; for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) { - efxoutl[i] = 0.0; - efxoutr[i] = 0.0; + efxoutl[i] = 0.0f; + efxoutr[i] = 0.0f; } if(efx != NULL) @@ -213,10 +213,10 @@ void EffectMgr::out(float *smpsl, float *smpsr) if(efx == NULL) { if(insertion == 0) for(i = 0; i < SOUND_BUFFER_SIZE; ++i) { - smpsl[i] = 0.0; - smpsr[i] = 0.0; - efxoutl[i] = 0.0; - efxoutr[i] = 0.0; + smpsl[i] = 0.0f; + smpsr[i] = 0.0f; + efxoutl[i] = 0.0f; + efxoutr[i] = 0.0f; } ; return; @@ -224,8 +224,8 @@ void EffectMgr::out(float *smpsl, float *smpsr) for(i = 0; i < SOUND_BUFFER_SIZE; ++i) { smpsl[i] += denormalkillbuf[i]; smpsr[i] += denormalkillbuf[i]; - efxoutl[i] = 0.0; - efxoutr[i] = 0.0; + efxoutl[i] = 0.0f; + efxoutr[i] = 0.0f; } efx->out(smpsl, smpsr); @@ -243,13 +243,13 @@ void EffectMgr::out(float *smpsl, float *smpsr) //Insertion effect if(insertion != 0) { float v1, v2; - if(volume < 0.5) { - v1 = 1.0; - v2 = volume * 2.0; + if(volume < 0.5f) { + v1 = 1.0f; + v2 = volume * 2.0f; } else { - v1 = (1.0 - volume) * 2.0; - v2 = 1.0; + v1 = (1.0f - volume) * 2.0f; + v2 = 1.0f; } if((nefx == 1) || (nefx == 2)) v2 *= v2; //for Reverb and Echo, the wet function is not liniar @@ -271,8 +271,8 @@ void EffectMgr::out(float *smpsl, float *smpsr) } else { //System effect for(i = 0; i < SOUND_BUFFER_SIZE; ++i) { - efxoutl[i] *= 2.0 * volume; - efxoutr[i] *= 2.0 * volume; + efxoutl[i] *= 2.0f * volume; + efxoutr[i] *= 2.0f * volume; smpsl[i] = efxoutl[i]; smpsr[i] = efxoutr[i]; } @@ -285,7 +285,7 @@ void EffectMgr::out(float *smpsl, float *smpsr) float EffectMgr::sysefxgetvolume() { if(efx == NULL) - return 1.0; + return 1.0f; else return efx->outvolume; } @@ -299,7 +299,7 @@ float EffectMgr::getEQfreqresponse(float freq) if(nefx == 7) return efx->getfreqresponse(freq); else - return 0.0; + return 0.0f; } diff --git a/src/Effects/Phaser.cpp b/src/Effects/Phaser.cpp @@ -36,12 +36,12 @@ using namespace std; #define PHASER_LFO_SHAPE 2 -#define ONE_ 0.99999f // To prevent LFO ever reaching 1.0 for filter stability purposes +#define ONE_ 0.99999f // To prevent LFO ever reaching 1.0f for filter stability purposes #define ZERO_ 0.00001f // Same idea as above. 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) + yn1(NULL), diff(0.0f), oldgain(0.0f), fb(0.0f) { analog_setup(); setpreset(Ppreset); @@ -101,7 +101,7 @@ void Phaser::out(const Stereo<float *> &input) void Phaser::AnalogPhase(const Stereo<float *> &input) { - Stereo<float> gain(0.0), lfoVal(0.0), mod(0.0), g(0.0), b(0.0), hpf(0.0); + Stereo<float> gain(0.0f), lfoVal(0.0f), mod(0.0f), g(0.0f), b(0.0f), hpf(0.0f); lfo.effectlfoout(&lfoVal.l, &lfoVal.r); mod.l = lfoVal.l*width + (depth - 0.5f); @@ -185,21 +185,21 @@ float Phaser::applyPhase(float x, float g, float fb, } void Phaser::normalPhase(const Stereo<float *> &input) { - Stereo<float> gain(0.0), lfoVal(0.0); + Stereo<float> gain(0.0f), lfoVal(0.0f); lfo.effectlfoout(&lfoVal.l, &lfoVal.r); - gain.l = (exp(lfoVal.l * PHASER_LFO_SHAPE) - 1) / (exp(PHASER_LFO_SHAPE) - 1.0); - gain.r = (exp(lfoVal.r * PHASER_LFO_SHAPE) - 1) / (exp(PHASER_LFO_SHAPE) - 1.0); + gain.l = (expf(lfoVal.l * PHASER_LFO_SHAPE) - 1) / (expf(PHASER_LFO_SHAPE) - 1.0f); + gain.r = (expf(lfoVal.r * PHASER_LFO_SHAPE) - 1) / (expf(PHASER_LFO_SHAPE) - 1.0f); - gain.l = 1.0 - phase * (1.0 - depth) - (1.0 - phase) * gain.l * depth; - gain.r = 1.0 - phase * (1.0 - depth) - (1.0 - phase) * gain.r * depth; + gain.l = 1.0f - phase * (1.0f - depth) - (1.0f - phase) * gain.l * depth; + gain.r = 1.0f - phase * (1.0f - depth) - (1.0f - phase) * gain.r * depth; gain.l = limit(gain.l, ZERO_, ONE_); gain.r = limit(gain.r, ZERO_, ONE_); for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) { float x = (float) i / SOUND_BUFFER_SIZE; - float x1 = 1.0 - x; + float x1 = 1.0f - x; //TODO think about making panning an external feature Stereo<float> xn(input.l[i] * pangainL + fb.l, input.r[i] * pangainR + fb.r); @@ -242,16 +242,16 @@ float Phaser::applyPhase(float x, float g, float *old) */ void Phaser::cleanup() { - fb = oldgain = Stereo<float>(0.0); + fb = oldgain = Stereo<float>(0.0f); for(int i = 0; i < Pstages * 2; ++i) { - old.l[i] = 0.0; - old.r[i] = 0.0; + old.l[i] = 0.0f; + old.r[i] = 0.0f; } for(int i = 0; i < Pstages; ++i) { - xn1.l[i] = 0.0; - yn1.l[i] = 0.0; - xn1.r[i] = 0.0; - yn1.r[i] = 0.0; + xn1.l[i] = 0.0f; + yn1.l[i] = 0.0f; + xn1.r[i] = 0.0f; + yn1.r[i] = 0.0f; } } @@ -273,9 +273,9 @@ void Phaser::setfb(unsigned char Pfb) void Phaser::setvolume(unsigned char Pvolume) { this->Pvolume = Pvolume; - outvolume = Pvolume / 127.0; + outvolume = Pvolume / 127.0f; if(insertion == 0) - volume = 1.0; + volume = 1.0f; else volume = outvolume; } @@ -321,7 +321,7 @@ void Phaser::setstages(unsigned char Pstages) void Phaser::setphase(unsigned char Pphase) { this->Pphase = Pphase; - phase = (Pphase / 127.0); + phase = (Pphase / 127.0f); } void Phaser::setdepth(unsigned char Pdepth) diff --git a/src/Effects/Reverb.cpp b/src/Effects/Reverb.cpp @@ -45,14 +45,14 @@ Reverb::Reverb(const int &insertion_, float *efxoutl_, float *efxoutr_) Ptype = 1; Proomsize = 64; Pbandwidth = 30; - roomsize = 1.0; - rs = 1.0; + roomsize = 1.0f; + rs = 1.0f; for(int i = 0; i < REV_COMBS * 2; ++i) { comblen[i] = 800 + (int)(RND * 1400); combk[i] = 0; lpcomb[i] = 0; - combfb[i] = -0.97; + combfb[i] = -0.97f; comb[i] = NULL; } @@ -97,18 +97,18 @@ void Reverb::cleanup() { int i, j; for(i = 0; i < REV_COMBS * 2; ++i) { - lpcomb[i] = 0.0; + lpcomb[i] = 0.0f; for(j = 0; j < comblen[i]; ++j) - comb[i][j] = 0.0; + comb[i][j] = 0.0f; } for(i = 0; i < REV_APS * 2; ++i) for(j = 0; j < aplen[i]; ++j) - ap[i][j] = 0.0; + ap[i][j] = 0.0f; if(idelay != NULL) for(i = 0; i < idelaylen; ++i) - idelay[i] = 0.0; + idelay[i] = 0.0f; if(hpf != NULL) hpf->cleanup(); @@ -129,7 +129,7 @@ void Reverb::processmono(int ch, float *output, float *inputbuf) for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) { float fbout = comb[j][ck] * combfb[j]; - fbout = fbout * (1.0 - lohifb) + lpcombj * lohifb; + fbout = fbout * (1.0f - lohifb) + lpcombj * lohifb; lpcombj = fbout; comb[j][ck] = inputbuf[i] + fbout; @@ -145,8 +145,8 @@ void Reverb::processmono(int ch, float *output, float *inputbuf) const int aplength = aplen[j]; for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) { float tmp = ap[j][ak]; - ap[j][ak] = 0.7 * tmp + output[i]; - output[i] = tmp - 0.7 * ap[j][ak]; + ap[j][ak] = 0.7f * tmp + output[i]; + output[i] = tmp - 0.7f * ap[j][ak]; if((++ak) >= aplength) ak = 0; } @@ -163,7 +163,7 @@ void Reverb::out(const Stereo<float *> &smp) float *inputbuf = getTmpBuffer(); for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) - inputbuf[i] = (smp.l[i] + smp.r[i]) / 2.0; + inputbuf[i] = (smp.l[i] + smp.r[i]) / 2.0f; if(idelay != NULL) { for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) { @@ -209,11 +209,11 @@ void Reverb::setvolume(unsigned char Pvolume) { this->Pvolume = Pvolume; if(insertion == 0) { - outvolume = pow(0.01, (1.0 - Pvolume / 127.0)) * 4.0; - volume = 1.0; + outvolume = powf(0.01f, (1.0f - Pvolume / 127.0f)) * 4.0f; + volume = 1.0f; } else { - volume = outvolume = Pvolume / 127.0; + volume = outvolume = Pvolume / 127.0f; if(Pvolume == 0) cleanup(); } @@ -224,11 +224,11 @@ void Reverb::settime(unsigned char Ptime) int i; float t; this->Ptime = Ptime; - t = pow(60.0, (float)Ptime / 127.0) - 0.97; + t = powf(60.0f, (float)Ptime / 127.0f) - 0.97f; for(i = 0; i < REV_COMBS * 2; ++i) combfb[i] = - -exp((float)comblen[i] / (float)SAMPLE_RATE * log(0.001) / t); + -expf((float)comblen[i] / (float)SAMPLE_RATE * logf(0.001f) / t); //the feedback is negative because it removes the DC } @@ -240,14 +240,14 @@ void Reverb::setlohidamp(unsigned char Plohidamp) this->Plohidamp = Plohidamp; if(Plohidamp == 64) { lohidamptype = 0; - lohifb = 0.0; + lohifb = 0.0f; } else { if(Plohidamp < 64) lohidamptype = 1; if(Plohidamp > 64) lohidamptype = 2; - float x = fabs((float)(Plohidamp - 64) / 64.1); + float x = fabs((float)(Plohidamp - 64) / 64.1f); lohifb = x * x; } } @@ -256,7 +256,7 @@ void Reverb::setidelay(unsigned char Pidelay) { float delay; this->Pidelay = Pidelay; - delay = pow(50 * Pidelay / 127.0, 2) - 1.0; + delay = powf(50 * Pidelay / 127.0f, 2) - 1.0f; if(idelay != NULL) delete [] idelay; @@ -267,14 +267,14 @@ void Reverb::setidelay(unsigned char Pidelay) idelayk = 0; idelay = new float[idelaylen]; for(int i = 0; i < idelaylen; ++i) - idelay[i] = 0.0; + idelay[i] = 0.0f; } } void Reverb::setidelayfb(unsigned char Pidelayfb) { this->Pidelayfb = Pidelayfb; - idelayfb = Pidelayfb / 128.0; + idelayfb = Pidelayfb / 128.0f; } void Reverb::sethpf(unsigned char Phpf) @@ -286,7 +286,7 @@ void Reverb::sethpf(unsigned char Phpf) hpf = NULL; } else { - float fr = exp(pow(Phpf / 127.0, 0.5) * log(10000.0)) + 20.0; + float fr = expf(powf(Phpf / 127.0f, 0.5f) * logf(10000.0f)) + 20.0f; if(hpf == NULL) hpf = new AnalogFilter(3, fr, 1, 0); else @@ -303,7 +303,7 @@ void Reverb::setlpf(unsigned char Plpf) lpf = NULL; } else { - float fr = exp(pow(Plpf / 127.0, 0.5) * log(25000.0)) + 40; + float fr = expf(powf(Plpf / 127.0f, 0.5f) * logf(25000.0f)) + 40; if(lpf == NULL) lpf = new AnalogFilter(2, fr, 1, 0); else @@ -338,13 +338,13 @@ void Reverb::settype(unsigned char Ptype) float tmp; for(int i = 0; i < REV_COMBS * 2; ++i) { if(Ptype == 0) - tmp = 800.0 + (int)(RND * 1400.0); + tmp = 800.0f + (int)(RND * 1400.0f); else tmp = combtunings[Ptype][i % REV_COMBS]; tmp *= roomsize; if(i > REV_COMBS) - tmp += 23.0; - tmp *= SAMPLE_RATE / 44100.0; //adjust the combs according to the samplerate + tmp += 23.0f; + tmp *= SAMPLE_RATE / 44100.0f; //adjust the combs according to the samplerate if(tmp < 10) tmp = 10; @@ -363,8 +363,8 @@ void Reverb::settype(unsigned char Ptype) tmp = aptunings[Ptype][i % REV_APS]; tmp *= roomsize; if(i > REV_APS) - tmp += 23.0; - tmp *= SAMPLE_RATE / 44100.0; //adjust the combs according to the samplerate + tmp += 23.0f; + tmp *= SAMPLE_RATE / 44100.0f; //adjust the combs according to the samplerate if(tmp < 10) tmp = 10; aplen[i] = (int) tmp; @@ -379,9 +379,9 @@ void Reverb::settype(unsigned char Ptype) delete bandwidth; bandwidth = NULL; if(Ptype == 2) { //bandwidth - bandwidth = new Unison(SOUND_BUFFER_SIZE / 4 + 1, 2.0); + bandwidth = new Unison(SOUND_BUFFER_SIZE / 4 + 1, 2.0f); bandwidth->set_size(50); - bandwidth->set_base_frequency(1.0); + bandwidth->set_base_frequency(1.0f); #warning sa schimb size-ul } } @@ -391,19 +391,19 @@ void Reverb::setroomsize(unsigned char Proomsize) this->Proomsize = Proomsize; if(Proomsize == 0) this->Proomsize = 64; //this is because the older versions consider roomsize=0 - roomsize = (this->Proomsize - 64.0) / 64.0; - if(roomsize > 0.0) - roomsize *= 2.0; - roomsize = pow(10.0, roomsize); + roomsize = (this->Proomsize - 64.0f) / 64.0f; + if(roomsize > 0.0f) + roomsize *= 2.0f; + roomsize = powf(10.0f, roomsize); rs = sqrt(roomsize); settype(Ptype); } void Reverb::setbandwidth(unsigned char Pbandwidth) { this->Pbandwidth = Pbandwidth; - float v = Pbandwidth / 127.0; + float v = Pbandwidth / 127.0f; if(bandwidth) - bandwidth->set_bandwidth(pow(v, 2.0) * 200.0); + bandwidth->set_bandwidth(powf(v, 2.0f) * 200.0f); } void Reverb::setpreset(unsigned char npreset) diff --git a/src/Misc/Config.cpp b/src/Misc/Config.cpp @@ -232,7 +232,7 @@ void Config::readConfig(const char *filename) xmlcfg.exitbranch(); } - cfg.OscilSize = (int) pow(2, ceil(log(cfg.OscilSize - 1.0) / log(2.0))); + cfg.OscilSize = (int) powf(2, ceil(logf(cfg.OscilSize - 1.0f) / logf(2.0f))); } void Config::saveConfig(const char *filename) diff --git a/src/Misc/Dump.cpp b/src/Misc/Dump.cpp @@ -68,7 +68,7 @@ void Dump::startnow() fprintf(file, "#date/time = %s\n", ctime(&tm)); fprintf(file, "#1 tick = %g milliseconds\n", - SOUND_BUFFER_SIZE * 1000.0 / SAMPLE_RATE); + SOUND_BUFFER_SIZE * 1000.0f / SAMPLE_RATE); fprintf(file, "SAMPLERATE = %d\n", SAMPLE_RATE); fprintf(file, "TICKSIZE = %d #samples\n", SOUND_BUFFER_SIZE); fprintf(file, "\n\nSTART\n"); diff --git a/src/Misc/Master.cpp b/src/Misc/Master.cpp @@ -67,7 +67,7 @@ Master::Master() void Master::defaults() { - volume = 1.0; + volume = 1.0f; setPvolume(80); setPkeyshift(64); @@ -198,7 +198,7 @@ void Master::vuUpdate(const float *outl, const float *outr) if(fabs(outr[i]) > vu.outpeakr) vu.outpeakr = fabs(outr[i]); } - if((vu.outpeakl > 1.0) || (vu.outpeakr > 1.0)) + if((vu.outpeakl > 1.0f) || (vu.outpeakr > 1.0f)) vu.clipped = 1; if(vu.maxoutpeakl < vu.outpeakl) vu.maxoutpeakl = vu.outpeakl; @@ -217,7 +217,7 @@ void Master::vuUpdate(const float *outl, const float *outr) //Part Peak computation (for Part vumeters or fake part vumeters) for(int npart = 0; npart < NUM_MIDI_PARTS; ++npart) { - vuoutpeakpart[npart] = 1.0e-12; + vuoutpeakpart[npart] = 1.0e-12f; if(part[npart]->Penabled != 0) { float *outl = part[npart]->partoutl, *outr = part[npart]->partoutr; @@ -296,10 +296,10 @@ void Master::AudioOut(float *outl, float *outr) part[npart]->oldvolumer); float pan = part[npart]->panning; - if(pan < 0.5) - newvol.l *= pan * 2.0; + if(pan < 0.5f) + newvol.l *= pan * 2.0f; else - newvol.r *= (1.0 - pan) * 2.0; + newvol.r *= (1.0f - pan) * 2.0f; //the volume or the panning has changed and needs interpolation if(ABOVE_AMPLITUDE_THRESHOLD(oldvol.l, newvol.l) @@ -487,7 +487,7 @@ Master::~Master() void Master::setPvolume(char Pvolume_) { Pvolume = Pvolume_; - volume = dB2rap((Pvolume - 96.0) / 96.0 * 40.0); + volume = dB2rap((Pvolume - 96.0f) / 96.0f * 40.0f); } void Master::setPkeyshift(char Pkeyshift_) @@ -500,13 +500,13 @@ void Master::setPkeyshift(char Pkeyshift_) void Master::setPsysefxvol(int Ppart, int Pefx, char Pvol) { Psysefxvol[Pefx][Ppart] = Pvol; - sysefxvol[Pefx][Ppart] = pow(0.1, (1.0 - Pvol / 96.0) * 2.0); + sysefxvol[Pefx][Ppart] = powf(0.1f, (1.0f - Pvol / 96.0f) * 2.0f); } void Master::setPsysefxsend(int Pefxfrom, int Pefxto, char Pvol) { Psysefxsend[Pefxfrom][Pefxto] = Pvol; - sysefxsend[Pefxfrom][Pefxto] = pow(0.1, (1.0 - Pvol / 96.0) * 2.0); + sysefxsend[Pefxfrom][Pefxto] = powf(0.1f, (1.0f - Pvol / 96.0f) * 2.0f); } diff --git a/src/Misc/Microtonal.cpp b/src/Misc/Microtonal.cpp @@ -40,7 +40,7 @@ void Microtonal::defaults() octavesize = 12; Penabled = 0; PAnote = 69; - PAfreq = 440.0; + PAfreq = 440.0f; Pscaleshift = 64; Pfirstkey = 0; @@ -53,10 +53,10 @@ void Microtonal::defaults() Pmapping[i] = i; for(int i = 0; i < MAX_OCTAVE_SIZE; ++i) { - octave[i].tuning = tmpoctave[i].tuning = pow( + octave[i].tuning = tmpoctave[i].tuning = powf( 2, (i % octavesize - + 1) / 12.0); + + 1) / 12.0f); octave[i].type = tmpoctave[i].type = 1; octave[i].x1 = tmpoctave[i].x1 = (i % octavesize + 1) * 100; octave[i].x2 = tmpoctave[i].x2 = 0; @@ -106,29 +106,29 @@ float Microtonal::getnotefreq(int note, int keyshift) const note = (int) Pinvertupdowncenter * 2 - note; //compute global fine detune - float globalfinedetunerap = pow(2.0, (Pglobalfinedetune - 64.0) / 1200.0); //-64.0 .. 63.0 cents + float globalfinedetunerap = powf(2.0f, (Pglobalfinedetune - 64.0f) / 1200.0f); //-64.0f .. 63.0f cents if(Penabled == 0) - return pow(2.0, + return powf(2.0f, (note - PAnote - + keyshift) / 12.0) * PAfreq * globalfinedetunerap; //12tET + + keyshift) / 12.0f) * PAfreq * globalfinedetunerap; //12tET int scaleshift = ((int)Pscaleshift - 64 + (int) octavesize * 100) % octavesize; //compute the keyshift - float rap_keyshift = 1.0; + float rap_keyshift = 1.0f; if(keyshift != 0) { int kskey = (keyshift + (int)octavesize * 100) % octavesize; int ksoct = (keyshift + (int)octavesize * 100) / octavesize - 100; - rap_keyshift = (kskey == 0) ? (1.0) : (octave[kskey - 1].tuning); - rap_keyshift *= pow(octave[octavesize - 1].tuning, ksoct); + rap_keyshift = (kskey == 0) ? (1.0f) : (octave[kskey - 1].tuning); + rap_keyshift *= powf(octave[octavesize - 1].tuning, ksoct); } //if the mapping is enabled if(Pmappingenabled != 0) { if((note < Pfirstkey) || (note > Plastkey)) - return -1.0; + return -1.0f; //Compute how many mapped keys are from middle note to reference note //and find out the proportion between the freq. of middle note and "A" note int tmp = PAnote - Pmiddlenote, minus = 0; @@ -142,12 +142,12 @@ float Microtonal::getnotefreq(int note, int keyshift) const deltanote++; float rap_anote_middlenote = (deltanote == - 0) ? (1.0) : (octave[(deltanote - 1) % octavesize].tuning); + 0) ? (1.0f) : (octave[(deltanote - 1) % octavesize].tuning); if(deltanote != 0) rap_anote_middlenote *= - pow(octave[octavesize - 1].tuning, (deltanote - 1) / octavesize); + powf(octave[octavesize - 1].tuning, (deltanote - 1) / octavesize); if(minus != 0) - rap_anote_middlenote = 1.0 / rap_anote_middlenote; + rap_anote_middlenote = 1.0f / rap_anote_middlenote; //Convert from note (midi) to degree (note from the tunning) int degoct = @@ -156,7 +156,7 @@ float Microtonal::getnotefreq(int note, int keyshift) const int degkey = (note - Pmiddlenote + (int)Pmapsize * 100) % Pmapsize; degkey = Pmapping[degkey]; if(degkey < 0) - return -1.0; //this key is not mapped + return -1.0f; //this key is not mapped //invert the keyboard upside-down if it is asked for //TODO: do the right way by using Pinvertupdowncenter @@ -169,8 +169,8 @@ float Microtonal::getnotefreq(int note, int keyshift) const degoct += degkey / octavesize; degkey %= octavesize; - float freq = (degkey == 0) ? (1.0) : octave[degkey - 1].tuning; - freq *= pow(octave[octavesize - 1].tuning, degoct); + float freq = (degkey == 0) ? (1.0f) : octave[degkey - 1].tuning; + freq *= powf(octave[octavesize - 1].tuning, degoct); freq *= PAfreq / rap_anote_middlenote; freq *= globalfinedetunerap; if(scaleshift != 0) @@ -184,14 +184,14 @@ float Microtonal::getnotefreq(int note, int keyshift) const float oct = octave[octavesize - 1].tuning; float freq = - octave[(ntkey + octavesize - 1) % octavesize].tuning *pow(oct, + octave[(ntkey + octavesize - 1) % octavesize].tuning *powf(oct, ntoct) * PAfreq; if(ntkey == 0) freq /= oct; if(scaleshift != 0) freq /= octave[scaleshift - 1].tuning; -// fprintf(stderr,"note=%d freq=%.3f cents=%d\n",note,freq,(int)floor(log(freq/PAfreq)/log(2.0)*1200.0+0.5)); +// fprintf(stderr,"note=%d freq=%.3f cents=%d\n",note,freq,(int)floor(logf(freq/PAfreq)/logf(2.0f)*1200.0f+0.5f)); freq *= globalfinedetunerap; return freq * rap_keyshift; } @@ -210,7 +210,7 @@ bool Microtonal::operator!=(const Microtonal &micro) const return true; //for floats -#define FMCREQ(x) if(!((x < micro.x + 0.0001) && (x > micro.x - 0.0001))) \ +#define FMCREQ(x) if(!((x < micro.x + 0.0001f) && (x > micro.x - 0.0001f))) \ return true; MCREQ(Pinvertupdown); @@ -255,7 +255,7 @@ bool Microtonal::operator!=(const Microtonal &micro) const int Microtonal::linetotunings(unsigned int nline, const char *line) { int x1 = -1, x2 = -1, type = -1; - float x = -1.0, tmp, tuning = 1.0; + float x = -1.0f, tmp, tuning = 1.0f; if(strstr(line, "/") == NULL) { if(strstr(line, ".") == NULL) { // M case (M=M/1) sscanf(line, "%d", &x1); @@ -264,7 +264,7 @@ int Microtonal::linetotunings(unsigned int nline, const char *line) } else { // float number case sscanf(line, "%f", &x); - if(x < 0.000001) + if(x < 0.000001f) return 1; type = 1; //float type(cents) } @@ -290,9 +290,9 @@ int Microtonal::linetotunings(unsigned int nline, const char *line) switch(type) { case 1: x1 = (int) floor(x); - tmp = fmod(x, 1.0); + tmp = fmod(x, 1.0f); x2 = (int) (floor(tmp * 1e6)); - tuning = pow(2.0, x / 1200.0); + tuning = powf(2.0f, x / 1200.0f); break; case 2: x = ((float)x1) / x2; @@ -514,7 +514,7 @@ int Microtonal::loadkbm(const char *filename) //loads the reference freq. if(loadline(file, &tmp[0]) != 0) return 2; - float tmpPAfreq = 440.0; + float tmpPAfreq = 440.0f; if(sscanf(&tmp[0], "%f", &tmpPAfreq) == 0) return 2; PAfreq = tmpPAfreq; @@ -610,7 +610,7 @@ void Microtonal::getfromXML(XMLwrapper *xml) Pglobalfinedetune = xml->getpar127("global_fine_detune", Pglobalfinedetune); PAnote = xml->getpar127("a_note", PAnote); - PAfreq = xml->getparreal("a_freq", PAfreq, 1.0, 10000.0); + PAfreq = xml->getparreal("a_freq", PAfreq, 1.0f, 10000.0f); if(xml->enterbranch("SCALE")) { Pscaleshift = xml->getpar127("scale_shift", Pscaleshift); diff --git a/src/Misc/Microtonal.h b/src/Misc/Microtonal.h @@ -122,8 +122,8 @@ class Microtonal struct { unsigned char type; //1 for cents or 2 for division - // the real tuning (eg. +1.05946 for one halftone) - // or 2.0 for one octave + // the real tuning (eg. +1.05946f for one halftone) + // or 2.0f for one octave float tuning; //the real tunning is x1/x2 diff --git a/src/Misc/Part.cpp b/src/Misc/Part.cpp @@ -66,7 +66,7 @@ Part::Part(Microtonal *microtonal_, FFTwrapper *fft_, pthread_mutex_t *mutex_) } killallnotes = 0; - oldfreq = -1.0; + oldfreq = -1.0f; for(int i = 0; i < POLIPHONY; ++i) { partnote[i].status = KEY_OFF; @@ -83,7 +83,7 @@ Part::Part(Microtonal *microtonal_, FFTwrapper *fft_, pthread_mutex_t *mutex_) Pname = new unsigned char [PART_MAX_NAME_LEN]; - oldvolumel = oldvolumer = 0.5; + oldvolumel = oldvolumer = 0.5f; lastnote = -1; lastpos = 0; // lastpos will store previously used NoteOn(...)'s pos. lastlegatomodevalid = false; // To store previous legatomodevalid value. @@ -156,16 +156,16 @@ void Part::cleanup(bool final) for(int k = 0; k < POLIPHONY; ++k) KillNotePos(k); for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) { - partoutl[i] = final ? 0.0 : denormalkillbuf[i]; - partoutr[i] = final ? 0.0 : denormalkillbuf[i]; + partoutl[i] = final ? 0.0f : denormalkillbuf[i]; + partoutr[i] = final ? 0.0f : denormalkillbuf[i]; } ctl.resetall(); for(int nefx = 0; nefx < NUM_PART_EFX; ++nefx) partefx[nefx]->cleanup(); for(int n = 0; n < NUM_PART_EFX + 1; ++n) { for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) { - partfxinputl[n][i] = final ? 0.0 : denormalkillbuf[i]; - partfxinputr[n][i] = final ? 0.0 : denormalkillbuf[i]; + partfxinputl[n][i] = final ? 0.0f : denormalkillbuf[i]; + partfxinputr[n][i] = final ? 0.0f : denormalkillbuf[i]; } } } @@ -302,15 +302,15 @@ void Part::NoteOn(unsigned char note, } //this computes the velocity sensing of the part - float vel = VelF(velocity / 127.0, Pvelsns); + float vel = VelF(velocity / 127.0f, Pvelsns); //compute the velocity offset - vel += (Pveloffs - 64.0) / 64.0; - if(vel < 0.0) - vel = 0.0; + vel += (Pveloffs - 64.0f) / 64.0f; + if(vel < 0.0f) + vel = 0.0f; else - if(vel > 1.0) - vel = 1.0; + if(vel > 1.0f) + vel = 1.0f; //compute the keyshift int partkeyshift = (int)Pkeyshift - 64; @@ -320,15 +320,15 @@ void Part::NoteOn(unsigned char note, float notebasefreq; if(Pdrummode == 0) { notebasefreq = microtonal->getnotefreq(note, keyshift); - if(notebasefreq < 0.0) + if(notebasefreq < 0.0f) return; //the key is no mapped } else - notebasefreq = 440.0 * pow(2.0, (note - 69.0) / 12.0); + notebasefreq = 440.0f * powf(2.0f, (note - 69.0f) / 12.0f); ; //Portamento - if(oldfreq < 1.0) + if(oldfreq < 1.0f) oldfreq = notebasefreq; //this is only the first note is played // For Mono/Legato: Force Portamento Off on first @@ -635,10 +635,10 @@ void Part::SetController(unsigned int type, int par) if(kit[item].adpars == NULL) continue; kit[item].adpars->GlobalPar.Reson-> - sendcontroller(C_resonance_center, 1.0); + sendcontroller(C_resonance_center, 1.0f); kit[item].adpars->GlobalPar.Reson-> - sendcontroller(C_resonance_bandwidth, 1.0); + sendcontroller(C_resonance_bandwidth, 1.0f); } //more update to add here if I add controllers break; @@ -849,8 +849,8 @@ void Part::ComputePartSmps() { for(unsigned nefx = 0; nefx < NUM_PART_EFX + 1; ++nefx) { for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) { - partfxinputl[nefx][i] = 0.0; - partfxinputr[nefx][i] = 0.0; + partfxinputl[nefx][i] = 0.0f; + partfxinputr[nefx][i] = 0.0f; } } @@ -909,18 +909,18 @@ void Part::ComputePartSmps() void Part::setPvolume(char Pvolume_) { Pvolume = Pvolume_; - volume = dB2rap((Pvolume - 96.0) / 96.0 * 40.0) * ctl.expression.relvolume; + volume = dB2rap((Pvolume - 96.0f) / 96.0f * 40.0f) * ctl.expression.relvolume; } void Part::setPpanning(char Ppanning_) { Ppanning = Ppanning_; - panning = Ppanning / 127.0 + ctl.panning.pan; - if(panning < 0.0) - panning = 0.0; + panning = Ppanning / 127.0f + ctl.panning.pan; + if(panning < 0.0f) + panning = 0.0f; else - if(panning > 1.0) - panning = 1.0; + if(panning > 1.0f) + panning = 1.0f; } /* diff --git a/src/Misc/Util.cpp b/src/Misc/Util.cpp @@ -49,11 +49,11 @@ float *denormalkillbuf; float VelF(float velocity, unsigned char scaling) { float x; - x = pow(VELOCITY_MAX_SCALE, (64.0 - scaling) / 64.0); - if((scaling == 127) || (velocity > 0.99)) - return 1.0; + x = powf(VELOCITY_MAX_SCALE, (64.0f - scaling) / 64.0f); + if((scaling == 127) || (velocity > 0.99f)) + return 1.0f; else - return pow(velocity, x); + return powf(velocity, x); } /* @@ -63,12 +63,12 @@ float getdetune(unsigned char type, unsigned short int coarsedetune, unsigned short int finedetune) { - float det = 0.0, octdet = 0.0, cdet = 0.0, findet = 0.0; + float det = 0.0f, octdet = 0.0f, cdet = 0.0f, findet = 0.0f; //Get Octave int octave = coarsedetune / 1024; if(octave >= 8) octave -= 16; - octdet = octave * 1200.0; + octdet = octave * 1200.0f; //Coarse and fine detune int cdetune = coarsedetune % 1024; @@ -80,21 +80,21 @@ float getdetune(unsigned char type, switch(type) { // case 1: is used for the default (see below) case 2: - cdet = fabs(cdetune * 10.0); - findet = fabs(fdetune / 8192.0) * 10.0; + cdet = fabs(cdetune * 10.0f); + findet = fabs(fdetune / 8192.0f) * 10.0f; break; case 3: cdet = fabs(cdetune * 100); - findet = pow(10, fabs(fdetune / 8192.0) * 3.0) / 10.0 - 0.1; + findet = powf(10, fabs(fdetune / 8192.0f) * 3.0f) / 10.0f - 0.1f; break; case 4: - cdet = fabs(cdetune * 701.95500087); //perfect fifth - findet = (pow(2, fabs(fdetune / 8192.0) * 12.0) - 1.0) / 4095 * 1200; + cdet = fabs(cdetune * 701.95500087f); //perfect fifth + findet = (powf(2, fabs(fdetune / 8192.0f) * 12.0f) - 1.0f) / 4095 * 1200; break; //case ...: need to update N_DETUNE_TYPES, if you'll add more default: - cdet = fabs(cdetune * 50.0); - findet = fabs(fdetune / 8192.0) * 35.0; //almost like "Paul's Sound Designer 2" + cdet = fabs(cdetune * 50.0f); + findet = fabs(fdetune / 8192.0f) * 35.0f; //almost like "Paul's Sound Designer 2" break; } if(finedetune < 8192) diff --git a/src/Misc/WaveShapeSmps.cpp b/src/Misc/WaveShapeSmps.cpp @@ -29,99 +29,99 @@ void waveShapeSmps(int n, unsigned char drive) { int i; - float ws = drive / 127.0; + float ws = drive / 127.0f; float tmpv; switch(type) { case 1: - ws = pow(10, ws * ws * 3.0) - 1.0 + 0.001; //Arctangent + ws = powf(10, ws * ws * 3.0f) - 1.0f + 0.001f; //Arctangent for(i = 0; i < n; ++i) - smps[i] = atan(smps[i] * ws) / atan(ws); + smps[i] = atanf(smps[i] * ws) / atanf(ws); break; case 2: - ws = ws * ws * 32.0 + 0.0001; //Asymmetric - if(ws < 1.0) - tmpv = sin(ws) + 0.1; + ws = ws * ws * 32.0f + 0.0001f; //Asymmetric + if(ws < 1.0f) + tmpv = sinf(ws) + 0.1f; else - tmpv = 1.1; + tmpv = 1.1f; for(i = 0; i < n; ++i) - smps[i] = sin(smps[i] * (0.1 + ws - ws * smps[i])) / tmpv; + smps[i] = sinf(smps[i] * (0.1f + ws - ws * smps[i])) / tmpv; ; break; case 3: - ws = ws * ws * ws * 20.0 + 0.0001; //Pow + ws = ws * ws * ws * 20.0f + 0.0001f; //Pow for(i = 0; i < n; ++i) { smps[i] *= ws; - if(fabs(smps[i]) < 1.0) { - smps[i] = (smps[i] - pow(smps[i], 3.0)) * 3.0; - if(ws < 1.0) + if(fabs(smps[i]) < 1.0f) { + smps[i] = (smps[i] - powf(smps[i], 3.0f)) * 3.0f; + if(ws < 1.0f) smps[i] /= ws; } else - smps[i] = 0.0; + smps[i] = 0.0f; } break; case 4: - ws = ws * ws * ws * 32.0 + 0.0001; //Sine - if(ws < 1.57) - tmpv = sin(ws); + ws = ws * ws * ws * 32.0f + 0.0001f; //Sine + if(ws < 1.57f) + tmpv = sinf(ws); else - tmpv = 1.0; + tmpv = 1.0f; for(i = 0; i < n; ++i) - smps[i] = sin(smps[i] * ws) / tmpv; + smps[i] = sinf(smps[i] * ws) / tmpv; break; case 5: - ws = ws * ws + 0.000001; //Quantisize + ws = ws * ws + 0.000001f; //Quantisize for(i = 0; i < n; ++i) - smps[i] = floor(smps[i] / ws + 0.5) * ws; + smps[i] = floor(smps[i] / ws + 0.5f) * ws; break; case 6: - ws = ws * ws * ws * 32 + 0.0001; //Zigzag - if(ws < 1.0) - tmpv = sin(ws); + ws = ws * ws * ws * 32 + 0.0001f; //Zigzag + if(ws < 1.0f) + tmpv = sinf(ws); else - tmpv = 1.0; + tmpv = 1.0f; for(i = 0; i < n; ++i) - smps[i] = asin(sin(smps[i] * ws)) / tmpv; + smps[i] = asinf(sinf(smps[i] * ws)) / tmpv; break; case 7: - ws = pow(2.0, -ws * ws * 8.0); //Limiter + ws = powf(2.0f, -ws * ws * 8.0f); //Limiter for(i = 0; i < n; ++i) { float tmp = smps[i]; if(fabs(tmp) > ws) { - if(tmp >= 0.0) - smps[i] = 1.0; + if(tmp >= 0.0f) + smps[i] = 1.0f; else - smps[i] = -1.0; + smps[i] = -1.0f; } else smps[i] /= ws; } break; case 8: - ws = pow(2.0, -ws * ws * 8.0); //Upper Limiter + ws = powf(2.0f, -ws * ws * 8.0f); //Upper Limiter for(i = 0; i < n; ++i) { float tmp = smps[i]; if(tmp > ws) smps[i] = ws; - smps[i] *= 2.0; + smps[i] *= 2.0f; } break; case 9: - ws = pow(2.0, -ws * ws * 8.0); //Lower Limiter + ws = powf(2.0f, -ws * ws * 8.0f); //Lower Limiter for(i = 0; i < n; ++i) { float tmp = smps[i]; if(tmp < -ws) smps[i] = -ws; - smps[i] *= 2.0; + smps[i] *= 2.0f; } break; case 10: - ws = (pow(2.0, ws * 6.0) - 1.0) / pow(2.0, 6.0); //Inverse Limiter + ws = (powf(2.0f, ws * 6.0f) - 1.0f) / powf(2.0f, 6.0f); //Inverse Limiter for(i = 0; i < n; ++i) { float tmp = smps[i]; if(fabs(tmp) > ws) { - if(tmp >= 0.0) + if(tmp >= 0.0f) smps[i] = tmp - ws; else smps[i] = tmp + ws; @@ -131,57 +131,57 @@ void waveShapeSmps(int n, } break; case 11: - ws = pow(5, ws * ws * 1.0) - 1.0; //Clip + ws = powf(5, ws * ws * 1.0f) - 1.0f; //Clip for(i = 0; i < n; ++i) smps[i] = smps[i] - * (ws + 0.5) * 0.9999 - floor( - 0.5 + smps[i] * (ws + 0.5) * 0.9999); + * (ws + 0.5f) * 0.9999f - floor( + 0.5f + smps[i] * (ws + 0.5f) * 0.9999f); break; case 12: - ws = ws * ws * ws * 30 + 0.001; //Asym2 - if(ws < 0.3) + ws = ws * ws * ws * 30 + 0.001f; //Asym2 + if(ws < 0.3f) tmpv = ws; else - tmpv = 1.0; + tmpv = 1.0f; for(i = 0; i < n; ++i) { float tmp = smps[i] * ws; - if((tmp > -2.0) && (tmp < 1.0)) - smps[i] = tmp * (1.0 - tmp) * (tmp + 2.0) / tmpv; + if((tmp > -2.0f) && (tmp < 1.0f)) + smps[i] = tmp * (1.0f - tmp) * (tmp + 2.0f) / tmpv; else - smps[i] = 0.0; + smps[i] = 0.0f; } break; case 13: - ws = ws * ws * ws * 32.0 + 0.0001; //Pow2 - if(ws < 1.0) - tmpv = ws * (1 + ws) / 2.0; + ws = ws * ws * ws * 32.0f + 0.0001f; //Pow2 + if(ws < 1.0f) + tmpv = ws * (1 + ws) / 2.0f; else - tmpv = 1.0; + tmpv = 1.0f; for(i = 0; i < n; ++i) { float tmp = smps[i] * ws; - if((tmp > -1.0) && (tmp < 1.618034)) - smps[i] = tmp * (1.0 - tmp) / tmpv; + if((tmp > -1.0f) && (tmp < 1.618034f)) + smps[i] = tmp * (1.0f - tmp) / tmpv; else - if(tmp > 0.0) - smps[i] = -1.0; + if(tmp > 0.0f) + smps[i] = -1.0f; else - smps[i] = -2.0; + smps[i] = -2.0f; } break; case 14: - ws = pow(ws, 5.0) * 80.0 + 0.0001; //sigmoid - if(ws > 10.0) - tmpv = 0.5; + ws = powf(ws, 5.0f) * 80.0f + 0.0001f; //sigmoid + if(ws > 10.0f) + tmpv = 0.5f; else - tmpv = 0.5 - 1.0 / (exp(ws) + 1.0); + tmpv = 0.5f - 1.0f / (expf(ws) + 1.0f); for(i = 0; i < n; ++i) { float tmp = smps[i] * ws; - if(tmp < -10.0) - tmp = -10.0; + if(tmp < -10.0f) + tmp = -10.0f; else - if(tmp > 10.0) - tmp = 10.0; - tmp = 0.5 - 1.0 / (exp(tmp) + 1.0); + if(tmp > 10.0f) + tmp = 10.0f; + tmp = 0.5f - 1.0f / (expf(tmp) + 1.0f); smps[i] = tmp / tmpv; } break; diff --git a/src/Misc/XMLwrapper.cpp b/src/Misc/XMLwrapper.cpp @@ -103,10 +103,10 @@ XMLwrapper::XMLwrapper() minimal = true; node = tree = mxmlNewElement(MXML_NO_PARENT, - "?xml version=\"1.0\" encoding=\"UTF-8\"?"); - /* for mxml 2.1 (and older) + "?xml version=\"1.0f\" encoding=\"UTF-8\"?"); + /* for mxml 2.1f (and older) tree=mxmlNewElement(MXML_NO_PARENT,"?xml"); - mxmlElementSetAttr(tree,"version","1.0"); + mxmlElementSetAttr(tree,"version","1.0f"); mxmlElementSetAttr(tree,"encoding","UTF-8"); */ diff --git a/src/Nio/AlsaEngine.cpp b/src/Nio/AlsaEngine.cpp @@ -242,9 +242,9 @@ short *AlsaEngine::interleave(const Stereo<float *> &smps) double scaled; for (int frame = 0; frame < bufferSize; ++frame) { // with a nod to libsamplerate ... - scaled = smps.l[frame] * (8.0 * 0x10000000); + scaled = smps.l[frame] * (8.0f * 0x10000000); shortInterleaved[idx++] = (short int)(lrint(scaled) >> 16); - scaled = smps.r[frame] * (8.0 * 0x10000000); + scaled = smps.r[frame] * (8.0f * 0x10000000); shortInterleaved[idx++] = (short int)(lrint(scaled) >> 16); } return shortInterleaved; diff --git a/src/Nio/OssEngine.cpp b/src/Nio/OssEngine.cpp @@ -216,19 +216,19 @@ void *OssEngine::thread() l = smps.l[i]; r = smps.r[i]; - if(l < -1.0) - l = -1.0; + if(l < -1.0f) + l = -1.0f; else - if(l > 1.0) - l = 1.0; - if(r < -1.0) - r = -1.0; + if(l > 1.0f) + l = 1.0f; + if(r < -1.0f) + r = -1.0f; else - if(r > 1.0) - r = 1.0; + if(r > 1.0f) + r = 1.0f; - audio.smps[i * 2] = (short int) (l * 32767.0); - audio.smps[i * 2 + 1] = (short int) (r * 32767.0); + audio.smps[i * 2] = (short int) (l * 32767.0f); + audio.smps[i * 2 + 1] = (short int) (r * 32767.0f); } int handle = audio.handle; if(handle != -1) diff --git a/src/Nio/WavEngine.cpp b/src/Nio/WavEngine.cpp @@ -117,8 +117,8 @@ void *WavEngine::AudioThread() float left=0.0f, right=0.0f; buffer.pop(left); buffer.pop(right); - recordbuf_16bit[2*i] = limit((int)(left * 32767.0), -32768, 32767); - recordbuf_16bit[2*i+1] = limit((int)(right * 32767.0), -32768, 32767); + recordbuf_16bit[2*i] = limit((int)(left * 32767.0f), -32768, 32767); + recordbuf_16bit[2*i+1] = limit((int)(right * 32767.0f), -32768, 32767); } file->writeStereoSamples(SOUND_BUFFER_SIZE, recordbuf_16bit); } diff --git a/src/Output/DSSIaudiooutput.cpp b/src/Output/DSSIaudiooutput.cpp @@ -605,7 +605,7 @@ DSSIaudiooutput::DSSIaudiooutput(unsigned long sampleRate) srand(time(NULL)); denormalkillbuf=new float [SOUND_BUFFER_SIZE]; - for (int i=0;i<SOUND_BUFFER_SIZE;i++) denormalkillbuf[i]=(RND-0.5)*1e-16; + for (int i=0;i<SOUND_BUFFER_SIZE;i++) denormalkillbuf[i]=(RND-0.5f)*1e-16; this->master = new Master(); } diff --git a/src/Params/ADnoteParameters.cpp b/src/Params/ADnoteParameters.cpp @@ -222,8 +222,8 @@ void ADnoteVoiceParam::enable(FFTwrapper *fft, Resonance *Reson) */ float ADnoteParameters::getBandwidthDetuneMultiplier() { - float bw = (GlobalPar.PBandwidth - 64.0) / 64.0; - bw = pow(2.0, bw * pow(fabs(bw), 0.2) * 5.0); + float bw = (GlobalPar.PBandwidth - 64.0f) / 64.0f; + bw = powf(2.0f, bw * powf(fabs(bw), 0.2f) * 5.0f); return bw; } @@ -233,8 +233,8 @@ float ADnoteParameters::getBandwidthDetuneMultiplier() */ 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 + float unison_spread = VoicePar[nvoice].Unison_frequency_spread / 127.0f; + unison_spread = powf(unison_spread * 2.0f, 2.0f) * 50.0f; //cents return unison_spread; } diff --git a/src/Params/Controller.cpp b/src/Params/Controller.cpp @@ -63,7 +63,7 @@ void Controller::defaults() resonancecenter.depth = 64; resonancebandwidth.depth = 64; - initportamento(440.0, 440.0, false); // Now has a third argument + initportamento(440.0f, 440.0f, false); // Now has a third argument setportamento(0); } @@ -92,9 +92,9 @@ void Controller::resetall() void Controller::setpitchwheel(int value) { pitchwheel.data = value; - float cents = value / 8192.0; + float cents = value / 8192.0f; cents *= pitchwheel.bendrange; - pitchwheel.relfreq = pow(2, cents / 1200.0); + pitchwheel.relfreq = powf(2, cents / 1200.0f); //fprintf(stderr,"%ld %ld -> %.3f\n",pitchwheel.bendrange,pitchwheel.data,pitchwheel.relfreq);fflush(stderr); } @@ -107,44 +107,44 @@ void Controller::setexpression(int value) { expression.data = value; if(expression.receive != 0) - expression.relvolume = value / 127.0; + expression.relvolume = value / 127.0f; else - expression.relvolume = 1.0; + expression.relvolume = 1.0f; } void Controller::setpanning(int value) { panning.data = value; - panning.pan = (value / 128.0 - 0.5) * (panning.depth / 64.0); + panning.pan = (value / 128.0f - 0.5f) * (panning.depth / 64.0f); } void Controller::setfiltercutoff(int value) { filtercutoff.data = value; filtercutoff.relfreq = - (value - 64.0) * filtercutoff.depth / 4096.0 * 3.321928; //3.3219..=ln2(10) + (value - 64.0f) * filtercutoff.depth / 4096.0f * 3.321928f; //3.3219f..=ln2(10) } void Controller::setfilterq(int value) { filterq.data = value; - filterq.relq = pow(30.0, (value - 64.0) / 64.0 * (filterq.depth / 64.0)); + filterq.relq = powf(30.0f, (value - 64.0f) / 64.0f * (filterq.depth / 64.0f)); } void Controller::setbandwidth(int value) { bandwidth.data = value; if(bandwidth.exponential == 0) { - float tmp = pow(25.0, pow(bandwidth.depth / 127.0, 1.5)) - 1.0; + float tmp = powf(25.0f, powf(bandwidth.depth / 127.0f, 1.5f)) - 1.0f; if((value < 64) && (bandwidth.depth >= 64)) - tmp = 1.0; - bandwidth.relbw = (value / 64.0 - 1.0) * tmp + 1.0; - if(bandwidth.relbw < 0.01) - bandwidth.relbw = 0.01; + tmp = 1.0f; + bandwidth.relbw = (value / 64.0f - 1.0f) * tmp + 1.0f; + if(bandwidth.relbw < 0.01f) + bandwidth.relbw = 0.01f; } else bandwidth.relbw = - pow(25.0, (value - 64.0) / 64.0 * (bandwidth.depth / 64.0)); + powf(25.0f, (value - 64.0f) / 64.0f * (bandwidth.depth / 64.0f)); ; } @@ -152,35 +152,35 @@ void Controller::setmodwheel(int value) { modwheel.data = value; if(modwheel.exponential == 0) { - float tmp = pow(25.0, pow(modwheel.depth / 127.0, 1.5) * 2.0) / 25.0; + float tmp = powf(25.0f, powf(modwheel.depth / 127.0f, 1.5f) * 2.0f) / 25.0f; if((value < 64) && (modwheel.depth >= 64)) - tmp = 1.0; - modwheel.relmod = (value / 64.0 - 1.0) * tmp + 1.0; - if(modwheel.relmod < 0.0) - modwheel.relmod = 0.0; + tmp = 1.0f; + modwheel.relmod = (value / 64.0f - 1.0f) * tmp + 1.0f; + if(modwheel.relmod < 0.0f) + modwheel.relmod = 0.0f; } else modwheel.relmod = - pow(25.0, (value - 64.0) / 64.0 * (modwheel.depth / 80.0)); + powf(25.0f, (value - 64.0f) / 64.0f * (modwheel.depth / 80.0f)); } void Controller::setfmamp(int value) { fmamp.data = value; - fmamp.relamp = value / 127.0; + fmamp.relamp = value / 127.0f; if(fmamp.receive != 0) - fmamp.relamp = value / 127.0; + fmamp.relamp = value / 127.0f; else - fmamp.relamp = 1.0; + fmamp.relamp = 1.0f; } void Controller::setvolume(int value) { volume.data = value; if(volume.receive != 0) - volume.volume = pow(0.1, (127 - value) / 127.0 * 2.0); + volume.volume = powf(0.1f, (127 - value) / 127.0f * 2.0f); else - volume.volume = 1.0; + volume.volume = 1.0f; } void Controller::setsustain(int value) @@ -203,7 +203,7 @@ int Controller::initportamento(float oldfreq, float newfreq, bool legatoflag) { - portamento.x = 0.0; + portamento.x = 0.0f; if(legatoflag) { // Legato in progress if(portamento.portamento == 0) @@ -214,7 +214,7 @@ int Controller::initportamento(float oldfreq, return 0; ; - float portamentotime = pow(100.0, portamento.time / 127.0) / 50.0; //portamento time in seconds + float portamentotime = powf(100.0f, portamento.time / 127.0f) / 50.0f; //portamento time in seconds if(portamento.proportional) { //If there is a min(float,float) and a max(float,float) then they @@ -222,23 +222,23 @@ int Controller::initportamento(float oldfreq, //Linear functors could also make this nicer if(oldfreq > newfreq) //2 is the center of propRate portamentotime *= - pow(oldfreq / newfreq / (portamento.propRate / 127.0 * 3 + .05), - (portamento.propDepth / 127.0 * 1.6 + .2)); + powf(oldfreq / newfreq / (portamento.propRate / 127.0f * 3 + .05), + (portamento.propDepth / 127.0f * 1.6f + .2)); else //1 is the center of propDepth portamentotime *= - pow(newfreq / oldfreq / (portamento.propRate / 127.0 * 3 + .05), - (portamento.propDepth / 127.0 * 1.6 + .2)); + powf(newfreq / oldfreq / (portamento.propRate / 127.0f * 3 + .05), + (portamento.propDepth / 127.0f * 1.6f + .2)); } if((portamento.updowntimestretch >= 64) && (newfreq < oldfreq)) { if(portamento.updowntimestretch == 127) return 0; - portamentotime *= pow(0.1, (portamento.updowntimestretch - 64) / 63.0); + portamentotime *= powf(0.1f, (portamento.updowntimestretch - 64) / 63.0f); } if((portamento.updowntimestretch < 64) && (newfreq > oldfreq)) { if(portamento.updowntimestretch == 0) return 0; - portamentotime *= pow(0.1, (64.0 - portamento.updowntimestretch) / 64.0); + portamentotime *= powf(0.1f, (64.0f - portamento.updowntimestretch) / 64.0f); } //printf("%f->%f : Time %f\n",oldfreq,newfreq,portamentotime); @@ -246,14 +246,14 @@ int Controller::initportamento(float oldfreq, portamento.dx = SOUND_BUFFER_SIZE / (portamentotime * SAMPLE_RATE); portamento.origfreqrap = oldfreq / newfreq; - float tmprap = ((portamento.origfreqrap > 1.0) ? + float tmprap = ((portamento.origfreqrap > 1.0f) ? (portamento.origfreqrap) : - (1.0 / portamento.origfreqrap)); + (1.0f / portamento.origfreqrap)); - float thresholdrap = pow(2.0, portamento.pitchthresh / 12.0); - if((portamento.pitchthreshtype == 0) && (tmprap - 0.00001 > thresholdrap)) + float thresholdrap = powf(2.0f, portamento.pitchthresh / 12.0f); + if((portamento.pitchthreshtype == 0) && (tmprap - 0.00001f > thresholdrap)) return 0; - if((portamento.pitchthreshtype == 1) && (tmprap + 0.00001 < thresholdrap)) + if((portamento.pitchthreshtype == 1) && (tmprap + 0.00001f < thresholdrap)) return 0; portamento.used = 1; @@ -267,12 +267,12 @@ void Controller::updateportamento() return; portamento.x += portamento.dx; - if(portamento.x > 1.0) { - portamento.x = 1.0; + if(portamento.x > 1.0f) { + portamento.x = 1.0f; portamento.used = 0; } portamento.freqrap = - (1.0 - portamento.x) * portamento.origfreqrap + portamento.x; + (1.0f - portamento.x) * portamento.origfreqrap + portamento.x; } @@ -280,13 +280,13 @@ void Controller::setresonancecenter(int value) { resonancecenter.data = value; resonancecenter.relcenter = - pow(3.0, (value - 64.0) / 64.0 * (resonancecenter.depth / 64.0)); + powf(3.0f, (value - 64.0f) / 64.0f * (resonancecenter.depth / 64.0f)); } void Controller::setresonancebw(int value) { resonancebandwidth.data = value; resonancebandwidth.relbw = - pow(1.5, (value - 64.0) / 64.0 * (resonancebandwidth.depth / 127.0)); + powf(1.5f, (value - 64.0f) / 64.0f * (resonancebandwidth.depth / 127.0f)); } diff --git a/src/Params/Controller.h b/src/Params/Controller.h @@ -76,7 +76,7 @@ class Controller struct { //Pitch Wheel int data; short int bendrange; //bendrange is in cents - float relfreq; //the relative frequency (default is 1.0) + float relfreq; //the relative frequency (default is 1.0f) } pitchwheel; struct { //Expression @@ -143,7 +143,7 @@ class Controller unsigned char receive; /** The time that it takes for the portamento to complete * - * Translates in an expontal fashion to 0 Seconds to 1.93 Seconds + * Translates in an expontal fashion to 0 Seconds to 1.93f Seconds * of completion time*/ unsigned char time; /**If the portamento is proportinal to the distance spanned @@ -186,7 +186,7 @@ class Controller //Internal data - /**x is from 0.0 (start portamento) to 1.0 (finished portamento)*/ + /**x is from 0.0f (start portamento) to 1.0f (finished portamento)*/ float x; /**dx is the increment to x when updateportamento is called*/ float dx; diff --git a/src/Params/EnvelopeParams.cpp b/src/Params/EnvelopeParams.cpp @@ -60,7 +60,7 @@ EnvelopeParams::~EnvelopeParams() float EnvelopeParams::getdt(char i) { - float result = (pow(2.0, Penvdt[(int)i] / 127.0 * 12.0) - 1.0) * 10.0; //miliseconds + float result = (powf(2.0f, Penvdt[(int)i] / 127.0f * 12.0f) - 1.0f) * 10.0f; //miliseconds return result; } diff --git a/src/Params/FilterParams.cpp b/src/Params/FilterParams.cpp @@ -75,7 +75,7 @@ void FilterParams::defaults(int n) { int j = n; for(int i = 0; i < FF_MAX_FORMANTS; ++i) { - Pvowels[j].formants[i].freq = (int)(RND * 127.0); //some random freqs + Pvowels[j].formants[i].freq = (int)(RND * 127.0f); //some random freqs Pvowels[j].formants[i].q = 64; Pvowels[j].formants[i].amp = 127; } @@ -129,21 +129,21 @@ void FilterParams::getfromFilterParams(FilterParams *pars) */ float FilterParams::getfreq() { - return (Pfreq / 64.0 - 1.0) * 5.0; + return (Pfreq / 64.0f - 1.0f) * 5.0f; } float FilterParams::getq() { - return exp(pow((float) Pq / 127.0, 2) * log(1000.0)) - 0.9; + return expf(powf((float) Pq / 127.0f, 2) * logf(1000.0f)) - 0.9f; } float FilterParams::getfreqtracking(float notefreq) { - return log(notefreq / 440.0) * (Pfreqtrack - 64.0) / (64.0 * LOG_2); + return logf(notefreq / 440.0f) * (Pfreqtrack - 64.0f) / (64.0f * LOG_2); } float FilterParams::getgain() { - return (Pgain / 64.0 - 1.0) * 30.0; //-30..30dB + return (Pgain / 64.0f - 1.0f) * 30.0f; //-30..30dB } /* @@ -151,7 +151,7 @@ float FilterParams::getgain() */ float FilterParams::getcenterfreq() { - return 10000.0 * pow(10, -(1.0 - Pcenterfreq / 127.0) * 2.0); + return 10000.0f * powf(10, -(1.0f - Pcenterfreq / 127.0f) * 2.0f); } /* @@ -159,7 +159,7 @@ float FilterParams::getcenterfreq() */ float FilterParams::getoctavesfreq() { - return 0.25 + 10.0 * Poctavesfreq / 127.0; + return 0.25f + 10.0f * Poctavesfreq / 127.0f; } /* @@ -167,10 +167,10 @@ float FilterParams::getoctavesfreq() */ float FilterParams::getfreqx(float x) { - if(x > 1.0) - x = 1.0; - float octf = pow(2.0, getoctavesfreq()); - return getcenterfreq() / sqrt(octf) * pow(octf, x); + if(x > 1.0f) + x = 1.0f; + float octf = powf(2.0f, getoctavesfreq()); + return getcenterfreq() / sqrt(octf) * powf(octf, x); } /* @@ -178,7 +178,7 @@ float FilterParams::getfreqx(float x) */ float FilterParams::getfreqpos(float freq) { - return (log(freq) - log(getfreqx(0.0))) / log(2.0) / getoctavesfreq(); + return (logf(freq) - logf(getfreqx(0.0f))) / logf(2.0f) / getoctavesfreq(); } @@ -192,7 +192,7 @@ void FilterParams::formantfilterH(int nvowel, int nfreqs, float *freqs) float omega, sn, cs, alpha; for(int i = 0; i < nfreqs; ++i) - freqs[i] = 0.0; + freqs[i] = 0.0f; //for each formant... for(int nformant = 0; nformant < Pnumformants; ++nformant) { @@ -201,15 +201,15 @@ void FilterParams::formantfilterH(int nvowel, int nfreqs, float *freqs) filter_q = getformantq(Pvowels[nvowel].formants[nformant].q) * getq(); if(Pstages > 0) filter_q = - (filter_q > 1.0 ? pow(filter_q, 1.0 / (Pstages + 1)) : filter_q); + (filter_q > 1.0f ? powf(filter_q, 1.0f / (Pstages + 1)) : filter_q); filter_amp = getformantamp(Pvowels[nvowel].formants[nformant].amp); - if(filter_freq <= (SAMPLE_RATE / 2 - 100.0)) { + if(filter_freq <= (SAMPLE_RATE / 2 - 100.0f)) { omega = 2 * PI * filter_freq / SAMPLE_RATE; - sn = sin(omega); - cs = cos(omega); + sn = sinf(omega); + cs = cosf(omega); alpha = sn / (2 * filter_q); float tmp = 1 + alpha; c[0] = alpha / tmp *sqrt(filter_q + 1); @@ -226,32 +226,32 @@ void FilterParams::formantfilterH(int nvowel, int nfreqs, float *freqs) float freq = getfreqx(i / (float) nfreqs); if(freq > SAMPLE_RATE / 2) { for(int tmp = i; tmp < nfreqs; ++tmp) - freqs[tmp] = 0.0; + freqs[tmp] = 0.0f; break; } - float fr = freq / SAMPLE_RATE * PI * 2.0; - float x = c[0], y = 0.0; + float fr = freq / SAMPLE_RATE * PI * 2.0f; + float x = c[0], y = 0.0f; for(int n = 1; n < 3; ++n) { - x += cos(n * fr) * c[n]; - y -= sin(n * fr) * c[n]; + x += cosf(n * fr) * c[n]; + y -= sinf(n * fr) * c[n]; } float h = x * x + y * y; - x = 1.0; - y = 0.0; + x = 1.0f; + y = 0.0f; for(int n = 1; n < 3; ++n) { - x -= cos(n * fr) * d[n]; - y += sin(n * fr) * d[n]; + x -= cosf(n * fr) * d[n]; + y += sinf(n * fr) * d[n]; } h = h / (x * x + y * y); - freqs[i] += pow(h, (Pstages + 1.0) / 2.0) * filter_amp; + freqs[i] += powf(h, (Pstages + 1.0f) / 2.0f) * filter_amp; } } for(int i = 0; i < nfreqs; ++i) { - if(freqs[i] > 0.000000001) + if(freqs[i] > 0.000000001f) freqs[i] = rap2dB(freqs[i]) + getgain(); else - freqs[i] = -90.0; + freqs[i] = -90.0f; } } @@ -260,20 +260,20 @@ void FilterParams::formantfilterH(int nvowel, int nfreqs, float *freqs) */ float FilterParams::getformantfreq(unsigned char freq) { - float result = getfreqx(freq / 127.0); + float result = getfreqx(freq / 127.0f); return result; } float FilterParams::getformantamp(unsigned char amp) { - float result = pow(0.1, (1.0 - amp / 127.0) * 4.0); + float result = powf(0.1f, (1.0f - amp / 127.0f) * 4.0f); return result; } float FilterParams::getformantq(unsigned char q) { //temp - float result = pow(25.0, (q - 32.0) / 64.0); + float result = powf(25.0f, (q - 32.0f) / 64.0f); return result; } diff --git a/src/Params/LFOParams.cpp b/src/Params/LFOParams.cpp @@ -65,7 +65,7 @@ LFOParams::~LFOParams() void LFOParams::defaults() { - Pfreq = Dfreq / 127.0; + Pfreq = Dfreq / 127.0f; Pintensity = Dintensity; Pstartphase = Dstartphase; PLFOtype = DLFOtype; @@ -92,7 +92,7 @@ void LFOParams::add2XML(XMLwrapper *xml) void LFOParams::getfromXML(XMLwrapper *xml) { - Pfreq = xml->getparreal("freq", Pfreq, 0.0, 1.0); + Pfreq = xml->getparreal("freq", Pfreq, 0.0f, 1.0f); Pintensity = xml->getpar127("intensity", Pintensity); Pstartphase = xml->getpar127("start_phase", Pstartphase); PLFOtype = xml->getpar127("lfo_type", PLFOtype); diff --git a/src/Params/PADnoteParameters.cpp b/src/Params/PADnoteParameters.cpp @@ -142,7 +142,7 @@ void PADnoteParameters::deletesample(int n) sample[n].smp = NULL; } sample[n].size = 0; - sample[n].basefreq = 440.0; + sample[n].basefreq = 440.0f; } void PADnoteParameters::deletesamples() @@ -157,37 +157,37 @@ void PADnoteParameters::deletesamples() float PADnoteParameters::getprofile(float *smp, int size) { for(int i = 0; i < size; ++i) - smp[i] = 0.0; + smp[i] = 0.0f; const int supersample = 16; - 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); - - float modfreq = floor(pow(2.0, - Php.modulator.freq / 127.0 - * 5.0) + 0.000001); - float modpar1 = pow(Php.modulator.par1 / 127.0, 4.0) * 5.0 / sqrt( + float basepar = powf(2.0f, (1.0f - Php.base.par1 / 127.0f) * 12.0f); + float freqmult = floor(powf(2.0f, + Php.freqmult / 127.0f * 5.0f) + 0.000001f); + + float modfreq = floor(powf(2.0f, + Php.modulator.freq / 127.0f + * 5.0f) + 0.000001f); + float modpar1 = powf(Php.modulator.par1 / 127.0f, 4.0f) * 5.0f / sqrt( modfreq); float amppar1 = - pow(2.0, pow(Php.amp.par1 / 127.0, 2.0) * 10.0) - 0.999; - float amppar2 = (1.0 - Php.amp.par2 / 127.0) * 0.998 + 0.001; - float width = pow(150.0 / (Php.width + 22.0), 2.0); + powf(2.0f, powf(Php.amp.par1 / 127.0f, 2.0f) * 10.0f) - 0.999f; + float amppar2 = (1.0f - Php.amp.par2 / 127.0f) * 0.998f + 0.001f; + float width = powf(150.0f / (Php.width + 22.0f), 2.0f); for(int i = 0; i < size * supersample; ++i) { bool makezero = false; - float x = i * 1.0 / (size * (float) supersample); + float x = i * 1.0f / (size * (float) supersample); float origx = x; //do the sizing (width) - x = (x - 0.5) * width + 0.5; - if(x < 0.0) { - x = 0.0; + x = (x - 0.5f) * width + 0.5f; + if(x < 0.0f) { + x = 0.0f; makezero = true; } else { - if(x > 1.0) { - x = 1.0; + if(x > 1.0f) { + x = 1.0f; makezero = true; } } @@ -195,10 +195,10 @@ float PADnoteParameters::getprofile(float *smp, int size) //compute the full profile or one half switch(Php.onehalf) { case 1: - x = x * 0.5 + 0.5; + x = x * 0.5f + 0.5f; break; case 2: - x = x * 0.5; + x = x * 0.5f; break; } @@ -208,43 +208,43 @@ float PADnoteParameters::getprofile(float *smp, int size) x *= freqmult; //do the modulation of the profile - x += sin(x_before_freq_mult * 3.1415926 * modfreq) * modpar1; - x = fmod(x + 1000.0, 1.0) * 2.0 - 1.0; + x += sinf(x_before_freq_mult * 3.1415926f * modfreq) * modpar1; + x = fmod(x + 1000.0f, 1.0f) * 2.0f - 1.0f; //this is the base function of the profile float f; switch(Php.base.type) { case 1: - f = exp(-(x * x) * basepar); - if(f < 0.4) - f = 0.0; + f = expf(-(x * x) * basepar); + if(f < 0.4f) + f = 0.0f; else - f = 1.0; + f = 1.0f; break; case 2: - f = exp(-(fabs(x)) * sqrt(basepar)); + f = expf(-(fabs(x)) * sqrt(basepar)); break; default: - f = exp(-(x * x) * basepar); + f = expf(-(x * x) * basepar); break; } if(makezero) - f = 0.0; + f = 0.0f; - float amp = 1.0; - origx = origx * 2.0 - 1.0; + float amp = 1.0f; + origx = origx * 2.0f - 1.0f; //compute the amplitude multiplier switch(Php.amp.type) { case 1: - amp = exp(-(origx * origx) * 10.0 * amppar1); + amp = expf(-(origx * origx) * 10.0f * amppar1); break; case 2: - amp = 0.5 * (1.0 + cos(3.1415926 * origx * sqrt(amppar1 * 4.0 + 1.0))); + amp = 0.5f * (1.0f + cosf(3.1415926f * origx * sqrt(amppar1 * 4.0f + 1.0f))); break; case 3: - amp = 1.0 / (pow(origx * (amppar1 * 2.0 + 0.8), 14.0) + 1.0); + amp = 1.0f / (powf(origx * (amppar1 * 2.0f + 0.8f), 14.0f) + 1.0f); break; } @@ -253,16 +253,16 @@ float PADnoteParameters::getprofile(float *smp, int size) if(Php.amp.type != 0) switch(Php.amp.mode) { case 0: - finalsmp = amp * (1.0 - amppar2) + finalsmp * amppar2; + finalsmp = amp * (1.0f - amppar2) + finalsmp * amppar2; break; case 1: - finalsmp *= amp * (1.0 - amppar2) + amppar2; + finalsmp *= amp * (1.0f - amppar2) + amppar2; break; case 2: - finalsmp = finalsmp / (amp + pow(amppar2, 4.0) * 20.0 + 0.0001); + finalsmp = finalsmp / (amp + powf(amppar2, 4.0f) * 20.0f + 0.0001f); break; case 3: - finalsmp = amp / (finalsmp + pow(amppar2, 4.0) * 20.0 + 0.0001); + finalsmp = amp / (finalsmp + powf(amppar2, 4.0f) * 20.0f + 0.0001f); break; } ; @@ -270,32 +270,32 @@ float PADnoteParameters::getprofile(float *smp, int size) smp[i / supersample] += finalsmp / supersample; } - //normalize the profile (make the max. to be equal to 1.0) - float max = 0.0; + //normalize the profile (make the max. to be equal to 1.0f) + float max = 0.0f; for(int i = 0; i < size; ++i) { - if(smp[i] < 0.0) - smp[i] = 0.0; + if(smp[i] < 0.0f) + smp[i] = 0.0f; if(smp[i] > max) max = smp[i]; } - if(max < 0.00001) - max = 1.0; + if(max < 0.00001f) + max = 1.0f; for(int i = 0; i < size; ++i) smp[i] /= max; if(!Php.autoscale) - return 0.5; + return 0.5f; //compute the estimated perceived bandwidth - float sum = 0.0; + float sum = 0.0f; int i; for(i = 0; i < size / 2 - 2; ++i) { sum += smp[i] * smp[i] + smp[size - i - 1] * smp[size - i - 1]; - if(sum >= 4.0) + if(sum >= 4.0f) break; } - float result = 1.0 - 2.0 * i / (float) size; + float result = 1.0f - 2.0f * i / (float) size; return result; } @@ -306,8 +306,8 @@ float PADnoteParameters::getprofile(float *smp, int size) float PADnoteParameters::setPbandwidth(int Pbandwidth) { this->Pbandwidth = Pbandwidth; - float result = pow(Pbandwidth / 1000.0, 1.1); - result = pow(10.0, result * 4.0) * 0.25; + float result = powf(Pbandwidth / 1000.0f, 1.1f); + result = powf(10.0f, result * 4.0f) * 0.25f; return result; } @@ -316,57 +316,57 @@ float PADnoteParameters::setPbandwidth(int Pbandwidth) */ float PADnoteParameters::getNhr(int n) { - float result = 1.0; - float par1 = pow(10.0, -(1.0 - Phrpos.par1 / 255.0) * 3.0); - float par2 = Phrpos.par2 / 255.0; + float result = 1.0f; + float par1 = powf(10.0f, -(1.0f - Phrpos.par1 / 255.0f) * 3.0f); + float par2 = Phrpos.par2 / 255.0f; - float n0 = n - 1.0; - float tmp = 0.0; + float n0 = n - 1.0f; + float tmp = 0.0f; int thresh = 0; switch(Phrpos.type) { case 1: - thresh = (int)(par2 * par2 * 100.0) + 1; + thresh = (int)(par2 * par2 * 100.0f) + 1; if(n < thresh) result = n; else - result = 1.0 + n0 + (n0 - thresh + 1.0) * par1 * 8.0; + result = 1.0f + n0 + (n0 - thresh + 1.0f) * par1 * 8.0f; break; case 2: - thresh = (int)(par2 * par2 * 100.0) + 1; + thresh = (int)(par2 * par2 * 100.0f) + 1; if(n < thresh) result = n; else - result = 1.0 + n0 - (n0 - thresh + 1.0) * par1 * 0.90; + result = 1.0f + n0 - (n0 - thresh + 1.0f) * par1 * 0.90f; break; case 3: - tmp = par1 * 100.0 + 1.0; - result = pow(n0 / tmp, 1.0 - par2 * 0.8) * tmp + 1.0; + tmp = par1 * 100.0f + 1.0f; + result = powf(n0 / tmp, 1.0f - par2 * 0.8f) * tmp + 1.0f; break; case 4: result = n0 - * (1.0 + * (1.0f - par1) - + pow(n0 * 0.1, par2 * 3.0 + 1.0) * par1 * 10.0 + 1.0; + + powf(n0 * 0.1f, par2 * 3.0f + 1.0f) * par1 * 10.0f + 1.0f; break; case 5: result = n0 - + sin(n0 * par2 * par2 * PI * 0.999) * sqrt(par1) * 2.0 + 1.0; + + sinf(n0 * par2 * par2 * PI * 0.999f) * sqrt(par1) * 2.0f + 1.0f; break; case 6: - tmp = pow(par2 * 2.0, 2.0) + 0.1; - result = n0 * pow(1.0 + par1 * pow(n0 * 0.8, tmp), tmp) + 1.0; + tmp = powf(par2 * 2.0f, 2.0f) + 0.1f; + result = n0 * powf(1.0f + par1 * powf(n0 * 0.8f, tmp), tmp) + 1.0f; break; default: result = n; break; } - float par3 = Phrpos.par3 / 255.0; + float par3 = Phrpos.par3 / 255.0f; - float iresult = floor(result + 0.5); + float iresult = floor(result + 0.5f); float dresult = result - iresult; - result = iresult + (1.0 - par3) * dresult; + result = iresult + (1.0f - par3) * dresult; return result; } @@ -382,29 +382,29 @@ void PADnoteParameters::generatespectrum_bandwidthMode(float *spectrum, float bwadjust) { for(int i = 0; i < size; ++i) - spectrum[i] = 0.0; + spectrum[i] = 0.0f; float harmonics[OSCIL_SIZE / 2]; for(int i = 0; i < OSCIL_SIZE / 2; ++i) - harmonics[i] = 0.0; + harmonics[i] = 0.0f; //get the harmonic structure from the oscillator (I am using the frequency amplitudes, only) oscilgen->get(harmonics, basefreq, false); //normalize - float max = 0.0; + float max = 0.0f; for(int i = 0; i < OSCIL_SIZE / 2; ++i) if(harmonics[i] > max) max = harmonics[i]; - if(max < 0.000001) + if(max < 0.000001f) max = 1; for(int i = 0; i < OSCIL_SIZE / 2; ++i) harmonics[i] /= max; for(int nh = 1; nh < OSCIL_SIZE / 2; ++nh) { //for each harmonic float realfreq = getNhr(nh) * basefreq; - if(realfreq > SAMPLE_RATE * 0.49999) + if(realfreq > SAMPLE_RATE * 0.49999f) break; - if(realfreq < 20.0) + if(realfreq < 20.0f) break; if(harmonics[nh - 1] < 1e-4) continue; @@ -412,36 +412,36 @@ void PADnoteParameters::generatespectrum_bandwidthMode(float *spectrum, //compute the bandwidth of each harmonic float bandwidthcents = setPbandwidth(Pbandwidth); float bw = - (pow(2.0, bandwidthcents / 1200.0) - 1.0) * basefreq / bwadjust; - float power = 1.0; + (powf(2.0f, bandwidthcents / 1200.0f) - 1.0f) * basefreq / bwadjust; + float power = 1.0f; switch(Pbwscale) { case 0: - power = 1.0; + power = 1.0f; break; case 1: - power = 0.0; + power = 0.0f; break; case 2: - power = 0.25; + power = 0.25f; break; case 3: - power = 0.5; + power = 0.5f; break; case 4: - power = 0.75; + power = 0.75f; break; case 5: - power = 1.5; + power = 1.5f; break; case 6: - power = 2.0; + power = 2.0f; break; case 7: - power = -0.5; + power = -0.5f; break; } - bw = bw * pow(realfreq / basefreq, power); - int ibw = (int)((bw / (SAMPLE_RATE * 0.5) * size)) + 1; + bw = bw * powf(realfreq / basefreq, power); + int ibw = (int)((bw / (SAMPLE_RATE * 0.5f) * size)) + 1; float amp = harmonics[nh - 1]; if(resonance->Penabled) @@ -450,7 +450,7 @@ void PADnoteParameters::generatespectrum_bandwidthMode(float *spectrum, if(ibw > profilesize) { //if the bandwidth is larger than the profilesize float rap = sqrt((float)profilesize / (float)ibw); int cfreq = - (int) (realfreq / (SAMPLE_RATE * 0.5) * size) - ibw / 2; + (int) (realfreq / (SAMPLE_RATE * 0.5f) * size) - ibw / 2; for(int i = 0; i < ibw; ++i) { int src = (int)(i * rap * rap); int spfreq = i + cfreq; @@ -463,17 +463,17 @@ void PADnoteParameters::generatespectrum_bandwidthMode(float *spectrum, } else { //if the bandwidth is smaller than the profilesize float rap = sqrt((float)ibw / (float)profilesize); - float ibasefreq = realfreq / (SAMPLE_RATE * 0.5) * size; + float ibasefreq = realfreq / (SAMPLE_RATE * 0.5f) * size; for(int i = 0; i < profilesize; ++i) { - float idfreq = i / (float)profilesize - 0.5; + float idfreq = i / (float)profilesize - 0.5f; idfreq *= ibw; int spfreq = (int) (idfreq + ibasefreq); - float fspfreq = fmod((double)idfreq + ibasefreq, 1.0); + float fspfreq = fmod((double)idfreq + ibasefreq, 1.0f); if(spfreq <= 0) continue; if(spfreq >= size - 1) break; - spectrum[spfreq] += amp * profile[i] * rap * (1.0 - fspfreq); + spectrum[spfreq] += amp * profile[i] * rap * (1.0f - fspfreq); spectrum[spfreq + 1] += amp * profile[i] * rap * fspfreq; } } @@ -488,20 +488,20 @@ void PADnoteParameters::generatespectrum_otherModes(float *spectrum, float basefreq) { for(int i = 0; i < size; ++i) - spectrum[i] = 0.0; + spectrum[i] = 0.0f; float harmonics[OSCIL_SIZE / 2]; for(int i = 0; i < OSCIL_SIZE / 2; ++i) - harmonics[i] = 0.0; + harmonics[i] = 0.0f; //get the harmonic structure from the oscillator (I am using the frequency amplitudes, only) oscilgen->get(harmonics, basefreq, false); //normalize - float max = 0.0; + float max = 0.0f; for(int i = 0; i < OSCIL_SIZE / 2; ++i) if(harmonics[i] > max) max = harmonics[i]; - if(max < 0.000001) + if(max < 0.000001f) max = 1; for(int i = 0; i < OSCIL_SIZE / 2; ++i) harmonics[i] /= max; @@ -511,9 +511,9 @@ void PADnoteParameters::generatespectrum_otherModes(float *spectrum, ///sa fac aici interpolarea si sa am grija daca frecv descresc - if(realfreq > SAMPLE_RATE * 0.49999) + if(realfreq > SAMPLE_RATE * 0.49999f) break; - if(realfreq < 20.0) + if(realfreq < 20.0f) break; // if (harmonics[nh-1]<1e-4) continue; @@ -521,7 +521,7 @@ void PADnoteParameters::generatespectrum_otherModes(float *spectrum, float amp = harmonics[nh - 1]; if(resonance->Penabled) amp *= resonance->getfreqresponse(realfreq); - int cfreq = (int) (realfreq / (SAMPLE_RATE * 0.5) * size); + int cfreq = (int) (realfreq / (SAMPLE_RATE * 0.5f) * size); spectrum[cfreq] = amp + 1e-9; } @@ -533,10 +533,10 @@ void PADnoteParameters::generatespectrum_otherModes(float *spectrum, int delta = k - old; float val1 = spectrum[old]; float val2 = spectrum[k]; - float idelta = 1.0 / delta; + float idelta = 1.0f / delta; for(int i = 0; i < delta; ++i) { float x = idelta * i; - spectrum[old + i] = val1 * (1.0 - x) + val2 * x; + spectrum[old + i] = val1 * (1.0f - x) + val2 * x; } old = k; } @@ -558,9 +558,9 @@ void PADnoteParameters::applyparameters(bool lockmutex) float bwadjust = getprofile(profile, profilesize); // for (int i=0;i<profilesize;i++) profile[i]*=profile[i]; - float basefreq = 65.406 * pow(2.0, Pquality.basenote / 2); + float basefreq = 65.406f * powf(2.0f, Pquality.basenote / 2); if(Pquality.basenote % 2 == 1) - basefreq *= 1.5; + basefreq *= 1.5f; int samplemax = Pquality.oct + 1; int smpoct = Pquality.smpoct; @@ -581,10 +581,10 @@ void PADnoteParameters::applyparameters(bool lockmutex) 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) * (float)nsample / samplemax; + adj[nsample] = (Pquality.oct + 1.0f) * (float)nsample / samplemax; for(int nsample = 0; nsample < samplemax; ++nsample) { - float tmp = adj[nsample] - adj[samplemax - 1] * 0.5; - float basefreqadjust = pow(2.0, tmp); + float tmp = adj[nsample] - adj[samplemax - 1] * 0.5f; + float basefreqadjust = powf(2.0f, tmp); if(Pmode == 0) generatespectrum_bandwidthMode(spectrum, @@ -600,22 +600,22 @@ void PADnoteParameters::applyparameters(bool lockmutex) const int extra_samples = 5; //the last samples contains the first samples (used for linear/cubic interpolation) newsample.smp = new float[samplesize + extra_samples]; - newsample.smp[0] = 0.0; + newsample.smp[0] = 0.0f; for(int i = 1; i < spectrumsize; ++i) //randomize the phases fftfreqs[i] = std::polar(spectrum[i], (float)RND * 6.29f); fft->freqs2smps(fftfreqs, newsample.smp); //that's all; here is the only ifft for the whole sample; no windows are used ;-) //normalize(rms) - float rms = 0.0; + float rms = 0.0f; for(int i = 0; i < samplesize; ++i) rms += newsample.smp[i] * newsample.smp[i]; rms = sqrt(rms); - if(rms < 0.000001) - rms = 1.0; - rms *= sqrt(262144.0 / samplesize); + if(rms < 0.000001f) + rms = 1.0f; + rms *= sqrt(262144.0f / samplesize); for(int i = 0; i < samplesize; ++i) - newsample.smp[i] *= 1.0 / rms * 50.0; + newsample.smp[i] *= 1.0f / rms * 50.0f; //prepare extra samples used by the linear or cubic interpolation for(int i = 0; i < extra_samples; ++i) @@ -669,7 +669,7 @@ void PADnoteParameters::export2wav(std::string basefilename) int nsmps = sample[k].size; short int *smps = new short int[nsmps]; for(int i = 0; i < nsmps; ++i) - smps[i] = (short int)(sample[k].smp[i] * 32767.0); + smps[i] = (short int)(sample[k].smp[i] * 32767.0f); wav.writeMonoSamples(nsmps, smps); } } diff --git a/src/Params/PADnoteParameters.h b/src/Params/PADnoteParameters.h @@ -47,7 +47,7 @@ class PADnoteParameters:public Presets void add2XML(XMLwrapper *xml); void getfromXML(XMLwrapper *xml); - //returns a value between 0.0-1.0 that represents the estimation perceived bandwidth + //returns a value between 0.0f-1.0f that represents the estimation perceived bandwidth float getprofile(float *smp, int size); //parameters diff --git a/src/Params/SUBnoteParameters.h b/src/Params/SUBnoteParameters.h @@ -87,7 +87,7 @@ class SUBnoteParameters:public Presets //Magnitudes unsigned char Phmag[MAX_SUB_HARMONICS]; - //Relative BandWidth ("64"=1.0) + //Relative BandWidth ("64"=1.0f) unsigned char Phrelbw[MAX_SUB_HARMONICS]; //how much the bandwidth is increased according to lower/higher frequency; 64-default diff --git a/src/Samples/Sample.cpp b/src/Samples/Sample.cpp @@ -32,7 +32,7 @@ using namespace std; Sample::Sample() :bufferSize(1),buffer(new float[1]) { - buffer[0] = 0.0; + buffer[0] = 0.0f; } Sample::Sample(const Sample &smp) @@ -105,7 +105,7 @@ bool Sample::operator==(const Sample &smp) const * @param xb X of point b * @return estimated Y of test point */ -float linearEstimate(float ya, float yb, float xt, float xa = 0.0, float xb =1.0) +float linearEstimate(float ya, float yb, float xt, float xa = 0.0f, float xb =1.0f) { #warning TODO this could be done with a good bit less computation //Lets make this simple by normalizing the x axis @@ -130,7 +130,7 @@ void Sample::resample(const unsigned int rate, const unsigned int nrate) if(rate == nrate) return; //no resampling here else {//resampling occurs here - float ratio = (nrate * 1.0) / (rate * 1.0); + float ratio = (nrate * 1.0f) / (rate * 1.0f); int nBufferSize = (int)bufferSize * ratio; float *nBuffer = new float[nBufferSize]; @@ -171,7 +171,7 @@ Sample Sample::subSample(int a, int b) const float Sample::max() const { - float 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.0f to 1.0f for(int i = 0; i < bufferSize; ++i) if(buffer[i] > max) max = buffer[i]; @@ -180,7 +180,7 @@ float Sample::max() const float Sample::min() const { - float 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.0f to 1.0f for(int i = 0; i < bufferSize; ++i) if(buffer[i] < min) min = buffer[i]; diff --git a/src/Synth/ADnote.cpp b/src/Synth/ADnote.cpp @@ -52,10 +52,10 @@ ADnote::ADnote(ADnoteParameters *pars, midinote = midinote_; NoteEnabled = ON; basefreq = freq; - if(velocity > 1.0) - velocity = 1.0; + if(velocity > 1.0f) + velocity = 1.0f; this->velocity = velocity; - time = 0.0; + time = 0.0f; stereo = pars->GlobalPar.PStereo; NoteGlobalPar.Detune = getdetune(pars->GlobalPar.PDetuneType, @@ -66,28 +66,28 @@ ADnote::ADnote(ADnoteParameters *pars, if(pars->GlobalPar.PPanning == 0) NoteGlobalPar.Panning = RND; else - NoteGlobalPar.Panning = pars->GlobalPar.PPanning / 128.0; + NoteGlobalPar.Panning = pars->GlobalPar.PPanning / 128.0f; NoteGlobalPar.FilterCenterPitch = pars->GlobalPar.GlobalFilter->getfreq() //center freq + pars->GlobalPar.PFilterVelocityScale - / 127.0 * 6.0 //velocity sensing + / 127.0f * 6.0f //velocity sensing * (VelF(velocity, pars->GlobalPar. PFilterVelocityScaleFunction) - 1); if(pars->GlobalPar.PPunchStrength != 0) { NoteGlobalPar.Punch.Enabled = 1; - NoteGlobalPar.Punch.t = 1.0; //start from 1.0 and to 0.0 + NoteGlobalPar.Punch.t = 1.0f; //start from 1.0f and to 0.0f NoteGlobalPar.Punch.initialvalue = - ((pow(10, 1.5 * pars->GlobalPar.PPunchStrength / 127.0) - 1.0) + ((powf(10, 1.5f * pars->GlobalPar.PPunchStrength / 127.0f) - 1.0f) * VelF(velocity, pars->GlobalPar.PPunchVelocitySensing)); float time = - pow(10, 3.0 * pars->GlobalPar.PPunchTime / 127.0) / 10000.0; //0.1 .. 100 ms - float stretch = pow(440.0 / freq, - pars->GlobalPar.PPunchStretch / 64.0); - NoteGlobalPar.Punch.dt = 1.0 / (time * SAMPLE_RATE * stretch); + powf(10, 3.0f * pars->GlobalPar.PPunchTime / 127.0f) / 10000.0f; //0.1f .. 100 ms + float stretch = powf(440.0f / freq, + pars->GlobalPar.PPunchStretch / 64.0f); + NoteGlobalPar.Punch.dt = 1.0f / (time * SAMPLE_RATE * stretch); } else NoteGlobalPar.Punch.Enabled = 0; @@ -107,7 +107,7 @@ ADnote::ADnote(ADnoteParameters *pars, } unison_stereo_spread[nvoice] = - pars->VoicePar[nvoice].Unison_stereo_spread / 127.0; + pars->VoicePar[nvoice].Unison_stereo_spread / 127.0f; int unison = pars->VoicePar[nvoice].Unison_size; if(unison < 1) unison = 1; @@ -120,17 +120,17 @@ ADnote::ADnote(ADnoteParameters *pars, unison_invert_phase[nvoice] = new bool[unison]; float unison_spread = pars->getUnisonFrequencySpreadCents( nvoice); - float unison_real_spread = pow(2.0, (unison_spread * 0.5) / 1200.0); + float unison_real_spread = powf(2.0f, (unison_spread * 0.5f) / 1200.0f); float unison_vibratto_a = pars->VoicePar[nvoice].Unison_vibratto - / 127.0; //0.0 .. 1.0 + / 127.0f; //0.0f .. 1.0f switch(unison) { case 1: - unison_base_freq_rap[nvoice][0] = 1.0; //if the unison is not used, always make the only subvoice to have the default note + unison_base_freq_rap[nvoice][0] = 1.0f; //if the unison is not used, always make the only subvoice to have the default note break; case 2: { //unison for 2 subvoices - unison_base_freq_rap[nvoice][0] = 1.0 / unison_real_spread; + unison_base_freq_rap[nvoice][0] = 1.0f / unison_real_spread; unison_base_freq_rap[nvoice][1] = unison_real_spread; }; break; @@ -138,16 +138,16 @@ ADnote::ADnote(ADnoteParameters *pars, float unison_values[unison]; float min = -1e-6, max = 1e-6; for(int k = 0; k < unison; ++k) { - 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); + float step = (k / (float) (unison - 1)) * 2.0f - 1.0f; //this makes the unison spread more uniform + float val = step + (RND * 2.0f - 1.0f) / (unison - 1); unison_values[k] = limit(val, min, max); } 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 + (unison_values[k] - (max + min) * 0.5f) / diff; //the lowest value will be -1 and the highest will be 1 unison_base_freq_rap[nvoice][k] = - pow(2.0, (unison_spread * unison_values[k]) / 1200); + powf(2.0f, (unison_spread * unison_values[k]) / 1200); } }; } @@ -155,38 +155,38 @@ ADnote::ADnote(ADnoteParameters *pars, //unison vibrattos if(unison > 1) { for(int k = 0; k < unison; ++k) //reduce the frequency difference for larger vibrattos - unison_base_freq_rap[nvoice][k] = 1.0 - + (unison_base_freq_rap[nvoice][k] - 1.0) - * (1.0 - unison_vibratto_a); + unison_base_freq_rap[nvoice][k] = 1.0f + + (unison_base_freq_rap[nvoice][k] - 1.0f) + * (1.0f - unison_vibratto_a); } 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; + (unison_real_spread - 1.0f) * unison_vibratto_a; float increments_per_second = SAMPLE_RATE / (float)SOUND_BUFFER_SIZE; - float vibratto_base_period = 0.25 - * pow(2.0, - (1.0 + float vibratto_base_period = 0.25f + * powf(2.0f, + (1.0f - pars->VoicePar[nvoice]. - Unison_vibratto_speed / 127.0) * 4.0); + Unison_vibratto_speed / 127.0f) * 4.0f); for(int k = 0; k < unison; ++k) { - unison_vibratto[nvoice].position[k] = RND * 1.8 - 0.9; + unison_vibratto[nvoice].position[k] = RND * 1.8f - 0.9f; //make period to vary randomly from 50% to 200% vibratto base period float vibratto_period = vibratto_base_period - * pow(2.0, RND * 2.0 - 1.0); + * powf(2.0f, RND * 2.0f - 1.0f); - float m = 4.0 / (vibratto_period * increments_per_second); - if(RND < 0.5) + float m = 4.0f / (vibratto_period * increments_per_second); + if(RND < 0.5f) m = -m; unison_vibratto[nvoice].step[k] = m; } if(unison == 1) { //no vibratto for a single voice - unison_vibratto[nvoice].step[0] = 0.0; - unison_vibratto[nvoice].position[0] = 0.0; - unison_vibratto[nvoice].amplitude = 0.0; + unison_vibratto[nvoice].step[0] = 0.0f; + unison_vibratto[nvoice].position[0] = 0.0f; + unison_vibratto[nvoice].amplitude = 0.0f; } //phase invert for unison @@ -198,7 +198,7 @@ ADnote::ADnote(ADnoteParameters *pars, unison_invert_phase[nvoice][k] = false; break; case 1: for(int k = 0; k < unison; ++k) - unison_invert_phase[nvoice][k] = (RND > 0.5); + unison_invert_phase[nvoice][k] = (RND > 0.5f); break; default: for(int k = 0; k < unison; ++k) unison_invert_phase[nvoice][k] = @@ -261,9 +261,9 @@ ADnote::ADnote(ADnoteParameters *pars, for(int k = 0; k < unison; ++k) { oscposhi[nvoice][k] = 0; - oscposlo[nvoice][k] = 0.0; + oscposlo[nvoice][k] = 0.0f; oscposhiFM[nvoice][k] = 0; - oscposloFM[nvoice][k] = 0.0; + oscposloFM[nvoice][k] = 0.0f; } //the extra points contains the first point @@ -289,7 +289,7 @@ ADnote::ADnote(ADnoteParameters *pars, oscposhi_start += (int)((pars->VoicePar[nvoice].Poscilphase - - 64.0) / 128.0 * OSCIL_SIZE + OSCIL_SIZE * 4); + - 64.0f) / 128.0f * OSCIL_SIZE + OSCIL_SIZE * 4); oscposhi_start %= OSCIL_SIZE; for(int k = 0; k < unison; ++k) { @@ -338,31 +338,31 @@ ADnote::ADnote(ADnoteParameters *pars, NoteVoicePar[nvoice].FMAmpEnvelope = NULL; //Compute the Voice's modulator volume (incl. damping) - float fmvoldamp = pow(440.0 / getvoicebasefreq( + float fmvoldamp = powf(440.0f / getvoicebasefreq( nvoice), - pars->VoicePar[nvoice].PFMVolumeDamp / 64.0 - - 1.0); + pars->VoicePar[nvoice].PFMVolumeDamp / 64.0f + - 1.0f); switch(NoteVoicePar[nvoice].FMEnabled) { case PHASE_MOD: fmvoldamp = - pow(440.0 / getvoicebasefreq( - nvoice), pars->VoicePar[nvoice].PFMVolumeDamp / 64.0); + powf(440.0f / getvoicebasefreq( + nvoice), pars->VoicePar[nvoice].PFMVolumeDamp / 64.0f); NoteVoicePar[nvoice].FMVolume = - (exp(pars->VoicePar[nvoice].PFMVolume / 127.0 - * FM_AMP_MULTIPLIER) - 1.0) * fmvoldamp * 4.0; + (expf(pars->VoicePar[nvoice].PFMVolume / 127.0f + * FM_AMP_MULTIPLIER) - 1.0f) * fmvoldamp * 4.0f; break; case FREQ_MOD: NoteVoicePar[nvoice].FMVolume = - (exp(pars->VoicePar[nvoice].PFMVolume / 127.0 - * FM_AMP_MULTIPLIER) - 1.0) * fmvoldamp * 4.0; + (expf(pars->VoicePar[nvoice].PFMVolume / 127.0f + * FM_AMP_MULTIPLIER) - 1.0f) * fmvoldamp * 4.0f; break; - // case PITCH_MOD:NoteVoicePar[nvoice].FMVolume=(pars->VoicePar[nvoice].PFMVolume/127.0*8.0)*fmvoldamp;//??????????? + // case PITCH_MOD:NoteVoicePar[nvoice].FMVolume=(pars->VoicePar[nvoice].PFMVolume/127.0f*8.0f)*fmvoldamp;//??????????? // break; default: - if(fmvoldamp > 1.0) - fmvoldamp = 1.0; + if(fmvoldamp > 1.0f) + fmvoldamp = 1.0f; NoteVoicePar[nvoice].FMVolume = pars->VoicePar[nvoice].PFMVolume - / 127.0 * fmvoldamp; + / 127.0f * fmvoldamp; } //Voice's modulator velocity sensing @@ -372,13 +372,13 @@ ADnote::ADnote(ADnoteParameters *pars, FMoldsmp[nvoice] = new float [unison]; for(int k = 0; k < unison; ++k) - FMoldsmp[nvoice][k] = 0.0; //this is for FM (integration) + FMoldsmp[nvoice][k] = 0.0f; //this is for FM (integration) firsttick[nvoice] = 1; NoteVoicePar[nvoice].DelayTicks = - (int)((exp(pars->VoicePar[nvoice].PDelay / 127.0 - * log(50.0)) - - 1.0) / SOUND_BUFFER_SIZE / 10.0 * SAMPLE_RATE); + (int)((expf(pars->VoicePar[nvoice].PDelay / 127.0f + * logf(50.0f)) + - 1.0f) / SOUND_BUFFER_SIZE / 10.0f * SAMPLE_RATE); } max_unison = 1; @@ -413,8 +413,8 @@ void ADnote::legatonote(float freq, float velocity, int portamento_, midinote = midinote_; basefreq = freq; - if(velocity > 1.0) - velocity = 1.0; + if(velocity > 1.0f) + velocity = 1.0f; this->velocity = velocity; NoteGlobalPar.Detune = getdetune(pars->GlobalPar.PDetuneType, @@ -425,11 +425,11 @@ void ADnote::legatonote(float freq, float velocity, int portamento_, if(pars->GlobalPar.PPanning == 0) NoteGlobalPar.Panning = RND; else - NoteGlobalPar.Panning = pars->GlobalPar.PPanning / 128.0; + NoteGlobalPar.Panning = pars->GlobalPar.PPanning / 128.0f; //center freq NoteGlobalPar.FilterCenterPitch = pars->GlobalPar.GlobalFilter->getfreq() - + pars->GlobalPar.PFilterVelocityScale / 127.0 * 6.0 //velocity sensing + + pars->GlobalPar.PFilterVelocityScale / 127.0f * 6.0f //velocity sensing * (VelF(velocity, pars->GlobalPar.PFilterVelocityScaleFunction) - 1); @@ -500,31 +500,31 @@ void ADnote::legatonote(float freq, float velocity, int portamento_, NoteVoicePar[nvoice].FMVoice = pars->VoicePar[nvoice].PFMVoice; //Compute the Voice's modulator volume (incl. damping) - float fmvoldamp = pow(440.0 / getvoicebasefreq(nvoice), - pars->VoicePar[nvoice].PFMVolumeDamp / 64.0 - - 1.0); + float fmvoldamp = powf(440.0f / getvoicebasefreq(nvoice), + pars->VoicePar[nvoice].PFMVolumeDamp / 64.0f + - 1.0f); switch(NoteVoicePar[nvoice].FMEnabled) { case PHASE_MOD: fmvoldamp = - pow(440.0 / getvoicebasefreq( - nvoice), pars->VoicePar[nvoice].PFMVolumeDamp / 64.0); + powf(440.0f / getvoicebasefreq( + nvoice), pars->VoicePar[nvoice].PFMVolumeDamp / 64.0f); NoteVoicePar[nvoice].FMVolume = - (exp(pars->VoicePar[nvoice].PFMVolume / 127.0 - * FM_AMP_MULTIPLIER) - 1.0) * fmvoldamp * 4.0; + (expf(pars->VoicePar[nvoice].PFMVolume / 127.0f + * FM_AMP_MULTIPLIER) - 1.0f) * fmvoldamp * 4.0f; break; case FREQ_MOD: NoteVoicePar[nvoice].FMVolume = - (exp(pars->VoicePar[nvoice].PFMVolume / 127.0 - * FM_AMP_MULTIPLIER) - 1.0) * fmvoldamp * 4.0; + (expf(pars->VoicePar[nvoice].PFMVolume / 127.0f + * FM_AMP_MULTIPLIER) - 1.0f) * fmvoldamp * 4.0f; break; - // case PITCH_MOD:NoteVoicePar[nvoice].FMVolume=(pars->VoicePar[nvoice].PFMVolume/127.0*8.0)*fmvoldamp;//??????????? + // case PITCH_MOD:NoteVoicePar[nvoice].FMVolume=(pars->VoicePar[nvoice].PFMVolume/127.0f*8.0f)*fmvoldamp;//??????????? // break; default: - if(fmvoldamp > 1.0) - fmvoldamp = 1.0; + if(fmvoldamp > 1.0f) + fmvoldamp = 1.0f; NoteVoicePar[nvoice].FMVolume = pars->VoicePar[nvoice].PFMVolume - / 127.0 * fmvoldamp; + / 127.0f * fmvoldamp; } //Voice's modulator velocity sensing @@ -533,9 +533,9 @@ void ADnote::legatonote(float freq, float velocity, int portamento_, partparams->VoicePar[nvoice].PFMVelocityScaleFunction); NoteVoicePar[nvoice].DelayTicks = - (int)((exp(pars->VoicePar[nvoice].PDelay / 127.0 - * log(50.0)) - - 1.0) / SOUND_BUFFER_SIZE / 10.0 * SAMPLE_RATE); + (int)((expf(pars->VoicePar[nvoice].PDelay / 127.0f + * logf(50.0f)) + - 1.0f) / SOUND_BUFFER_SIZE / 10.0f * SAMPLE_RATE); } /// initparameters(); @@ -545,9 +545,9 @@ void ADnote::legatonote(float freq, float velocity, int portamento_, int tmp[NUM_VOICES]; - NoteGlobalPar.Volume = 4.0 - * pow(0.1, 3.0 - * (1.0 - partparams->GlobalPar.PVolume / 96.0)) //-60 dB .. 0 dB + NoteGlobalPar.Volume = 4.0f + * powf(0.1f, 3.0f + * (1.0f - partparams->GlobalPar.PVolume / 96.0f)) //-60 dB .. 0 dB * VelF( velocity, partparams->GlobalPar. @@ -574,7 +574,7 @@ void ADnote::legatonote(float freq, float velocity, int portamento_, NoteVoicePar[nvoice].noisetype = partparams->VoicePar[nvoice].Type; /* Voice Amplitude Parameters Init */ NoteVoicePar[nvoice].Volume = - pow(0.1, 3.0 * (1.0 - partparams->VoicePar[nvoice].PVolume / 127.0)) // -60 dB .. 0 dB + powf(0.1f, 3.0f * (1.0f - partparams->VoicePar[nvoice].PVolume / 127.0f)) // -60 dB .. 0 dB * VelF(velocity, partparams->VoicePar[nvoice].PAmpVelocityScaleFunction);//velocity @@ -585,9 +585,9 @@ void ADnote::legatonote(float freq, float velocity, int portamento_, NoteVoicePar[nvoice].Panning = RND; // random panning else NoteVoicePar[nvoice].Panning = - partparams->VoicePar[nvoice].PPanning / 128.0; + partparams->VoicePar[nvoice].PPanning / 128.0f; - newamplitude[nvoice] = 1.0; + newamplitude[nvoice] = 1.0f; if((partparams->VoicePar[nvoice].PAmpEnvelopeEnabled != 0) && (NoteVoicePar[nvoice].AmpEnvelope != NULL)) newamplitude[nvoice] *= NoteVoicePar[nvoice].AmpEnvelope->envout_dB(); @@ -730,7 +730,7 @@ void ADnote::initparameters() vce.noisetype = param.Type; /* Voice Amplitude Parameters Init */ - vce.Volume = pow(0.1, 3.0 * (1.0 - param.PVolume / 127.0))// -60dB..0dB + vce.Volume = powf(0.1f, 3.0f * (1.0f - param.PVolume / 127.0f))// -60dB..0dB * VelF(velocity, param.PAmpVelocityScaleFunction); if(param.PVolumeminus) @@ -739,9 +739,9 @@ void ADnote::initparameters() if(param.PPanning == 0) vce.Panning = RND; // random panning else - vce.Panning = param.PPanning / 128.0; + vce.Panning = param.PPanning / 128.0f; - newamplitude[nvoice] = 1.0; + newamplitude[nvoice] = 1.0f; if(param.PAmpEnvelopeEnabled) { vce.AmpEnvelope = new Envelope(param.AmpEnvelope, basefreq); vce.AmpEnvelope->envout_dB(); //discard the first envelope sample @@ -786,7 +786,7 @@ void ADnote::initparameters() if(param.PextFMoscil != -1) vc = param.PextFMoscil; - float tmp = 1.0; + float tmp = 1.0f; if((partparams->VoicePar[vc].FMSmp->Padaptiveharmonics != 0) || (vce.FMEnabled == MORPH) || (vce.FMEnabled == RING_MOD)) @@ -804,7 +804,7 @@ void ADnote::initparameters() vce.FMSmp[OSCIL_SIZE + i] = vce.FMSmp[i]; int oscposhiFM_add = (int)((param.PFMoscilphase - - 64.0) / 128.0 * OSCIL_SIZE + OSCIL_SIZE * 4); + - 64.0f) / 128.0f * OSCIL_SIZE + OSCIL_SIZE * 4); for(int k = 0; k < unison_size[nvoice]; ++k) { oscposhiFM[nvoice][k] += oscposhiFM_add; oscposhiFM[nvoice][k] %= OSCIL_SIZE; @@ -843,7 +843,7 @@ void ADnote::initparameters() */ void ADnote::compute_unison_freq_rap(int nvoice) { if(unison_size[nvoice] == 1) { //no unison - unison_freq_rap[nvoice][0] = 1.0; + unison_freq_rap[nvoice][0] = 1.0f; return; } float relbw = ctl->bandwidth.relbw * bandwidthDetuneMultiplier; @@ -851,18 +851,18 @@ void ADnote::compute_unison_freq_rap(int nvoice) { float pos = unison_vibratto[nvoice].position[k]; float step = unison_vibratto[nvoice].step[k]; pos += step; - if(pos <= -1.0) { - pos = -1.0; + if(pos <= -1.0f) { + pos = -1.0f; step = -step; } - if(pos >= 1.0) { - pos = 1.0; + if(pos >= 1.0f) { + pos = 1.0f; step = -step; } - float vibratto_val = (pos - 0.333333333 * pos * pos * pos) * 1.5; //make the vibratto lfo smoother - unison_freq_rap[nvoice][k] = 1.0 + float vibratto_val = (pos - 0.333333333f * pos * pos * pos) * 1.5f; //make the vibratto lfo smoother + unison_freq_rap[nvoice][k] = 1.0f + ((unison_base_freq_rap[nvoice][k] - - 1.0) + vibratto_val + - 1.0f) + vibratto_val * unison_vibratto[nvoice].amplitude) * relbw; @@ -909,26 +909,26 @@ void ADnote::setfreqFM(int nvoice, float in_freq) */ float ADnote::getvoicebasefreq(int nvoice) const { - float detune = NoteVoicePar[nvoice].Detune / 100.0 - + NoteVoicePar[nvoice].FineDetune / 100.0 + float detune = NoteVoicePar[nvoice].Detune / 100.0f + + NoteVoicePar[nvoice].FineDetune / 100.0f * ctl->bandwidth.relbw * bandwidthDetuneMultiplier - + NoteGlobalPar.Detune / 100.0; + + NoteGlobalPar.Detune / 100.0f; if(NoteVoicePar[nvoice].fixedfreq == 0) - return this->basefreq * pow(2, detune / 12.0); + return this->basefreq * powf(2, detune / 12.0f); else { //the fixed freq is enabled - float fixedfreq = 440.0; + float fixedfreq = 440.0f; int fixedfreqET = NoteVoicePar[nvoice].fixedfreqET; if(fixedfreqET != 0) { //if the frequency varies according the keyboard note float tmp = (midinote - - 69.0) / 12.0 * (pow(2.0, (fixedfreqET - 1) / 63.0) - 1.0); + - 69.0f) / 12.0f * (powf(2.0f, (fixedfreqET - 1) / 63.0f) - 1.0f); if(fixedfreqET <= 64) - fixedfreq *= pow(2.0, tmp); + fixedfreq *= powf(2.0f, tmp); else - fixedfreq *= pow(3.0, tmp); + fixedfreq *= powf(3.0f, tmp); } - return fixedfreq * pow(2.0, detune / 12.0); + return fixedfreq * powf(2.0f, detune / 12.0f); } } @@ -937,8 +937,8 @@ float ADnote::getvoicebasefreq(int nvoice) const */ float ADnote::getFMvoicebasefreq(int nvoice) const { - float detune = NoteVoicePar[nvoice].FMDetune / 100.0; - return getvoicebasefreq(nvoice) * pow(2, detune / 12.0); + float detune = NoteVoicePar[nvoice].FMDetune / 100.0f; + return getvoicebasefreq(nvoice) * powf(2, detune / 12.0f); } /* @@ -949,7 +949,7 @@ void ADnote::computecurrentparameters() int nvoice; float voicefreq, voicepitch, filterpitch, filterfreq, FMfreq, FMrelativepitch, globalpitch, globalfilterpitch; - globalpitch = 0.01 * (NoteGlobalPar.FreqEnvelope->envout() + globalpitch = 0.01f * (NoteGlobalPar.FreqEnvelope->envout() + NoteGlobalPar.FreqLfo->lfoout() * ctl->modwheel.relmod); globaloldamplitude = globalnewamplitude; @@ -972,7 +972,7 @@ void ADnote::computecurrentparameters() NoteGlobalPar.GlobalFilterR->setfreq_and_q(tmpfilterfreq, globalfilterq); //compute the portamento, if it is used by this note - float portamentofreqrap = 1.0; + float portamentofreqrap = 1.0f; if(portamento != 0) { //this voice use portamento portamentofreqrap = ctl->portamento.freqrap; if(ctl->portamento.used == 0) //the portamento has finished @@ -994,7 +994,7 @@ void ADnote::computecurrentparameters() /* Voice Amplitude */ /*******************/ oldamplitude[nvoice] = newamplitude[nvoice]; - newamplitude[nvoice] = 1.0; + newamplitude[nvoice] = 1.0f; if(NoteVoicePar[nvoice].AmpEnvelope != NULL) newamplitude[nvoice] *= NoteVoicePar[nvoice].AmpEnvelope->envout_dB(); @@ -1026,16 +1026,16 @@ void ADnote::computecurrentparameters() /*******************/ /* Voice Frequency */ /*******************/ - voicepitch = 0.0; + voicepitch = 0.0f; if(NoteVoicePar[nvoice].FreqLfo != NULL) - voicepitch += NoteVoicePar[nvoice].FreqLfo->lfoout() / 100.0 + voicepitch += NoteVoicePar[nvoice].FreqLfo->lfoout() / 100.0f * ctl->bandwidth.relbw; if(NoteVoicePar[nvoice].FreqEnvelope != NULL) voicepitch += NoteVoicePar[nvoice].FreqEnvelope->envout() - / 100.0; + / 100.0f; voicefreq = getvoicebasefreq(nvoice) - * pow(2, (voicepitch + globalpitch) / 12.0); //Hz frequency + * powf(2, (voicepitch + globalpitch) / 12.0f); //Hz frequency voicefreq *= ctl->pitchwheel.relfreq; //change the frequency by the controller setfreq(nvoice, voicefreq * portamentofreqrap); @@ -1043,13 +1043,13 @@ void ADnote::computecurrentparameters() /* Modulator */ /***************/ if(NoteVoicePar[nvoice].FMEnabled != NONE) { - FMrelativepitch = NoteVoicePar[nvoice].FMDetune / 100.0; + FMrelativepitch = NoteVoicePar[nvoice].FMDetune / 100.0f; if(NoteVoicePar[nvoice].FMFreqEnvelope != NULL) FMrelativepitch += NoteVoicePar[nvoice].FMFreqEnvelope->envout() / 100; FMfreq = - pow(2.0, FMrelativepitch - / 12.0) * voicefreq * portamentofreqrap; + powf(2.0f, FMrelativepitch + / 12.0f) * voicefreq * portamentofreqrap; setfreqFM(nvoice, FMfreq); FMoldamplitude[nvoice] = FMnewamplitude[nvoice]; @@ -1072,19 +1072,19 @@ 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)) + if((smps[i - 1] < 0.0f) && (smps[i] > 0.0f)) zerocrossings++; //this is only the possitive crossings - float tmp = (SOUND_BUFFER_SIZE - 1.0) / (zerocrossings + 1) / 3.0; - if(tmp < 8.0) - tmp = 8.0; + float tmp = (SOUND_BUFFER_SIZE - 1.0f) / (zerocrossings + 1) / 3.0f; + if(tmp < 8.0f) + tmp = 8.0f; int n; F2I(tmp, n); //how many samples is the fade-in if(n > SOUND_BUFFER_SIZE) n = SOUND_BUFFER_SIZE; for(int i = 0; i < n; ++i) { //fade-in - float tmp = 0.5 - cos((float)i / (float) n * PI) * 0.5; + float tmp = 0.5f - cosf((float)i / (float) n * PI) * 0.5f; smps[i] *= tmp; } } @@ -1105,10 +1105,10 @@ inline void ADnote::ComputeVoiceOscillator_LinearInterpolation(int nvoice) 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; + tw[i] = smps[poshi] * (1.0f - poslo) + smps[poshi + 1] * poslo; poslo += freqlo; - if(poslo >= 1.0) { - poslo -= 1.0; + if(poslo >= 1.0f) { + poslo -= 1.0f; poshi++; } poshi += freqhi; @@ -1138,15 +1138,15 @@ inline void ADnote::ComputeVoiceOscillator_CubicInterpolation(int nvoice){ x0=smps[poshi+1]; x1=smps[poshi+2]; x2=smps[poshi+3]; - a=(3.0 * (x0-x1) - xm1 + x2) / 2.0; - b = 2.0*x1 + xm1 - (5.0*x0 + x2) / 2.0; - c = (x1 - xm1) / 2.0; + a=(3.0f * (x0-x1) - xm1 + x2) / 2.0f; + b = 2.0f*x1 + xm1 - (5.0f*x0 + x2) / 2.0f; + c = (x1 - xm1) / 2.0f; tmpwave[i]=(((a * poslo) + b) * poslo + c) * poslo + x0; printf("a\n"); - //tmpwave[i]=smps[poshi]*(1.0-poslo)+smps[poshi+1]*poslo; + //tmpwave[i]=smps[poshi]*(1.0f-poslo)+smps[poshi+1]*poslo; poslo+=oscfreqlo[nvoice]; - if (poslo>=1.0) { - poslo-=1.0; + if (poslo>=1.0f) { + poslo-=1.0f; poshi++; }; poshi+=oscfreqhi[nvoice]; @@ -1164,10 +1164,10 @@ inline void ADnote::ComputeVoiceOscillatorMorph(int nvoice) int i; float amp; ComputeVoiceOscillator_LinearInterpolation(nvoice); - if(FMnewamplitude[nvoice] > 1.0) - FMnewamplitude[nvoice] = 1.0; - if(FMoldamplitude[nvoice] > 1.0) - FMoldamplitude[nvoice] = 1.0; + if(FMnewamplitude[nvoice] > 1.0f) + FMnewamplitude[nvoice] = 1.0f; + if(FMoldamplitude[nvoice] > 1.0f) + FMoldamplitude[nvoice] = 1.0f; if(NoteVoicePar[nvoice].FMVoice >= 0) { //if I use VoiceOut[] as modullator @@ -1180,7 +1180,7 @@ inline void ADnote::ComputeVoiceOscillatorMorph(int nvoice) i, SOUND_BUFFER_SIZE); tw[i] = tw[i] - * (1.0 - amp) + amp * NoteVoicePar[FMVoice].VoiceOut[i]; + * (1.0f - amp) + amp * NoteVoicePar[FMVoice].VoiceOut[i]; } } } @@ -1197,12 +1197,12 @@ inline void ADnote::ComputeVoiceOscillatorMorph(int nvoice) FMnewamplitude[nvoice], i, SOUND_BUFFER_SIZE); - tw[i] = tw[i] * (1.0 - amp) + amp + tw[i] = tw[i] * (1.0f - amp) + amp * (NoteVoicePar[nvoice].FMSmp[poshiFM] * (1 - posloFM) + NoteVoicePar[nvoice].FMSmp[poshiFM + 1] * posloFM); posloFM += freqloFM; - if(posloFM >= 1.0) { - posloFM -= 1.0; + if(posloFM >= 1.0f) { + posloFM -= 1.0f; poshiFM++; } poshiFM += freqhiFM; @@ -1222,10 +1222,10 @@ inline void ADnote::ComputeVoiceOscillatorRingModulation(int nvoice) int i; float amp; ComputeVoiceOscillator_LinearInterpolation(nvoice); - if(FMnewamplitude[nvoice] > 1.0) - FMnewamplitude[nvoice] = 1.0; - if(FMoldamplitude[nvoice] > 1.0) - FMoldamplitude[nvoice] = 1.0; + if(FMnewamplitude[nvoice] > 1.0f) + FMnewamplitude[nvoice] = 1.0f; + if(FMoldamplitude[nvoice] > 1.0f) + FMoldamplitude[nvoice] = 1.0f; if(NoteVoicePar[nvoice].FMVoice >= 0) { // if I use VoiceOut[] as modullator for(int k = 0; k < unison_size[nvoice]; ++k) { @@ -1236,7 +1236,7 @@ inline void ADnote::ComputeVoiceOscillatorRingModulation(int nvoice) i, SOUND_BUFFER_SIZE); int FMVoice = NoteVoicePar[nvoice].FMVoice; - tw[i] *= (1.0 - amp) + amp * NoteVoicePar[FMVoice].VoiceOut[i]; + tw[i] *= (1.0f - amp) + amp * NoteVoicePar[FMVoice].VoiceOut[i]; } } } @@ -1253,13 +1253,13 @@ inline void ADnote::ComputeVoiceOscillatorRingModulation(int nvoice) FMnewamplitude[nvoice], i, SOUND_BUFFER_SIZE); - tw[i] *= (NoteVoicePar[nvoice].FMSmp[poshiFM] * (1.0 - posloFM) + tw[i] *= (NoteVoicePar[nvoice].FMSmp[poshiFM] * (1.0f - posloFM) + NoteVoicePar[nvoice].FMSmp[poshiFM + 1] * posloFM) * amp - + (1.0 - amp); + + (1.0f - amp); posloFM += freqloFM; - if(posloFM >= 1.0) { - posloFM -= 1.0; + if(posloFM >= 1.0f) { + posloFM -= 1.0f; poshiFM++; } poshiFM += freqhiFM; @@ -1302,11 +1302,11 @@ inline void ADnote::ComputeVoiceOscillatorFrequencyModulation(int nvoice, for(i = 0; i < SOUND_BUFFER_SIZE; ++i) { tw[i] = - (NoteVoicePar[nvoice].FMSmp[poshiFM] * (1.0 - posloFM) + (NoteVoicePar[nvoice].FMSmp[poshiFM] * (1.0f - posloFM) + NoteVoicePar[nvoice].FMSmp[poshiFM + 1] * posloFM); posloFM += freqloFM; - if(posloFM >= 1.0) { - posloFM = fmod(posloFM, 1.0); + if(posloFM >= 1.0f) { + posloFM = fmod(posloFM, 1.0f); poshiFM++; } poshiFM += freqhiFM; @@ -1340,7 +1340,7 @@ inline void ADnote::ComputeVoiceOscillatorFrequencyModulation(int nvoice, //normalize: makes all sample-rates, oscil_sizes to produce same sound if(FMmode != 0) { //Frequency modulation - float normalize = OSCIL_SIZE / 262144.0 * 44100.0 + float normalize = OSCIL_SIZE / 262144.0f * 44100.0f / (float)SAMPLE_RATE; for(int k = 0; k < unison_size[nvoice]; ++k) { float *tw = tmpwave_unison[k]; @@ -1353,7 +1353,7 @@ inline void ADnote::ComputeVoiceOscillatorFrequencyModulation(int nvoice, } } else { //Phase modulation - float normalize = OSCIL_SIZE / 262144.0; + float normalize = OSCIL_SIZE / 262144.0f; for(int k = 0; k < unison_size[nvoice]; ++k) { float *tw = tmpwave_unison[k]; for(i = 0; i < SOUND_BUFFER_SIZE; ++i) @@ -1371,7 +1371,7 @@ inline void ADnote::ComputeVoiceOscillatorFrequencyModulation(int nvoice, for(i = 0; i < SOUND_BUFFER_SIZE; ++i) { F2I(tw[i], FMmodfreqhi); - FMmodfreqlo = fmod(tw[i] + 0.0000000001, 1.0); + FMmodfreqlo = fmod(tw[i] + 0.0000000001f, 1.0f); if(FMmodfreqhi < 0) FMmodfreqlo++; @@ -1379,20 +1379,20 @@ inline void ADnote::ComputeVoiceOscillatorFrequencyModulation(int nvoice, carposhi = poshi + FMmodfreqhi; carposlo = poslo + FMmodfreqlo; - if(carposlo >= 1.0) { + if(carposlo >= 1.0f) { carposhi++; - carposlo = fmod(carposlo, 1.0); + carposlo = fmod(carposlo, 1.0f); } carposhi &= (OSCIL_SIZE - 1); tw[i] = NoteVoicePar[nvoice].OscilSmp[carposhi] - * (1.0 - carposlo) + * (1.0f - carposlo) + NoteVoicePar[nvoice].OscilSmp[carposhi + 1] * carposlo; poslo += freqlo; - if(poslo >= 1.0) { - poslo = fmod(poslo, 1.0); + if(poslo >= 1.0f) { + poslo = fmod(poslo, 1.0f); poshi++; } @@ -1419,7 +1419,7 @@ inline void ADnote::ComputeVoiceNoise(int nvoice) for(int k = 0; k < unison_size[nvoice]; ++k) { float *tw = tmpwave_unison[k]; for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) - tw[i] = RND * 2.0 - 1.0; + tw[i] = RND * 2.0f - 1.0f; } } @@ -1480,30 +1480,30 @@ int ADnote::noteout(float *outl, float *outr) if(unison_size[nvoice] > 1) stereo_pos = k / (float)(unison_size[nvoice] - - 1) * 2.0 - 1.0; - float stereo_spread = unison_stereo_spread[nvoice] * 2.0; //between 0 and 2.0 - if(stereo_spread > 1.0) { - float stereo_pos_1 = (stereo_pos >= 0.0) ? 1.0 : -1.0; + - 1) * 2.0f - 1.0f; + float stereo_spread = unison_stereo_spread[nvoice] * 2.0f; //between 0 and 2.0f + if(stereo_spread > 1.0f) { + float stereo_pos_1 = (stereo_pos >= 0.0f) ? 1.0f : -1.0f; stereo_pos = - (2.0 + (2.0f - stereo_spread) * stereo_pos - + (stereo_spread - 1.0) * stereo_pos_1; + + (stereo_spread - 1.0f) * stereo_pos_1; } else stereo_pos *= stereo_spread; if(unison_size[nvoice] == 1) - stereo_pos = 0.0; - float panning = (stereo_pos + 1.0) * 0.5; + stereo_pos = 0.0f; + float panning = (stereo_pos + 1.0f) * 0.5f; - float lvol = (1.0 - panning) * 2.0; - if(lvol > 1.0) - lvol = 1.0; + float lvol = (1.0f - panning) * 2.0f; + if(lvol > 1.0f) + lvol = 1.0f; - float rvol = panning * 2.0; - if(rvol > 1.0) - rvol = 1.0; + float rvol = panning * 2.0f; + if(rvol > 1.0f) + rvol = 1.0f; if(unison_invert_phase[nvoice][k]) { lvol = -lvol; @@ -1522,7 +1522,7 @@ int ADnote::noteout(float *outl, float *outr) } - float unison_amplitude = 1.0 / sqrt(unison_size[nvoice]); //reduce the amplitude for large unison sizes + float unison_amplitude = 1.0f / sqrt(unison_size[nvoice]); //reduce the amplitude for large unison sizes // Amplitude float oldam = oldamplitude[nvoice] * unison_amplitude; float newam = newamplitude[nvoice] * unison_amplitude; @@ -1530,7 +1530,7 @@ int ADnote::noteout(float *outl, float *outr) if(ABOVE_AMPLITUDE_THRESHOLD(oldam, newam)) { int rest = SOUND_BUFFER_SIZE; //test if the amplitude if raising and the difference is high - if((newam > oldam) && ((newam - oldam) > 0.25)) { + if((newam > oldam) && ((newam - oldam) > 0.25f)) { rest = 10; if(rest > SOUND_BUFFER_SIZE) rest = SOUND_BUFFER_SIZE; @@ -1575,11 +1575,11 @@ int ADnote::noteout(float *outl, float *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 - (float)i + tmpwavel[i] *= 1.0f - (float)i / (float)SOUND_BUFFER_SIZE; if(stereo) for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) - tmpwaver[i] *= 1.0 - (float)i + tmpwaver[i] *= 1.0f - (float)i / (float)SOUND_BUFFER_SIZE; } //the voice is killed later @@ -1604,9 +1604,9 @@ int ADnote::noteout(float *outl, float *outr) if(stereo) { for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) { //stereo outl[i] += tmpwavel[i] * NoteVoicePar[nvoice].Volume - * NoteVoicePar[nvoice].Panning * 2.0; + * NoteVoicePar[nvoice].Panning * 2.0f; outr[i] += tmpwaver[i] * NoteVoicePar[nvoice].Volume - * (1.0 - NoteVoicePar[nvoice].Panning) * 2.0; + * (1.0f - NoteVoicePar[nvoice].Panning) * 2.0f; } } else @@ -1618,9 +1618,9 @@ int ADnote::noteout(float *outl, float *outr) if(stereo) { for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) { //stereo bypassl[i] += tmpwavel[i] * NoteVoicePar[nvoice].Volume - * NoteVoicePar[nvoice].Panning * 2.0; + * NoteVoicePar[nvoice].Panning * 2.0f; bypassr[i] += tmpwaver[i] * NoteVoicePar[nvoice].Volume - * (1.0 - NoteVoicePar[nvoice].Panning) * 2.0; + * (1.0f - NoteVoicePar[nvoice].Panning) * 2.0f; } } else @@ -1659,13 +1659,13 @@ int ADnote::noteout(float *outl, float *outr) i, SOUND_BUFFER_SIZE); outl[i] *= tmpvol * NoteGlobalPar.Panning; - outr[i] *= tmpvol * (1.0 - NoteGlobalPar.Panning); + outr[i] *= tmpvol * (1.0f - NoteGlobalPar.Panning); } } else { for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) { outl[i] *= globalnewamplitude * NoteGlobalPar.Panning; - outr[i] *= globalnewamplitude * (1.0 - NoteGlobalPar.Panning); + outr[i] *= globalnewamplitude * (1.0f - NoteGlobalPar.Panning); } } @@ -1673,11 +1673,11 @@ int ADnote::noteout(float *outl, float *outr) if(NoteGlobalPar.Punch.Enabled != 0) { for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) { float punchamp = NoteGlobalPar.Punch.initialvalue - * NoteGlobalPar.Punch.t + 1.0; + * NoteGlobalPar.Punch.t + 1.0f; outl[i] *= punchamp; outr[i] *= punchamp; NoteGlobalPar.Punch.t -= NoteGlobalPar.Punch.dt; - if(NoteGlobalPar.Punch.t < 0.0) { + if(NoteGlobalPar.Punch.t < 0.0f) { NoteGlobalPar.Punch.Enabled = 0; break; } @@ -1693,7 +1693,7 @@ int ADnote::noteout(float *outl, float *outr) // If it does, disable the note if(NoteGlobalPar.AmpEnvelope->finished()) { for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) { //fade-out - float tmp = 1.0 - (float)i / (float)SOUND_BUFFER_SIZE; + float tmp = 1.0f - (float)i / (float)SOUND_BUFFER_SIZE; outl[i] *= tmp; outr[i] *= tmp; } @@ -1795,7 +1795,7 @@ void ADnote::Global::initparameters(const ADnoteGlobalParam &param, AmpEnvelope = new Envelope(param.AmpEnvelope, basefreq); AmpLfo = new LFO(param.AmpLfo, basefreq); - Volume = 4.0 * pow(0.1, 3.0 * (1.0 - param.PVolume / 96.0)) //-60 dB .. 0 dB + Volume = 4.0f * powf(0.1f, 3.0f * (1.0f - param.PVolume / 96.0f)) //-60 dB .. 0 dB * VelF(velocity, param.PAmpVelocityScaleFunction); //sensing GlobalFilterL = Filter::generate(param.GlobalFilter); diff --git a/src/Synth/ADnote.h b/src/Synth/ADnote.h @@ -32,7 +32,7 @@ //Globals /**FM amplitude tune*/ -#define FM_AMP_MULTIPLIER 14.71280603 +#define FM_AMP_MULTIPLIER 14.71280603f #define OSCIL_SMP_EXTRA_SAMPLES 5 @@ -206,9 +206,9 @@ class ADnote :public SynthNote * AMPLITUDE PARAMETERS * ***************************/ - /* Panning 0.0=left, 0.5 - center, 1.0 = right */ + /* Panning 0.0f=left, 0.5f - center, 1.0f = right */ float Panning; - float Volume; // [-1.0 .. 1.0] + float Volume; // [-1.0f .. 1.0f] Envelope *AmpEnvelope; LFO *AmpLfo; @@ -259,7 +259,7 @@ class ADnote :public SynthNote //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) + //the stereo spread of the unison subvoices (0.0f=mono,1.0f=max) float unison_stereo_spread[NUM_VOICES]; //fractional part (skip) @@ -274,7 +274,7 @@ class ADnote :public SynthNote //the unison base_value float *unison_base_freq_rap[NUM_VOICES]; - //how the unison subvoice's frequency is changed (1.0 for no change) + //how the unison subvoice's frequency is changed (1.0f for no change) float *unison_freq_rap[NUM_VOICES]; //which subvoice has phase inverted @@ -284,7 +284,7 @@ class ADnote :public SynthNote struct { 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 + float *position; //between -1.0f and 1.0f } unison_vibratto[NUM_VOICES]; diff --git a/src/Synth/Envelope.cpp b/src/Synth/Envelope.cpp @@ -32,7 +32,7 @@ Envelope::Envelope(EnvelopeParams *envpars, float basefreq) envpoints = MAX_ENVELOPE_POINTS; envsustain = (envpars->Penvsustain == 0) ? -1 : envpars->Penvsustain; forcedrelase = envpars->Pforcedrelease; - envstretch = pow(440.0 / basefreq, envpars->Penvstretch / 64.0); + envstretch = powf(440.0f / basefreq, envpars->Penvstretch / 64.0f); linearenvelope = envpars->Plinearenvelope; if(envpars->Pfreemode == 0) @@ -49,42 +49,42 @@ Envelope::Envelope(EnvelopeParams *envpars, float basefreq) mode = 1; //change to linear for(i = 0; i < MAX_ENVELOPE_POINTS; ++i) { - float tmp = envpars->getdt(i) / 1000.0 * envstretch; + float tmp = envpars->getdt(i) / 1000.0f * envstretch; if(tmp > bufferdt) envdt[i] = bufferdt / tmp; else - envdt[i] = 2.0; //any value larger than 1 + envdt[i] = 2.0f; //any value larger than 1 switch(mode) { case 2: - envval[i] = (1.0 - envpars->Penvval[i] / 127.0) * -40; + envval[i] = (1.0f - envpars->Penvval[i] / 127.0f) * -40; break; case 3: envval[i] = - (pow(2, 6.0 - * fabs(envpars->Penvval[i] - 64.0) / 64.0) - 1.0) * 100.0; + (powf(2, 6.0f + * fabs(envpars->Penvval[i] - 64.0f) / 64.0f) - 1.0f) * 100.0f; if(envpars->Penvval[i] < 64) envval[i] = -envval[i]; break; case 4: - envval[i] = (envpars->Penvval[i] - 64.0) / 64.0 * 6.0; //6 octaves (filtru) + envval[i] = (envpars->Penvval[i] - 64.0f) / 64.0f * 6.0f; //6 octaves (filtru) break; case 5: - envval[i] = (envpars->Penvval[i] - 64.0) / 64.0 * 10; + envval[i] = (envpars->Penvval[i] - 64.0f) / 64.0f * 10; break; default: - envval[i] = envpars->Penvval[i] / 127.0; + envval[i] = envpars->Penvval[i] / 127.0f; } } - envdt[0] = 1.0; + envdt[0] = 1.0f; currentpoint = 1; //the envelope starts from 1 keyreleased = false; - t = 0.0; + t = 0.0f; envfinish = false; inct = envdt[1]; - envoutval = 0.0; + envoutval = 0.0f; } Envelope::~Envelope() @@ -100,7 +100,7 @@ void Envelope::relasekey() return; keyreleased = true; if(forcedrelase != 0) - t = 0.0; + t = 0.0f; } /* @@ -122,35 +122,35 @@ float Envelope::envout() if(keyreleased && (forcedrelase != 0)) { //do the forced release int tmp = (envsustain < 0) ? (envpoints - 1) : (envsustain + 1); //if there is no sustain point, use the last point for release - if(envdt[tmp] < 0.00000001) + if(envdt[tmp] < 0.00000001f) out = envval[tmp]; else out = envoutval + (envval[tmp] - envoutval) * t; t += envdt[tmp] * envstretch; - if(t >= 1.0) { + if(t >= 1.0f) { currentpoint = envsustain + 2; forcedrelase = 0; - t = 0.0; + t = 0.0f; inct = envdt[currentpoint]; if((currentpoint >= envpoints) || (envsustain < 0)) envfinish = true; } return out; } - if(inct >= 1.0) + if(inct >= 1.0f) out = envval[currentpoint]; else out = envval[currentpoint - 1] + (envval[currentpoint] - envval[currentpoint - 1]) * t; t += inct; - if(t >= 1.0) { + if(t >= 1.0f) { if(currentpoint >= envpoints - 1) envfinish = true; else currentpoint++; - t = 0.0; + t = 0.0f; inct = envdt[currentpoint]; } @@ -173,14 +173,14 @@ float Envelope::envout_dB() out = v1 + (v2 - v1) * t; t += inct; - if(t >= 1.0) { - t = 0.0; + if(t >= 1.0f) { + t = 0.0f; inct = envdt[2]; currentpoint++; out = v2; } - if(out > 0.001) + if(out > 0.001f) envoutval = rap2dB(out); else envoutval = MIN_ENVELOPE_DB; diff --git a/src/Synth/Envelope.h b/src/Synth/Envelope.h @@ -45,7 +45,7 @@ class Envelope int envpoints; int envsustain; //"-1" means disabled float envdt[MAX_ENVELOPE_POINTS]; //millisecons - float envval[MAX_ENVELOPE_POINTS]; // [0.0 .. 1.0] + float envval[MAX_ENVELOPE_POINTS]; // [0.0f .. 1.0f] float envstretch; int linearenvelope; diff --git a/src/Synth/LFO.cpp b/src/Synth/LFO.cpp @@ -31,57 +31,57 @@ LFO::LFO(LFOParams *lfopars, float basefreq) { if(lfopars->Pstretch == 0) lfopars->Pstretch = 1; - float lfostretch = pow(basefreq / 440.0, - (lfopars->Pstretch - 64.0) / 63.0); //max 2x/octave + float lfostretch = powf(basefreq / 440.0f, + (lfopars->Pstretch - 64.0f) / 63.0f); //max 2x/octave float lfofreq = - (pow(2, lfopars->Pfreq * 10.0) - 1.0) / 12.0 * lfostretch; + (powf(2, lfopars->Pfreq * 10.0f) - 1.0f) / 12.0f * lfostretch; incx = fabs(lfofreq) * (float)SOUND_BUFFER_SIZE / (float)SAMPLE_RATE; if(lfopars->Pcontinous == 0) { if(lfopars->Pstartphase == 0) x = RND; else - x = fmod((lfopars->Pstartphase - 64.0) / 127.0 + 1.0, 1.0); + x = fmod((lfopars->Pstartphase - 64.0f) / 127.0f + 1.0f, 1.0f); } else { - float tmp = fmod(lfopars->time * incx, 1.0); - x = fmod((lfopars->Pstartphase - 64.0) / 127.0 + 1.0 + tmp, 1.0); + float tmp = fmod(lfopars->time * incx, 1.0f); + x = fmod((lfopars->Pstartphase - 64.0f) / 127.0f + 1.0f + tmp, 1.0f); } //Limit the Frequency(or else...) - if(incx > 0.49999999) - incx = 0.499999999; + if(incx > 0.49999999f) + incx = 0.499999999f; - lfornd = lfopars->Prandomness / 127.0; - if(lfornd < 0.0) - lfornd = 0.0; + lfornd = lfopars->Prandomness / 127.0f; + if(lfornd < 0.0f) + lfornd = 0.0f; else - if(lfornd > 1.0) - lfornd = 1.0; + if(lfornd > 1.0f) + lfornd = 1.0f; -// lfofreqrnd=pow(lfopars->Pfreqrand/127.0,2.0)*2.0*4.0; - lfofreqrnd = pow(lfopars->Pfreqrand / 127.0, 2.0) * 4.0; +// lfofreqrnd=powf(lfopars->Pfreqrand/127.0f,2.0f)*2.0f*4.0f; + lfofreqrnd = powf(lfopars->Pfreqrand / 127.0f, 2.0f) * 4.0f; switch(lfopars->fel) { case 1: - lfointensity = lfopars->Pintensity / 127.0; + lfointensity = lfopars->Pintensity / 127.0f; break; case 2: - lfointensity = lfopars->Pintensity / 127.0 * 4.0; + lfointensity = lfopars->Pintensity / 127.0f * 4.0f; break; //in octave default: - lfointensity = pow(2, lfopars->Pintensity / 127.0 * 11.0) - 1.0; //in centi - x -= 0.25; //chance the starting phase + lfointensity = powf(2, lfopars->Pintensity / 127.0f * 11.0f) - 1.0f; //in centi + x -= 0.25f; //chance the starting phase break; } amp1 = (1 - lfornd) + lfornd * RND; amp2 = (1 - lfornd) + lfornd * RND; lfotype = lfopars->PLFOtype; - lfodelay = lfopars->Pdelay / 127.0 * 4.0; //0..4 sec - incrnd = nextincrnd = 1.0; + lfodelay = lfopars->Pdelay / 127.0f * 4.0f; //0..4 sec + incrnd = nextincrnd = 1.0f; freqrndenabled = (lfopars->Pfreqrand != 0); computenextincrnd(); computenextincrnd(); //twice because I want incrnd & nextincrnd to be random @@ -98,34 +98,34 @@ float LFO::lfoout() float out; switch(lfotype) { case 1: //LFO_TRIANGLE - if((x >= 0.0) && (x < 0.25)) - out = 4.0 * x; + if((x >= 0.0f) && (x < 0.25f)) + out = 4.0f * x; else - if((x > 0.25) && (x < 0.75)) + if((x > 0.25f) && (x < 0.75f)) out = 2 - 4 * x; else - out = 4.0 * x - 4.0; + out = 4.0f * x - 4.0f; break; case 2: //LFO_SQUARE - if(x < 0.5) + if(x < 0.5f) out = -1; else out = 1; break; case 3: //LFO_RAMPUP - out = (x - 0.5) * 2.0; + out = (x - 0.5f) * 2.0f; break; case 4: //LFO_RAMPDOWN - out = (0.5 - x) * 2.0; + out = (0.5f - x) * 2.0f; break; case 5: //LFO_EXP_DOWN 1 - out = pow(0.05, x) * 2.0 - 1.0; + out = powf(0.05f, x) * 2.0f - 1.0f; break; case 6: //LFO_EXP_DOWN 2 - out = pow(0.001, x) * 2.0 - 1.0; + out = powf(0.001f, x) * 2.0f - 1.0f; break; default: - out = cos(x * 2.0 * PI); //LFO_SINE + out = cosf(x * 2.0f * PI); //LFO_SINE } @@ -133,20 +133,20 @@ float LFO::lfoout() out *= lfointensity * (amp1 + x * (amp2 - amp1)); else out *= lfointensity * amp2; - if(lfodelay < 0.00001) { + if(lfodelay < 0.00001f) { if(freqrndenabled == 0) x += incx; else { - float tmp = (incrnd * (1.0 - x) + nextincrnd * x); - if(tmp > 1.0) - tmp = 1.0; + float tmp = (incrnd * (1.0f - x) + nextincrnd * x); + if(tmp > 1.0f) + tmp = 1.0f; else - if(tmp < 0.0) - tmp = 0.0; + if(tmp < 0.0f) + tmp = 0.0f; x += incx * tmp; } if(x >= 1) { - x = fmod(x, 1.0); + x = fmod(x, 1.0f); amp1 = amp2; amp2 = (1 - lfornd) + lfornd * RND; @@ -164,12 +164,12 @@ float LFO::lfoout() float LFO::amplfoout() { float out; - out = 1.0 - lfointensity + lfoout(); - if(out < -1.0) - out = -1.0; + out = 1.0f - lfointensity + lfoout(); + if(out < -1.0f) + out = -1.0f; else - if(out > 1.0) - out = 1.0; + if(out > 1.0f) + out = 1.0f; return out; } @@ -179,6 +179,6 @@ void LFO::computenextincrnd() if(freqrndenabled == 0) return; incrnd = nextincrnd; - nextincrnd = pow(0.5, lfofreqrnd) + RND * (pow(2.0, lfofreqrnd) - 1.0); + nextincrnd = powf(0.5f, lfofreqrnd) + RND * (powf(2.0f, lfofreqrnd) - 1.0f); } diff --git a/src/Synth/OscilGen.cpp b/src/Synth/OscilGen.cpp @@ -65,7 +65,7 @@ inline float arg(const fft_t *freqs, off_t x) */ void normalize(fft_t *freqs) { - float normMax = 0.0; + float normMax = 0.0f; for(int i = 0; i < OSCIL_SIZE / 2; ++i) { //magnitude squared const float norm = normal(freqs, i); @@ -88,10 +88,10 @@ void rmsNormalize(fft_t *freqs) for(int i = 1; i < OSCIL_SIZE / 2; ++i) sum += normal(freqs, i); - if(sum < 0.000001) + if(sum < 0.000001f) return; //data is all ~zero, do not amplify noise - const float gain = 1.0 / sqrt(sum); + const float gain = 1.0f / sqrt(sum); for(int i = 1; i < OSCIL_SIZE / 2; ++i) freqs[i] *= gain; @@ -146,8 +146,8 @@ void OscilGen::defaults() oldmodulationpar3 = 0; for(int i = 0; i < MAX_AD_HARMONICS; ++i) { - hmag[i] = 0.0; - hphase[i] = 0.0; + hmag[i] = 0.0f; + hphase[i] = 0.0f; Phmag[i] = 64; Phphase[i] = 64; } @@ -205,7 +205,7 @@ void OscilGen::convert2sine() float oscil[OSCIL_SIZE]; fft_t *freqs = new fft_t[OSCIL_SIZE / 2]; - get(oscil, -1.0); + get(oscil, -1.0f); FFTwrapper *fft = new FFTwrapper(OSCIL_SIZE); fft->smps2freqs(oscil, freqs); delete (fft); @@ -225,9 +225,9 @@ void OscilGen::convert2sine() float newmag = mag[i]; float newphase = phase[i]; - Phmag[i] = (int) ((newmag) * 64.0) + 64; + Phmag[i] = (int) ((newmag) * 64.0f) + 64; - Phphase[i] = 64 - (int) (64.0 * newphase / PI); + Phphase[i] = 64 - (int) (64.0f * newphase / PI); if(Phphase[i] > 127) Phphase[i] = 127; @@ -244,58 +244,58 @@ void OscilGen::convert2sine() void OscilGen::getbasefunction(float *smps) { int i; - float par = (Pbasefuncpar + 0.5) / 128.0; + float par = (Pbasefuncpar + 0.5f) / 128.0f; if(Pbasefuncpar == 64) - par = 0.5; + par = 0.5f; - float basefuncmodulationpar1 = Pbasefuncmodulationpar1 / 127.0, - basefuncmodulationpar2 = Pbasefuncmodulationpar2 / 127.0, - basefuncmodulationpar3 = Pbasefuncmodulationpar3 / 127.0; + float basefuncmodulationpar1 = Pbasefuncmodulationpar1 / 127.0f, + basefuncmodulationpar2 = Pbasefuncmodulationpar2 / 127.0f, + basefuncmodulationpar3 = Pbasefuncmodulationpar3 / 127.0f; switch(Pbasefuncmodulation) { case 1: basefuncmodulationpar1 = - (pow(2, basefuncmodulationpar1 * 5.0) - 1.0) / 10.0; + (powf(2, basefuncmodulationpar1 * 5.0f) - 1.0f) / 10.0f; basefuncmodulationpar3 = - floor((pow(2, basefuncmodulationpar3 * 5.0) - 1.0)); - if(basefuncmodulationpar3 < 0.9999) - basefuncmodulationpar3 = -1.0; + floor((powf(2, basefuncmodulationpar3 * 5.0f) - 1.0f)); + if(basefuncmodulationpar3 < 0.9999f) + basefuncmodulationpar3 = -1.0f; break; case 2: basefuncmodulationpar1 = - (pow(2, basefuncmodulationpar1 * 5.0) - 1.0) / 10.0; - basefuncmodulationpar3 = 1.0 - + floor((pow(2, basefuncmodulationpar3 - * 5.0) - 1.0)); + (powf(2, basefuncmodulationpar1 * 5.0f) - 1.0f) / 10.0f; + basefuncmodulationpar3 = 1.0f + + floor((powf(2, basefuncmodulationpar3 + * 5.0f) - 1.0f)); break; case 3: basefuncmodulationpar1 = - (pow(2, basefuncmodulationpar1 * 7.0) - 1.0) / 10.0; - basefuncmodulationpar3 = 0.01 - + (pow(2, basefuncmodulationpar3 - * 16.0) - 1.0) / 10.0; + (powf(2, basefuncmodulationpar1 * 7.0f) - 1.0f) / 10.0f; + basefuncmodulationpar3 = 0.01f + + (powf(2, basefuncmodulationpar3 + * 16.0f) - 1.0f) / 10.0f; break; } base_func func = getBaseFunction(Pcurrentbasefunc); for(i = 0; i < OSCIL_SIZE; ++i) { - float t = i * 1.0 / OSCIL_SIZE; + float t = i * 1.0f / OSCIL_SIZE; switch(Pbasefuncmodulation) { case 1: - t = t * basefuncmodulationpar3 + sin( + t = t * basefuncmodulationpar3 + sinf( (t - + basefuncmodulationpar2) * 2.0 * PI) * basefuncmodulationpar1;//rev + + basefuncmodulationpar2) * 2.0f * PI) * basefuncmodulationpar1;//rev break; case 2: - t = t + sin( + t = t + sinf( (t * basefuncmodulationpar3 - + basefuncmodulationpar2) * 2.0 * PI) * basefuncmodulationpar1;//sine + + basefuncmodulationpar2) * 2.0f * PI) * basefuncmodulationpar1;//sine break; case 3: - t = t + pow((1.0 - cos( - (t + basefuncmodulationpar2) * 2.0 * PI)) * 0.5, + t = t + powf((1.0f - cosf( + (t + basefuncmodulationpar2) * 2.0f * PI)) * 0.5f, basefuncmodulationpar3) * basefuncmodulationpar1;//power break; } @@ -305,7 +305,7 @@ void OscilGen::getbasefunction(float *smps) if(func) smps[i] = func(t, par); else - smps[i] = -sin(2.0 * PI * i / OSCIL_SIZE); + smps[i] = -sinf(2.0f * PI * i / OSCIL_SIZE); } } @@ -318,8 +318,8 @@ void OscilGen::oscilfilter() if(Pfiltertype == 0) return; - const float par = 1.0 - Pfilterpar1 / 128.0; - const float par2 = Pfilterpar2 / 127.0; + const float par = 1.0f - Pfilterpar1 / 128.0f; + const float par2 = Pfilterpar2 / 127.0f; filter_func filter = getFilter(Pfiltertype); for(int i = 1; i < OSCIL_SIZE / 2; ++i) @@ -353,12 +353,12 @@ void OscilGen::changebasefunction() inline void normalize(float *smps, size_t N) { //Find max - float max = 0.0; + float max = 0.0f; for(size_t i = 0; i < N; ++i) if(max < fabs(smps[i])) max = fabs(smps[i]); - if(max < 0.00001) - max = 1.0; + if(max < 0.00001f) + max = 1.0f; //Normalize to +-1 for(size_t i = 0; i < N; ++i) @@ -378,7 +378,7 @@ void OscilGen::waveshape() clearDC(oscilFFTfreqs); //reduce the amplitude of the freqs near the nyquist for(int i = 1; i < OSCIL_SIZE / 8; ++i) { - float gain = i / (OSCIL_SIZE / 8.0); + float gain = i / (OSCIL_SIZE / 8.0f); oscilFFTfreqs[OSCIL_SIZE / 2 - i] *= gain; } fft->freqs2smps(oscilFFTfreqs, tmpsmps); @@ -408,31 +408,31 @@ void OscilGen::modulation() return; - float modulationpar1 = Pmodulationpar1 / 127.0, - modulationpar2 = 0.5 - Pmodulationpar2 / 127.0, - modulationpar3 = Pmodulationpar3 / 127.0; + float modulationpar1 = Pmodulationpar1 / 127.0f, + modulationpar2 = 0.5f - Pmodulationpar2 / 127.0f, + modulationpar3 = Pmodulationpar3 / 127.0f; switch(Pmodulation) { case 1: - modulationpar1 = (pow(2, modulationpar1 * 7.0) - 1.0) / 100.0; - modulationpar3 = floor((pow(2, modulationpar3 * 5.0) - 1.0)); - if(modulationpar3 < 0.9999) - modulationpar3 = -1.0; + modulationpar1 = (powf(2, modulationpar1 * 7.0f) - 1.0f) / 100.0f; + modulationpar3 = floor((powf(2, modulationpar3 * 5.0f) - 1.0f)); + if(modulationpar3 < 0.9999f) + modulationpar3 = -1.0f; break; case 2: - modulationpar1 = (pow(2, modulationpar1 * 7.0) - 1.0) / 100.0; - modulationpar3 = 1.0 + floor((pow(2, modulationpar3 * 5.0) - 1.0)); + modulationpar1 = (powf(2, modulationpar1 * 7.0f) - 1.0f) / 100.0f; + modulationpar3 = 1.0f + floor((powf(2, modulationpar3 * 5.0f) - 1.0f)); break; case 3: - modulationpar1 = (pow(2, modulationpar1 * 9.0) - 1.0) / 100.0; - modulationpar3 = 0.01 + (pow(2, modulationpar3 * 16.0) - 1.0) / 10.0; + modulationpar1 = (powf(2, modulationpar1 * 9.0f) - 1.0f) / 100.0f; + modulationpar3 = 0.01f + (powf(2, modulationpar3 * 16.0f) - 1.0f) / 10.0f; break; } clearDC(oscilFFTfreqs); //remove the DC //reduce the amplitude of the freqs near the nyquist for(i = 1; i < OSCIL_SIZE / 8; ++i) { - float tmp = i / (OSCIL_SIZE / 8.0); + float tmp = i / (OSCIL_SIZE / 8.0f); oscilFFTfreqs[OSCIL_SIZE / 2 - i] *= tmp; } fft->freqs2smps(oscilFFTfreqs, tmpsmps); @@ -449,21 +449,21 @@ void OscilGen::modulation() //Do the modulation for(i = 0; i < OSCIL_SIZE; ++i) { - float t = i * 1.0 / OSCIL_SIZE; + float t = i * 1.0f / OSCIL_SIZE; switch(Pmodulation) { case 1: t = t * modulationpar3 - + sin((t + modulationpar2) * 2.0 * PI) * modulationpar1; //rev + + sinf((t + modulationpar2) * 2.0f * PI) * modulationpar1; //rev break; case 2: t = t - + sin((t * modulationpar3 - + modulationpar2) * 2.0 * PI) * modulationpar1; //sine + + sinf((t * modulationpar3 + + modulationpar2) * 2.0f * PI) * modulationpar1; //sine break; case 3: - t = t + pow((1.0 - cos( - (t + modulationpar2) * 2.0 * PI)) * 0.5, + t = t + powf((1.0f - cosf( + (t + modulationpar2) * 2.0f * PI)) * 0.5f, modulationpar3) * modulationpar1; //power break; } @@ -473,7 +473,7 @@ void OscilGen::modulation() int poshi = (int) t; float poslo = t - floor(t); - tmpsmps[i] = in[poshi] * (1.0 - poslo) + in[poshi + 1] * poslo; + tmpsmps[i] = in[poshi] * (1.0f - poslo) + in[poshi + 1] * poslo; } delete [] in; @@ -488,20 +488,20 @@ void OscilGen::spectrumadjust() { if(Psatype == 0) return; - float par = Psapar / 127.0; + float par = Psapar / 127.0f; switch(Psatype) { case 1: - par = 1.0 - par * 2.0; - if(par >= 0.0) - par = pow(5.0, par); + par = 1.0f - par * 2.0f; + if(par >= 0.0f) + par = powf(5.0f, par); else - par = pow(8.0, par); + par = powf(8.0f, par); break; case 2: - par = pow(10.0, (1.0 - par) * 3.0) * 0.25; + par = powf(10.0f, (1.0f - par) * 3.0f) * 0.25f; break; case 3: - par = pow(10.0, (1.0 - par) * 3.0) * 0.25; + par = powf(10.0f, (1.0f - par) * 3.0f) * 0.25f; break; } @@ -514,16 +514,16 @@ void OscilGen::spectrumadjust() switch(Psatype) { case 1: - mag = pow(mag, par); + mag = powf(mag, par); break; case 2: if(mag < par) - mag = 0.0; + mag = 0.0f; break; case 3: mag /= par; - if(mag > 1.0) - mag = 1.0; + if(mag > 1.0f) + mag = 1.0f; break; } oscilFFTfreqs[i] = std::polar<fftw_real>(mag, phase); @@ -552,11 +552,11 @@ void OscilGen::shiftharmonics() for(int i = 0; i < OSCIL_SIZE / 2 - 1; ++i) { int oldh = i + abs(harmonicshift); if(oldh >= (OSCIL_SIZE / 2 - 1)) - h = 0.0; + h = 0.0f; else { h = oscilFFTfreqs[oldh + 1]; - if(abs(h) < 0.000001) - h = 0.0; + if(abs(h) < 0.000001f) + h = 0.0f; } oscilFFTfreqs[i + 1] = h; @@ -577,25 +577,25 @@ void OscilGen::prepare() changebasefunction(); for(int i = 0; i < MAX_AD_HARMONICS; ++i) - hphase[i] = (Phphase[i] - 64.0) / 64.0 * PI / (i + 1); + hphase[i] = (Phphase[i] - 64.0f) / 64.0f * PI / (i + 1); for(int i = 0; i < MAX_AD_HARMONICS; ++i) { - const float hmagnew = 1.0 - fabs(Phmag[i] / 64.0 - 1.0); + const float hmagnew = 1.0f - fabs(Phmag[i] / 64.0f - 1.0f); switch(Phmagtype) { case 1: - hmag[i] = exp(hmagnew * log(0.01)); + hmag[i] = expf(hmagnew * logf(0.01f)); break; case 2: - hmag[i] = exp(hmagnew * log(0.001)); + hmag[i] = expf(hmagnew * logf(0.001f)); break; case 3: - hmag[i] = exp(hmagnew * log(0.0001)); + hmag[i] = expf(hmagnew * logf(0.0001f)); break; case 4: - hmag[i] = exp(hmagnew * log(0.00001)); + hmag[i] = expf(hmagnew * logf(0.00001f)); break; default: - hmag[i] = 1.0 - hmagnew; + hmag[i] = 1.0f - hmagnew; break; } @@ -606,14 +606,14 @@ void OscilGen::prepare() //remove the harmonics where Phmag[i]==64 for(int i = 0; i < MAX_AD_HARMONICS; ++i) if(Phmag[i] == 64) - hmag[i] = 0.0; + hmag[i] = 0.0f; clearAll(oscilFFTfreqs); if(Pcurrentbasefunc == 0) { //the sine case for(int i = 0; i < MAX_AD_HARMONICS; ++i) { - oscilFFTfreqs[i + 1].real() = -hmag[i] * sin(hphase[i] * (i + 1)) / 2.0; - oscilFFTfreqs[i + 1].imag() = hmag[i] * cos(hphase[i] * (i + 1)) / 2.0; + oscilFFTfreqs[i + 1].real() = -hmag[i] * sinf(hphase[i] * (i + 1)) / 2.0f; + oscilFFTfreqs[i + 1].imag() = hmag[i] * cosf(hphase[i] * (i + 1)) / 2.0f; } } else { @@ -656,10 +656,10 @@ void OscilGen::prepare() void OscilGen::adaptiveharmonic(fft_t *f, float freq) { - if(Padaptiveharmonics == 0 /*||(freq<1.0)*/) + if(Padaptiveharmonics == 0 /*||(freq<1.0f)*/) return; - if(freq < 1.0) - freq = 440.0; + if(freq < 1.0f) + freq = 440.0f; fft_t *inf = new fft_t[OSCIL_SIZE / 2]; for(int i = 0; i < OSCIL_SIZE / 2; ++i) @@ -667,42 +667,42 @@ void OscilGen::adaptiveharmonic(fft_t *f, float freq) clearAll(f); clearDC(inf); - float hc = 0.0, hs = 0.0; - float basefreq = 30.0 * pow(10.0, Padaptiveharmonicsbasefreq / 128.0); - float power = (Padaptiveharmonicspower + 1.0) / 101.0; + float hc = 0.0f, hs = 0.0f; + float basefreq = 30.0f * powf(10.0f, Padaptiveharmonicsbasefreq / 128.0f); + float power = (Padaptiveharmonicspower + 1.0f) / 101.0f; float rap = freq / basefreq; - rap = pow(rap, power); + rap = powf(rap, power); bool down = false; - if(rap > 1.0) { - rap = 1.0 / rap; + if(rap > 1.0f) { + rap = 1.0f / rap; down = true; } for(int i = 0; i < OSCIL_SIZE / 2 - 2; ++i) { float h = i * rap; int high = (int)(i * rap); - float low = fmod(h, 1.0); + float low = fmod(h, 1.0f); if(high >= (OSCIL_SIZE / 2 - 2)) break; else { if(down) { - f[high].real() += inf[i].real() * (1.0 - low); - f[high].imag() += inf[i].imag() * (1.0 - low); + f[high].real() += inf[i].real() * (1.0f - low); + f[high].imag() += inf[i].imag() * (1.0f - low); f[high + 1].real() += inf[i].real() * low; f[high + 1].imag() += inf[i].imag() * low; } else { - hc = inf[high].real() * (1.0 - low) + inf[high + 1].real() * low; - hs = inf[high].imag() * (1.0 - low) + inf[high + 1].imag() * low; + hc = inf[high].real() * (1.0f - low) + inf[high + 1].real() * low; + hs = inf[high].imag() * (1.0f - low) + inf[high + 1].imag() * low; } - if(fabs(hc) < 0.000001) - hc = 0.0; - if(fabs(hs) < 0.000001) - hs = 0.0; + if(fabs(hc) < 0.000001f) + hc = 0.0f; + if(fabs(hs) < 0.000001f) + hs = 0.0f; } if(!down) { @@ -724,12 +724,12 @@ void OscilGen::adaptiveharmonicpostprocess(fft_t *f, int size) if(Padaptiveharmonics <= 1) return; fft_t *inf = new fft_t[size]; - float par = Padaptiveharmonicspar * 0.01; - par = 1.0 - pow((1.0 - par), 1.5); + float par = Padaptiveharmonicspar * 0.01f; + par = 1.0f - powf((1.0f - par), 1.5f); for(int i = 0; i < size; ++i) { inf[i] = f[i] * double(par); - f[i] *= (1.0 - par); + f[i] *= (1.0f - par); } @@ -810,13 +810,13 @@ short int OscilGen::get(float *smps, float freqHz, int resonance) prepare(); int outpos = - (int)((RND * 2.0 - 1.0) * (float) OSCIL_SIZE * (Prand - 64.0) / 64.0); + (int)((RND * 2.0f - 1.0f) * (float) OSCIL_SIZE * (Prand - 64.0f) / 64.0f); outpos = (outpos + 2 * OSCIL_SIZE) % OSCIL_SIZE; clearAll(outoscilFFTfreqs); - int nyquist = (int)(0.5 * SAMPLE_RATE / fabs(freqHz)) + 2; + int nyquist = (int)(0.5f * SAMPLE_RATE / fabs(freqHz)) + 2; if(ADvsPAD) nyquist = (int)(OSCIL_SIZE / 2); if(nyquist > OSCIL_SIZE / 2) @@ -844,49 +844,49 @@ short int OscilGen::get(float *smps, float 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)) { - const float rnd = PI * pow((Prand - 64.0) / 64.0, 2.0); + if((Prand > 64) && (freqHz >= 0.0f) && (!ADvsPAD)) { + const float rnd = PI * powf((Prand - 64.0f) / 64.0f, 2.0f); for(int i = 1; i < nyquist - 1; ++i) //to Nyquist only for AntiAliasing outoscilFFTfreqs[i] *= std::polar<fftw_real>(1.0f, (float)(rnd * i * RND)); } //Harmonic Amplitude Randomness - if((freqHz > 0.1) && (!ADvsPAD)) { + if((freqHz > 0.1f) && (!ADvsPAD)) { unsigned int realrnd = rand(); srand(randseed); - float power = Pamprandpower / 127.0; - float normalize = 1.0 / (1.2 - power); + float power = Pamprandpower / 127.0f; + float normalize = 1.0f / (1.2f - power); switch(Pamprandtype) { case 1: - power = power * 2.0 - 0.5; - power = pow(15.0, power); + power = power * 2.0f - 0.5f; + power = powf(15.0f, power); for(int i = 1; i < nyquist - 1; ++i) - outoscilFFTfreqs[i] *= pow(RND, power) * normalize; + outoscilFFTfreqs[i] *= powf(RND, power) * normalize; break; case 2: - power = power * 2.0 - 0.5; - power = pow(15.0, power) * 2.0; + power = power * 2.0f - 0.5f; + power = powf(15.0f, power) * 2.0f; float rndfreq = 2 * PI * RND; for(int i = 1; i < nyquist - 1; ++i) - outoscilFFTfreqs[i] *= pow(fabs(sin(i * rndfreq)), power) + outoscilFFTfreqs[i] *= powf(fabs(sinf(i * rndfreq)), power) * normalize; break; } srand(realrnd + 1); } - if((freqHz > 0.1) && (resonance != 0)) + if((freqHz > 0.1f) && (resonance != 0)) res->applyres(nyquist - 1, outoscilFFTfreqs, freqHz); rmsNormalize(outoscilFFTfreqs); - if((ADvsPAD) && (freqHz > 0.1)) //in this case the smps will contain the freqs + if((ADvsPAD) && (freqHz > 0.1f)) //in this case the smps will contain the freqs for(int i = 1; i < OSCIL_SIZE / 2; ++i) smps[i - 1] = abs(outoscilFFTfreqs, i); else { fft->freqs2smps(outoscilFFTfreqs, smps); for(int i = 0; i < OSCIL_SIZE; ++i) - smps[i] *= 0.25; //correct the amplitude + smps[i] *= 0.25f; //correct the amplitude } if(Prand < 64) @@ -909,7 +909,7 @@ void OscilGen::getspectrum(int n, float *spc, int what) spc[i - 1] = abs(oscilFFTfreqs, i); else { if(Pcurrentbasefunc == 0) - spc[i - 1] = ((i == 1) ? (1.0) : (0.0)); + spc[i - 1] = ((i == 1) ? (1.0f) : (0.0f)); else spc[i - 1] = abs(basefuncFFTfreqs, i); } @@ -919,7 +919,7 @@ void OscilGen::getspectrum(int n, float *spc, int what) for(int i = 0; i < n; ++i) outoscilFFTfreqs[i] = fft_t(spc[i], spc[i]); memset(outoscilFFTfreqs+n, 0, (OSCIL_SIZE / 2 - n) * sizeof(fft_t)); - adaptiveharmonic(outoscilFFTfreqs, 0.0); + adaptiveharmonic(outoscilFFTfreqs, 0.0f); adaptiveharmonicpostprocess(outoscilFFTfreqs, n - 1); for(int i = 0; i < n; ++i) spc[i] = outoscilFFTfreqs[i].imag(); @@ -1007,7 +1007,7 @@ void OscilGen::add2XML(XMLwrapper *xml) for(int i = 1; i < OSCIL_SIZE / 2; ++i) { float xc = basefuncFFTfreqs[i].real(); float xs = basefuncFFTfreqs[i].imag(); - if((fabs(xs) > 0.00001) && (fabs(xs) > 0.00001)) { + if((fabs(xs) > 0.00001f) && (fabs(xs) > 0.00001f)) { xml->beginbranch("BF_HARMONIC", i); xml->addparreal("cos", xc); xml->addparreal("sin", xs); @@ -1101,8 +1101,8 @@ void OscilGen::getfromXML(XMLwrapper *xml) if(xml->enterbranch("BASE_FUNCTION")) { for(int i = 1; i < OSCIL_SIZE / 2; ++i) { if(xml->enterbranch("BF_HARMONIC", i)) { - basefuncFFTfreqs[i].real() = xml->getparreal("cos", 0.0); - basefuncFFTfreqs[i].imag() = xml->getparreal("sin", 0.0); + basefuncFFTfreqs[i].real() = xml->getparreal("cos", 0.0f); + basefuncFFTfreqs[i].imag() = xml->getparreal("sin", 0.0f); xml->exitbranch(); } } @@ -1119,143 +1119,143 @@ void OscilGen::getfromXML(XMLwrapper *xml) FUNC(pulse) { - return (fmod(x, 1.0) < a) ? -1.0 : 1.0; + return (fmod(x, 1.0f) < a) ? -1.0f : 1.0f; } FUNC(saw) { - if(a < 0.00001) - a = 0.00001; + if(a < 0.00001f) + a = 0.00001f; else - if(a > 0.99999) - a = 0.99999; + if(a > 0.99999f) + a = 0.99999f; x = fmod(x, 1); if(x < a) - return x / a * 2.0 - 1.0; + return x / a * 2.0f - 1.0f; else - return (1.0 - x) / (1.0 - a) * 2.0 - 1.0; + return (1.0f - x) / (1.0f - a) * 2.0f - 1.0f; } FUNC(triangle) { - x = fmod(x + 0.25, 1); + x = fmod(x + 0.25f, 1); a = 1 - a; - if(a < 0.00001) - a = 0.00001; - if(x < 0.5) - x = x * 4 - 1.0; + if(a < 0.00001f) + a = 0.00001f; + if(x < 0.5f) + x = x * 4 - 1.0f; else - x = (1.0 - x) * 4 - 1.0; + x = (1.0f - x) * 4 - 1.0f; x /= -a; - if(x < -1.0) - x = -1.0; - if(x > 1.0) - x = 1.0; + if(x < -1.0f) + x = -1.0f; + if(x > 1.0f) + x = 1.0f; return x; } FUNC(power) { x = fmod(x, 1); - if(a < 0.00001) - a = 0.00001; + if(a < 0.00001f) + a = 0.00001f; else - if(a > 0.99999) - a = 0.99999; - return pow(x, exp((a - 0.5) * 10.0)) * 2.0 - 1.0; + if(a > 0.99999f) + a = 0.99999f; + return powf(x, expf((a - 0.5f) * 10.0f)) * 2.0f - 1.0f; } FUNC(gauss) { - x = fmod(x, 1) * 2.0 - 1.0; - if(a < 0.00001) - a = 0.00001; - return exp(-x * x * (exp(a * 8) + 5.0)) * 2.0 - 1.0; + x = fmod(x, 1) * 2.0f - 1.0f; + if(a < 0.00001f) + a = 0.00001f; + return expf(-x * x * (expf(a * 8) + 5.0f)) * 2.0f - 1.0f; } FUNC(diode) { - if(a < 0.00001) - a = 0.00001; + if(a < 0.00001f) + a = 0.00001f; else - if(a > 0.99999) - a = 0.99999; - a = a * 2.0 - 1.0; - x = cos((x + 0.5) * 2.0 * PI) - a; - if(x < 0.0) - x = 0.0; - return x / (1.0 - a) * 2 - 1.0; + if(a > 0.99999f) + a = 0.99999f; + a = a * 2.0f - 1.0f; + x = cosf((x + 0.5f) * 2.0f * PI) - a; + if(x < 0.0f) + x = 0.0f; + return x / (1.0f - a) * 2 - 1.0f; } FUNC(abssine) { x = fmod(x, 1); - if(a < 0.00001) - a = 0.00001; + if(a < 0.00001f) + a = 0.00001f; else - if(a > 0.99999) - a = 0.99999; - return sin(pow(x, exp((a - 0.5) * 5.0)) * PI) * 2.0 - 1.0; + if(a > 0.99999f) + a = 0.99999f; + return sinf(powf(x, expf((a - 0.5f) * 5.0f)) * PI) * 2.0f - 1.0f; } FUNC(pulsesine) { - if(a < 0.00001) - a = 0.00001; - x = (fmod(x, 1) - 0.5) * exp((a - 0.5) * log(128)); - if(x < -0.5) - x = -0.5; + if(a < 0.00001f) + a = 0.00001f; + x = (fmod(x, 1) - 0.5f) * expf((a - 0.5f) * logf(128)); + if(x < -0.5f) + x = -0.5f; else - if(x > 0.5) - x = 0.5; - x = sin(x * PI * 2.0); + if(x > 0.5f) + x = 0.5f; + x = sinf(x * PI * 2.0f); return x; } FUNC(stretchsine) { - x = fmod(x + 0.5, 1) * 2.0 - 1.0; - a = (a - 0.5) * 4; - if(a > 0.0) + x = fmod(x + 0.5f, 1) * 2.0f - 1.0f; + a = (a - 0.5f) * 4; + if(a > 0.0f) a *= 2; - a = pow(3.0, a); - float b = pow(fabs(x), a); + a = powf(3.0f, a); + float b = powf(fabs(x), a); if(x < 0) b = -b; - return -sin(b * PI); + return -sinf(b * PI); } FUNC(chirp) { - x = fmod(x, 1.0) * 2.0 * PI; - a = (a - 0.5) * 4; - if(a < 0.0) - a *= 2.0; - a = pow(3.0, a); - return sin(x / 2.0) * sin(a * x * x); + x = fmod(x, 1.0f) * 2.0f * PI; + a = (a - 0.5f) * 4; + if(a < 0.0f) + a *= 2.0f; + a = powf(3.0f, a); + return sinf(x / 2.0f) * sinf(a * x * x); } FUNC(absstretchsine) { - x = fmod(x + 0.5, 1) * 2.0 - 1.0; - a = (a - 0.5) * 9; - a = pow(3.0, a); - float b = pow(fabs(x), a); + x = fmod(x + 0.5f, 1) * 2.0f - 1.0f; + a = (a - 0.5f) * 9; + a = powf(3.0f, a); + float b = powf(fabs(x), a); if(x < 0) b = -b; - return -pow(sin(b * PI), 2); + return -powf(sinf(b * PI), 2); } FUNC(chebyshev) { - a = a * a * a * 30.0 + 1.0; - return cos(acos(x * 2.0 - 1.0) * a); + a = a * a * a * 30.0f + 1.0f; + return cosf(acosf(x * 2.0f - 1.0f) * a); } FUNC(sqr) { - a = a * a * a * a * 160.0 + 0.001; - return -atan(sin(x * 2.0 * PI) * a); + a = a * a * a * a * 160.0f + 0.001f; + return -atanf(sinf(x * 2.0f * PI) * a); } typedef float(*base_func)(float,float); @@ -1291,34 +1291,34 @@ base_func getBaseFunction(unsigned char func) #define FILTER(x) float osc_##x(unsigned int i, float par, float par2) FILTER(lp) { - float gain = pow(1.0 - par * par * par * 0.99, i); - float tmp = par2 * par2 * par2 * par2 * 0.5 + 0.0001; + float gain = powf(1.0f - par * par * par * 0.99f, i); + float tmp = par2 * par2 * par2 * par2 * 0.5f + 0.0001f; if(gain < tmp) - gain = pow(gain, 10.0) / pow(tmp, 9.0); + gain = powf(gain, 10.0f) / powf(tmp, 9.0f); return gain; } FILTER(hp1) { - float gain = 1.0 - pow(1.0 - par * par, i + 1); - return pow(gain, par2 * 2.0 + 0.1); + float gain = 1.0f - powf(1.0f - par * par, i + 1); + return powf(gain, par2 * 2.0f + 0.1f); } FILTER(hp1b) { - if(par < 0.2) - par = par * 0.25 + 0.15; - 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); + if(par < 0.2f) + par = par * 0.25f + 0.15f; + float gain = 1.0f - powf(1.0f - par * par * 0.999f + 0.001f, i * 0.05f * i + 1.0f); + float tmp = powf(5.0f, par2 * 2.0f); + return powf(gain, tmp); } FILTER(bp1) { - float gain = i + 1 - pow(2, (1.0 - par) * 7.5); - gain = 1.0 / (1.0 + gain * gain / (i + 1.0)); - float tmp = pow(5.0, par2 * 2.0); - gain = pow(gain, tmp); + float gain = i + 1 - powf(2, (1.0f - par) * 7.5f); + gain = 1.0f / (1.0f + gain * gain / (i + 1.0f)); + float tmp = powf(5.0f, par2 * 2.0f); + gain = powf(gain, tmp); if(gain < 1e-5) gain = 1e-5; return gain; @@ -1326,31 +1326,31 @@ FILTER(bp1) FILTER(bs1) { - 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); + float gain = i + 1 - powf(2, (1.0f - par) * 7.5f); + gain = powf(atanf(gain / (i / 10.0f + 1)) / 1.57f, 6); + return powf(gain, par2 * par2 * 3.9f + 0.1f); } FILTER(lp2) { - return (i + 1 > pow(2, (1.0 - par) * 10) ? 0.0 : 1.0) * par2 + (1.0 - par2); + return (i + 1 > powf(2, (1.0f - par) * 10) ? 0.0f : 1.0f) * par2 + (1.0f - par2); } FILTER(hp2) { if(par == 1) - return 1.0; - return (i + 1 > pow(2, (1.0 - par) * 7) ? 1.0 : 0.0) * par2 + (1.0 - par2); + return 1.0f; + return (i + 1 > powf(2, (1.0f - par) * 7) ? 1.0f : 0.0f) * par2 + (1.0f - par2); } FILTER(bp2) { - return (fabs(pow(2, (1.0 - par) * 7) - i) > i / 2 + 1 ? 0.0 : 1.0) * par2 + (1.0 - par2); + return (fabs(powf(2, (1.0f - par) * 7) - i) > i / 2 + 1 ? 0.0f : 1.0f) * par2 + (1.0f - par2); } FILTER(bs2) { - return (fabs(pow(2, (1.0 - par) * 7) - i) < i / 2 + 1 ? 0.0 : 1.0) * par2 + (1.0 - par2); + return (fabs(powf(2, (1.0f - par) * 7) - i) < i / 2 + 1 ? 0.0f : 1.0f) * par2 + (1.0f - par2); } bool floatEq(float a, float b) @@ -1361,45 +1361,45 @@ bool floatEq(float a, float b) FILTER(cos) { - 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)) + float tmp = powf(5.0f, par2 * 2.0f - 1.0f); + tmp = powf(i / 32.0f, tmp) * 32.0f; + if(floatEq(par2 * 127.0f, 64.0f)) tmp = i; - float gain = cos(par * par * PI / 2.0 * tmp); + float gain = cosf(par * par * PI / 2.0f * tmp); gain *= gain; return gain; } FILTER(sin) { - 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)) + float tmp = powf(5.0f, par2 * 2.0f - 1.0f); + tmp = powf(i / 32.0f, tmp) * 32.0f; + if(floatEq(par2 * 127.0f, 64.0f)) tmp = i; - float gain = sin(par * par * PI / 2.0 * tmp); + float gain = sinf(par * par * PI / 2.0f * tmp); gain *= gain; return gain; } FILTER(low_shelf) { - float p2 = 1.0 - par + 0.2; - float x = i / (64.0 * p2 * p2); - if(x < 0.0) - x = 0.0; + float p2 = 1.0f - par + 0.2f; + float x = i / (64.0f * p2 * p2); + if(x < 0.0f) + x = 0.0f; else - if(x > 1.0) - x = 1.0; - float tmp = pow(1.0 - par2, 2.0); - return cos(x * PI) * (1.0 - tmp) + 1.01 + tmp; + if(x > 1.0f) + x = 1.0f; + float tmp = powf(1.0f - par2, 2.0f); + return cosf(x * PI) * (1.0f - tmp) + 1.01f + tmp; } FILTER(s) { - unsigned int tmp = (int) (pow(2.0, (1.0 - par) * 7.2)); - float gain = 1.0; + unsigned int tmp = (int) (powf(2.0f, (1.0f - par) * 7.2f)); + float gain = 1.0f; if(i == tmp) - gain = pow(2.0, par2 * par2 * 8.0); + gain = powf(2.0f, par2 * par2 * 8.0f); return gain; } #undef FILTER diff --git a/src/Synth/PADnote.cpp b/src/Synth/PADnote.cpp @@ -50,16 +50,16 @@ void PADnote::setup(float freq, float velocity,int portamento_, int midinote, bo if(pars->Pfixedfreq == 0) basefreq = freq; else { - basefreq = 440.0; + basefreq = 440.0f; int fixedfreqET = pars->PfixedfreqET; if(fixedfreqET != 0) { //if the frequency varies according the keyboard note float tmp = (midinote - - 69.0) / 12.0 * (pow(2.0, (fixedfreqET - 1) / 63.0) - 1.0); + - 69.0f) / 12.0f * (powf(2.0f, (fixedfreqET - 1) / 63.0f) - 1.0f); if(fixedfreqET <= 64) - basefreq *= pow(2.0, tmp); + basefreq *= powf(2.0f, tmp); else - basefreq *= pow(3.0, tmp); + basefreq *= powf(3.0f, tmp); } } @@ -72,13 +72,13 @@ void PADnote::setup(float freq, float velocity,int portamento_, int midinote, bo //find out the closest note - float logfreq = log(basefreq * pow(2.0, NoteGlobalPar.Detune / 1200.0)); - float mindist = fabs(logfreq - log(pars->sample[0].basefreq + 0.0001)); + float logfreq = logf(basefreq * powf(2.0f, NoteGlobalPar.Detune / 1200.0f)); + float mindist = fabs(logfreq - logf(pars->sample[0].basefreq + 0.0001f)); nsample = 0; for(int i = 1; i < PAD_MAX_SAMPLES; ++i) { if(pars->sample[i].smp == NULL) break; - float dist = fabs(logfreq - log(pars->sample[i].basefreq + 0.0001)); + float dist = fabs(logfreq - logf(pars->sample[i].basefreq + 0.0001f)); if(dist < mindist) { nsample = i; @@ -97,18 +97,18 @@ void PADnote::setup(float freq, float velocity,int portamento_, int midinote, bo poshi_r = (poshi_l + size / 2) % size; else poshi_r = poshi_l; - poslo = 0.0; + poslo = 0.0f; } if(pars->PPanning == 0) NoteGlobalPar.Panning = RND; else - NoteGlobalPar.Panning = pars->PPanning / 128.0; + NoteGlobalPar.Panning = pars->PPanning / 128.0f; NoteGlobalPar.FilterCenterPitch = pars->GlobalFilter->getfreq() //center freq - + pars->PFilterVelocityScale / 127.0 - * 6.0 //velocity sensing + + pars->PFilterVelocityScale / 127.0f + * 6.0f //velocity sensing * (VelF(velocity, pars-> PFilterVelocityScaleFunction) - 1); @@ -116,14 +116,14 @@ void PADnote::setup(float freq, float velocity,int portamento_, int midinote, bo if(!legato) { if(pars->PPunchStrength != 0) { NoteGlobalPar.Punch.Enabled = 1; - NoteGlobalPar.Punch.t = 1.0; //start from 1.0 and to 0.0 + NoteGlobalPar.Punch.t = 1.0f; //start from 1.0f and to 0.0f NoteGlobalPar.Punch.initialvalue = - ((pow(10, 1.5 * pars->PPunchStrength / 127.0) - 1.0) + ((powf(10, 1.5f * pars->PPunchStrength / 127.0f) - 1.0f) * VelF(velocity, pars->PPunchVelocitySensing)); - 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); + float time = powf(10, 3.0f * pars->PPunchTime / 127.0f) / 10000.0f; //0.1f .. 100 ms + float stretch = powf(440.0f / freq, pars->PPunchStretch / 64.0f); + NoteGlobalPar.Punch.dt = 1.0f / (time * SAMPLE_RATE * stretch); } else NoteGlobalPar.Punch.Enabled = 0; @@ -135,7 +135,7 @@ void PADnote::setup(float freq, float velocity,int portamento_, int midinote, bo NoteGlobalPar.AmpLfo = new LFO(pars->AmpLfo, basefreq); } - NoteGlobalPar.Volume = 4.0 * pow(0.1, 3.0 * (1.0 - pars->PVolume / 96.0)) //-60 dB .. 0 dB + NoteGlobalPar.Volume = 4.0f * powf(0.1f, 3.0f * (1.0f - pars->PVolume / 96.0f)) //-60 dB .. 0 dB * VelF(velocity, pars->PAmpVelocityScaleFunction); //velocity sensing NoteGlobalPar.AmpEnvelope->envout_dB(); //discard the first envelope output @@ -193,19 +193,19 @@ 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)) + if((smps[i - 1] < 0.0f) && (smps[i] > 0.0f)) zerocrossings++; //this is only the possitive crossings - float tmp = (SOUND_BUFFER_SIZE - 1.0) / (zerocrossings + 1) / 3.0; - if(tmp < 8.0) - tmp = 8.0; + float tmp = (SOUND_BUFFER_SIZE - 1.0f) / (zerocrossings + 1) / 3.0f; + if(tmp < 8.0f) + tmp = 8.0f; int n; F2I(tmp, n); //how many samples is the fade-in if(n > SOUND_BUFFER_SIZE) n = SOUND_BUFFER_SIZE; for(int i = 0; i < n; ++i) { //fade-in - float tmp = 0.5 - cos((float)i / (float) n * PI) * 0.5; + float tmp = 0.5f - cosf((float)i / (float) n * PI) * 0.5f; smps[i] *= tmp; } } @@ -214,7 +214,7 @@ inline void PADnote::fadein(float *smps) void PADnote::computecurrentparameters() { float globalpitch, globalfilterpitch; - globalpitch = 0.01 * (NoteGlobalPar.FreqEnvelope->envout() + globalpitch = 0.01f * (NoteGlobalPar.FreqEnvelope->envout() + NoteGlobalPar.FreqLfo->lfoout() * ctl->modwheel.relmod + NoteGlobalPar.Detune); globaloldamplitude = globalnewamplitude; @@ -236,7 +236,7 @@ void PADnote::computecurrentparameters() NoteGlobalPar.GlobalFilterR->setfreq_and_q(tmpfilterfreq, globalfilterq); //compute the portamento, if it is used by this note - float portamentofreqrap = 1.0; + float portamentofreqrap = 1.0f; if(portamento != 0) { //this voice use portamento portamentofreqrap = ctl->portamento.freqrap; if(ctl->portamento.used == 0) //the portamento has finished @@ -245,7 +245,7 @@ void PADnote::computecurrentparameters() } realfreq = basefreq * portamentofreqrap - * pow(2.0, globalpitch / 12.0) * ctl->pitchwheel.relfreq; + * powf(2.0f, globalpitch / 12.0f) * ctl->pitchwheel.relfreq; } @@ -264,18 +264,18 @@ int PADnote::Compute_Linear(float *outl, poshi_l += freqhi; poshi_r += freqhi; poslo += freqlo; - if(poslo >= 1.0) { + if(poslo >= 1.0f) { poshi_l += 1; poshi_r += 1; - poslo -= 1.0; + poslo -= 1.0f; } if(poshi_l >= size) poshi_l %= size; if(poshi_r >= size) poshi_r %= size; - outl[i] = smps[poshi_l] * (1.0 - poslo) + smps[poshi_l + 1] * poslo; - outr[i] = smps[poshi_r] * (1.0 - poslo) + smps[poshi_r + 1] * poslo; + outl[i] = smps[poshi_l] * (1.0f - poslo) + smps[poshi_l + 1] * poslo; + outr[i] = smps[poshi_r] * (1.0f - poslo) + smps[poshi_r + 1] * poslo; } return 1; } @@ -295,10 +295,10 @@ int PADnote::Compute_Cubic(float *outl, poshi_l += freqhi; poshi_r += freqhi; poslo += freqlo; - if(poslo >= 1.0) { + if(poslo >= 1.0f) { poshi_l += 1; poshi_r += 1; - poslo -= 1.0; + poslo -= 1.0f; } if(poshi_l >= size) poshi_l %= size; @@ -311,18 +311,18 @@ int PADnote::Compute_Cubic(float *outl, x0 = smps[poshi_l + 1]; x1 = smps[poshi_l + 2]; x2 = smps[poshi_l + 3]; - a = (3.0 * (x0 - x1) - xm1 + x2) * 0.5; - b = 2.0 * x1 + xm1 - (5.0 * x0 + x2) * 0.5; - c = (x1 - xm1) * 0.5; + a = (3.0f * (x0 - x1) - xm1 + x2) * 0.5f; + b = 2.0f * x1 + xm1 - (5.0f * x0 + x2) * 0.5f; + c = (x1 - xm1) * 0.5f; outl[i] = (((a * poslo) + b) * poslo + c) * poslo + x0; //right xm1 = smps[poshi_r]; x0 = smps[poshi_r + 1]; x1 = smps[poshi_r + 2]; x2 = smps[poshi_r + 3]; - a = (3.0 * (x0 - x1) - xm1 + x2) * 0.5; - b = 2.0 * x1 + xm1 - (5.0 * x0 + x2) * 0.5; - c = (x1 - xm1) * 0.5; + a = (3.0f * (x0 - x1) - xm1 + x2) * 0.5f; + b = 2.0f * x1 + xm1 - (5.0f * x0 + x2) * 0.5f; + c = (x1 - xm1) * 0.5f; outr[i] = (((a * poslo) + b) * poslo + c) * poslo + x0; } return 1; @@ -335,8 +335,8 @@ int PADnote::noteout(float *outl, float *outr) float *smps = pars->sample[nsample].smp; if(smps == NULL) { for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) { - outl[i] = 0.0; - outr[i] = 0.0; + outl[i] = 0.0f; + outr[i] = 0.0f; } return 1; } @@ -367,11 +367,11 @@ int PADnote::noteout(float *outl, float *outr) if(NoteGlobalPar.Punch.Enabled != 0) { for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) { float punchamp = NoteGlobalPar.Punch.initialvalue - * NoteGlobalPar.Punch.t + 1.0; + * NoteGlobalPar.Punch.t + 1.0f; outl[i] *= punchamp; outr[i] *= punchamp; NoteGlobalPar.Punch.t -= NoteGlobalPar.Punch.dt; - if(NoteGlobalPar.Punch.t < 0.0) { + if(NoteGlobalPar.Punch.t < 0.0f) { NoteGlobalPar.Punch.Enabled = 0; break; } @@ -386,13 +386,13 @@ int PADnote::noteout(float *outl, float *outr) i, SOUND_BUFFER_SIZE); outl[i] *= tmpvol * NoteGlobalPar.Panning; - outr[i] *= tmpvol * (1.0 - NoteGlobalPar.Panning); + outr[i] *= tmpvol * (1.0f - NoteGlobalPar.Panning); } } else { for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) { outl[i] *= globalnewamplitude * NoteGlobalPar.Panning; - outr[i] *= globalnewamplitude * (1.0 - NoteGlobalPar.Panning); + outr[i] *= globalnewamplitude * (1.0f - NoteGlobalPar.Panning); } } @@ -404,7 +404,7 @@ int PADnote::noteout(float *outl, float *outr) // If it does, disable the note if(NoteGlobalPar.AmpEnvelope->finished() != 0) { for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) { //fade-out - float tmp = 1.0 - (float)i / (float)SOUND_BUFFER_SIZE; + float tmp = 1.0f - (float)i / (float)SOUND_BUFFER_SIZE; outl[i] *= tmp; outr[i] *= tmp; } diff --git a/src/Synth/Resonance.cpp b/src/Synth/Resonance.cpp @@ -40,8 +40,8 @@ void Resonance::defaults() Pcenterfreq = 64; //1 kHz Poctavesfreq = 64; Pprotectthefundamental = 0; - ctlcenter = 1.0; - ctlbw = 1.0; + ctlcenter = 1.0f; + ctlbw = 1.0f; for(int i = 0; i < N_RES_POINTS; ++i) Prespoints[i] = 64; } @@ -63,20 +63,20 @@ void Resonance::applyres(int n, fft_t *fftdata, float freq) { if(Penabled == 0) return; //if the resonance is disabled - float sum = 0.0, - l1 = log(getfreqx(0.0) * ctlcenter), - l2 = log(2.0) * getoctavesfreq() * ctlbw; + float sum = 0.0f, + l1 = logf(getfreqx(0.0f) * ctlcenter), + l2 = logf(2.0f) * getoctavesfreq() * ctlbw; for(int i = 0; i < N_RES_POINTS; ++i) if(sum < Prespoints[i]) sum = Prespoints[i]; - if(sum < 1.0) - sum = 1.0; + if(sum < 1.0f) + sum = 1.0f; for(int i = 1; i < n; ++i) { - float x = (log(freq * i) - l1) / l2; //compute where the n-th hamonics fits to the graph - if(x < 0.0) - x = 0.0; + float x = (logf(freq * i) - l1) / l2; //compute where the n-th hamonics fits to the graph + if(x < 0.0f) + x = 0.0f; x *= N_RES_POINTS; float dx = x - floor(x); @@ -89,12 +89,12 @@ void Resonance::applyres(int n, fft_t *fftdata, float freq) kx2 = N_RES_POINTS - 1; float y = (Prespoints[kx1] - * (1.0 - dx) + Prespoints[kx2] * dx) / 127.0 - sum / 127.0; + * (1.0f - dx) + Prespoints[kx2] * dx) / 127.0f - sum / 127.0f; - y = pow(10.0, y * PmaxdB / 20.0); + y = powf(10.0f, y * PmaxdB / 20.0f); if((Pprotectthefundamental != 0) && (i == 1)) - y = 1.0; + y = 1.0f; fftdata[i] *= y; } @@ -106,18 +106,18 @@ void Resonance::applyres(int n, fft_t *fftdata, float freq) float Resonance::getfreqresponse(float freq) { - float l1 = log(getfreqx(0.0) * ctlcenter), - l2 = log(2.0) * getoctavesfreq() * ctlbw, sum = 0.0; + float l1 = logf(getfreqx(0.0f) * ctlcenter), + l2 = logf(2.0f) * getoctavesfreq() * ctlbw, sum = 0.0f; for(int i = 0; i < N_RES_POINTS; ++i) if(sum < Prespoints[i]) sum = Prespoints[i]; - if(sum < 1.0) - sum = 1.0; + if(sum < 1.0f) + sum = 1.0f; - float x = (log(freq) - l1) / l2; //compute where the n-th hamonics fits to the graph - if(x < 0.0) - x = 0.0; + float x = (logf(freq) - l1) / l2; //compute where the n-th hamonics fits to the graph + if(x < 0.0f) + x = 0.0f; x *= N_RES_POINTS; float dx = x - floor(x); x = floor(x); @@ -129,8 +129,8 @@ float Resonance::getfreqresponse(float freq) kx2 = N_RES_POINTS - 1; float result = (Prespoints[kx1] - * (1.0 - dx) + Prespoints[kx2] * dx) / 127.0 - sum / 127.0; - result = pow(10.0, result * PmaxdB / 20.0); + * (1.0f - dx) + Prespoints[kx2] * dx) / 127.0f - sum / 127.0f; + result = powf(10.0f, result * PmaxdB / 20.0f); return result; } @@ -142,12 +142,12 @@ void Resonance::smooth() { float old = Prespoints[0]; for(int i = 0; i < N_RES_POINTS; ++i) { - old = old * 0.4 + Prespoints[i] * 0.6; + old = old * 0.4f + Prespoints[i] * 0.6f; Prespoints[i] = (int) old; } old = Prespoints[N_RES_POINTS - 1]; for(int i = N_RES_POINTS - 1; i > 0; i--) { - old = old * 0.4 + Prespoints[i] * 0.6; + old = old * 0.4f + Prespoints[i] * 0.6f; Prespoints[i] = (int) old + 1; if(Prespoints[i] > 127) Prespoints[i] = 127; @@ -159,15 +159,15 @@ void Resonance::smooth() */ void Resonance::randomize(int type) { - int r = (int)(RND * 127.0); + int r = (int)(RND * 127.0f); for(int i = 0; i < N_RES_POINTS; ++i) { Prespoints[i] = r; - if((RND < 0.1) && (type == 0)) - r = (int)(RND * 127.0); - if((RND < 0.3) && (type == 1)) - r = (int)(RND * 127.0); + if((RND < 0.1f) && (type == 0)) + r = (int)(RND * 127.0f); + if((RND < 0.3f) && (type == 1)) + r = (int)(RND * 127.0f); if(type == 2) - r = (int)(RND * 127.0); + r = (int)(RND * 127.0f); } smooth(); } @@ -184,8 +184,8 @@ void Resonance::interpolatepeaks(int type) for(int k = 0; k < i - x1; ++k) { float x = (float) k / (i - x1); if(type == 0) - x = (1 - cos(x * PI)) * 0.5; - Prespoints[x1 + k] = (int)(y1 * (1.0 - x) + y2 * x); + x = (1 - cosf(x * PI)) * 0.5f; + Prespoints[x1 + k] = (int)(y1 * (1.0f - x) + y2 * x); } x1 = i; y1 = y2; @@ -198,10 +198,10 @@ void Resonance::interpolatepeaks(int type) */ float Resonance::getfreqx(float x) { - if(x > 1.0) - x = 1.0; - float octf = pow(2.0, getoctavesfreq()); - return getcenterfreq() / sqrt(octf) * pow(octf, x); + if(x > 1.0f) + x = 1.0f; + float octf = powf(2.0f, getoctavesfreq()); + return getcenterfreq() / sqrt(octf) * powf(octf, x); } /* @@ -209,7 +209,7 @@ float Resonance::getfreqx(float x) */ float Resonance::getfreqpos(float freq) { - return (log(freq) - log(getfreqx(0.0))) / log(2.0) / getoctavesfreq(); + return (logf(freq) - logf(getfreqx(0.0f))) / logf(2.0f) / getoctavesfreq(); } /* @@ -217,7 +217,7 @@ float Resonance::getfreqpos(float freq) */ float Resonance::getcenterfreq() { - return 10000.0 * pow(10, -(1.0 - Pcenterfreq / 127.0) * 2.0); + return 10000.0f * powf(10, -(1.0f - Pcenterfreq / 127.0f) * 2.0f); } /* @@ -225,7 +225,7 @@ float Resonance::getcenterfreq() */ float Resonance::getoctavesfreq() { - return 0.25 + 10.0 * Poctavesfreq / 127.0; + return 0.25f + 10.0f * Poctavesfreq / 127.0f; } void Resonance::sendcontroller(MidiControllers ctl, float par) diff --git a/src/Synth/SUBnote.cpp b/src/Synth/SUBnote.cpp @@ -47,10 +47,10 @@ void SUBnote::setup(float freq, float velocity, int portamento_, int midinote, b { portamento = portamento_; NoteEnabled = ON; - volume = pow(0.1, 3.0 * (1.0 - pars->PVolume / 96.0)); //-60 dB .. 0 dB + volume = powf(0.1f, 3.0f * (1.0f - pars->PVolume / 96.0f)); //-60 dB .. 0 dB volume *= VelF(velocity, pars->PAmpVelocityScaleFunction); if(pars->PPanning != 0) - panning = pars->PPanning / 127.0; + panning = pars->PPanning / 127.0f; else panning = RND; if(!legato) { @@ -64,27 +64,27 @@ void SUBnote::setup(float freq, float velocity, int portamento_, int midinote, b if(pars->Pfixedfreq == 0) basefreq = freq; else { - basefreq = 440.0; + basefreq = 440.0f; int fixedfreqET = pars->PfixedfreqET; if(fixedfreqET != 0) { //if the frequency varies according the keyboard note float tmp = (midinote - - 69.0) / 12.0 * (pow(2.0, (fixedfreqET - 1) / 63.0) - 1.0); + - 69.0f) / 12.0f * (powf(2.0f, (fixedfreqET - 1) / 63.0f) - 1.0f); if(fixedfreqET <= 64) - basefreq *= pow(2.0, tmp); + basefreq *= powf(2.0f, tmp); else - basefreq *= pow(3.0, tmp); + basefreq *= powf(3.0f, tmp); } } float detune = getdetune(pars->PDetuneType, pars->PCoarseDetune, pars->PDetune); - basefreq *= pow(2.0, detune / 1200.0); //detune + basefreq *= powf(2.0f, detune / 1200.0f); //detune // basefreq*=ctl->pitchwheel.relfreq;//pitch wheel //global filter GlobalFilterCenterPitch = pars->GlobalFilter->getfreq() //center freq - + (pars->PGlobalFilterVelocityScale / 127.0 * 6.0) //velocity sensing + + (pars->PGlobalFilterVelocityScale / 127.0f * 6.0f) //velocity sensing * (VelF(velocity, pars->PGlobalFilterVelocityScaleFunction) - 1); @@ -100,7 +100,7 @@ void SUBnote::setup(float freq, float velocity, int portamento_, int midinote, b for(int n = 0; n < MAX_SUB_HARMONICS; ++n) { if(pars->Phmag[n] == 0) continue; - if(n * basefreq > SAMPLE_RATE / 2.0) + if(n * basefreq > SAMPLE_RATE / 2.0f) break; //remove the freqs above the Nyquist freq pos[harmonics++] = n; } @@ -127,51 +127,51 @@ void SUBnote::setup(float freq, float velocity, int portamento_, int midinote, b } //how much the amplitude is normalised (because the harmonics) - float reduceamp = 0.0; + float reduceamp = 0.0f; for(int n = 0; n < numharmonics; ++n) { float freq = basefreq * (pos[n] + 1); //the bandwidth is not absolute(Hz); it is relative to frequency float bw = - pow(10, (pars->Pbandwidth - 127.0) / 127.0 * 4) * numstages; + powf(10, (pars->Pbandwidth - 127.0f) / 127.0f * 4) * numstages; //Bandwidth Scale - bw *= pow(1000 / freq, (pars->Pbwscale - 64.0) / 64.0 * 3.0); + bw *= powf(1000 / freq, (pars->Pbwscale - 64.0f) / 64.0f * 3.0f); //Relative BandWidth - bw *= pow(100, (pars->Phrelbw[pos[n]] - 64.0) / 64.0); + bw *= powf(100, (pars->Phrelbw[pos[n]] - 64.0f) / 64.0f); - if(bw > 25.0) - bw = 25.0; + if(bw > 25.0f) + bw = 25.0f; //try to keep same amplitude on all freqs and bw. (empirically) - float gain = sqrt(1500.0 / (bw * freq)); + float gain = sqrt(1500.0f / (bw * freq)); - float hmagnew = 1.0 - pars->Phmag[pos[n]] / 127.0; + float hmagnew = 1.0f - pars->Phmag[pos[n]] / 127.0f; float hgain; switch(pars->Phmagtype) { case 1: - hgain = exp(hmagnew * log(0.01)); + hgain = expf(hmagnew * logf(0.01f)); break; case 2: - hgain = exp(hmagnew * log(0.001)); + hgain = expf(hmagnew * logf(0.001f)); break; case 3: - hgain = exp(hmagnew * log(0.0001)); + hgain = expf(hmagnew * logf(0.0001f)); break; case 4: - hgain = exp(hmagnew * log(0.00001)); + hgain = expf(hmagnew * logf(0.00001f)); break; default: - hgain = 1.0 - hmagnew; + hgain = 1.0f - hmagnew; } gain *= hgain; reduceamp += hgain; for(int nph = 0; nph < numstages; ++nph) { - float amp = 1.0; + float amp = 1.0f; if(nph == 0) amp = gain; initfilter(lfilter[nph + n * numstages], freq, bw, amp, hgain); @@ -180,8 +180,8 @@ void SUBnote::setup(float freq, float velocity, int portamento_, int midinote, b } } - if(reduceamp < 0.001) - reduceamp = 1.0; + if(reduceamp < 0.001f) + reduceamp = 1.0f; volume /= reduceamp; oldpitchwheel = 0; @@ -190,13 +190,13 @@ void SUBnote::setup(float freq, float velocity, int portamento_, int midinote, b if(pars->Pfixedfreq == 0) initparameters(basefreq); else - initparameters(basefreq / 440.0 * freq); + initparameters(basefreq / 440.0f * freq); } else { if(pars->Pfixedfreq == 0) freq = basefreq; else - freq *= basefreq / 440.0; + freq *= basefreq / 440.0f; if(pars->PGlobalFilterEnabled != 0) { globalfiltercenterq = pars->GlobalFilter->getq(); @@ -253,24 +253,24 @@ void SUBnote::computefiltercoefs(bpfilter &filter, float bw, float gain) { - if(freq > SAMPLE_RATE / 2.0 - 200.0) - freq = SAMPLE_RATE / 2.0 - 200.0; + if(freq > SAMPLE_RATE / 2.0f - 200.0f) + freq = SAMPLE_RATE / 2.0f - 200.0f; - 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); + float omega = 2.0f * PI * freq / SAMPLE_RATE; + float sn = sinf(omega); + float cs = cosf(omega); + float alpha = sn * sinh(LOG_2 / 2.0f * bw * omega / sn); if(alpha > 1) alpha = 1; if(alpha > bw) alpha = bw; - filter.b0 = alpha / (1.0 + alpha) * filter.amp * gain; - filter.b2 = -alpha / (1.0 + alpha) * filter.amp * gain; - filter.a1 = -2.0 * cs / (1.0 + alpha); - filter.a2 = (1.0 - alpha) / (1.0 + alpha); + filter.b0 = alpha / (1.0f + alpha) * filter.amp * gain; + filter.b2 = -alpha / (1.0f + alpha) * filter.amp * gain; + filter.a1 = -2.0f * cs / (1.0f + alpha); + filter.a2 = (1.0f - alpha) / (1.0f + alpha); } @@ -283,33 +283,33 @@ void SUBnote::initfilter(bpfilter &filter, float amp, float mag) { - filter.xn1 = 0.0; - filter.xn2 = 0.0; + filter.xn1 = 0.0f; + filter.xn2 = 0.0f; if(start == 0) { - filter.yn1 = 0.0; - filter.yn2 = 0.0; + filter.yn1 = 0.0f; + filter.yn2 = 0.0f; } else { - float a = 0.1 * mag; //empirically - float p = RND * 2.0 * PI; + float a = 0.1f * mag; //empirically + float p = RND * 2.0f * PI; if(start == 1) a *= RND; - filter.yn1 = a * cos(p); - filter.yn2 = a * cos(p + freq * 2.0 * PI / SAMPLE_RATE); + filter.yn1 = a * cosf(p); + filter.yn2 = a * cosf(p + freq * 2.0f * PI / SAMPLE_RATE); //correct the error of computation the start amplitude //at very high frequencies - if(freq > SAMPLE_RATE * 0.96) { - filter.yn1 = 0.0; - filter.yn2 = 0.0; + if(freq > SAMPLE_RATE * 0.96f) { + filter.yn1 = 0.0f; + filter.yn2 = 0.0f; } } filter.amp = amp; filter.freq = freq; filter.bw = bw; - computefiltercoefs(filter, freq, bw, 1.0); + computefiltercoefs(filter, freq, bw, 1.0f); } /* @@ -377,13 +377,13 @@ void SUBnote::computecurrentparameters() || (oldpitchwheel != ctl->pitchwheel.data) || (oldbandwidth != ctl->bandwidth.data) || (portamento != 0)) { - float envfreq = 1.0; - float envbw = 1.0; - float gain = 1.0; + float envfreq = 1.0f; + float envbw = 1.0f; + float gain = 1.0f; if(FreqEnvelope != NULL) { envfreq = FreqEnvelope->envout() / 1200; - envfreq = pow(2.0, envfreq); + envfreq = powf(2.0f, envfreq); } envfreq *= ctl->pitchwheel.relfreq; //pitch wheel if(portamento != 0) { //portamento is used @@ -395,18 +395,18 @@ void SUBnote::computecurrentparameters() if(BandWidthEnvelope != NULL) { envbw = BandWidthEnvelope->envout(); - envbw = pow(2, envbw); + envbw = powf(2, envbw); } envbw *= ctl->bandwidth.relbw; //bandwidth controller - float tmpgain = 1.0 / sqrt(envbw * envfreq); + float tmpgain = 1.0f / sqrt(envbw * envfreq); for(int n = 0; n < numharmonics; ++n) { for(int nph = 0; nph < numstages; ++nph) { if(nph == 0) gain = tmpgain; else - gain = 1.0; + gain = 1.0f; computefiltercoefs(lfilter[nph + n * numstages], lfilter[nph + n * numstages].freq * envfreq, lfilter[nph + n * numstages].bw * envbw, @@ -419,7 +419,7 @@ void SUBnote::computecurrentparameters() if(nph == 0) gain = tmpgain; else - gain = 1.0; + gain = 1.0f; computefiltercoefs( rfilter[nph + n * numstages], rfilter[nph + n @@ -432,7 +432,7 @@ void SUBnote::computecurrentparameters() oldbandwidth = ctl->bandwidth.data; oldpitchwheel = ctl->pitchwheel.data; } - newamplitude = volume * AmpEnvelope->envout_dB() * 2.0; + newamplitude = volume * AmpEnvelope->envout_dB() * 2.0f; //Filter if(GlobalFilterL != NULL) { @@ -467,7 +467,7 @@ int SUBnote::noteout(float *outl, float *outr) float *tmpsmp = getTmpBuffer(); //left channel for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) - tmprnd[i] = RND * 2.0 - 1.0; + tmprnd[i] = RND * 2.0f - 1.0f; for(int n = 0; n < numharmonics; ++n) { memcpy(tmpsmp, tmprnd, SOUND_BUFFER_SIZE * sizeof(float)); for(int nph = 0; nph < numstages; ++nph) @@ -482,7 +482,7 @@ int SUBnote::noteout(float *outl, float *outr) //right channel if(stereo != 0) { for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) - tmprnd[i] = RND * 2.0 - 1.0; + tmprnd[i] = RND * 2.0f - 1.0f; for(int n = 0; n < numharmonics; ++n) { memcpy(tmpsmp, tmprnd, SOUND_BUFFER_SIZE * sizeof(float)); for(int nph = 0; nph < numstages; ++nph) @@ -503,7 +503,7 @@ int SUBnote::noteout(float *outl, float *outr) if(n > SOUND_BUFFER_SIZE) n = SOUND_BUFFER_SIZE; for(int i = 0; i < n; ++i) { - float ampfadein = 0.5 - 0.5 * cos( + float ampfadein = 0.5f - 0.5f * cosf( (float) i / (float) n * PI); outl[i] *= ampfadein; outr[i] *= ampfadein; @@ -519,13 +519,13 @@ int SUBnote::noteout(float *outl, float *outr) i, SOUND_BUFFER_SIZE); outl[i] *= tmpvol * panning; - outr[i] *= tmpvol * (1.0 - panning); + outr[i] *= tmpvol * (1.0f - panning); } } else { for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) { outl[i] *= newamplitude * panning; - outr[i] *= newamplitude * (1.0 - panning); + outr[i] *= newamplitude * (1.0f - panning); } } @@ -538,7 +538,7 @@ int SUBnote::noteout(float *outl, float *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 - float tmp = 1.0 - (float)i / (float)SOUND_BUFFER_SIZE; + float tmp = 1.0f - (float)i / (float)SOUND_BUFFER_SIZE; outl[i] *= tmp; outr[i] *= tmp; } diff --git a/src/Synth/SynthNote.cpp b/src/Synth/SynthNote.cpp @@ -11,16 +11,16 @@ SynthNote::Legato::Legato(float freq, float vel, int port, { // Initialise some legato-specific vars msg = LM_Norm; - fade.length = (int)(SAMPLE_RATE * 0.005); // 0.005 seems ok. + fade.length = (int)(SAMPLE_RATE * 0.005f); // 0.005f seems ok. if(fade.length < 1) fade.length = 1; // (if something's fishy) - fade.step = (1.0 / fade.length); + fade.step = (1.0f / fade.length); decounter = -10; param.freq = freq; param.vel = vel; param.portamento = port; param.midinote = note; - lastfreq = 0.0; + lastfreq = 0.0f; silent = quiet; } @@ -37,11 +37,11 @@ int SynthNote::Legato::update(float freq, float velocity, int portamento_, param.midinote = midinote_; if(msg == LM_Norm) { if(silent) { - fade.m = 0.0; + fade.m = 0.0f; msg = LM_FadeIn; } else { - fade.m = 1.0; + fade.m = 1.0f; msg = LM_FadeOut; return 1; } @@ -100,8 +100,8 @@ void SynthNote::Legato::apply(SynthNote &note, float *outl, float *outr) decounter--; if(decounter < 1) { for(int j = i; j < SOUND_BUFFER_SIZE; ++j) { - outl[j] = 0.0; - outr[j] = 0.0; + outl[j] = 0.0f; + outr[j] = 0.0f; } decounter = -10; silent = true; diff --git a/src/Tests/AdNoteTest.h b/src/Tests/AdNoteTest.h @@ -73,7 +73,7 @@ class AdNoteTest:public CxxTest::TestSuite //lets go with.... 50! as a nice note testnote = 50; - float freq = 440.0 * pow(2.0, (testnote - 69.0) / 12.0); + float freq = 440.0f * powf(2.0f, (testnote - 69.0f) / 12.0f); note = new ADnote(defaultPreset, controller, @@ -118,26 +118,26 @@ class AdNoteTest:public CxxTest::TestSuite #endif sampleCount += SOUND_BUFFER_SIZE; - TS_ASSERT_DELTA(outL[255], 0.3019, 0.0001); + TS_ASSERT_DELTA(outL[255], 0.3019f, 0.0001f); note->relasekey(); note->noteout(outL, outR); sampleCount += SOUND_BUFFER_SIZE; - TS_ASSERT_DELTA(outL[255], -0.1382, 0.0001); + TS_ASSERT_DELTA(outL[255], -0.1382f, 0.0001f); note->noteout(outL, outR); sampleCount += SOUND_BUFFER_SIZE; - TS_ASSERT_DELTA(outL[255], -0.0334, 0.0001); + TS_ASSERT_DELTA(outL[255], -0.0334f, 0.0001f); note->noteout(outL, outR); sampleCount += SOUND_BUFFER_SIZE; - TS_ASSERT_DELTA(outL[255], -0.1329, 0.0001); + TS_ASSERT_DELTA(outL[255], -0.1329f, 0.0001f); note->noteout(outL, outR); sampleCount += SOUND_BUFFER_SIZE; - TS_ASSERT_DELTA(outL[255], 0.2690, 0.0001); + TS_ASSERT_DELTA(outL[255], 0.2690f, 0.0001f); while(!note->finished()) { note->noteout(outL, outR); diff --git a/src/Tests/ControllerTest.h b/src/Tests/ControllerTest.h @@ -39,31 +39,31 @@ class ControllerTest:public CxxTest::TestSuite //Initialize portamento testCtl->setportamento(127); testCtl->portamento.time = 127; - testCtl->initportamento(40.0, 400.0, false); + testCtl->initportamento(40.0f, 400.0f, false); //Bounds Check while(testCtl->portamento.used) { - TS_ASSERT((0.0 <= testCtl->portamento.x) - && (testCtl->portamento.x <= 1.0)); - TS_ASSERT((0.1 <= testCtl->portamento.freqrap) - && (testCtl->portamento.freqrap <= 1.0)); + TS_ASSERT((0.0f <= testCtl->portamento.x) + && (testCtl->portamento.x <= 1.0f)); + TS_ASSERT((0.1f <= testCtl->portamento.freqrap) + && (testCtl->portamento.freqrap <= 1.0f)); testCtl->updateportamento(); } - TS_ASSERT((0.0 <= testCtl->portamento.x) - && (testCtl->portamento.x <= 1.0)); - TS_ASSERT((0.1 <= testCtl->portamento.freqrap) - && (testCtl->portamento.freqrap <= 1.0)); + TS_ASSERT((0.0f <= testCtl->portamento.x) + && (testCtl->portamento.x <= 1.0f)); + TS_ASSERT((0.1f <= testCtl->portamento.freqrap) + && (testCtl->portamento.freqrap <= 1.0f)); } void testPortamentoValue() { testCtl->setportamento(127); testCtl->portamento.time = 127; - testCtl->initportamento(40.0, 400.0, false); + testCtl->initportamento(40.0f, 400.0f, false); int i; for(i = 0; i < 10; ++i) testCtl->updateportamento(); //Assert that the numbers are the same as they were at release - TS_ASSERT_DELTA(testCtl->portamento.x, 0.0290249, 0.000001) - TS_ASSERT_DELTA(testCtl->portamento.freqrap, 0.126122, 0.000001) + TS_ASSERT_DELTA(testCtl->portamento.x, 0.0290249f, 0.000001f) + TS_ASSERT_DELTA(testCtl->portamento.freqrap, 0.126122f, 0.000001f) } private: diff --git a/src/Tests/EchoTest.h b/src/Tests/EchoTest.h @@ -34,10 +34,10 @@ class EchoTest:public CxxTest::TestSuite void setUp() { outL = new float[SOUND_BUFFER_SIZE]; for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) - outL[i] = 0.0; + outL[i] = 0.0f; outR = new float[SOUND_BUFFER_SIZE]; for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) - outR[i] = 0.0; + outR[i] = 0.0f; 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; @@ -59,8 +59,8 @@ class EchoTest:public CxxTest::TestSuite //(given a zero input) testFX->out(*input); for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) { - TS_ASSERT_DELTA(outL[i], 0.0, 0.0001); - TS_ASSERT_DELTA(outR[i], 0.0, 0.0001); + TS_ASSERT_DELTA(outL[i], 0.0f, 0.0001f); + TS_ASSERT_DELTA(outR[i], 0.0f, 0.0001f); } } @@ -70,13 +70,13 @@ class EchoTest:public CxxTest::TestSuite //flood with high input for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) - input->r[i] = input->l[i] = 1.0; + input->r[i] = input->l[i] = 1.0f; for(int i = 0; i < 500; ++i) testFX->out(*input); for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) { - TS_ASSERT_DIFFERS(outL[i], 0.0); - TS_ASSERT_DIFFERS(outR[i], 0.0) + TS_ASSERT_DIFFERS(outL[i], 0.0f); + TS_ASSERT_DIFFERS(outR[i], 0.0f) } //After making sure the internal buffer has a nonzero value //cleanup @@ -85,8 +85,8 @@ class EchoTest:public CxxTest::TestSuite testFX->cleanup(); testFX->out(*input); for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) { - TS_ASSERT_DELTA(outL[i], 0.0, 0.0001); - TS_ASSERT_DELTA(outR[i], 0.0, 0.0001); + TS_ASSERT_DELTA(outL[i], 0.0f, 0.0001f); + TS_ASSERT_DELTA(outR[i], 0.0f, 0.0001f); } } //Insures that the proper decay occurs with high feedback @@ -94,19 +94,19 @@ class EchoTest:public CxxTest::TestSuite //flood with high input for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) - input->r[i] = input->l[i] = 1.0; + input->r[i] = input->l[i] = 1.0f; char FEEDBACK = 5; testFX->changepar(FEEDBACK, 127); for(int i = 0; i < 100; ++i) testFX->out(*input); for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) { - TS_ASSERT_DIFFERS(outL[i], 0.0); - TS_ASSERT_DIFFERS(outR[i], 0.0) + TS_ASSERT_DIFFERS(outL[i], 0.0f); + TS_ASSERT_DIFFERS(outR[i], 0.0f) } float amp = abs(outL[0] + outR[0]) / 2; //reset input to zero for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) - input->r[i] = input->l[i] = 0.0; + input->r[i] = input->l[i] = 0.0f; //give the echo time to fade based upon zero input and high feedback for(int i = 0; i < 50; ++i) diff --git a/src/Tests/MicrotonalTest.h b/src/Tests/MicrotonalTest.h @@ -46,7 +46,7 @@ class MicrotonalTest:public CxxTest::TestSuite TS_ASSERT_EQUALS(testMicro->getoctavesize(), 12); TS_ASSERT_EQUALS(testMicro->Penabled, 0); TS_ASSERT_EQUALS(testMicro->PAnote, 69); - TS_ASSERT_EQUALS(testMicro->PAfreq, 440.0); + TS_ASSERT_EQUALS(testMicro->PAfreq, 440.0f); TS_ASSERT_EQUALS(testMicro->Pscaleshift, 64); TS_ASSERT_EQUALS(testMicro->Pfirstkey, 0); TS_ASSERT_EQUALS(testMicro->Plastkey, 127); @@ -63,14 +63,14 @@ class MicrotonalTest:public CxxTest::TestSuite for(int i = 0; i < 128; ++i) TS_ASSERT_EQUALS(testMicro->Pmapping[i], i); - TS_ASSERT_DELTA(testMicro->getnotefreq(19, 0), 24.4997, 0.0001); + TS_ASSERT_DELTA(testMicro->getnotefreq(19, 0), 24.4997f, 0.0001f); } //performs basic sanity check with the == and != operators void testeqeq() { Microtonal other; TS_ASSERT(*testMicro == other); //both are constructed the same, so they should be equal - other.PAfreq = 220.0; + other.PAfreq = 220.0f; TS_ASSERT(*testMicro != other); //other is now different } diff --git a/src/Tests/OscilGenTest.h b/src/Tests/OscilGenTest.h @@ -53,7 +53,7 @@ class OscilGenTest:public CxxTest::TestSuite //lets go with.... 50! as a nice note const char testnote = 50; - freq = 440.0 * pow(2.0, (testnote - 69.0) / 12.0); + freq = 440.0f * powf(2.0f, (testnote - 69.0f) / 12.0f); } void tearDown() { @@ -74,23 +74,23 @@ class OscilGenTest:public CxxTest::TestSuite void testOutput(void) { oscil->get(outL, freq); - TS_ASSERT_DELTA(outL[23], -0.014717, 0.0001); - TS_ASSERT_DELTA(outL[129], -0.567502, 0.0001); - TS_ASSERT_DELTA(outL[586], -0.030894, 0.0001); - TS_ASSERT_DELTA(outL[1023], -0.080001, 0.0001); + TS_ASSERT_DELTA(outL[23], -0.014717f, 0.0001f); + TS_ASSERT_DELTA(outL[129], -0.567502f, 0.0001f); + TS_ASSERT_DELTA(outL[586], -0.030894f, 0.0001f); + TS_ASSERT_DELTA(outL[1023], -0.080001f, 0.0001f); } void testSpectrum(void) { oscil->getspectrum(OSCIL_SIZE / 2, outR, 1); - TS_ASSERT_DELTA(outR[0], 350.698059, 0.0001); - TS_ASSERT_DELTA(outR[1], 228.889267, 0.0001); - TS_ASSERT_DELTA(outR[2], 62.187931, 0.0001); - TS_ASSERT_DELTA(outR[3], 22.295225, 0.0001); - TS_ASSERT_DELTA(outR[4], 6.942001, 0.0001); - TS_ASSERT_DELTA(outR[26], 0.015110, 0.0001); - TS_ASSERT_DELTA(outR[47], 0.003425, 0.0001); - TS_ASSERT_DELTA(outR[65], 0.001293, 0.0001); + TS_ASSERT_DELTA(outR[0], 350.698059f, 0.0001f); + TS_ASSERT_DELTA(outR[1], 228.889267f, 0.0001f); + TS_ASSERT_DELTA(outR[2], 62.187931f, 0.0001f); + TS_ASSERT_DELTA(outR[3], 22.295225f, 0.0001f); + TS_ASSERT_DELTA(outR[4], 6.942001f, 0.0001f); + TS_ASSERT_DELTA(outR[26], 0.015110f, 0.0001f); + TS_ASSERT_DELTA(outR[47], 0.003425f, 0.0001f); + TS_ASSERT_DELTA(outR[65], 0.001293f, 0.0001f); } //performance testing diff --git a/src/Tests/RandTest.h b/src/Tests/RandTest.h @@ -31,11 +31,11 @@ class RandTest:public CxxTest::TestSuite public: void testPRNG(void) { //verify RND returns expected pattern when unseeded - TS_ASSERT_DELTA(RND, 0.840188, 0.00001); - TS_ASSERT_DELTA(RND, 0.394383, 0.00001); - TS_ASSERT_DELTA(RND, 0.783099, 0.00001); - TS_ASSERT_DELTA(RND, 0.798440, 0.00001); - TS_ASSERT_DELTA(RND, 0.911647, 0.00001); + TS_ASSERT_DELTA(RND, 0.840188f, 0.00001f); + TS_ASSERT_DELTA(RND, 0.394383f, 0.00001f); + TS_ASSERT_DELTA(RND, 0.783099f, 0.00001f); + TS_ASSERT_DELTA(RND, 0.798440f, 0.00001f); + TS_ASSERT_DELTA(RND, 0.911647f, 0.00001f); } }; diff --git a/src/Tests/SampleTest.h b/src/Tests/SampleTest.h @@ -29,10 +29,10 @@ class SampleTest:public CxxTest::TestSuite Sample smp(10); TS_ASSERT_EQUALS(smp.size(), 10); for(int i = 0; i < 20; ++i) - TS_ASSERT_EQUALS(smp[i], 0.0); - Sample nsmp(5, 15.0); + TS_ASSERT_EQUALS(smp[i], 0.0f); + Sample nsmp(5, 15.0f); TS_ASSERT_EQUALS(nsmp.size(), 5); - TS_ASSERT_EQUALS(nsmp[4], 15.0); + TS_ASSERT_EQUALS(nsmp[4], 15.0f); } void testAssign() { @@ -59,7 +59,7 @@ class SampleTest:public CxxTest::TestSuite smp = Sample(50, fl); delete [] fl; for(int i = 0; i < 50; ++i) - TS_ASSERT_DELTA(smp[i], i, 0.001); + TS_ASSERT_DELTA(smp[i], i, 0.001f); smp = Sample(3); } @@ -78,7 +78,7 @@ class SampleTest:public CxxTest::TestSuite smp1.append(smp2); TS_ASSERT_EQUALS(smp1.size(), 74); for(int i = 0; i < 74; ++i) - TS_ASSERT_DELTA(smp1[i], (i < 54 ? 2 : 17), 0.001); + TS_ASSERT_DELTA(smp1[i], (i < 54 ? 2 : 17), 0.001f); } void testResample() { diff --git a/src/Tests/SubNoteTest.h b/src/Tests/SubNoteTest.h @@ -58,7 +58,7 @@ class SubNoteTest:public CxxTest::TestSuite //lets go with.... 50! as a nice note testnote = 50; - float freq = 440.0 * pow(2.0, (testnote - 69.0) / 12.0); + float freq = 440.0f * powf(2.0f, (testnote - 69.0f) / 12.0f); note = new SUBnote(defaultPreset, controller, @@ -104,26 +104,26 @@ class SubNoteTest:public CxxTest::TestSuite #endif sampleCount += SOUND_BUFFER_SIZE; - TS_ASSERT_DELTA(outL[255], 0.0000, 0.0001); + TS_ASSERT_DELTA(outL[255], 0.0000f, 0.0001f); note->relasekey(); note->noteout(outL, outR); sampleCount += SOUND_BUFFER_SIZE; - TS_ASSERT_DELTA(outL[255], 0.0022, 0.0001); + TS_ASSERT_DELTA(outL[255], 0.0022f, 0.0001f); note->noteout(outL, outR); sampleCount += SOUND_BUFFER_SIZE; - TS_ASSERT_DELTA(outL[255], -0.0020, 0.0001); + TS_ASSERT_DELTA(outL[255], -0.0020f, 0.0001f); note->noteout(outL, outR); sampleCount += SOUND_BUFFER_SIZE; - TS_ASSERT_DELTA(outL[255], 0.0010, 0.0001); + TS_ASSERT_DELTA(outL[255], 0.0010f, 0.0001f); note->noteout(outL, outR); sampleCount += SOUND_BUFFER_SIZE; - TS_ASSERT_DELTA(outL[255], 0.0005, 0.0001); + TS_ASSERT_DELTA(outL[255], 0.0005f, 0.0001f); while(!note->finished()) { note->noteout(outL, outR); diff --git a/src/Tests/XMLwrapperTest.h b/src/Tests/XMLwrapperTest.h @@ -46,7 +46,7 @@ class XMLwrapperTest:public CxxTest::TestSuite void testAnotherLoad() { - string dat = "\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\ + string dat = "\n<?xml version=\"1.0f\" encoding=\"UTF-8\"?>\n\ <!DOCTYPE ZynAddSubFX-data>\n\ <ZynAddSubFX-data version-major=\"2\" version-minor=\"4\"\n\ version-revision=\"1\" ZynAddSubFX-author=\"Nasca Octavian Paul\">\n\ diff --git a/src/UI/WidgetPDial.cpp b/src/UI/WidgetPDial.cpp @@ -1,4 +1,4 @@ -// generated by Fast Light User Interface Designer (fluid) version 1.0107 +// generated by Fast Light User Interface Designer (fluid) version 1.0107f #include "WidgetPDial.h" #include <cstdio> @@ -96,7 +96,7 @@ const char *TipWin::getStr() const //static int numobj = 0; WidgetPDial::WidgetPDial(int x,int y, int w, int h, const char *label) - :Fl_Dial(x,y,w,h,label),oldvalue(0.0),pos(false),textset(false) + :Fl_Dial(x,y,w,h,label),oldvalue(0.0f),pos(false),textset(false) { //cout << "[" << label << "] There are now " << ++numobj << endl; Fl_Group *save = Fl_Group::current(); @@ -124,7 +124,7 @@ int WidgetPDial::handle(int event) tipwin->showValue(value()); my=-(Fl::event_y()-y()-h()/2); - dragsize=200.0; + dragsize=200.0f; if (Fl::event_state(FL_BUTTON1)==0) dragsize*=10; @@ -155,7 +155,7 @@ int WidgetPDial::handle(int event) void WidgetPDial::drawgradient(int cx,int cy,int sx,double m1,double m2) { for (int i=(int)(m1*sx);i<(int)(m2*sx);i++){ - double tmp=1.0-pow(i*1.0/sx,2.0); + double tmp=1.0f-powf(i*1.0f/sx,2.0f); pdialcolor(140+(int) (tmp*90),140+(int)(tmp*90),140+(int) (tmp*100)); fl_arc(cx+sx/2-i/2,cy+sx/2-i/2,i,i,0,360); } @@ -170,7 +170,7 @@ void WidgetPDial::draw() fl_pie(cx-1,cy-1,sx+2,sy+2,0,360); //Draws the button face (gradinet) - drawgradient(cx,cy,sx,0.5,1.0); + drawgradient(cx,cy,sx,0.5f,1.0f); double val=(value()-minimum())/(maximum()-minimum()); @@ -178,29 +178,29 @@ void WidgetPDial::draw() pdialcolor(220,220,250); double a1=angle1(),a2=angle2(); for (int i=0;i<12;i++){ - double a=-i/12.0*360.0-val*(a2-a1)-a1; + double a=-i/12.0f*360.0f-val*(a2-a1)-a1; fl_pie(cx,cy,sx,sy,a+270-3,a+3+270); }; - drawgradient(cx,cy,sx,0.0,0.75); + drawgradient(cx,cy,sx,0.0f,0.75f); //draws the value double a=-(a2-a1)*val-a1; //draws the max and min points pdialcolor(0,100,200); - int xp=(int)(cx+sx/2.0+sx/2.0*sin(angle1()/180.0*3.141592)); - int yp=(int)(cy+sy/2.0+sy/2.0*cos(angle1()/180.0*3.141592)); + int xp=(int)(cx+sx/2.0f+sx/2.0f*sinf(angle1()/180.0f*3.141592f)); + int yp=(int)(cy+sy/2.0f+sy/2.0f*cosf(angle1()/180.0f*3.141592f)); fl_pie(xp-2,yp-2,4,4,0,360); - xp=(int)(cx+sx/2.0+sx/2.0*sin(angle2()/180.0*3.141592)); - yp=(int)(cy+sy/2.0+sy/2.0*cos(angle2()/180.0*3.141592)); + xp=(int)(cx+sx/2.0f+sx/2.0f*sinf(angle2()/180.0f*3.141592f)); + yp=(int)(cy+sy/2.0f+sy/2.0f*cosf(angle2()/180.0f*3.141592f)); fl_pie(xp-2,yp-2,4,4,0,360); fl_push_matrix(); fl_translate(cx+sx/2,cy+sy/2); - fl_rotate(a-90.0); + fl_rotate(a-90.0f); fl_translate(sx/2,0); diff --git a/src/UI/WidgetPDial.h b/src/UI/WidgetPDial.h @@ -1,4 +1,4 @@ -// generated by Fast Light User Interface Designer (fluid) version 1.0107 +// generated by Fast Light User Interface Designer (fluid) version 1.0107f #ifndef WIDGETPDIAL_h #define WIDGETPDIAL_h diff --git a/src/globals.h b/src/globals.h @@ -110,7 +110,7 @@ extern int OSCIL_SIZE; /* * How is applied the velocity sensing */ -#define VELOCITY_MAX_SCALE 8.0 +#define VELOCITY_MAX_SCALE 8.0f /* * The maximum length of instrument's name @@ -138,22 +138,22 @@ extern int OSCIL_SIZE; #define FF_MAX_FORMANTS 12 #define FF_MAX_SEQUENCE 8 -#define LOG_2 0.693147181 -#define PI 3.1415926536 -#define LOG_10 2.302585093 +#define LOG_2 0.693147181f +#define PI 3.1415926536f +#define LOG_10 2.302585093f /* * The threshold for the amplitude interpolation used if the amplitude * is changed (by LFO's or Envelope's). If the change of the amplitude * is below this, the amplitude is not interpolated */ -#define AMPLITUDE_INTERPOLATION_THRESHOLD 0.0001 +#define AMPLITUDE_INTERPOLATION_THRESHOLD 0.0001f /* * How the amplitude threshold is computed */ -#define ABOVE_AMPLITUDE_THRESHOLD(a, b) ((2.0 * fabs((b) - (a)) \ - / (fabs((b) + (a) + 0.0000000001))) > \ +#define ABOVE_AMPLITUDE_THRESHOLD(a, b) ((2.0f * fabs((b) - (a)) \ + / (fabs((b) + (a) + 0.0000000001f))) > \ AMPLITUDE_INTERPOLATION_THRESHOLD) /* @@ -168,13 +168,13 @@ extern int OSCIL_SIZE; /* * dB */ -#define dB2rap(dB) ((exp((dB) * LOG_10 / 20.0))) -#define rap2dB(rap) ((20 * log(rap) / LOG_10)) +#define dB2rap(dB) ((expf((dB) * LOG_10 / 20.0f))) +#define rap2dB(rap) ((20 * logf(rap) / LOG_10)) /* - * The random generator (0.0..1.0) + * The random generator (0.0f..1.0f) */ -#define RND (rand() / (RAND_MAX * 1.0)) +#define RND (rand() / (RAND_MAX * 1.0f)) #define ZERO(data, size) {char *data_ = (char *) data; for(int i = 0; \ i < size; \ @@ -184,7 +184,7 @@ extern int OSCIL_SIZE; for(int i = 0; \ i < size; \ i++) \ - data_[i] = 0.0;} + data_[i] = 0.0f;} enum ONOFFTYPE { OFF = 0, ON = 1 @@ -209,10 +209,10 @@ enum LegatoMsg { #ifdef ASM_F2I_YES #define F2I(f, \ i) __asm__ __volatile__ ("fistpl %0" : "=m" (i) : "t" (f \ - - 0.49999999) \ + - 0.49999999f) \ : "st"); #else -#define F2I(f, i) (i) = ((f > 0) ? ((int)(f)) : ((int)(f - 1.0))); +#define F2I(f, i) (i) = ((f > 0) ? ((int)(f)) : ((int)(f - 1.0f))); #endif diff --git a/src/main.cpp b/src/main.cpp @@ -100,7 +100,7 @@ void *thread3(void *v) break; } #endif //LASH - Fl::wait(0.1); + Fl::wait(0.1f); } #elif defined QT_GUI @@ -139,7 +139,7 @@ void initprogram(int argc, char **argv) cerr << std::fixed; cerr << "\nSample Rate = \t\t" << SAMPLE_RATE << endl; cerr << "Sound Buffer Size = \t" << SOUND_BUFFER_SIZE << " samples" << endl; - cerr << "Internal latency = \t" << SOUND_BUFFER_SIZE * 1000.0 + cerr << "Internal latency = \t" << SOUND_BUFFER_SIZE * 1000.0f / SAMPLE_RATE << " ms" << endl; cerr << "ADsynth Oscil.Size = \t" << OSCIL_SIZE << " samples" << endl; @@ -198,7 +198,7 @@ int main(int argc, char *argv[]) //produce denormal buf denormalkillbuf = new float [SOUND_BUFFER_SIZE]; for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) - denormalkillbuf[i] = (RND - 0.5) * 1e-16; + denormalkillbuf[i] = (RND - 0.5f) * 1e-16; /* Parse command-line options */ struct option opts[] = { @@ -276,7 +276,7 @@ int main(int argc, char *argv[]) OSCIL_SIZE = tmp = atoi(optarguments); if(OSCIL_SIZE < MAX_AD_HARMONICS * 2) OSCIL_SIZE = MAX_AD_HARMONICS * 2; - OSCIL_SIZE = (int) pow(2, ceil(log(OSCIL_SIZE - 1.0) / log(2.0))); + OSCIL_SIZE = (int) powf(2, ceil(logf(OSCIL_SIZE - 1.0f) / logf(2.0f))); if(tmp != OSCIL_SIZE) { cerr << "OSCIL_SIZE is wrong (must be 2^n) or too small. Adjusting to " << OSCIL_SIZE << "." << endl;