diff --git a/PluginFx.cpp b/PluginFx.cpp index 2616ffd..001b3ed 100644 --- a/PluginFx.cpp +++ b/PluginFx.cpp @@ -25,6 +25,7 @@ #define _USE_MATH_DEFINES #include #include "PluginFx.h" +#include "synth.h" const float dc = 1e-18; @@ -48,7 +49,7 @@ inline static float tptlpupw(float & state , float inp , float cutoff , float sr //} static float logsc(float param, const float min, const float max, const float rolloff = 19.0f) { - return ((expf(param * logf(rolloff + 1)) - 1.0f) / (rolloff)) * (max - min) + min; + return ((EXP_FUNC(param * LOG_FUNC(rolloff + 1)) - 1.0f) / (rolloff)) * (max - min) + min; } PluginFx::PluginFx() { @@ -67,7 +68,11 @@ void PluginFx::init(int sr) { sampleRate = sr; sampleRateInv = 1 / sampleRate; - float rcrate = sqrt((44000 / sampleRate)); +#if defined(ARM_SQRT_FUNC) + float rcrate; ARM_SQRT_FUNC(44000 / sampleRate, &rcrate); +#else + float rcrate = SQRT_FUNC((44000 / sampleRate)); +#endif rcor24 = (970.0 / 44000) * rcrate; rcor24Inv = 1 / rcor24; diff --git a/config.h b/config.h index adcc1e0..1cc4003 100644 --- a/config.h +++ b/config.h @@ -229,9 +229,9 @@ enum { DEXED, REVERB, DELAY, CHORUS }; // Teensy-3.6 settings #define MIDI_DEVICE_USB_HOST 1 #if defined(USE_REVERB) -#define MAX_NOTES 11 -#else #define MAX_NOTES 14 +#else +#define MAX_NOTES 16 #endif #endif diff --git a/effect_mono_stereo.cpp b/effect_mono_stereo.cpp index a3e6aae..2375861 100644 --- a/effect_mono_stereo.cpp +++ b/effect_mono_stereo.cpp @@ -51,20 +51,15 @@ void AudioEffectMonoStereo::update(void) if (in && mod && out[0] && out[1]) { - int16_t *ip = in->data; float pan = mapfloat(mod->data[0], -1.0, 1.0, 0.0, 1.0); - int16_t *op[2] = { out[0]->data, out[1]->data }; + const float f[2] = { _pseudo_log * arm_sin_f32(pan * PI / 2), _pseudo_log * arm_cos_f32(pan * PI / 2) }; // Pan [L0.0 ... M0.5 ... 1.0R] - float f_l = _pseudo_log * sinf(pan * PI / 2); // Pan [L0.0 ... M0.5 ... 1.0R] - float f_r = _pseudo_log * cosf(pan * PI / 2); + arm_q15_to_float (in->data, in_f, AUDIO_BLOCK_SAMPLES); - for (uint16_t i = 0; i < AUDIO_BLOCK_SAMPLES; i++) + for (uint8_t i = 0; i < 2; i++) { - *op[0] = int16_t(f_l * (*ip)); - *op[1] = int16_t(f_r * (*ip)); - op[0]++; - op[1]++; - ip++; + arm_scale_f32 (in_f, f[i], out_f[i], AUDIO_BLOCK_SAMPLES); + arm_float_to_q15 (out_f[i], out[i]->data, AUDIO_BLOCK_SAMPLES); } if (in) diff --git a/effect_mono_stereo.h b/effect_mono_stereo.h index 87ff969..477fbaa 100644 --- a/effect_mono_stereo.h +++ b/effect_mono_stereo.h @@ -41,10 +41,12 @@ class AudioEffectMonoStereo : public AudioStream } virtual void update(void); - + private: audio_block_t *inputQueueArray[2]; audio_block_t *out[2]; + float in_f[AUDIO_BLOCK_SAMPLES]; + float out_f[2][AUDIO_BLOCK_SAMPLES]; const float _pseudo_log = 1048575 / (float)(1 << 20); }; diff --git a/effect_stereo_mono.cpp b/effect_stereo_mono.cpp index 119142e..88e2200 100644 --- a/effect_stereo_mono.cpp +++ b/effect_stereo_mono.cpp @@ -56,7 +56,7 @@ void AudioEffectStereoMono::update(void) bp[1]++; } #else - // device every channel by 2 + // devide every channel by 2 arm_shift_q15(block[0]->data, -1, block[0]->data, AUDIO_BLOCK_SAMPLES); arm_shift_q15(block[1]->data, -1, block[1]->data, AUDIO_BLOCK_SAMPLES); // add channel 2 to channel 1 diff --git a/synth.h b/synth.h index 06239bb..268f4ac 100644 --- a/synth.h +++ b/synth.h @@ -1,18 +1,18 @@ /* - * Copyright 2012 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + Copyright 2012 Google Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ #ifndef __SYNTH_H #define __SYNTH_H @@ -53,20 +53,25 @@ typedef __int16 SInt16; template inline static T min(const T& a, const T& b) { - return a < b ? a : b; + return a < b ? a : b; } template inline static T max(const T& a, const T& b) { - return a > b ? a : b; + return a > b ? a : b; } #define QER(n,b) ( ((float)n)/(1<