External, Non-PPA KXStudio Repository
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2925 lines
98KB

  1. diff --git a/CMakeLists.txt b/CMakeLists.txt
  2. index 9636c5e..6696c38 100644
  3. --- a/CMakeLists.txt
  4. +++ b/CMakeLists.txt
  5. @@ -39,52 +39,64 @@ function(add_plugin PLUGIN_NAME)
  6. configure_file(src/${PLUGIN_NAME}/${PLUGIN_NAME}.ttl ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${PLUGIN_NAME}.ttl)
  7. endfunction()
  8. -add_plugin(Acceleration)
  9. +# Yay Distortions
  10. +add_plugin(Dyno)
  11. +add_plugin(Mojo)
  12. +add_plugin(Spiral)
  13. +
  14. +# Yay Reverbs
  15. +add_plugin(Galactic)
  16. +add_plugin(PocketVerbs)
  17. +add_plugin(StarChild)
  18. +
  19. +# Yay Misc
  20. +add_plugin(DeBess)
  21. +add_plugin(Baxandall)
  22. +add_plugin(Channel8)
  23. +add_plugin(EveryTrim)
  24. +add_plugin(Mackity)
  25. +
  26. +# Maybe
  27. add_plugin(Acceleration2)
  28. add_plugin(ADClip7)
  29. -add_plugin(Baxandall)
  30. -add_plugin(BitShiftGain)
  31. add_plugin(Capacitor)
  32. add_plugin(Capacitor2)
  33. -add_plugin(Channel8)
  34. add_plugin(ClipOnly)
  35. add_plugin(ClipOnly2)
  36. add_plugin(Console7Buss)
  37. add_plugin(Console7Cascade)
  38. add_plugin(Console7Channel)
  39. add_plugin(Console7Crunch)
  40. -add_plugin(DCVoltage)
  41. -add_plugin(DeBess)
  42. -add_plugin(Dyno)
  43. add_plugin(EdIsDim)
  44. -add_plugin(EveryTrim)
  45. -add_plugin(Galactic)
  46. +add_plugin(MidSide)
  47. +add_plugin(MV)
  48. +add_plugin(Nikola)
  49. +add_plugin(Pressure5)
  50. +add_plugin(Sidepass)
  51. +
  52. +# Nay
  53. +add_plugin(Acceleration)
  54. +add_plugin(BitShiftGain)
  55. +add_plugin(DCVoltage)
  56. add_plugin(HermeTrim)
  57. add_plugin(Hypersonic)
  58. add_plugin(Infrasonic)
  59. add_plugin(Interstage)
  60. add_plugin(LeftoMono)
  61. -add_plugin(Mackity)
  62. -add_plugin(MidSide)
  63. -add_plugin(Mojo)
  64. -add_plugin(MV)
  65. -add_plugin(Nikola)
  66. -add_plugin(PocketVerbs)
  67. -add_plugin(Pressure5)
  68. add_plugin(PurestConsoleBuss)
  69. add_plugin(PurestConsoleChannel)
  70. add_plugin(PurestGain)
  71. add_plugin(RightoMono)
  72. -add_plugin(Sidepass)
  73. add_plugin(Slew)
  74. add_plugin(SlewOnly)
  75. -add_plugin(Spiral)
  76. -add_plugin(StarChild)
  77. add_plugin(SubsOnly)
  78. add_plugin(Ultrasonic)
  79. add_plugin(UltrasonicLite)
  80. add_plugin(UltrasonicMed)
  81. +set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsingle-precision-constant -std=gnu99 -Wno-implicit-fallthrough -Werror=incompatible-pointer-types")
  82. +set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsingle-precision-constant")
  83. +
  84. configure_file(src/manifest.ttl.in ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/manifest.ttl)
  85. if(APPLE OR UNIX)
  86. diff --git a/src/ADClip7/ADClip7.c b/src/ADClip7/ADClip7.c
  87. index e502a66..9f0c763 100644
  88. --- a/src/ADClip7/ADClip7.c
  89. +++ b/src/ADClip7/ADClip7.c
  90. @@ -3,6 +3,7 @@
  91. #include <math.h>
  92. #include <stdint.h>
  93. #include <stdlib.h>
  94. +#include "../optimizations.h"
  95. #define ADCLIP7_URI "https://hannesbraun.net/ns/lv2/airwindows/adclip7"
  96. @@ -26,8 +27,6 @@ typedef struct {
  97. const float* enhance;
  98. const float* mode;
  99. - uint32_t fpdL;
  100. - uint32_t fpdR;
  101. //default stuff
  102. double lastSampleL;
  103. double lastSampleR;
  104. @@ -46,7 +45,7 @@ typedef struct {
  105. static LV2_Handle instantiate(
  106. const LV2_Descriptor* descriptor,
  107. - double rate,
  108. + realdouble rate,
  109. const char* bundle_path,
  110. const LV2_Feature* const* features)
  111. {
  112. @@ -106,11 +105,6 @@ static void activate(LV2_Handle instance)
  113. adclip7->iirLowsAR = 0.0;
  114. adclip7->iirLowsBL = 0.0;
  115. adclip7->iirLowsBR = 0.0;
  116. -
  117. - adclip7->fpdL = 1.0;
  118. - while (adclip7->fpdL < 16386) adclip7->fpdL = rand() * UINT32_MAX;
  119. - adclip7->fpdR = 1.0;
  120. - while (adclip7->fpdR < 16386) adclip7->fpdR = rand() * UINT32_MAX;
  121. }
  122. static void run(LV2_Handle instance, uint32_t sampleFrames)
  123. @@ -169,9 +163,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  124. while (sampleFrames-- > 0) {
  125. inputSampleL = *in1;
  126. inputSampleR = *in2;
  127. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = adclip7->fpdL * 1.18e-17;
  128. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = adclip7->fpdR * 1.18e-17;
  129. -
  130. if (inputGain != 1.0) {
  131. inputSampleL *= inputGain;
  132. @@ -517,20 +508,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  133. if (inputSampleR < -adclip7->refclipR) inputSampleR = -adclip7->refclipR;
  134. //final iron bar
  135. - //begin 32 bit stereo floating point dither
  136. - int expon;
  137. - frexpf((float) inputSampleL, &expon);
  138. - adclip7->fpdL ^= adclip7->fpdL << 13;
  139. - adclip7->fpdL ^= adclip7->fpdL >> 17;
  140. - adclip7->fpdL ^= adclip7->fpdL << 5;
  141. - inputSampleL += (((double) adclip7->fpdL - (uint32_t) 0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  142. - frexpf((float) inputSampleR, &expon);
  143. - adclip7->fpdR ^= adclip7->fpdR << 13;
  144. - adclip7->fpdR ^= adclip7->fpdR >> 17;
  145. - adclip7->fpdR ^= adclip7->fpdR << 5;
  146. - inputSampleR += (((double) adclip7->fpdR - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  147. - //end 32 bit stereo floating point dither
  148. -
  149. *out1 = (float) inputSampleL;
  150. *out2 = (float) inputSampleR;
  151. diff --git a/src/Acceleration/Acceleration.c b/src/Acceleration/Acceleration.c
  152. index d6af6c5..f4366a0 100644
  153. --- a/src/Acceleration/Acceleration.c
  154. +++ b/src/Acceleration/Acceleration.c
  155. @@ -3,6 +3,7 @@
  156. #include <math.h>
  157. #include <stdint.h>
  158. #include <stdlib.h>
  159. +#include "../optimizations.h"
  160. #define ACCELERATION_URI "https://hannesbraun.net/ns/lv2/airwindows/acceleration"
  161. @@ -22,8 +23,6 @@ typedef struct {
  162. const float* limit;
  163. const float* drywet;
  164. - uint32_t fpdL;
  165. - uint32_t fpdR;
  166. //default stuff
  167. double ataLastOutL;
  168. double s1L;
  169. @@ -50,7 +49,7 @@ typedef struct {
  170. static LV2_Handle instantiate(
  171. const LV2_Descriptor* descriptor,
  172. - double rate,
  173. + realdouble rate,
  174. const char* bundle_path,
  175. const LV2_Feature* const* features)
  176. {
  177. @@ -108,11 +107,6 @@ static void activate(LV2_Handle instance)
  178. acceleration->m1R = 0.0;
  179. acceleration->m2R = 0.0;
  180. acceleration->desR = 0.0;
  181. -
  182. - acceleration->fpdL = 1.0;
  183. - while (acceleration->fpdL < 16386) acceleration->fpdL = rand() * UINT32_MAX;
  184. - acceleration->fpdR = 1.0;
  185. - while (acceleration->fpdR < 16386) acceleration->fpdR = rand() * UINT32_MAX;
  186. }
  187. static void run(LV2_Handle instance, uint32_t sampleFrames)
  188. @@ -145,8 +139,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  189. while (sampleFrames-- > 0) {
  190. inputSampleL = *in1;
  191. inputSampleR = *in2;
  192. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = acceleration->fpdL * 1.18e-17;
  193. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = acceleration->fpdR * 1.18e-17;
  194. drySampleL = inputSampleL;
  195. drySampleR = inputSampleR;
  196. @@ -205,20 +197,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  197. inputSampleR = (inputSampleR * wet) + (drySampleR * (1.0 - wet));
  198. }
  199. - //begin 32 bit stereo floating point dither
  200. - int expon;
  201. - frexpf((float) inputSampleL, &expon);
  202. - acceleration->fpdL ^= acceleration->fpdL << 13;
  203. - acceleration->fpdL ^= acceleration->fpdL >> 17;
  204. - acceleration->fpdL ^= acceleration->fpdL << 5;
  205. - inputSampleL += (((double) acceleration->fpdL - (uint32_t) 0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  206. - frexpf((float) inputSampleR, &expon);
  207. - acceleration->fpdR ^= acceleration->fpdR << 13;
  208. - acceleration->fpdR ^= acceleration->fpdR >> 17;
  209. - acceleration->fpdR ^= acceleration->fpdR << 5;
  210. - inputSampleR += (((double) acceleration->fpdR - (uint32_t) 0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  211. - //end 32 bit stereo floating point dither
  212. -
  213. *out1 = (float) inputSampleL;
  214. *out2 = (float) inputSampleR;
  215. diff --git a/src/Acceleration2/Acceleration2.c b/src/Acceleration2/Acceleration2.c
  216. index 3cdf047..88b5f03 100644
  217. --- a/src/Acceleration2/Acceleration2.c
  218. +++ b/src/Acceleration2/Acceleration2.c
  219. @@ -3,6 +3,7 @@
  220. #include <math.h>
  221. #include <stdint.h>
  222. #include <stdlib.h>
  223. +#include "../optimizations.h"
  224. #define ACCELERATION2_URI "https://hannesbraun.net/ns/lv2/airwindows/acceleration2"
  225. @@ -36,14 +37,11 @@ typedef struct {
  226. double biquadB[11]; //note that this stereo form doesn't require L and R forms!
  227. //This is because so much of it is coefficients etc. that are the same on both channels.
  228. //So the stored samples are in 7-8 and 9-10, and freq/res/coefficients serve both.
  229. -
  230. - uint32_t fpdL;
  231. - uint32_t fpdR;
  232. } Acceleration2;
  233. static LV2_Handle instantiate(
  234. const LV2_Descriptor* descriptor,
  235. - double rate,
  236. + realdouble rate,
  237. const char* bundle_path,
  238. const LV2_Feature* const* features)
  239. {
  240. @@ -95,11 +93,6 @@ static void activate(LV2_Handle instance)
  241. acceleration2->biquadA[x] = 0.0;
  242. acceleration2->biquadB[x] = 0.0;
  243. }
  244. -
  245. - acceleration2->fpdL = 1.0;
  246. - while (acceleration2->fpdL < 16386) acceleration2->fpdL = rand() * UINT32_MAX;
  247. - acceleration2->fpdR = 1.0;
  248. - while (acceleration2->fpdR < 16386) acceleration2->fpdR = rand() * UINT32_MAX;
  249. }
  250. static void run(LV2_Handle instance, uint32_t sampleFrames)
  251. @@ -145,8 +138,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  252. while (sampleFrames-- > 0) {
  253. double inputSampleL = *in1;
  254. double inputSampleR = *in2;
  255. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = acceleration2->fpdL * 1.18e-17;
  256. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = acceleration2->fpdR * 1.18e-17;
  257. double drySampleL = inputSampleL;
  258. double drySampleR = inputSampleR;
  259. @@ -194,20 +185,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  260. inputSampleR = (inputSampleR * wet) + (drySampleR * (1.0 - wet));
  261. }
  262. - //begin 32 bit stereo floating point dither
  263. - int expon;
  264. - frexpf((float)inputSampleL, &expon);
  265. - acceleration2->fpdL ^= acceleration2->fpdL << 13;
  266. - acceleration2->fpdL ^= acceleration2->fpdL >> 17;
  267. - acceleration2->fpdL ^= acceleration2->fpdL << 5;
  268. - inputSampleL += (((double)acceleration2->fpdL - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  269. - frexpf((float)inputSampleR, &expon);
  270. - acceleration2->fpdR ^= acceleration2->fpdR << 13;
  271. - acceleration2->fpdR ^= acceleration2->fpdR >> 17;
  272. - acceleration2->fpdR ^= acceleration2->fpdR << 5;
  273. - inputSampleR += (((double)acceleration2->fpdR - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  274. - //end 32 bit stereo floating point dither
  275. -
  276. *out1 = (float) inputSampleL;
  277. *out2 = (float) inputSampleR;
  278. diff --git a/src/Baxandall/Baxandall.c b/src/Baxandall/Baxandall.c
  279. index 263b1ca..82d7f52 100644
  280. --- a/src/Baxandall/Baxandall.c
  281. +++ b/src/Baxandall/Baxandall.c
  282. @@ -4,6 +4,7 @@
  283. #include <stdbool.h>
  284. #include <stdint.h>
  285. #include <stdlib.h>
  286. +#include "../optimizations.h"
  287. #define BAXANDALL_URI "https://hannesbraun.net/ns/lv2/airwindows/baxandall"
  288. @@ -25,8 +26,6 @@ typedef struct {
  289. const float* bass;
  290. const float* outputGain;
  291. - uint32_t fpdL;
  292. - uint32_t fpdR;
  293. //default stuff
  294. double trebleAL[9];
  295. double trebleBL[9];
  296. @@ -42,7 +41,7 @@ typedef struct {
  297. static LV2_Handle instantiate(
  298. const LV2_Descriptor* descriptor,
  299. - double rate,
  300. + realdouble rate,
  301. const char* bundle_path,
  302. const LV2_Feature* const* features)
  303. {
  304. @@ -94,10 +93,6 @@ static void activate(LV2_Handle instance)
  305. baxandall->bassBR[x] = 0.0;
  306. }
  307. baxandall->flip = false;
  308. - baxandall->fpdL = 1.0;
  309. - while (baxandall->fpdL < 16386) baxandall->fpdL = rand() * UINT32_MAX;
  310. - baxandall->fpdR = 1.0;
  311. - while (baxandall->fpdR < 16386) baxandall->fpdR = rand() * UINT32_MAX;
  312. }
  313. static void run(LV2_Handle instance, uint32_t sampleFrames)
  314. @@ -183,8 +178,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  315. while (sampleFrames-- > 0) {
  316. double inputSampleL = *in1;
  317. double inputSampleR = *in2;
  318. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = baxandall->fpdL * 1.18e-17;
  319. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = baxandall->fpdR * 1.18e-17;
  320. if (output != 1.0) {
  321. inputSampleL *= output;
  322. @@ -258,20 +251,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  323. inputSampleR = asin(inputSampleR);
  324. //amplitude aspect
  325. - //begin 32 bit stereo floating point dither
  326. - int expon;
  327. - frexpf((float) inputSampleL, &expon);
  328. - baxandall->fpdL ^= baxandall->fpdL << 13;
  329. - baxandall->fpdL ^= baxandall->fpdL >> 17;
  330. - baxandall->fpdL ^= baxandall->fpdL << 5;
  331. - inputSampleL += (((double) baxandall->fpdL - (uint32_t) 0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  332. - frexpf((float) inputSampleR, &expon);
  333. - baxandall->fpdR ^= baxandall->fpdR << 13;
  334. - baxandall->fpdR ^= baxandall->fpdR >> 17;
  335. - baxandall->fpdR ^= baxandall->fpdR << 5;
  336. - inputSampleR += (((double) baxandall->fpdR - (uint32_t) 0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  337. - //end 32 bit stereo floating point dither
  338. -
  339. *out1 = (float) inputSampleL;
  340. *out2 = (float) inputSampleR;
  341. diff --git a/src/BitShiftGain/BitShiftGain.c b/src/BitShiftGain/BitShiftGain.c
  342. index 4c5a5d1..1235099 100644
  343. --- a/src/BitShiftGain/BitShiftGain.c
  344. +++ b/src/BitShiftGain/BitShiftGain.c
  345. @@ -2,6 +2,7 @@
  346. #include <stdint.h>
  347. #include <stdlib.h>
  348. +#include "../optimizations.h"
  349. #define BITSHIFTGAIN_URI "https://hannesbraun.net/ns/lv2/airwindows/bitshiftgain"
  350. @@ -21,7 +22,7 @@ typedef struct {
  351. static LV2_Handle instantiate(
  352. const LV2_Descriptor* descriptor,
  353. - double rate,
  354. + realdouble rate,
  355. const char* bundle_path,
  356. const LV2_Feature* const* features)
  357. {
  358. diff --git a/src/Capacitor/Capacitor.c b/src/Capacitor/Capacitor.c
  359. index 907c2d3..fe0d466 100644
  360. --- a/src/Capacitor/Capacitor.c
  361. +++ b/src/Capacitor/Capacitor.c
  362. @@ -3,6 +3,7 @@
  363. #include <math.h>
  364. #include <stdint.h>
  365. #include <stdlib.h>
  366. +#include "../optimizations.h"
  367. #define CAPACITOR_URI "https://hannesbraun.net/ns/lv2/airwindows/capacitor"
  368. @@ -62,14 +63,11 @@ typedef struct {
  369. double lastLowpass;
  370. double lastHighpass;
  371. double lastWet;
  372. -
  373. - uint32_t fpdL;
  374. - uint32_t fpdR;
  375. } Capacitor;
  376. static LV2_Handle instantiate(
  377. const LV2_Descriptor* descriptor,
  378. - double rate,
  379. + realdouble rate,
  380. const char* bundle_path,
  381. const LV2_Feature* const* features)
  382. {
  383. @@ -145,11 +143,6 @@ static void activate(LV2_Handle instance)
  384. capacitor->lastLowpass = 1000.0;
  385. capacitor->lastHighpass = 1000.0;
  386. capacitor->lastWet = 1000.0;
  387. -
  388. - capacitor->fpdL = 1.0;
  389. - while (capacitor->fpdL < 16386) capacitor->fpdL = rand() * UINT32_MAX;
  390. - capacitor->fpdR = 1.0;
  391. - while (capacitor->fpdR < 16386) capacitor->fpdR = rand() * UINT32_MAX;
  392. }
  393. static void run(LV2_Handle instance, uint32_t sampleFrames)
  394. @@ -186,8 +179,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  395. while (sampleFrames-- > 0) {
  396. inputSampleL = *in1;
  397. inputSampleR = *in2;
  398. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = capacitor->fpdL * 1.18e-17;
  399. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = capacitor->fpdR * 1.18e-17;
  400. drySampleL = inputSampleL;
  401. drySampleR = inputSampleR;
  402. @@ -365,20 +356,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  403. inputSampleL = (drySampleL * dry) + (inputSampleL * capacitor->wet);
  404. inputSampleR = (drySampleR * dry) + (inputSampleR * capacitor->wet);
  405. - //begin 32 bit stereo floating point dither
  406. - int expon;
  407. - frexpf((float)inputSampleL, &expon);
  408. - capacitor->fpdL ^= capacitor->fpdL << 13;
  409. - capacitor->fpdL ^= capacitor->fpdL >> 17;
  410. - capacitor->fpdL ^= capacitor->fpdL << 5;
  411. - inputSampleL += (((double)capacitor->fpdL - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  412. - frexpf((float)inputSampleR, &expon);
  413. - capacitor->fpdR ^= capacitor->fpdR << 13;
  414. - capacitor->fpdR ^= capacitor->fpdR >> 17;
  415. - capacitor->fpdR ^= capacitor->fpdR << 5;
  416. - inputSampleR += (((double)capacitor->fpdR - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  417. - //end 32 bit stereo floating point dither
  418. -
  419. *out1 = (float) inputSampleL;
  420. *out2 = (float) inputSampleR;
  421. diff --git a/src/Capacitor2/Capacitor2.c b/src/Capacitor2/Capacitor2.c
  422. index 111ff8a..53050eb 100644
  423. --- a/src/Capacitor2/Capacitor2.c
  424. +++ b/src/Capacitor2/Capacitor2.c
  425. @@ -3,6 +3,7 @@
  426. #include <math.h>
  427. #include <stdint.h>
  428. #include <stdlib.h>
  429. +#include "../optimizations.h"
  430. #define CAPACITOR2_URI "https://hannesbraun.net/ns/lv2/airwindows/capacitor2"
  431. @@ -65,14 +66,11 @@ typedef struct {
  432. double lastLowpass;
  433. double lastHighpass;
  434. double lastWet;
  435. -
  436. - uint32_t fpdL;
  437. - uint32_t fpdR;
  438. } Capacitor2;
  439. static LV2_Handle instantiate(
  440. const LV2_Descriptor* descriptor,
  441. - double rate,
  442. + realdouble rate,
  443. const char* bundle_path,
  444. const LV2_Feature* const* features)
  445. {
  446. @@ -152,11 +150,6 @@ static void activate(LV2_Handle instance)
  447. capacitor2->lastLowpass = 1000.0;
  448. capacitor2->lastHighpass = 1000.0;
  449. capacitor2->lastWet = 1000.0;
  450. -
  451. - capacitor2->fpdL = 1.0;
  452. - while (capacitor2->fpdL < 16386) capacitor2->fpdL = rand() * UINT32_MAX;
  453. - capacitor2->fpdR = 1.0;
  454. - while (capacitor2->fpdR < 16386) capacitor2->fpdR = rand() * UINT32_MAX;
  455. }
  456. static void run(LV2_Handle instance, uint32_t sampleFrames)
  457. @@ -185,8 +178,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  458. while (sampleFrames-- > 0) {
  459. double inputSampleL = *in1;
  460. double inputSampleR = *in2;
  461. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = capacitor2->fpdL * 1.18e-17;
  462. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = capacitor2->fpdR * 1.18e-17;
  463. double drySampleL = inputSampleL;
  464. double drySampleR = inputSampleR;
  465. @@ -377,20 +368,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  466. inputSampleL = (drySampleL * (1.0 - capacitor2->wet)) + (inputSampleL * nonLinTrim * capacitor2->wet);
  467. inputSampleR = (drySampleR * (1.0 - capacitor2->wet)) + (inputSampleR * nonLinTrim * capacitor2->wet);
  468. - //begin 32 bit stereo floating point dither
  469. - int expon;
  470. - frexpf((float)inputSampleL, &expon);
  471. - capacitor2->fpdL ^= capacitor2->fpdL << 13;
  472. - capacitor2->fpdL ^= capacitor2->fpdL >> 17;
  473. - capacitor2->fpdL ^= capacitor2->fpdL << 5;
  474. - inputSampleL += (((double)capacitor2->fpdL - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  475. - frexpf((float)inputSampleR, &expon);
  476. - capacitor2->fpdR ^= capacitor2->fpdR << 13;
  477. - capacitor2->fpdR ^= capacitor2->fpdR >> 17;
  478. - capacitor2->fpdR ^= capacitor2->fpdR << 5;
  479. - inputSampleR += (((double)capacitor2->fpdR - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  480. - //end 32 bit stereo floating point dither
  481. -
  482. *out1 = (float) inputSampleL;
  483. *out2 = (float) inputSampleR;
  484. diff --git a/src/Channel8/Channel8.c b/src/Channel8/Channel8.c
  485. index 5130655..80e75a7 100644
  486. --- a/src/Channel8/Channel8.c
  487. +++ b/src/Channel8/Channel8.c
  488. @@ -4,6 +4,7 @@
  489. #include <stdbool.h>
  490. #include <stdint.h>
  491. #include <stdlib.h>
  492. +#include "../optimizations.h"
  493. #define CHANNEL8_URI "https://hannesbraun.net/ns/lv2/airwindows/channel8"
  494. @@ -25,8 +26,6 @@ typedef struct {
  495. const float* drive;
  496. const float* outputGain;
  497. - uint32_t fpdL;
  498. - uint32_t fpdR;
  499. //default stuff
  500. double iirSampleLA;
  501. double iirSampleRA;
  502. @@ -45,7 +44,7 @@ typedef struct {
  503. static LV2_Handle instantiate(
  504. const LV2_Descriptor* descriptor,
  505. - double rate,
  506. + realdouble rate,
  507. const char* bundle_path,
  508. const LV2_Feature* const* features)
  509. {
  510. @@ -87,10 +86,6 @@ static void activate(LV2_Handle instance)
  511. {
  512. Channel8* channel8 = (Channel8*) instance;
  513. - channel8->fpdL = 1.0;
  514. - while (channel8->fpdL < 16386) channel8->fpdL = rand() * UINT32_MAX;
  515. - channel8->fpdR = 1.0;
  516. - while (channel8->fpdR < 16386) channel8->fpdR = rand() * UINT32_MAX;
  517. channel8->iirSampleLA = 0.0;
  518. channel8->iirSampleRA = 0.0;
  519. channel8->iirSampleLB = 0.0;
  520. @@ -150,8 +145,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  521. while (sampleFrames-- > 0) {
  522. double inputSampleL = *in1;
  523. double inputSampleR = *in2;
  524. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = channel8->fpdL * 1.18e-17;
  525. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = channel8->fpdR * 1.18e-17;
  526. double dielectricScaleL = fabs(2.0 - ((inputSampleL + nonLin) / nonLin));
  527. double dielectricScaleR = fabs(2.0 - ((inputSampleR + nonLin) / nonLin));
  528. @@ -236,20 +229,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  529. inputSampleR *= output;
  530. }
  531. - //begin 32 bit stereo floating point dither
  532. - int expon;
  533. - frexpf((float)inputSampleL, &expon);
  534. - channel8->fpdL ^= channel8->fpdL << 13;
  535. - channel8->fpdL ^= channel8->fpdL >> 17;
  536. - channel8->fpdL ^= channel8->fpdL << 5;
  537. - inputSampleL += (((double)channel8->fpdL - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  538. - frexpf((float)inputSampleR, &expon);
  539. - channel8->fpdR ^= channel8->fpdR << 13;
  540. - channel8->fpdR ^= channel8->fpdR >> 17;
  541. - channel8->fpdR ^= channel8->fpdR << 5;
  542. - inputSampleR += (((double)channel8->fpdR - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  543. - //end 32 bit stereo floating point dither
  544. -
  545. *out1 = (float) inputSampleL;
  546. *out2 = (float) inputSampleR;
  547. diff --git a/src/ClipOnly/ClipOnly.c b/src/ClipOnly/ClipOnly.c
  548. index 2d83605..94f0ef8 100644
  549. --- a/src/ClipOnly/ClipOnly.c
  550. +++ b/src/ClipOnly/ClipOnly.c
  551. @@ -3,6 +3,7 @@
  552. #include <stdbool.h>
  553. #include <stdint.h>
  554. #include <stdlib.h>
  555. +#include "../optimizations.h"
  556. #define CLIPONLY_URI "https://hannesbraun.net/ns/lv2/airwindows/cliponly"
  557. @@ -28,7 +29,7 @@ typedef struct {
  558. static LV2_Handle instantiate(
  559. const LV2_Descriptor* descriptor,
  560. - double rate,
  561. + realdouble rate,
  562. const char* bundle_path,
  563. const LV2_Feature* const* features)
  564. {
  565. diff --git a/src/ClipOnly2/ClipOnly2.c b/src/ClipOnly2/ClipOnly2.c
  566. index eec1237..7f28c8c 100644
  567. --- a/src/ClipOnly2/ClipOnly2.c
  568. +++ b/src/ClipOnly2/ClipOnly2.c
  569. @@ -4,6 +4,7 @@
  570. #include <stdbool.h>
  571. #include <stdint.h>
  572. #include <stdlib.h>
  573. +#include "../optimizations.h"
  574. #define CLIPONLY2_URI "https://hannesbraun.net/ns/lv2/airwindows/cliponly2"
  575. @@ -31,7 +32,7 @@ typedef struct {
  576. static LV2_Handle instantiate(
  577. const LV2_Descriptor* descriptor,
  578. - double rate,
  579. + realdouble rate,
  580. const char* bundle_path,
  581. const LV2_Feature* const* features)
  582. {
  583. diff --git a/src/Console7Buss/Console7Buss.c b/src/Console7Buss/Console7Buss.c
  584. index f6f006e..2cd7e8b 100644
  585. --- a/src/Console7Buss/Console7Buss.c
  586. +++ b/src/Console7Buss/Console7Buss.c
  587. @@ -3,6 +3,7 @@
  588. #include <math.h>
  589. #include <stdint.h>
  590. #include <stdlib.h>
  591. +#include "../optimizations.h"
  592. #define CONSOLE7BUSS_URI "https://hannesbraun.net/ns/lv2/airwindows/console7buss"
  593. @@ -25,14 +26,11 @@ typedef struct {
  594. double biquadA[15];
  595. double biquadB[15];
  596. -
  597. - uint32_t fpdL;
  598. - uint32_t fpdR;
  599. } Console7Buss;
  600. static LV2_Handle instantiate(
  601. const LV2_Descriptor* descriptor,
  602. - double rate,
  603. + realdouble rate,
  604. const char* bundle_path,
  605. const LV2_Feature* const* features)
  606. {
  607. @@ -74,10 +72,6 @@ static void activate(LV2_Handle instance)
  608. console7Buss->biquadA[x] = 0.0;
  609. console7Buss->biquadB[x] = 0.0;
  610. }
  611. - console7Buss->fpdL = 1.0;
  612. - while (console7Buss->fpdL < 16386) console7Buss->fpdL = rand() * UINT32_MAX;
  613. - console7Buss->fpdR = 1.0;
  614. - while (console7Buss->fpdR < 16386) console7Buss->fpdR = rand() * UINT32_MAX;
  615. }
  616. static void run(LV2_Handle instance, uint32_t sampleFrames)
  617. @@ -118,8 +112,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  618. while (sampleFrames-- > 0) {
  619. double inputSampleL = *in1;
  620. double inputSampleR = *in2;
  621. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = console7Buss->fpdL * 1.18e-17;
  622. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = console7Buss->fpdR * 1.18e-17;
  623. double outSampleL = console7Buss->biquadA[2] * inputSampleL + console7Buss->biquadA[3] * console7Buss->biquadA[7] + console7Buss->biquadA[4] * console7Buss->biquadA[8] - console7Buss->biquadA[5] * console7Buss->biquadA[9] - console7Buss->biquadA[6] * console7Buss->biquadA[10];
  624. console7Buss->biquadA[8] = console7Buss->biquadA[7];
  625. @@ -176,20 +168,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  626. }
  627. //we re-amplify after the distortion relative to how much we cut back previously.
  628. - //begin 32 bit stereo floating point dither
  629. - int expon;
  630. - frexpf((float)inputSampleL, &expon);
  631. - console7Buss->fpdL ^= console7Buss->fpdL << 13;
  632. - console7Buss->fpdL ^= console7Buss->fpdL >> 17;
  633. - console7Buss->fpdL ^= console7Buss->fpdL << 5;
  634. - inputSampleL += (((double)console7Buss->fpdL - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  635. - frexpf((float)inputSampleR, &expon);
  636. - console7Buss->fpdR ^= console7Buss->fpdR << 13;
  637. - console7Buss->fpdR ^= console7Buss->fpdR >> 17;
  638. - console7Buss->fpdR ^= console7Buss->fpdR << 5;
  639. - inputSampleR += (((double)console7Buss->fpdR - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  640. - //end 32 bit stereo floating point dither
  641. -
  642. *out1 = (float) inputSampleL;
  643. *out2 = (float) inputSampleR;
  644. diff --git a/src/Console7Cascade/Console7Cascade.c b/src/Console7Cascade/Console7Cascade.c
  645. index 2f5f8ee..e4fd69d 100644
  646. --- a/src/Console7Cascade/Console7Cascade.c
  647. +++ b/src/Console7Cascade/Console7Cascade.c
  648. @@ -3,6 +3,7 @@
  649. #include <math.h>
  650. #include <stdint.h>
  651. #include <stdlib.h>
  652. +#include "../optimizations.h"
  653. #define CONSOLE7CASCADE_URI "https://hannesbraun.net/ns/lv2/airwindows/console7cascade"
  654. @@ -28,14 +29,11 @@ typedef struct {
  655. double biquadC[15];
  656. double biquadD[15];
  657. double biquadE[15];
  658. -
  659. - uint32_t fpdL;
  660. - uint32_t fpdR;
  661. } Console7Cascade;
  662. static LV2_Handle instantiate(
  663. const LV2_Descriptor* descriptor,
  664. - double rate,
  665. + realdouble rate,
  666. const char* bundle_path,
  667. const LV2_Feature* const* features)
  668. {
  669. @@ -80,10 +78,6 @@ static void activate(LV2_Handle instance)
  670. console7Cascade->biquadD[x] = 0.0;
  671. console7Cascade->biquadE[x] = 0.0;
  672. }
  673. - console7Cascade->fpdL = 1.0;
  674. - while (console7Cascade->fpdL < 16386) console7Cascade->fpdL = rand() * UINT32_MAX;
  675. - console7Cascade->fpdR = 1.0;
  676. - while (console7Cascade->fpdR < 16386) console7Cascade->fpdR = rand() * UINT32_MAX;
  677. }
  678. static void run(LV2_Handle instance, uint32_t sampleFrames)
  679. @@ -150,8 +144,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  680. while (sampleFrames-- > 0) {
  681. double inputSampleL = *in1;
  682. double inputSampleR = *in2;
  683. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = console7Cascade->fpdL * 1.18e-17;
  684. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = console7Cascade->fpdR * 1.18e-17;
  685. double outSampleL = console7Cascade->biquadA[2] * inputSampleL + console7Cascade->biquadA[3] * console7Cascade->biquadA[7] + console7Cascade->biquadA[4] * console7Cascade->biquadA[8] - console7Cascade->biquadA[5] * console7Cascade->biquadA[9] - console7Cascade->biquadA[6] * console7Cascade->biquadA[10];
  686. console7Cascade->biquadA[8] = console7Cascade->biquadA[7];
  687. @@ -292,20 +284,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  688. }
  689. //we re-amplify after the distortion relative to how much we cut back previously.
  690. - //begin 32 bit stereo floating point dither
  691. - int expon;
  692. - frexpf((float)inputSampleL, &expon);
  693. - console7Cascade->fpdL ^= console7Cascade->fpdL << 13;
  694. - console7Cascade->fpdL ^= console7Cascade->fpdL >> 17;
  695. - console7Cascade->fpdL ^= console7Cascade->fpdL << 5;
  696. - inputSampleL += (((double)console7Cascade->fpdL - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  697. - frexpf((float)inputSampleR, &expon);
  698. - console7Cascade->fpdR ^= console7Cascade->fpdR << 13;
  699. - console7Cascade->fpdR ^= console7Cascade->fpdR >> 17;
  700. - console7Cascade->fpdR ^= console7Cascade->fpdR << 5;
  701. - inputSampleR += (((double)console7Cascade->fpdR - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  702. - //end 32 bit stereo floating point dither
  703. -
  704. *out1 = (float) inputSampleL;
  705. *out2 = (float) inputSampleR;
  706. diff --git a/src/Console7Channel/Console7Channel.c b/src/Console7Channel/Console7Channel.c
  707. index 9d531c4..e76936a 100644
  708. --- a/src/Console7Channel/Console7Channel.c
  709. +++ b/src/Console7Channel/Console7Channel.c
  710. @@ -3,6 +3,7 @@
  711. #include <math.h>
  712. #include <stdint.h>
  713. #include <stdlib.h>
  714. +#include "../optimizations.h"
  715. #define CONSOLE7CHANNEL_URI "https://hannesbraun.net/ns/lv2/airwindows/console7channel"
  716. @@ -24,14 +25,11 @@ typedef struct {
  717. double chasespeed;
  718. double biquadA[15];
  719. -
  720. - uint32_t fpdL;
  721. - uint32_t fpdR;
  722. } Console7Channel;
  723. static LV2_Handle instantiate(
  724. const LV2_Descriptor* descriptor,
  725. - double rate,
  726. + realdouble rate,
  727. const char* bundle_path,
  728. const LV2_Feature* const* features)
  729. {
  730. @@ -71,10 +69,6 @@ static void activate(LV2_Handle instance)
  731. for (int x = 0; x < 15; x++) {
  732. console7Channel->biquadA[x] = 0.0;
  733. }
  734. - console7Channel->fpdL = 1.0;
  735. - while (console7Channel->fpdL < 16386) console7Channel->fpdL = rand() * UINT32_MAX;
  736. - console7Channel->fpdR = 1.0;
  737. - while (console7Channel->fpdR < 16386) console7Channel->fpdR = rand() * UINT32_MAX;
  738. }
  739. static void run(LV2_Handle instance, uint32_t sampleFrames)
  740. @@ -109,8 +103,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  741. while (sampleFrames-- > 0) {
  742. double inputSampleL = *in1;
  743. double inputSampleR = *in2;
  744. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = console7Channel->fpdL * 1.18e-17;
  745. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = console7Channel->fpdR * 1.18e-17;
  746. double outSampleL = console7Channel->biquadA[2] * inputSampleL + console7Channel->biquadA[3] * console7Channel->biquadA[7] + console7Channel->biquadA[4] * console7Channel->biquadA[8] - console7Channel->biquadA[5] * console7Channel->biquadA[9] - console7Channel->biquadA[6] * console7Channel->biquadA[10];
  747. console7Channel->biquadA[8] = console7Channel->biquadA[7];
  748. @@ -155,20 +147,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  749. }
  750. //we re-amplify after the distortion relative to how much we cut back previously.
  751. - //begin 32 bit stereo floating point dither
  752. - int expon;
  753. - frexpf((float)inputSampleL, &expon);
  754. - console7Channel->fpdL ^= console7Channel->fpdL << 13;
  755. - console7Channel->fpdL ^= console7Channel->fpdL >> 17;
  756. - console7Channel->fpdL ^= console7Channel->fpdL << 5;
  757. - inputSampleL += (((double)console7Channel->fpdL - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  758. - frexpf((float)inputSampleR, &expon);
  759. - console7Channel->fpdR ^= console7Channel->fpdR << 13;
  760. - console7Channel->fpdR ^= console7Channel->fpdR >> 17;
  761. - console7Channel->fpdR ^= console7Channel->fpdR << 5;
  762. - inputSampleR += (((double)console7Channel->fpdR - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  763. - //end 32 bit stereo floating point dither
  764. -
  765. *out1 = (float) inputSampleL;
  766. *out2 = (float) inputSampleR;
  767. diff --git a/src/Console7Crunch/Console7Crunch.c b/src/Console7Crunch/Console7Crunch.c
  768. index 8f3049e..7d51bb7 100644
  769. --- a/src/Console7Crunch/Console7Crunch.c
  770. +++ b/src/Console7Crunch/Console7Crunch.c
  771. @@ -3,6 +3,7 @@
  772. #include <math.h>
  773. #include <stdint.h>
  774. #include <stdlib.h>
  775. +#include "../optimizations.h"
  776. #define CONSOLE7CRUNCH_URI "https://hannesbraun.net/ns/lv2/airwindows/console7crunch"
  777. @@ -28,14 +29,11 @@ typedef struct {
  778. double biquadC[15];
  779. double biquadD[15];
  780. double biquadE[15];
  781. -
  782. - uint32_t fpdL;
  783. - uint32_t fpdR;
  784. } Console7Crunch;
  785. static LV2_Handle instantiate(
  786. const LV2_Descriptor* descriptor,
  787. - double rate,
  788. + realdouble rate,
  789. const char* bundle_path,
  790. const LV2_Feature* const* features)
  791. {
  792. @@ -80,10 +78,6 @@ static void activate(LV2_Handle instance)
  793. console7Crunch->biquadD[x] = 0.0;
  794. console7Crunch->biquadE[x] = 0.0;
  795. }
  796. - console7Crunch->fpdL = 1.0;
  797. - while (console7Crunch->fpdL < 16386) console7Crunch->fpdL = rand() * UINT32_MAX;
  798. - console7Crunch->fpdR = 1.0;
  799. - while (console7Crunch->fpdR < 16386) console7Crunch->fpdR = rand() * UINT32_MAX;
  800. }
  801. static void run(LV2_Handle instance, uint32_t sampleFrames)
  802. @@ -150,8 +144,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  803. while (sampleFrames-- > 0) {
  804. double inputSampleL = *in1;
  805. double inputSampleR = *in2;
  806. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = console7Crunch->fpdL * 1.18e-17;
  807. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = console7Crunch->fpdR * 1.18e-17;
  808. double outSampleL = console7Crunch->biquadA[2] * inputSampleL + console7Crunch->biquadA[3] * console7Crunch->biquadA[7] + console7Crunch->biquadA[4] * console7Crunch->biquadA[8] - console7Crunch->biquadA[5] * console7Crunch->biquadA[9] - console7Crunch->biquadA[6] * console7Crunch->biquadA[10];
  809. console7Crunch->biquadA[8] = console7Crunch->biquadA[7];
  810. @@ -292,20 +284,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  811. }
  812. //we re-amplify after the distortion relative to how much we cut back previously.
  813. - //begin 32 bit stereo floating point dither
  814. - int expon;
  815. - frexpf((float)inputSampleL, &expon);
  816. - console7Crunch->fpdL ^= console7Crunch->fpdL << 13;
  817. - console7Crunch->fpdL ^= console7Crunch->fpdL >> 17;
  818. - console7Crunch->fpdL ^= console7Crunch->fpdL << 5;
  819. - inputSampleL += (((double)console7Crunch->fpdL - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  820. - frexpf((float)inputSampleR, &expon);
  821. - console7Crunch->fpdR ^= console7Crunch->fpdR << 13;
  822. - console7Crunch->fpdR ^= console7Crunch->fpdR >> 17;
  823. - console7Crunch->fpdR ^= console7Crunch->fpdR << 5;
  824. - inputSampleR += (((double)console7Crunch->fpdR - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  825. - //end 32 bit stereo floating point dither
  826. -
  827. *out1 = (float) inputSampleL;
  828. *out2 = (float) inputSampleR;
  829. diff --git a/src/DCVoltage/DCVoltage.c b/src/DCVoltage/DCVoltage.c
  830. index 18f904e..8d17086 100644
  831. --- a/src/DCVoltage/DCVoltage.c
  832. +++ b/src/DCVoltage/DCVoltage.c
  833. @@ -2,6 +2,7 @@
  834. #include <stdint.h>
  835. #include <stdlib.h>
  836. +#include "../optimizations.h"
  837. #define DCVOLTAGE_URI "https://hannesbraun.net/ns/lv2/airwindows/dcvoltage"
  838. @@ -21,7 +22,7 @@ typedef struct {
  839. static LV2_Handle instantiate(
  840. const LV2_Descriptor* descriptor,
  841. - double rate,
  842. + realdouble rate,
  843. const char* bundle_path,
  844. const LV2_Feature* const* features)
  845. {
  846. diff --git a/src/DeBess/DeBess.c b/src/DeBess/DeBess.c
  847. index 54a84d6..85ec475 100644
  848. --- a/src/DeBess/DeBess.c
  849. +++ b/src/DeBess/DeBess.c
  850. @@ -4,6 +4,7 @@
  851. #include <stdbool.h>
  852. #include <stdint.h>
  853. #include <stdlib.h>
  854. +#include "../optimizations.h"
  855. #define DEBESS_URI "https://hannesbraun.net/ns/lv2/airwindows/debess"
  856. @@ -43,13 +44,11 @@ typedef struct {
  857. bool flip;
  858. - uint32_t fpdL;
  859. - uint32_t fpdR;
  860. } DeBess;
  861. static LV2_Handle instantiate(
  862. const LV2_Descriptor* descriptor,
  863. - double rate,
  864. + realdouble rate,
  865. const char* bundle_path,
  866. const LV2_Feature* const* features)
  867. {
  868. @@ -115,10 +114,6 @@ static void activate(LV2_Handle instance)
  869. debess->iirSampleBR = 0.0;
  870. debess->flip = false;
  871. - debess->fpdL = 1.0;
  872. - while (debess->fpdL < 16386) debess->fpdL = rand() * UINT32_MAX;
  873. - debess->fpdR = 1.0;
  874. - while (debess->fpdR < 16386) debess->fpdR = rand() * UINT32_MAX;
  875. }
  876. static void run(LV2_Handle instance, uint32_t sampleFrames)
  877. @@ -145,8 +140,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  878. while (sampleFrames-- > 0) {
  879. double inputSampleL = *in1;
  880. double inputSampleR = *in2;
  881. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = debess->fpdL * 1.18e-17;
  882. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = debess->fpdR * 1.18e-17;
  883. debess->sL[0] = inputSampleL; //set up so both [0] and [1] will be input sample
  884. debess->sR[0] = inputSampleR; //set up so both [0] and [1] will be input sample
  885. @@ -208,20 +201,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  886. }
  887. //sense monitoring
  888. - //begin 32 bit stereo floating point dither
  889. - int expon;
  890. - frexpf((float)inputSampleL, &expon);
  891. - debess->fpdL ^= debess->fpdL << 13;
  892. - debess->fpdL ^= debess->fpdL >> 17;
  893. - debess->fpdL ^= debess->fpdL << 5;
  894. - inputSampleL += (((double)debess->fpdL - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  895. - frexpf((float)inputSampleR, &expon);
  896. - debess->fpdR ^= debess->fpdR << 13;
  897. - debess->fpdR ^= debess->fpdR >> 17;
  898. - debess->fpdR ^= debess->fpdR << 5;
  899. - inputSampleR += (((double)debess->fpdR - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  900. - //end 32 bit stereo floating point dither
  901. -
  902. *out1 = (float) inputSampleL;
  903. *out2 = (float) inputSampleR;
  904. diff --git a/src/Dyno/Dyno.c b/src/Dyno/Dyno.c
  905. index ed028dd..cbbdf58 100644
  906. --- a/src/Dyno/Dyno.c
  907. +++ b/src/Dyno/Dyno.c
  908. @@ -3,6 +3,7 @@
  909. #include <math.h>
  910. #include <stdint.h>
  911. #include <stdlib.h>
  912. +#include "../optimizations.h"
  913. #define DYNO_URI "https://hannesbraun.net/ns/lv2/airwindows/dyno"
  914. @@ -18,14 +19,11 @@ typedef struct {
  915. const float* input[2];
  916. float* output[2];
  917. const float* gain;
  918. -
  919. - uint32_t fpdL;
  920. - uint32_t fpdR;
  921. } Dyno;
  922. static LV2_Handle instantiate(
  923. const LV2_Descriptor* descriptor,
  924. - double rate,
  925. + realdouble rate,
  926. const char* bundle_path,
  927. const LV2_Feature* const* features)
  928. {
  929. @@ -56,14 +54,7 @@ static void connect_port(LV2_Handle instance, uint32_t port, void* data)
  930. }
  931. }
  932. -static void activate(LV2_Handle instance)
  933. -{
  934. - Dyno* dyno = (Dyno*) instance;
  935. - dyno->fpdL = 1.0;
  936. - while (dyno->fpdL < 16386) dyno->fpdL = rand() * UINT32_MAX;
  937. - dyno->fpdR = 1.0;
  938. - while (dyno->fpdR < 16386) dyno->fpdR = rand() * UINT32_MAX;
  939. -}
  940. +static void activate(LV2_Handle instance) {}
  941. static void run(LV2_Handle instance, uint32_t sampleFrames)
  942. {
  943. @@ -79,8 +70,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  944. while (sampleFrames-- > 0) {
  945. double inputSampleL = *in1;
  946. double inputSampleR = *in2;
  947. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = dyno_instance->fpdL * 1.18e-17;
  948. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = dyno_instance->fpdR * 1.18e-17;
  949. if (gain != 1.0) {
  950. inputSampleL *= gain;
  951. @@ -94,20 +83,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  952. if (dyno > 0.0) inputSampleR = (sin(inputSampleR * dyno) / dyno) * 1.1654321;
  953. //dyno is the one that tries to raise peak energy
  954. - //begin 32 bit stereo floating point dither
  955. - int expon;
  956. - frexpf((float)inputSampleL, &expon);
  957. - dyno_instance->fpdL ^= dyno_instance->fpdL << 13;
  958. - dyno_instance->fpdL ^= dyno_instance->fpdL >> 17;
  959. - dyno_instance->fpdL ^= dyno_instance->fpdL << 5;
  960. - inputSampleL += (((double)dyno_instance->fpdL - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  961. - frexpf((float)inputSampleR, &expon);
  962. - dyno_instance->fpdR ^= dyno_instance->fpdR << 13;
  963. - dyno_instance->fpdR ^= dyno_instance->fpdR >> 17;
  964. - dyno_instance->fpdR ^= dyno_instance->fpdR << 5;
  965. - inputSampleR += (((double)dyno_instance->fpdR - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  966. - //end 32 bit stereo floating point dither
  967. -
  968. *out1 = (float) inputSampleL;
  969. *out2 = (float) inputSampleR;
  970. diff --git a/src/EdIsDim/EdIsDim.c b/src/EdIsDim/EdIsDim.c
  971. index 9fb5f2d..3a2d982 100644
  972. --- a/src/EdIsDim/EdIsDim.c
  973. +++ b/src/EdIsDim/EdIsDim.c
  974. @@ -3,6 +3,7 @@
  975. #include <math.h>
  976. #include <stdint.h>
  977. #include <stdlib.h>
  978. +#include "../optimizations.h"
  979. #define EDISDIM_URI "https://hannesbraun.net/ns/lv2/airwindows/edisdim"
  980. @@ -18,14 +19,11 @@ typedef struct {
  981. const float* input[2];
  982. float* output[2];
  983. const float* edisdim;
  984. -
  985. - uint32_t fpdL;
  986. - uint32_t fpdR;
  987. } EdIsDim;
  988. static LV2_Handle instantiate(
  989. const LV2_Descriptor* descriptor,
  990. - double rate,
  991. + realdouble rate,
  992. const char* bundle_path,
  993. const LV2_Feature* const* features)
  994. {
  995. @@ -56,14 +54,7 @@ static void connect_port(LV2_Handle instance, uint32_t port, void* data)
  996. }
  997. }
  998. -static void activate(LV2_Handle instance)
  999. -{
  1000. - EdIsDim* edisdim = (EdIsDim*) instance;
  1001. - edisdim->fpdL = 1.0;
  1002. - while (edisdim->fpdL < 16386) edisdim->fpdL = rand() * UINT32_MAX;
  1003. - edisdim->fpdR = 1.0;
  1004. - while (edisdim->fpdR < 16386) edisdim->fpdR = rand() * UINT32_MAX;
  1005. -}
  1006. +static void activate(LV2_Handle instance) {}
  1007. static void run(LV2_Handle instance, uint32_t sampleFrames)
  1008. {
  1009. @@ -85,8 +76,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  1010. while (sampleFrames-- > 0) {
  1011. inputSampleL = *in1;
  1012. inputSampleR = *in2;
  1013. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = edisdim->fpdL * 1.18e-17;
  1014. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = edisdim->fpdR * 1.18e-17;
  1015. inputSampleL *= midgain;
  1016. inputSampleR *= sidegain;
  1017. @@ -94,22 +83,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  1018. mid = (inputSampleL + inputSampleR) / 2.0;
  1019. side = (inputSampleL - inputSampleR) / 2.0;
  1020. - //begin 32 bit floating point dither
  1021. - int expon;
  1022. - frexpf((float)mid, &expon);
  1023. - edisdim->fpdL ^= edisdim->fpdL << 13;
  1024. - edisdim->fpdL ^= edisdim->fpdL >> 17;
  1025. - edisdim->fpdL ^= edisdim->fpdL << 5;
  1026. - mid += (((double)edisdim->fpdL - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  1027. - //end 32 bit floating point dither
  1028. - //begin 32 bit floating point dither
  1029. - frexpf((float)side, &expon);
  1030. - edisdim->fpdR ^= edisdim->fpdR << 13;
  1031. - edisdim->fpdR ^= edisdim->fpdR >> 17;
  1032. - edisdim->fpdR ^= edisdim->fpdR << 5;
  1033. - side += (((double)edisdim->fpdR - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  1034. - //end 32 bit floating point dither
  1035. -
  1036. *out1 = (float) mid;
  1037. *out2 = (float) side;
  1038. diff --git a/src/EveryTrim/EveryTrim.c b/src/EveryTrim/EveryTrim.c
  1039. index d22e1b9..58f8c57 100644
  1040. --- a/src/EveryTrim/EveryTrim.c
  1041. +++ b/src/EveryTrim/EveryTrim.c
  1042. @@ -3,6 +3,7 @@
  1043. #include <math.h>
  1044. #include <stdint.h>
  1045. #include <stdlib.h>
  1046. +#include "../optimizations.h"
  1047. #define EVERYTRIM_URI "https://hannesbraun.net/ns/lv2/airwindows/everytrim"
  1048. @@ -26,14 +27,11 @@ typedef struct {
  1049. const float* mid;
  1050. const float* side;
  1051. const float* master;
  1052. -
  1053. - uint32_t fpdL;
  1054. - uint32_t fpdR;
  1055. } EveryTrim;
  1056. static LV2_Handle instantiate(
  1057. const LV2_Descriptor* descriptor,
  1058. - double rate,
  1059. + realdouble rate,
  1060. const char* bundle_path,
  1061. const LV2_Feature* const* features)
  1062. {
  1063. @@ -76,14 +74,7 @@ static void connect_port(LV2_Handle instance, uint32_t port, void* data)
  1064. }
  1065. }
  1066. -static void activate(LV2_Handle instance)
  1067. -{
  1068. - EveryTrim* everytrim = (EveryTrim*) instance;
  1069. - everytrim->fpdL = 1.0;
  1070. - while (everytrim->fpdL < 16386) everytrim->fpdL = rand() * UINT32_MAX;
  1071. - everytrim->fpdR = 1.0;
  1072. - while (everytrim->fpdR < 16386) everytrim->fpdR = rand() * UINT32_MAX;
  1073. -}
  1074. +static void activate(LV2_Handle instance) {}
  1075. static void run(LV2_Handle instance, uint32_t sampleFrames)
  1076. {
  1077. @@ -111,8 +102,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  1078. while (sampleFrames-- > 0) {
  1079. inputSampleL = *in1;
  1080. inputSampleR = *in2;
  1081. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = everytrim->fpdL * 1.18e-17;
  1082. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = everytrim->fpdR * 1.18e-17;
  1083. mid = inputSampleL + inputSampleR;
  1084. side = inputSampleL - inputSampleR;
  1085. @@ -122,20 +111,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  1086. inputSampleR = (mid - side) * rightgain;
  1087. //contains mastergain and the gain trim fixing the mid/side
  1088. - //begin 32 bit stereo floating point dither
  1089. - int expon;
  1090. - frexpf((float)inputSampleL, &expon);
  1091. - everytrim->fpdL ^= everytrim->fpdL << 13;
  1092. - everytrim->fpdL ^= everytrim->fpdL >> 17;
  1093. - everytrim->fpdL ^= everytrim->fpdL << 5;
  1094. - inputSampleL += (((double)everytrim->fpdL - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  1095. - frexpf((float)inputSampleR, &expon);
  1096. - everytrim->fpdR ^= everytrim->fpdR << 13;
  1097. - everytrim->fpdR ^= everytrim->fpdR >> 17;
  1098. - everytrim->fpdR ^= everytrim->fpdR << 5;
  1099. - inputSampleR += (((double)everytrim->fpdR - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  1100. - //end 32 bit stereo floating point dither
  1101. -
  1102. *out1 = (float) inputSampleL;
  1103. *out2 = (float) inputSampleR;
  1104. diff --git a/src/Galactic/Galactic.c b/src/Galactic/Galactic.c
  1105. index 4629372..e38e881 100644
  1106. --- a/src/Galactic/Galactic.c
  1107. +++ b/src/Galactic/Galactic.c
  1108. @@ -3,6 +3,7 @@
  1109. #include <math.h>
  1110. #include <stdint.h>
  1111. #include <stdlib.h>
  1112. +#include "../optimizations.h"
  1113. #define GALACTIC_URI "https://hannesbraun.net/ns/lv2/airwindows/galactic"
  1114. @@ -48,7 +49,7 @@ typedef struct {
  1115. double aML[3111];
  1116. double aMR[3111];
  1117. - double vibML, vibMR, depthM, oldfpd;
  1118. + double vibML, vibMR, depthM;
  1119. double feedbackAL;
  1120. double feedbackBL;
  1121. @@ -101,14 +102,12 @@ typedef struct {
  1122. double vibM;
  1123. - uint32_t fpdL;
  1124. - uint32_t fpdR;
  1125. //default stuff
  1126. } Galactic;
  1127. static LV2_Handle instantiate(
  1128. const LV2_Descriptor* descriptor,
  1129. - double rate,
  1130. + realdouble rate,
  1131. const char* bundle_path,
  1132. const LV2_Feature* const* features)
  1133. {
  1134. @@ -253,13 +252,6 @@ static void activate(LV2_Handle instance)
  1135. galactic->cycle = 0;
  1136. galactic->vibM = 3.0;
  1137. -
  1138. - galactic->oldfpd = 429496.7295;
  1139. -
  1140. - galactic->fpdL = 1;
  1141. - while (galactic->fpdL < 16386) galactic->fpdL = rand() * UINT32_MAX;
  1142. - galactic->fpdR = 1;
  1143. - while (galactic->fpdR < 16386) galactic->fpdR = rand() * UINT32_MAX;
  1144. }
  1145. static void run(LV2_Handle instance, uint32_t sampleFrames)
  1146. @@ -308,15 +300,12 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  1147. while (sampleFrames-- > 0) {
  1148. double inputSampleL = *in1;
  1149. double inputSampleR = *in2;
  1150. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = galactic->fpdL * 1.18e-17;
  1151. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = galactic->fpdR * 1.18e-17;
  1152. double drySampleL = inputSampleL;
  1153. double drySampleR = inputSampleR;
  1154. - galactic->vibM += (galactic->oldfpd * drift);
  1155. + galactic->vibM += drift;
  1156. if (galactic->vibM > (3.141592653589793238 * 2.0)) {
  1157. galactic->vibM = 0.0;
  1158. - galactic->oldfpd = 0.4294967295 + (galactic->fpdL * 0.0000000000618);
  1159. }
  1160. galactic->aML[galactic->countM] = inputSampleL * attenuate;
  1161. @@ -496,20 +485,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  1162. inputSampleR = (inputSampleR * wet) + (drySampleR * (1.0 - wet));
  1163. }
  1164. - //begin 32 bit stereo floating point dither
  1165. - int expon;
  1166. - frexpf((float)inputSampleL, &expon);
  1167. - galactic->fpdL ^= galactic->fpdL << 13;
  1168. - galactic->fpdL ^= galactic->fpdL >> 17;
  1169. - galactic->fpdL ^= galactic->fpdL << 5;
  1170. - inputSampleL += ((((double) galactic->fpdL) - (uint32_t) 0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  1171. - frexpf((float)inputSampleR, &expon);
  1172. - galactic->fpdR ^= galactic->fpdR << 13;
  1173. - galactic->fpdR ^= galactic->fpdR >> 17;
  1174. - galactic->fpdR ^= galactic->fpdR << 5;
  1175. - inputSampleR += ((((double) galactic->fpdL) - (uint32_t) 0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  1176. - //end 32 bit stereo floating point dither
  1177. -
  1178. *out1 = (float) inputSampleL;
  1179. *out2 = (float) inputSampleR;
  1180. diff --git a/src/HermeTrim/HermeTrim.c b/src/HermeTrim/HermeTrim.c
  1181. index 1f2d728..fd754f4 100644
  1182. --- a/src/HermeTrim/HermeTrim.c
  1183. +++ b/src/HermeTrim/HermeTrim.c
  1184. @@ -3,6 +3,7 @@
  1185. #include <math.h>
  1186. #include <stdint.h>
  1187. #include <stdlib.h>
  1188. +#include "../optimizations.h"
  1189. #define HERMETRIM_URI "https://hannesbraun.net/ns/lv2/airwindows/hermetrim"
  1190. @@ -26,14 +27,11 @@ typedef struct {
  1191. const float* mid;
  1192. const float* side;
  1193. const float* master;
  1194. -
  1195. - uint32_t fpdL;
  1196. - uint32_t fpdR;
  1197. } HermeTrim;
  1198. static LV2_Handle instantiate(
  1199. const LV2_Descriptor* descriptor,
  1200. - double rate,
  1201. + realdouble rate,
  1202. const char* bundle_path,
  1203. const LV2_Feature* const* features)
  1204. {
  1205. @@ -76,14 +74,7 @@ static void connect_port(LV2_Handle instance, uint32_t port, void* data)
  1206. }
  1207. }
  1208. -static void activate(LV2_Handle instance)
  1209. -{
  1210. - HermeTrim* hermetrim = (HermeTrim*) instance;
  1211. - hermetrim->fpdL = 1.0;
  1212. - while (hermetrim->fpdL < 16386) hermetrim->fpdL = rand() * UINT32_MAX;
  1213. - hermetrim->fpdR = 1.0;
  1214. - while (hermetrim->fpdR < 16386) hermetrim->fpdR = rand() * UINT32_MAX;
  1215. -}
  1216. +static void activate(LV2_Handle instance) {}
  1217. static void run(LV2_Handle instance, uint32_t sampleFrames)
  1218. {
  1219. @@ -111,8 +102,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  1220. while (sampleFrames-- > 0) {
  1221. inputSampleL = *in1;
  1222. inputSampleR = *in2;
  1223. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = hermetrim->fpdL * 1.18e-17;
  1224. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = hermetrim->fpdR * 1.18e-17;
  1225. mid = inputSampleL + inputSampleR;
  1226. side = inputSampleL - inputSampleR;
  1227. @@ -122,20 +111,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  1228. inputSampleR = (mid - side) * rightgain;
  1229. //contains mastergain and the gain trim fixing the mid/side
  1230. - //begin 32 bit stereo floating point dither
  1231. - int expon;
  1232. - frexpf((float)inputSampleL, &expon);
  1233. - hermetrim->fpdL ^= hermetrim->fpdL << 13;
  1234. - hermetrim->fpdL ^= hermetrim->fpdL >> 17;
  1235. - hermetrim->fpdL ^= hermetrim->fpdL << 5;
  1236. - inputSampleL += (((double)hermetrim->fpdL - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  1237. - frexpf((float)inputSampleR, &expon);
  1238. - hermetrim->fpdR ^= hermetrim->fpdR << 13;
  1239. - hermetrim->fpdR ^= hermetrim->fpdR >> 17;
  1240. - hermetrim->fpdR ^= hermetrim->fpdR << 5;
  1241. - inputSampleR += (((double)hermetrim->fpdR - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  1242. - //end 32 bit stereo floating point dither
  1243. -
  1244. *out1 = (float) inputSampleL;
  1245. *out2 = (float) inputSampleR;
  1246. diff --git a/src/Hypersonic/Hypersonic.c b/src/Hypersonic/Hypersonic.c
  1247. index 68e8a7e..4f9daa7 100644
  1248. --- a/src/Hypersonic/Hypersonic.c
  1249. +++ b/src/Hypersonic/Hypersonic.c
  1250. @@ -3,6 +3,7 @@
  1251. #include <math.h>
  1252. #include <stdint.h>
  1253. #include <stdlib.h>
  1254. +#include "../optimizations.h"
  1255. #define HYPERSONIC_URI "https://hannesbraun.net/ns/lv2/airwindows/hypersonic"
  1256. @@ -40,15 +41,12 @@ typedef struct {
  1257. double fixE[fix_total];
  1258. double fixF[fix_total];
  1259. double fixG[fix_total];
  1260. -
  1261. - uint32_t fpdL;
  1262. - uint32_t fpdR;
  1263. //default stuff
  1264. } Hypersonic;
  1265. static LV2_Handle instantiate(
  1266. const LV2_Descriptor* descriptor,
  1267. - double rate,
  1268. + realdouble rate,
  1269. const char* bundle_path,
  1270. const LV2_Feature* const* features)
  1271. {
  1272. @@ -89,10 +87,6 @@ static void activate(LV2_Handle instance)
  1273. hypersonic->fixF[x] = 0.0;
  1274. hypersonic->fixG[x] = 0.0;
  1275. }
  1276. - hypersonic->fpdL = 1.0;
  1277. - while (hypersonic->fpdL < 16386) hypersonic->fpdL = rand() * UINT32_MAX;
  1278. - hypersonic->fpdR = 1.0;
  1279. - while (hypersonic->fpdR < 16386) hypersonic->fpdR = rand() * UINT32_MAX;
  1280. }
  1281. static void run(LV2_Handle instance, uint32_t sampleFrames)
  1282. @@ -182,8 +176,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  1283. while (sampleFrames-- > 0) {
  1284. double inputSampleL = *in1;
  1285. double inputSampleR = *in2;
  1286. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = hypersonic->fpdL * 1.18e-17;
  1287. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = hypersonic->fpdR * 1.18e-17;
  1288. double outSample = (inputSampleL * hypersonic->fixA[fix_a0]) + hypersonic->fixA[fix_sL1];
  1289. hypersonic->fixA[fix_sL1] = (inputSampleL * hypersonic->fixA[fix_a1]) - (outSample * hypersonic->fixA[fix_b1]) + hypersonic->fixA[fix_sL2];
  1290. @@ -248,20 +240,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  1291. hypersonic->fixG[fix_sR2] = (inputSampleR * hypersonic->fixG[fix_a2]) - (outSample * hypersonic->fixG[fix_b2]);
  1292. inputSampleR = outSample; //fixed biquad filtering ultrasonics
  1293. - //begin 32 bit stereo floating point dither
  1294. - int expon;
  1295. - frexpf((float)inputSampleL, &expon);
  1296. - hypersonic->fpdL ^= hypersonic->fpdL << 13;
  1297. - hypersonic->fpdL ^= hypersonic->fpdL >> 17;
  1298. - hypersonic->fpdL ^= hypersonic->fpdL << 5;
  1299. - inputSampleL += (((double)hypersonic->fpdL - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  1300. - frexpf((float)inputSampleR, &expon);
  1301. - hypersonic->fpdR ^= hypersonic->fpdR << 13;
  1302. - hypersonic->fpdR ^= hypersonic->fpdR >> 17;
  1303. - hypersonic->fpdR ^= hypersonic->fpdR << 5;
  1304. - inputSampleR += (((double)hypersonic->fpdR - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  1305. - //end 32 bit stereo floating point dither
  1306. -
  1307. *out1 = (float) inputSampleL;
  1308. *out2 = (float) inputSampleR;
  1309. diff --git a/src/Infrasonic/Infrasonic.c b/src/Infrasonic/Infrasonic.c
  1310. index 82c2d71..7288316 100644
  1311. --- a/src/Infrasonic/Infrasonic.c
  1312. +++ b/src/Infrasonic/Infrasonic.c
  1313. @@ -3,6 +3,7 @@
  1314. #include <math.h>
  1315. #include <stdint.h>
  1316. #include <stdlib.h>
  1317. +#include "../optimizations.h"
  1318. #define INFRASONIC_URI "https://hannesbraun.net/ns/lv2/airwindows/infrasonic"
  1319. @@ -22,13 +23,11 @@ typedef struct {
  1320. double biquadC[15];
  1321. double biquadD[15];
  1322. double biquadE[15];
  1323. - uint32_t fpdL;
  1324. - uint32_t fpdR;
  1325. } Infrasonic;
  1326. static LV2_Handle instantiate(
  1327. const LV2_Descriptor* descriptor,
  1328. - double rate,
  1329. + realdouble rate,
  1330. const char* bundle_path,
  1331. const LV2_Feature* const* features)
  1332. {
  1333. @@ -66,10 +65,6 @@ static void activate(LV2_Handle instance)
  1334. infrasonic->biquadD[x] = 0.0;
  1335. infrasonic->biquadE[x] = 0.0;
  1336. }
  1337. - infrasonic->fpdL = 1.0;
  1338. - while (infrasonic->fpdL < 16386) infrasonic->fpdL = rand() * UINT32_MAX;
  1339. - infrasonic->fpdR = 1.0;
  1340. - while (infrasonic->fpdR < 16386) infrasonic->fpdR = rand() * UINT32_MAX;
  1341. }
  1342. static void run(LV2_Handle instance, uint32_t sampleFrames)
  1343. @@ -136,8 +131,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  1344. while (sampleFrames-- > 0) {
  1345. double inputSampleL = *in1;
  1346. double inputSampleR = *in2;
  1347. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = infrasonic->fpdL * 1.18e-17;
  1348. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = infrasonic->fpdR * 1.18e-17;
  1349. double outSampleL = infrasonic->biquadA[2] * inputSampleL + infrasonic->biquadA[3] * infrasonic->biquadA[7] + infrasonic->biquadA[4] * infrasonic->biquadA[8] - infrasonic->biquadA[5] * infrasonic->biquadA[9] - infrasonic->biquadA[6] * infrasonic->biquadA[10];
  1350. infrasonic->biquadA[8] = infrasonic->biquadA[7];
  1351. @@ -209,20 +202,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  1352. infrasonic->biquadE[14] = infrasonic->biquadE[13];
  1353. infrasonic->biquadE[13] = inputSampleR; //DF1 right
  1354. - //begin 32 bit stereo floating point dither
  1355. - int expon;
  1356. - frexpf((float)inputSampleL, &expon);
  1357. - infrasonic->fpdL ^= infrasonic->fpdL << 13;
  1358. - infrasonic->fpdL ^= infrasonic->fpdL >> 17;
  1359. - infrasonic->fpdL ^= infrasonic->fpdL << 5;
  1360. - inputSampleL += (((double)infrasonic->fpdL - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  1361. - frexpf((float)inputSampleR, &expon);
  1362. - infrasonic->fpdR ^= infrasonic->fpdR << 13;
  1363. - infrasonic->fpdR ^= infrasonic->fpdR >> 17;
  1364. - infrasonic->fpdR ^= infrasonic->fpdR << 5;
  1365. - inputSampleR += (((double)infrasonic->fpdR - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  1366. - //end 32 bit stereo floating point dither
  1367. -
  1368. *out1 = (float) inputSampleL;
  1369. *out2 = (float) inputSampleR;
  1370. diff --git a/src/Interstage/Interstage.c b/src/Interstage/Interstage.c
  1371. index 885ef83..2d4df77 100644
  1372. --- a/src/Interstage/Interstage.c
  1373. +++ b/src/Interstage/Interstage.c
  1374. @@ -4,6 +4,7 @@
  1375. #include <stdbool.h>
  1376. #include <stdint.h>
  1377. #include <stdlib.h>
  1378. +#include "../optimizations.h"
  1379. #define INTERSTAGE_URI "https://hannesbraun.net/ns/lv2/airwindows/interstage"
  1380. @@ -33,14 +34,12 @@ typedef struct {
  1381. double iirSampleER;
  1382. double iirSampleFR;
  1383. double lastSampleR;
  1384. - uint32_t fpdL;
  1385. - uint32_t fpdR;
  1386. bool flip;
  1387. } Interstage;
  1388. static LV2_Handle instantiate(
  1389. const LV2_Descriptor* descriptor,
  1390. - double rate,
  1391. + realdouble rate,
  1392. const char* bundle_path,
  1393. const LV2_Feature* const* features)
  1394. {
  1395. @@ -86,10 +85,6 @@ static void activate(LV2_Handle instance)
  1396. interstage->iirSampleER = 0.0;
  1397. interstage->iirSampleFR = 0.0;
  1398. interstage->lastSampleR = 0.0;
  1399. - interstage->fpdL = 1.0;
  1400. - while (interstage->fpdL < 16386) interstage->fpdL = rand() * UINT32_MAX;
  1401. - interstage->fpdR = 1.0;
  1402. - while (interstage->fpdR < 16386) interstage->fpdR = rand() * UINT32_MAX;
  1403. interstage->flip = true;
  1404. }
  1405. @@ -113,8 +108,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  1406. while (sampleFrames-- > 0) {
  1407. double inputSampleL = *in1;
  1408. double inputSampleR = *in2;
  1409. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = interstage->fpdL * 1.18e-17;
  1410. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = interstage->fpdR * 1.18e-17;
  1411. double drySampleL = inputSampleL;
  1412. double drySampleR = inputSampleR;
  1413. @@ -174,20 +167,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  1414. interstage->lastSampleL = inputSampleL;
  1415. interstage->lastSampleR = inputSampleR;
  1416. - //begin 32 bit stereo floating point dither
  1417. - int expon;
  1418. - frexpf((float)inputSampleL, &expon);
  1419. - interstage->fpdL ^= interstage->fpdL << 13;
  1420. - interstage->fpdL ^= interstage->fpdL >> 17;
  1421. - interstage->fpdL ^= interstage->fpdL << 5;
  1422. - inputSampleL += (((double)interstage->fpdL - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  1423. - frexpf((float)inputSampleR, &expon);
  1424. - interstage->fpdR ^= interstage->fpdR << 13;
  1425. - interstage->fpdR ^= interstage->fpdR >> 17;
  1426. - interstage->fpdR ^= interstage->fpdR << 5;
  1427. - inputSampleR += (((double)interstage->fpdR - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  1428. - //end 32 bit stereo floating point dither
  1429. -
  1430. *out1 = (float) inputSampleL;
  1431. *out2 = (float) inputSampleR;
  1432. diff --git a/src/LeftoMono/LeftoMono.c b/src/LeftoMono/LeftoMono.c
  1433. index bd0b49d..8fedca5 100644
  1434. --- a/src/LeftoMono/LeftoMono.c
  1435. +++ b/src/LeftoMono/LeftoMono.c
  1436. @@ -2,6 +2,7 @@
  1437. #include <stdint.h>
  1438. #include <stdlib.h>
  1439. +#include "../optimizations.h"
  1440. #define LEFTOMONO_URI "https://hannesbraun.net/ns/lv2/airwindows/leftomono"
  1441. @@ -22,7 +23,7 @@ typedef struct {
  1442. static LV2_Handle instantiate(
  1443. const LV2_Descriptor* descriptor,
  1444. - double rate,
  1445. + realdouble rate,
  1446. const char* bundle_path,
  1447. const LV2_Feature* const* features)
  1448. {
  1449. diff --git a/src/MV/MV.c b/src/MV/MV.c
  1450. index 8d57a06..25f7b82 100644
  1451. --- a/src/MV/MV.c
  1452. +++ b/src/MV/MV.c
  1453. @@ -3,6 +3,7 @@
  1454. #include <math.h>
  1455. #include <stdint.h>
  1456. #include <stdlib.h>
  1457. +#include "../optimizations.h"
  1458. #define MV_URI "https://hannesbraun.net/ns/lv2/airwindows/mv"
  1459. @@ -27,9 +28,6 @@ typedef struct {
  1460. const float* gain;
  1461. const float* drywet;
  1462. - uint32_t fpdL;
  1463. - uint32_t fpdR;
  1464. -
  1465. double aAL[15150];
  1466. double aBL[14618];
  1467. double aCL[14358];
  1468. @@ -173,7 +171,7 @@ typedef struct {
  1469. static LV2_Handle instantiate(
  1470. const LV2_Descriptor* descriptor,
  1471. - double rate,
  1472. + realdouble rate,
  1473. const char* bundle_path,
  1474. const LV2_Feature* const* features)
  1475. {
  1476. @@ -433,11 +431,6 @@ static void activate(LV2_Handle instance)
  1477. mv->feedbackL = 0.0;
  1478. mv->feedbackR = 0.0;
  1479. -
  1480. - mv->fpdL = 1.0;
  1481. - while (mv->fpdL < 16386) mv->fpdL = rand() * UINT32_MAX;
  1482. - mv->fpdR = 1.0;
  1483. - while (mv->fpdR < 16386) mv->fpdR = rand() * UINT32_MAX;
  1484. }
  1485. static void run(LV2_Handle instance, uint32_t sampleFrames)
  1486. @@ -468,8 +461,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  1487. double inputSampleL = *in1;
  1488. double inputSampleR = *in2;
  1489. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = mv->fpdL * 1.18e-17;
  1490. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = mv->fpdR * 1.18e-17;
  1491. double drySampleL = inputSampleL;
  1492. double drySampleR = inputSampleR;
  1493. @@ -1314,20 +1305,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  1494. }
  1495. //Dry/Wet control, defaults to the last slider
  1496. - //begin 32 bit stereo floating point dither
  1497. - int expon;
  1498. - frexpf((float)inputSampleL, &expon);
  1499. - mv->fpdL ^= mv->fpdL << 13;
  1500. - mv->fpdL ^= mv->fpdL >> 17;
  1501. - mv->fpdL ^= mv->fpdL << 5;
  1502. - inputSampleL += (((double)mv->fpdL - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  1503. - frexpf((float)inputSampleR, &expon);
  1504. - mv->fpdR ^= mv->fpdR << 13;
  1505. - mv->fpdR ^= mv->fpdR >> 17;
  1506. - mv->fpdR ^= mv->fpdR << 5;
  1507. - inputSampleR += (((double)mv->fpdR - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  1508. - //end 32 bit stereo floating point dither
  1509. -
  1510. *out1 = (float) inputSampleL;
  1511. *out2 = (float) inputSampleR;
  1512. diff --git a/src/Mackity/Mackity.c b/src/Mackity/Mackity.c
  1513. index 5250dd8..933d3a7 100644
  1514. --- a/src/Mackity/Mackity.c
  1515. +++ b/src/Mackity/Mackity.c
  1516. @@ -3,6 +3,7 @@
  1517. #include <math.h>
  1518. #include <stdint.h>
  1519. #include <stdlib.h>
  1520. +#include "../optimizations.h"
  1521. #define MACKITY_URI "https://hannesbraun.net/ns/lv2/airwindows/mackity"
  1522. @@ -28,14 +29,11 @@ typedef struct {
  1523. double iirSampleBR;
  1524. double biquadA[15];
  1525. double biquadB[15];
  1526. -
  1527. - uint32_t fpdL;
  1528. - uint32_t fpdR;
  1529. } Mackity;
  1530. static LV2_Handle instantiate(
  1531. const LV2_Descriptor* descriptor,
  1532. - double rate,
  1533. + realdouble rate,
  1534. const char* bundle_path,
  1535. const LV2_Feature* const* features)
  1536. {
  1537. @@ -82,11 +80,6 @@ static void activate(LV2_Handle instance)
  1538. mackity->biquadA[x] = 0.0;
  1539. mackity->biquadB[x] = 0.0;
  1540. }
  1541. -
  1542. - mackity->fpdL = 1.0;
  1543. - while (mackity->fpdL < 16386) mackity->fpdL = rand() * UINT32_MAX;
  1544. - mackity->fpdR = 1.0;
  1545. - while (mackity->fpdR < 16386) mackity->fpdR = rand() * UINT32_MAX;
  1546. }
  1547. static void run(LV2_Handle instance, uint32_t sampleFrames)
  1548. @@ -132,8 +125,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  1549. while (sampleFrames-- > 0) {
  1550. double inputSampleL = *in1;
  1551. double inputSampleR = *in2;
  1552. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = mackity->fpdL * 1.18e-17;
  1553. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = mackity->fpdR * 1.18e-17;
  1554. if (fabs(mackity->iirSampleAL) < 1.18e-37) mackity->iirSampleAL = 0.0;
  1555. mackity->iirSampleAL = (mackity->iirSampleAL * (1.0 - iirAmountA)) + (inputSampleL * iirAmountA);
  1556. @@ -194,20 +185,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  1557. inputSampleR *= outPad;
  1558. }
  1559. - //begin 32 bit stereo floating point dither
  1560. - int expon;
  1561. - frexpf((float)inputSampleL, &expon);
  1562. - mackity->fpdL ^= mackity->fpdL << 13;
  1563. - mackity->fpdL ^= mackity->fpdL >> 17;
  1564. - mackity->fpdL ^= mackity->fpdL << 5;
  1565. - inputSampleL += (((double)mackity->fpdL - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  1566. - frexpf((float)inputSampleR, &expon);
  1567. - mackity->fpdR ^= mackity->fpdR << 13;
  1568. - mackity->fpdR ^= mackity->fpdR >> 17;
  1569. - mackity->fpdR ^= mackity->fpdR << 5;
  1570. - inputSampleR += (((double)mackity->fpdR - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  1571. - //end 32 bit stereo floating point dither
  1572. -
  1573. *out1 = (float) inputSampleL;
  1574. *out2 = (float) inputSampleR;
  1575. diff --git a/src/MidSide/MidSide.c b/src/MidSide/MidSide.c
  1576. index 4c27ce7..7ee0c90 100644
  1577. --- a/src/MidSide/MidSide.c
  1578. +++ b/src/MidSide/MidSide.c
  1579. @@ -3,6 +3,7 @@
  1580. #include <math.h>
  1581. #include <stdint.h>
  1582. #include <stdlib.h>
  1583. +#include "../optimizations.h"
  1584. #define MIDSIDE_URI "https://hannesbraun.net/ns/lv2/airwindows/midside"
  1585. @@ -18,14 +19,11 @@ typedef struct {
  1586. const float* input[2];
  1587. float* output[2];
  1588. const float* midside;
  1589. -
  1590. - uint32_t fpdL;
  1591. - uint32_t fpdR;
  1592. } MidSide;
  1593. static LV2_Handle instantiate(
  1594. const LV2_Descriptor* descriptor,
  1595. - double rate,
  1596. + realdouble rate,
  1597. const char* bundle_path,
  1598. const LV2_Feature* const* features)
  1599. {
  1600. @@ -56,14 +54,7 @@ static void connect_port(LV2_Handle instance, uint32_t port, void* data)
  1601. }
  1602. }
  1603. -static void activate(LV2_Handle instance)
  1604. -{
  1605. - MidSide* midside = (MidSide*) instance;
  1606. - midside->fpdL = 1.0;
  1607. - while (midside->fpdL < 16386) midside->fpdL = rand() * UINT32_MAX;
  1608. - midside->fpdR = 1.0;
  1609. - while (midside->fpdR < 16386) midside->fpdR = rand() * UINT32_MAX;
  1610. -}
  1611. +static void activate(LV2_Handle instance) {}
  1612. static void run(LV2_Handle instance, uint32_t sampleFrames)
  1613. {
  1614. @@ -86,8 +77,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  1615. while (sampleFrames-- > 0) {
  1616. inputSampleL = *in1;
  1617. inputSampleR = *in2;
  1618. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = midside->fpdL * 1.18e-17;
  1619. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = midside->fpdR * 1.18e-17;
  1620. mid = inputSampleL + inputSampleR;
  1621. side = inputSampleL - inputSampleR;
  1622. @@ -95,21 +84,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  1623. mid *= midgain;
  1624. side *= sidegain;
  1625. - //begin 32 bit floating point dither
  1626. - int expon;
  1627. - frexpf((float)mid, &expon);
  1628. - midside->fpdL ^= midside->fpdL << 13;
  1629. - midside->fpdL ^= midside->fpdL >> 17;
  1630. - midside->fpdL ^= midside->fpdL << 5;
  1631. - mid += (((double)midside->fpdL - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  1632. - //end 32 bit floating point dither
  1633. - frexpf((float)side, &expon);
  1634. - midside->fpdR ^= midside->fpdR << 13;
  1635. - midside->fpdR ^= midside->fpdR >> 17;
  1636. - midside->fpdR ^= midside->fpdR << 5;
  1637. - side += (((double)midside->fpdR - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  1638. - //end 32 bit floating point dither
  1639. -
  1640. *out1 = (float) mid;
  1641. *out2 = (float) side;
  1642. diff --git a/src/Mojo/Mojo.c b/src/Mojo/Mojo.c
  1643. index ee39090..d8ef7cf 100644
  1644. --- a/src/Mojo/Mojo.c
  1645. +++ b/src/Mojo/Mojo.c
  1646. @@ -3,6 +3,7 @@
  1647. #include <math.h>
  1648. #include <stdint.h>
  1649. #include <stdlib.h>
  1650. +#include "../optimizations.h"
  1651. #define MOJO_URI "https://hannesbraun.net/ns/lv2/airwindows/mojo"
  1652. @@ -18,14 +19,11 @@ typedef struct {
  1653. const float* input[2];
  1654. float* output[2];
  1655. const float* gain;
  1656. -
  1657. - uint32_t fpdL;
  1658. - uint32_t fpdR;
  1659. } Mojo;
  1660. static LV2_Handle instantiate(
  1661. const LV2_Descriptor* descriptor,
  1662. - double rate,
  1663. + realdouble rate,
  1664. const char* bundle_path,
  1665. const LV2_Feature* const* features)
  1666. {
  1667. @@ -56,14 +54,7 @@ static void connect_port(LV2_Handle instance, uint32_t port, void* data)
  1668. }
  1669. }
  1670. -static void activate(LV2_Handle instance)
  1671. -{
  1672. - Mojo* mojo = (Mojo*) instance;
  1673. - mojo->fpdL = 1.0;
  1674. - while (mojo->fpdL < 16386) mojo->fpdL = rand() * UINT32_MAX;
  1675. - mojo->fpdR = 1.0;
  1676. - while (mojo->fpdR < 16386) mojo->fpdR = rand() * UINT32_MAX;
  1677. -}
  1678. +static void activate(LV2_Handle instance) {}
  1679. static void run(LV2_Handle instance, uint32_t sampleFrames)
  1680. {
  1681. @@ -79,8 +70,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  1682. while (sampleFrames-- > 0) {
  1683. double inputSampleL = *in1;
  1684. double inputSampleR = *in2;
  1685. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = mojoInstance->fpdL * 1.18e-17;
  1686. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = mojoInstance->fpdR * 1.18e-17;
  1687. if (gain != 1.0) {
  1688. inputSampleL *= gain;
  1689. @@ -94,20 +83,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  1690. if (mojo > 0.0) inputSampleR = (sin(inputSampleR * mojo * M_PI * 0.5) / mojo) * 0.987654321;
  1691. //mojo is the one that flattens WAAAAY out very softly before wavefolding
  1692. - //begin 32 bit stereo floating point dither
  1693. - int expon;
  1694. - frexpf((float)inputSampleL, &expon);
  1695. - mojoInstance->fpdL ^= mojoInstance->fpdL << 13;
  1696. - mojoInstance->fpdL ^= mojoInstance->fpdL >> 17;
  1697. - mojoInstance->fpdL ^= mojoInstance->fpdL << 5;
  1698. - inputSampleL += (((double)mojoInstance->fpdL - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  1699. - frexpf((float)inputSampleR, &expon);
  1700. - mojoInstance->fpdR ^= mojoInstance->fpdR << 13;
  1701. - mojoInstance->fpdR ^= mojoInstance->fpdR >> 17;
  1702. - mojoInstance->fpdR ^= mojoInstance->fpdR << 5;
  1703. - inputSampleR += (((double)mojoInstance->fpdR - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  1704. - //end 32 bit stereo floating point dither
  1705. -
  1706. *out1 = (float) inputSampleL;
  1707. *out2 = (float) inputSampleR;
  1708. diff --git a/src/Nikola/Nikola.c b/src/Nikola/Nikola.c
  1709. index 772fbe2..0a5a274 100644
  1710. --- a/src/Nikola/Nikola.c
  1711. +++ b/src/Nikola/Nikola.c
  1712. @@ -4,6 +4,7 @@
  1713. #include <stdbool.h>
  1714. #include <stdint.h>
  1715. #include <stdlib.h>
  1716. +#include "../optimizations.h"
  1717. #define NIKOLA_URI "https://hannesbraun.net/ns/lv2/airwindows/nikola"
  1718. @@ -29,14 +30,11 @@ typedef struct {
  1719. int framenumberR;
  1720. bool wasNegativeR;
  1721. double outlevelR;
  1722. -
  1723. - uint32_t fpdL;
  1724. - uint32_t fpdR;
  1725. } Nikola;
  1726. static LV2_Handle instantiate(
  1727. const LV2_Descriptor* descriptor,
  1728. - double rate,
  1729. + realdouble rate,
  1730. const char* bundle_path,
  1731. const LV2_Feature* const* features)
  1732. {
  1733. @@ -80,11 +78,6 @@ static void activate(LV2_Handle instance)
  1734. nikola->wasNegativeR = false;
  1735. nikola->outlevelR = 0.0;
  1736. nikola->framenumberR = 0;
  1737. -
  1738. - nikola->fpdL = 1.0;
  1739. - while (nikola->fpdL < 16386) nikola->fpdL = rand() * UINT32_MAX;
  1740. - nikola->fpdR = 1.0;
  1741. - while (nikola->fpdR < 16386) nikola->fpdR = rand() * UINT32_MAX;
  1742. }
  1743. static void run(LV2_Handle instance, uint32_t sampleFrames)
  1744. @@ -103,8 +96,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  1745. while (sampleFrames-- > 0) {
  1746. double inputSampleL = *in1;
  1747. double inputSampleR = *in2;
  1748. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = nikola->fpdL * 1.18e-17;
  1749. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = nikola->fpdR * 1.18e-17;
  1750. double drySampleL = inputSampleL;
  1751. double drySampleR = inputSampleR;
  1752. @@ -2965,20 +2956,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  1753. inputSampleR = (inputSampleR * wet) + (drySampleR * (1.0 - wet));
  1754. }
  1755. - //begin 32 bit stereo floating point dither
  1756. - int expon;
  1757. - frexpf((float)inputSampleL, &expon);
  1758. - nikola->fpdL ^= nikola->fpdL << 13;
  1759. - nikola->fpdL ^= nikola->fpdL >> 17;
  1760. - nikola->fpdL ^= nikola->fpdL << 5;
  1761. - inputSampleL += (((double)nikola->fpdL - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  1762. - frexpf((float)inputSampleR, &expon);
  1763. - nikola->fpdR ^= nikola->fpdR << 13;
  1764. - nikola->fpdR ^= nikola->fpdR >> 17;
  1765. - nikola->fpdR ^= nikola->fpdR << 5;
  1766. - inputSampleR += (((double)nikola->fpdR - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  1767. - //end 32 bit stereo floating point dither
  1768. -
  1769. *out1 = (float) inputSampleL;
  1770. *out2 = (float) inputSampleR;
  1771. diff --git a/src/PocketVerbs/PocketVerbs.c b/src/PocketVerbs/PocketVerbs.c
  1772. index 694321a..df4be1f 100644
  1773. --- a/src/PocketVerbs/PocketVerbs.c
  1774. +++ b/src/PocketVerbs/PocketVerbs.c
  1775. @@ -3,6 +3,7 @@
  1776. #include <math.h>
  1777. #include <stdint.h>
  1778. #include <stdlib.h>
  1779. +#include "../optimizations.h"
  1780. #define POCKETVERBS_URI "https://hannesbraun.net/ns/lv2/airwindows/pocketverbs"
  1781. @@ -245,14 +246,11 @@ typedef struct {
  1782. int countdown;
  1783. double peakL;
  1784. double peakR;
  1785. -
  1786. - uint32_t fpdL;
  1787. - uint32_t fpdR;
  1788. } PocketVerbs;
  1789. static LV2_Handle instantiate(
  1790. const LV2_Descriptor* descriptor,
  1791. - double rate,
  1792. + realdouble rate,
  1793. const char* bundle_path,
  1794. const LV2_Feature* const* features)
  1795. {
  1796. @@ -831,10 +829,6 @@ static void activate(LV2_Handle instance)
  1797. pocketverbs->countdown = -1;
  1798. pocketverbs->peakL = 1.0;
  1799. pocketverbs->peakR = 1.0;
  1800. - pocketverbs->fpdL = 1.0;
  1801. - while (pocketverbs->fpdL < 16386) pocketverbs->fpdL = rand() * UINT32_MAX;
  1802. - pocketverbs->fpdR = 1.0;
  1803. - while (pocketverbs->fpdR < 16386) pocketverbs->fpdR = rand() * UINT32_MAX;
  1804. }
  1805. static void run(LV2_Handle instance, uint32_t sampleFrames)
  1806. @@ -1778,9 +1772,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  1807. double inputSampleL = *in1;
  1808. double inputSampleR = *in2;
  1809. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = pocketverbs->fpdL * 1.18e-17;
  1810. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = pocketverbs->fpdR * 1.18e-17;
  1811. -
  1812. double drySampleL = inputSampleL;
  1813. double drySampleR = inputSampleR;
  1814. @@ -13590,20 +13581,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  1815. inputSampleR += drySampleR;
  1816. //here we combine the tanks with the dry signal
  1817. - //begin 32 bit stereo floating point dither
  1818. - int expon;
  1819. - frexpf((float)inputSampleL, &expon);
  1820. - pocketverbs->fpdL ^= pocketverbs->fpdL << 13;
  1821. - pocketverbs->fpdL ^= pocketverbs->fpdL >> 17;
  1822. - pocketverbs->fpdL ^= pocketverbs->fpdL << 5;
  1823. - inputSampleL += (((double)pocketverbs->fpdL - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  1824. - frexpf((float)inputSampleR, &expon);
  1825. - pocketverbs->fpdR ^= pocketverbs->fpdR << 13;
  1826. - pocketverbs->fpdR ^= pocketverbs->fpdR >> 17;
  1827. - pocketverbs->fpdR ^= pocketverbs->fpdR << 5;
  1828. - inputSampleR += (((double)pocketverbs->fpdR - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  1829. - //end 32 bit stereo floating point dither
  1830. -
  1831. *out1 = (float) inputSampleL;
  1832. *out2 = (float) inputSampleR;
  1833. diff --git a/src/Pressure5/Pressure5.c b/src/Pressure5/Pressure5.c
  1834. index 0ea5c79..e16c291 100644
  1835. --- a/src/Pressure5/Pressure5.c
  1836. +++ b/src/Pressure5/Pressure5.c
  1837. @@ -4,6 +4,7 @@
  1838. #include <math.h>
  1839. #include <stdint.h>
  1840. #include <stdlib.h>
  1841. +#include "../optimizations.h"
  1842. #define PRESSURE5_URI "https://hannesbraun.net/ns/lv2/airwindows/pressure5"
  1843. @@ -70,14 +71,11 @@ typedef struct {
  1844. bool wasNegClipR; //Stereo ClipOnly2
  1845. double slewMax; //to adust mewiness
  1846. -
  1847. - uint32_t fpdL;
  1848. - uint32_t fpdR;
  1849. } Pressure5;
  1850. static LV2_Handle instantiate(
  1851. const LV2_Descriptor* descriptor,
  1852. - double rate,
  1853. + realdouble rate,
  1854. const char* bundle_path,
  1855. const LV2_Feature* const* features)
  1856. {
  1857. @@ -149,11 +147,6 @@ static void activate(LV2_Handle instance)
  1858. pressure5->intermediateR[x] = 0.0;
  1859. }
  1860. pressure5->slewMax = 0.0;
  1861. -
  1862. - pressure5->fpdL = 1.0;
  1863. - while (pressure5->fpdL < 16386) pressure5->fpdL = rand() * UINT32_MAX;
  1864. - pressure5->fpdR = 1.0;
  1865. - while (pressure5->fpdR < 16386) pressure5->fpdR = rand() * UINT32_MAX;
  1866. }
  1867. static void run(LV2_Handle instance, uint32_t sampleFrames)
  1868. @@ -202,8 +195,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  1869. while (sampleFrames-- > 0) {
  1870. double inputSampleL = *in1;
  1871. double inputSampleR = *in2;
  1872. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = pressure5->fpdL * 1.18e-17;
  1873. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = pressure5->fpdR * 1.18e-17;
  1874. double drySampleL = inputSampleL;
  1875. double drySampleR = inputSampleR;
  1876. @@ -373,20 +364,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  1877. //end ClipOnly2 stereo as a little, compressed chunk that can be dropped into code
  1878. //final clip runs AFTER the Dry/Wet. It serves as a safety clip even if you're not full wet
  1879. - //begin 32 bit stereo floating point dither
  1880. - int expon;
  1881. - frexpf((float)inputSampleL, &expon);
  1882. - pressure5->fpdL ^= pressure5->fpdL << 13;
  1883. - pressure5->fpdL ^= pressure5->fpdL >> 17;
  1884. - pressure5->fpdL ^= pressure5->fpdL << 5;
  1885. - inputSampleL += (((double)pressure5->fpdL - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  1886. - frexpf((float)inputSampleR, &expon);
  1887. - pressure5->fpdR ^= pressure5->fpdR << 13;
  1888. - pressure5->fpdR ^= pressure5->fpdR >> 17;
  1889. - pressure5->fpdR ^= pressure5->fpdR << 5;
  1890. - inputSampleR += (((double)pressure5->fpdR - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  1891. - //end 32 bit stereo floating point dither
  1892. -
  1893. *out1 = (float) inputSampleL;
  1894. *out2 = (float) inputSampleR;
  1895. diff --git a/src/PurestConsoleBuss/PurestConsoleBuss.c b/src/PurestConsoleBuss/PurestConsoleBuss.c
  1896. index 663ff27..a8cae6c 100644
  1897. --- a/src/PurestConsoleBuss/PurestConsoleBuss.c
  1898. +++ b/src/PurestConsoleBuss/PurestConsoleBuss.c
  1899. @@ -3,6 +3,7 @@
  1900. #include <math.h>
  1901. #include <stdint.h>
  1902. #include <stdlib.h>
  1903. +#include "../optimizations.h"
  1904. #define PURESTCONSOLEBUSS_URI "https://hannesbraun.net/ns/lv2/airwindows/purestconsolebuss"
  1905. @@ -16,14 +17,11 @@ typedef enum {
  1906. typedef struct {
  1907. const float* input[2];
  1908. float* output[2];
  1909. -
  1910. - uint32_t fpdL;
  1911. - uint32_t fpdR;
  1912. } PurestConsoleBuss;
  1913. static LV2_Handle instantiate(
  1914. const LV2_Descriptor* descriptor,
  1915. - double rate,
  1916. + realdouble rate,
  1917. const char* bundle_path,
  1918. const LV2_Feature* const* features)
  1919. {
  1920. @@ -51,14 +49,7 @@ static void connect_port(LV2_Handle instance, uint32_t port, void* data)
  1921. }
  1922. }
  1923. -static void activate(LV2_Handle instance)
  1924. -{
  1925. - PurestConsoleBuss* purestConsoleBuss = (PurestConsoleBuss*) instance;
  1926. - purestConsoleBuss->fpdL = 1.0;
  1927. - while (purestConsoleBuss->fpdL < 16386) purestConsoleBuss->fpdL = rand() * UINT32_MAX;
  1928. - purestConsoleBuss->fpdR = 1.0;
  1929. - while (purestConsoleBuss->fpdR < 16386) purestConsoleBuss->fpdR = rand() * UINT32_MAX;
  1930. -}
  1931. +static void activate(LV2_Handle instance) {}
  1932. static void run(LV2_Handle instance, uint32_t sampleFrames)
  1933. {
  1934. @@ -75,8 +66,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  1935. while (sampleFrames-- > 0) {
  1936. inputSampleL = *in1;
  1937. inputSampleR = *in2;
  1938. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = purestConsoleBuss->fpdL * 1.18e-17;
  1939. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = purestConsoleBuss->fpdR * 1.18e-17;
  1940. if (inputSampleL > 1.0) inputSampleL = 1.0;
  1941. if (inputSampleL < -1.0) inputSampleL = -1.0;
  1942. @@ -88,20 +77,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  1943. inputSampleR = asin(inputSampleR);
  1944. //amplitude aspect
  1945. - //begin 32 bit stereo floating point dither
  1946. - int expon;
  1947. - frexpf((float)inputSampleL, &expon);
  1948. - purestConsoleBuss->fpdL ^= purestConsoleBuss->fpdL << 13;
  1949. - purestConsoleBuss->fpdL ^= purestConsoleBuss->fpdL >> 17;
  1950. - purestConsoleBuss->fpdL ^= purestConsoleBuss->fpdL << 5;
  1951. - inputSampleL += (((double)purestConsoleBuss->fpdL - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  1952. - frexpf((float)inputSampleR, &expon);
  1953. - purestConsoleBuss->fpdR ^= purestConsoleBuss->fpdR << 13;
  1954. - purestConsoleBuss->fpdR ^= purestConsoleBuss->fpdR >> 17;
  1955. - purestConsoleBuss->fpdR ^= purestConsoleBuss->fpdR << 5;
  1956. - inputSampleR += (((double)purestConsoleBuss->fpdR - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  1957. - //end 32 bit stereo floating point dither
  1958. -
  1959. *out1 = (float) inputSampleL;
  1960. *out2 = (float) inputSampleR;
  1961. diff --git a/src/PurestConsoleChannel/PurestConsoleChannel.c b/src/PurestConsoleChannel/PurestConsoleChannel.c
  1962. index cee3dcb..29f7187 100644
  1963. --- a/src/PurestConsoleChannel/PurestConsoleChannel.c
  1964. +++ b/src/PurestConsoleChannel/PurestConsoleChannel.c
  1965. @@ -3,6 +3,7 @@
  1966. #include <math.h>
  1967. #include <stdint.h>
  1968. #include <stdlib.h>
  1969. +#include "../optimizations.h"
  1970. #define PURESTCONSOLECHANNEL_URI "https://hannesbraun.net/ns/lv2/airwindows/purestconsolechannel"
  1971. @@ -16,14 +17,11 @@ typedef enum {
  1972. typedef struct {
  1973. const float* input[2];
  1974. float* output[2];
  1975. -
  1976. - uint32_t fpdL;
  1977. - uint32_t fpdR;
  1978. } PurestConsoleChannel;
  1979. static LV2_Handle instantiate(
  1980. const LV2_Descriptor* descriptor,
  1981. - double rate,
  1982. + realdouble rate,
  1983. const char* bundle_path,
  1984. const LV2_Feature* const* features)
  1985. {
  1986. @@ -51,14 +49,7 @@ static void connect_port(LV2_Handle instance, uint32_t port, void* data)
  1987. }
  1988. }
  1989. -static void activate(LV2_Handle instance)
  1990. -{
  1991. - PurestConsoleChannel* purestConsoleChannel = (PurestConsoleChannel*) instance;
  1992. - purestConsoleChannel->fpdL = 1.0;
  1993. - while (purestConsoleChannel->fpdL < 16386) purestConsoleChannel->fpdL = rand() * UINT32_MAX;
  1994. - purestConsoleChannel->fpdR = 1.0;
  1995. - while (purestConsoleChannel->fpdR < 16386) purestConsoleChannel->fpdR = rand() * UINT32_MAX;
  1996. -}
  1997. +static void activate(LV2_Handle instance) {}
  1998. static void run(LV2_Handle instance, uint32_t sampleFrames)
  1999. {
  2000. @@ -75,27 +66,11 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  2001. while (sampleFrames-- > 0) {
  2002. inputSampleL = *in1;
  2003. inputSampleR = *in2;
  2004. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = purestConsoleChannel->fpdL * 1.18e-17;
  2005. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = purestConsoleChannel->fpdR * 1.18e-17;
  2006. inputSampleL = sin(inputSampleL);
  2007. inputSampleR = sin(inputSampleR);
  2008. //amplitude aspect
  2009. - //begin 32 bit stereo floating point dither
  2010. - int expon;
  2011. - frexpf((float)inputSampleL, &expon);
  2012. - purestConsoleChannel->fpdL ^= purestConsoleChannel->fpdL << 13;
  2013. - purestConsoleChannel->fpdL ^= purestConsoleChannel->fpdL >> 17;
  2014. - purestConsoleChannel->fpdL ^= purestConsoleChannel->fpdL << 5;
  2015. - inputSampleL += (((double)purestConsoleChannel->fpdL - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  2016. - frexpf((float)inputSampleR, &expon);
  2017. - purestConsoleChannel->fpdR ^= purestConsoleChannel->fpdR << 13;
  2018. - purestConsoleChannel->fpdR ^= purestConsoleChannel->fpdR >> 17;
  2019. - purestConsoleChannel->fpdR ^= purestConsoleChannel->fpdR << 5;
  2020. - inputSampleR += (((double)purestConsoleChannel->fpdR - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  2021. - //end 32 bit stereo floating point dither
  2022. -
  2023. *out1 = (float) inputSampleL;
  2024. *out2 = (float) inputSampleR;
  2025. diff --git a/src/PurestGain/PurestGain.c b/src/PurestGain/PurestGain.c
  2026. index 97c9925..b06c780 100644
  2027. --- a/src/PurestGain/PurestGain.c
  2028. +++ b/src/PurestGain/PurestGain.c
  2029. @@ -3,6 +3,7 @@
  2030. #include <math.h>
  2031. #include <stdint.h>
  2032. #include <stdlib.h>
  2033. +#include "../optimizations.h"
  2034. #define PURESTGAIN_URI "https://hannesbraun.net/ns/lv2/airwindows/purestgain"
  2035. @@ -22,8 +23,6 @@ typedef struct {
  2036. const float* gain;
  2037. const float* slowfade;
  2038. - uint32_t fpdL;
  2039. - uint32_t fpdR;
  2040. //default stuff
  2041. double gainchase;
  2042. double settingchase;
  2043. @@ -33,7 +32,7 @@ typedef struct {
  2044. static LV2_Handle instantiate(
  2045. const LV2_Descriptor* descriptor,
  2046. - double rate,
  2047. + realdouble rate,
  2048. const char* bundle_path,
  2049. const LV2_Feature* const* features)
  2050. {
  2051. @@ -75,10 +74,6 @@ static void activate(LV2_Handle instance)
  2052. purestGain->settingchase = -90.0;
  2053. purestGain->gainBchase = -90.0;
  2054. purestGain->chasespeed = 350.0;
  2055. - purestGain->fpdL = 1.0;
  2056. - while (purestGain->fpdL < 16386) purestGain->fpdL = rand() * UINT32_MAX;
  2057. - purestGain->fpdR = 1.0;
  2058. - while (purestGain->fpdR < 16386) purestGain->fpdR = rand() * UINT32_MAX;
  2059. }
  2060. static void run(LV2_Handle instance, uint32_t sampleFrames)
  2061. @@ -143,8 +138,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  2062. inputSampleL = *in1;
  2063. inputSampleR = *in2;
  2064. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = purestGain->fpdL * 1.18e-17;
  2065. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = purestGain->fpdR * 1.18e-17;
  2066. if (1.0 == outputgain) {
  2067. *out1 = *in1;
  2068. @@ -152,19 +145,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  2069. } else {
  2070. inputSampleL *= outputgain;
  2071. inputSampleR *= outputgain;
  2072. - //begin 32 bit stereo floating point dither
  2073. - int expon;
  2074. - frexpf((float)inputSampleL, &expon);
  2075. - purestGain->fpdL ^= purestGain->fpdL << 13;
  2076. - purestGain->fpdL ^= purestGain->fpdL >> 17;
  2077. - purestGain->fpdL ^= purestGain->fpdL << 5;
  2078. - inputSampleL += (((double)purestGain->fpdL - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  2079. - frexpf((float)inputSampleR, &expon);
  2080. - purestGain->fpdR ^= purestGain->fpdR << 13;
  2081. - purestGain->fpdR ^= purestGain->fpdR >> 17;
  2082. - purestGain->fpdR ^= purestGain->fpdR << 5;
  2083. - inputSampleR += (((double)purestGain->fpdR - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  2084. - //end 32 bit stereo floating point dither
  2085. *out1 = (float) inputSampleL;
  2086. *out2 = (float) inputSampleR;
  2087. }
  2088. diff --git a/src/RightoMono/RightoMono.c b/src/RightoMono/RightoMono.c
  2089. index 03acec9..e6eb262 100644
  2090. --- a/src/RightoMono/RightoMono.c
  2091. +++ b/src/RightoMono/RightoMono.c
  2092. @@ -2,6 +2,7 @@
  2093. #include <stdint.h>
  2094. #include <stdlib.h>
  2095. +#include "../optimizations.h"
  2096. #define RIGHTOMONO_URI "https://hannesbraun.net/ns/lv2/airwindows/rightomono"
  2097. @@ -22,7 +23,7 @@ typedef struct {
  2098. static LV2_Handle instantiate(
  2099. const LV2_Descriptor* descriptor,
  2100. - double rate,
  2101. + realdouble rate,
  2102. const char* bundle_path,
  2103. const LV2_Feature* const* features)
  2104. {
  2105. diff --git a/src/Sidepass/Sidepass.c b/src/Sidepass/Sidepass.c
  2106. index 0e99ac2..b55f35e 100644
  2107. --- a/src/Sidepass/Sidepass.c
  2108. +++ b/src/Sidepass/Sidepass.c
  2109. @@ -4,6 +4,7 @@
  2110. #include <stdbool.h>
  2111. #include <stdint.h>
  2112. #include <stdlib.h>
  2113. +#include "../optimizations.h"
  2114. #define SIDEPASS_URI "https://hannesbraun.net/ns/lv2/airwindows/sidepass"
  2115. @@ -24,13 +25,11 @@ typedef struct {
  2116. double iirSampleA;
  2117. double iirSampleB;
  2118. bool flip;
  2119. - uint32_t fpdL;
  2120. - uint32_t fpdR;
  2121. } Sidepass;
  2122. static LV2_Handle instantiate(
  2123. const LV2_Descriptor* descriptor,
  2124. - double rate,
  2125. + realdouble rate,
  2126. const char* bundle_path,
  2127. const LV2_Feature* const* features)
  2128. {
  2129. @@ -68,10 +67,6 @@ static void activate(LV2_Handle instance)
  2130. sidepass->iirSampleA = 0.0;
  2131. sidepass->iirSampleB = 0.0;
  2132. sidepass->flip = true;
  2133. - sidepass->fpdL = 1.0;
  2134. - while (sidepass->fpdL < 16386) sidepass->fpdL = rand() * UINT32_MAX;
  2135. - sidepass->fpdR = 1.0;
  2136. - while (sidepass->fpdR < 16386) sidepass->fpdR = rand() * UINT32_MAX;
  2137. }
  2138. static void run(LV2_Handle instance, uint32_t sampleFrames)
  2139. @@ -95,8 +90,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  2140. while (sampleFrames-- > 0) {
  2141. inputSampleL = *in1;
  2142. inputSampleR = *in2;
  2143. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = sidepass->fpdL * 1.18e-17;
  2144. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = sidepass->fpdR * 1.18e-17;
  2145. mid = inputSampleL + inputSampleR;
  2146. side = inputSampleL - inputSampleR;
  2147. @@ -113,20 +106,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  2148. inputSampleL = (mid + side) / 2.0;
  2149. inputSampleR = (mid - side) / 2.0;
  2150. - //begin 32 bit stereo floating point dither
  2151. - int expon;
  2152. - frexpf((float)inputSampleL, &expon);
  2153. - sidepass->fpdL ^= sidepass->fpdL << 13;
  2154. - sidepass->fpdL ^= sidepass->fpdL >> 17;
  2155. - sidepass->fpdL ^= sidepass->fpdL << 5;
  2156. - inputSampleL += (((double)sidepass->fpdL - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  2157. - frexpf((float)inputSampleR, &expon);
  2158. - sidepass->fpdR ^= sidepass->fpdR << 13;
  2159. - sidepass->fpdR ^= sidepass->fpdR >> 17;
  2160. - sidepass->fpdR ^= sidepass->fpdR << 5;
  2161. - inputSampleR += (((double)sidepass->fpdR - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  2162. - //end 32 bit stereo floating point dither
  2163. -
  2164. *out1 = (float) inputSampleL;
  2165. *out2 = (float) inputSampleR;
  2166. diff --git a/src/Slew/Slew.c b/src/Slew/Slew.c
  2167. index e23ad33..97fe6fb 100644
  2168. --- a/src/Slew/Slew.c
  2169. +++ b/src/Slew/Slew.c
  2170. @@ -3,6 +3,7 @@
  2171. #include <math.h>
  2172. #include <stdint.h>
  2173. #include <stdlib.h>
  2174. +#include "../optimizations.h"
  2175. #define SLEW_URI "https://hannesbraun.net/ns/lv2/airwindows/slew"
  2176. @@ -22,13 +23,11 @@ typedef struct {
  2177. double lastSampleL;
  2178. double lastSampleR;
  2179. - uint32_t fpdL;
  2180. - uint32_t fpdR;
  2181. } Slew;
  2182. static LV2_Handle instantiate(
  2183. const LV2_Descriptor* descriptor,
  2184. - double rate,
  2185. + realdouble rate,
  2186. const char* bundle_path,
  2187. const LV2_Feature* const* features)
  2188. {
  2189. @@ -91,8 +90,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  2190. while (sampleFrames-- > 0) {
  2191. inputSampleL = *in1;
  2192. inputSampleR = *in2;
  2193. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = slew->fpdL * 1.18e-17;
  2194. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = slew->fpdR * 1.18e-17;
  2195. clamp = inputSampleL - slew->lastSampleL;
  2196. outputSampleL = inputSampleL;
  2197. diff --git a/src/SlewOnly/SlewOnly.c b/src/SlewOnly/SlewOnly.c
  2198. index d2de114..2148b40 100644
  2199. --- a/src/SlewOnly/SlewOnly.c
  2200. +++ b/src/SlewOnly/SlewOnly.c
  2201. @@ -3,6 +3,7 @@
  2202. #include <math.h>
  2203. #include <stdint.h>
  2204. #include <stdlib.h>
  2205. +#include "../optimizations.h"
  2206. #define SLEWONLY_URI "https://hannesbraun.net/ns/lv2/airwindows/slewonly"
  2207. @@ -19,13 +20,11 @@ typedef struct {
  2208. double lastSampleL;
  2209. double lastSampleR;
  2210. - uint32_t fpdL;
  2211. - uint32_t fpdR;
  2212. } SlewOnly;
  2213. static LV2_Handle instantiate(
  2214. const LV2_Descriptor* descriptor,
  2215. - double rate,
  2216. + realdouble rate,
  2217. const char* bundle_path,
  2218. const LV2_Feature* const* features)
  2219. {
  2220. @@ -78,8 +77,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  2221. while (sampleFrames-- > 0) {
  2222. inputSampleL = *in1;
  2223. inputSampleR = *in2;
  2224. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = slewonly->fpdL * 1.18e-17;
  2225. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = slewonly->fpdR * 1.18e-17;
  2226. outputSampleL = (inputSampleL - slewonly->lastSampleL) * trim;
  2227. outputSampleR = (inputSampleR - slewonly->lastSampleR) * trim;
  2228. diff --git a/src/Spiral/Spiral.c b/src/Spiral/Spiral.c
  2229. index 05a3361..619b60a 100644
  2230. --- a/src/Spiral/Spiral.c
  2231. +++ b/src/Spiral/Spiral.c
  2232. @@ -3,6 +3,7 @@
  2233. #include <math.h>
  2234. #include <stdint.h>
  2235. #include <stdlib.h>
  2236. +#include "../optimizations.h"
  2237. #define SPIRAL_URI "https://hannesbraun.net/ns/lv2/airwindows/spiral"
  2238. @@ -16,14 +17,11 @@ typedef enum {
  2239. typedef struct {
  2240. const float* input[2];
  2241. float* output[2];
  2242. -
  2243. - uint32_t fpdL;
  2244. - uint32_t fpdR;
  2245. } Spiral;
  2246. static LV2_Handle instantiate(
  2247. const LV2_Descriptor* descriptor,
  2248. - double rate,
  2249. + realdouble rate,
  2250. const char* bundle_path,
  2251. const LV2_Feature* const* features)
  2252. {
  2253. @@ -51,14 +49,7 @@ static void connect_port(LV2_Handle instance, uint32_t port, void* data)
  2254. }
  2255. }
  2256. -static void activate(LV2_Handle instance)
  2257. -{
  2258. - Spiral* spiral = (Spiral*) instance;
  2259. - spiral->fpdL = 1.0;
  2260. - while (spiral->fpdL < 16386) spiral->fpdL = rand() * UINT32_MAX;
  2261. - spiral->fpdR = 1.0;
  2262. - while (spiral->fpdR < 16386) spiral->fpdR = rand() * UINT32_MAX;
  2263. -}
  2264. +static void activate(LV2_Handle instance) {}
  2265. static void run(LV2_Handle instance, uint32_t sampleFrames)
  2266. {
  2267. @@ -73,28 +64,10 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  2268. double inputSampleL = *in1;
  2269. double inputSampleR = *in2;
  2270. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = spiral->fpdL * 1.18e-17;
  2271. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = spiral->fpdR * 1.18e-17;
  2272. -
  2273. -
  2274. //clip to 1.2533141373155 to reach maximum output
  2275. inputSampleL = sin(inputSampleL * fabs(inputSampleL)) / ((fabs(inputSampleL) == 0.0) ? 1 : fabs(inputSampleL));
  2276. inputSampleR = sin(inputSampleR * fabs(inputSampleR)) / ((fabs(inputSampleR) == 0.0) ? 1 : fabs(inputSampleR));
  2277. - //begin 32 bit stereo floating point dither
  2278. - int expon;
  2279. - frexpf((float)inputSampleL, &expon);
  2280. - spiral->fpdL ^= spiral->fpdL << 13;
  2281. - spiral->fpdL ^= spiral->fpdL >> 17;
  2282. - spiral->fpdL ^= spiral->fpdL << 5;
  2283. - inputSampleL += (((double)spiral->fpdL - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  2284. - frexpf((float)inputSampleR, &expon);
  2285. - spiral->fpdR ^= spiral->fpdR << 13;
  2286. - spiral->fpdR ^= spiral->fpdR >> 17;
  2287. - spiral->fpdR ^= spiral->fpdR << 5;
  2288. - inputSampleR += (((double)spiral->fpdR - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  2289. - //end 32 bit stereo floating point dither
  2290. -
  2291. *out1 = (float) inputSampleL;
  2292. *out2 = (float) inputSampleR;
  2293. diff --git a/src/StarChild/StarChild.c b/src/StarChild/StarChild.c
  2294. index c45f41d..e16f9ef 100644
  2295. --- a/src/StarChild/StarChild.c
  2296. +++ b/src/StarChild/StarChild.c
  2297. @@ -3,6 +3,7 @@
  2298. #include <math.h>
  2299. #include <stdint.h>
  2300. #include <stdlib.h>
  2301. +#include "../optimizations.h"
  2302. #define STARCHILD_URI "https://hannesbraun.net/ns/lv2/airwindows/starchild"
  2303. @@ -23,8 +24,6 @@ typedef struct {
  2304. const float* grain;
  2305. const float* drywet;
  2306. - uint32_t fpdL;
  2307. - uint32_t fpdR;
  2308. //default stuff
  2309. double d[45102];
  2310. @@ -47,7 +46,7 @@ typedef struct {
  2311. static LV2_Handle instantiate(
  2312. const LV2_Descriptor* descriptor,
  2313. - double rate,
  2314. + realdouble rate,
  2315. const char* bundle_path,
  2316. const LV2_Feature* const* features)
  2317. {
  2318. @@ -303,11 +302,6 @@ static void activate(LV2_Handle instance)
  2319. starchild->pitchCounter = 2;
  2320. starchild->increment = 1;
  2321. starchild->dutyCycle = 1;
  2322. -
  2323. - starchild->fpdL = 1.0;
  2324. - while (starchild->fpdL < 16386) starchild->fpdL = rand() * UINT32_MAX;
  2325. - starchild->fpdR = 1.0;
  2326. - while (starchild->fpdR < 16386) starchild->fpdR = rand() * UINT32_MAX;
  2327. }
  2328. static void run(LV2_Handle instance, uint32_t sampleFrames)
  2329. @@ -437,8 +431,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  2330. while (sampleFrames-- > 0) {
  2331. inputSampleL = *in1;
  2332. inputSampleR = *in2;
  2333. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = starchild->fpdL * 1.18e-17;
  2334. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = starchild->fpdR * 1.18e-17;
  2335. drySampleL = inputSampleL;
  2336. drySampleR = inputSampleR;
  2337. @@ -1058,20 +1050,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  2338. inputSampleR += drySampleR;
  2339. //here we combine the tanks with the dry signal
  2340. - //begin 32 bit stereo floating point dither
  2341. - int expon;
  2342. - frexpf((float)inputSampleL, &expon);
  2343. - starchild->fpdL ^= starchild->fpdL << 13;
  2344. - starchild->fpdL ^= starchild->fpdL >> 17;
  2345. - starchild->fpdL ^= starchild->fpdL << 5;
  2346. - inputSampleL += (((double)starchild->fpdL - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  2347. - frexpf((float)inputSampleR, &expon);
  2348. - starchild->fpdR ^= starchild->fpdR << 13;
  2349. - starchild->fpdR ^= starchild->fpdR >> 17;
  2350. - starchild->fpdR ^= starchild->fpdR << 5;
  2351. - inputSampleR += (((double)starchild->fpdR - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  2352. - //end 32 bit stereo floating point dither
  2353. -
  2354. *out1 = (float) inputSampleL;
  2355. *out2 = (float) inputSampleR;
  2356. diff --git a/src/SubsOnly/SubsOnly.c b/src/SubsOnly/SubsOnly.c
  2357. index 886ae22..e649464 100644
  2358. --- a/src/SubsOnly/SubsOnly.c
  2359. +++ b/src/SubsOnly/SubsOnly.c
  2360. @@ -3,6 +3,7 @@
  2361. #include <math.h>
  2362. #include <stdint.h>
  2363. #include <stdlib.h>
  2364. +#include "../optimizations.h"
  2365. #define SUBSONLY_URI "https://hannesbraun.net/ns/lv2/airwindows/subsonly"
  2366. @@ -71,14 +72,11 @@ typedef struct {
  2367. double iirSampleXR;
  2368. double iirSampleYR;
  2369. double iirSampleZR;
  2370. -
  2371. - uint32_t fpdL;
  2372. - uint32_t fpdR;
  2373. } SubsOnly;
  2374. static LV2_Handle instantiate(
  2375. const LV2_Descriptor* descriptor,
  2376. - double rate,
  2377. + realdouble rate,
  2378. const char* bundle_path,
  2379. const LV2_Feature* const* features)
  2380. {
  2381. @@ -188,8 +186,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  2382. while (sampleFrames-- > 0) {
  2383. inputSampleL = *in1;
  2384. inputSampleR = *in2;
  2385. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = subsonly->fpdL * 1.18e-17;
  2386. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = subsonly->fpdR * 1.18e-17;
  2387. gain = gaintarget;
  2388. diff --git a/src/Ultrasonic/Ultrasonic.c b/src/Ultrasonic/Ultrasonic.c
  2389. index 57b2398..6aacb3b 100644
  2390. --- a/src/Ultrasonic/Ultrasonic.c
  2391. +++ b/src/Ultrasonic/Ultrasonic.c
  2392. @@ -3,6 +3,7 @@
  2393. #include <math.h>
  2394. #include <stdint.h>
  2395. #include <stdlib.h>
  2396. +#include "../optimizations.h"
  2397. #define ULTRASONIC_URI "https://hannesbraun.net/ns/lv2/airwindows/ultrasonic"
  2398. @@ -22,13 +23,11 @@ typedef struct {
  2399. double biquadC[15];
  2400. double biquadD[15];
  2401. double biquadE[15];
  2402. - uint32_t fpdL;
  2403. - uint32_t fpdR;
  2404. } Ultrasonic;
  2405. static LV2_Handle instantiate(
  2406. const LV2_Descriptor* descriptor,
  2407. - double rate,
  2408. + realdouble rate,
  2409. const char* bundle_path,
  2410. const LV2_Feature* const* features)
  2411. {
  2412. @@ -66,10 +65,6 @@ static void activate(LV2_Handle instance)
  2413. ultrasonic->biquadD[x] = 0.0;
  2414. ultrasonic->biquadE[x] = 0.0;
  2415. }
  2416. - ultrasonic->fpdL = 1.0;
  2417. - while (ultrasonic->fpdL < 16386) ultrasonic->fpdL = rand() * UINT32_MAX;
  2418. - ultrasonic->fpdR = 1.0;
  2419. - while (ultrasonic->fpdR < 16386) ultrasonic->fpdR = rand() * UINT32_MAX;
  2420. }
  2421. static void run(LV2_Handle instance, uint32_t sampleFrames)
  2422. @@ -136,8 +131,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  2423. while (sampleFrames-- > 0) {
  2424. double inputSampleL = *in1;
  2425. double inputSampleR = *in2;
  2426. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = ultrasonic->fpdL * 1.18e-17;
  2427. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = ultrasonic->fpdR * 1.18e-17;
  2428. double outSampleL = ultrasonic->biquadA[2] * inputSampleL + ultrasonic->biquadA[3] * ultrasonic->biquadA[7] + ultrasonic->biquadA[4] * ultrasonic->biquadA[8] - ultrasonic->biquadA[5] * ultrasonic->biquadA[9] - ultrasonic->biquadA[6] * ultrasonic->biquadA[10];
  2429. ultrasonic->biquadA[8] = ultrasonic->biquadA[7];
  2430. @@ -209,20 +202,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  2431. ultrasonic->biquadE[14] = ultrasonic->biquadE[13];
  2432. ultrasonic->biquadE[13] = inputSampleR; // DF1 right
  2433. - //begin 32 bit stereo floating point dither
  2434. - int expon;
  2435. - frexpf((float)inputSampleL, &expon);
  2436. - ultrasonic->fpdL ^= ultrasonic->fpdL << 13;
  2437. - ultrasonic->fpdL ^= ultrasonic->fpdL >> 17;
  2438. - ultrasonic->fpdL ^= ultrasonic->fpdL << 5;
  2439. - inputSampleL += (((double)ultrasonic->fpdL - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  2440. - frexpf((float)inputSampleR, &expon);
  2441. - ultrasonic->fpdR ^= ultrasonic->fpdR << 13;
  2442. - ultrasonic->fpdR ^= ultrasonic->fpdR >> 17;
  2443. - ultrasonic->fpdR ^= ultrasonic->fpdR << 5;
  2444. - inputSampleR += (((double)ultrasonic->fpdR - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  2445. - //end 32 bit stereo floating point dither
  2446. -
  2447. *out1 = (float) inputSampleL;
  2448. *out2 = (float) inputSampleR;
  2449. diff --git a/src/UltrasonicLite/UltrasonicLite.c b/src/UltrasonicLite/UltrasonicLite.c
  2450. index f73d3f5..ef932f2 100644
  2451. --- a/src/UltrasonicLite/UltrasonicLite.c
  2452. +++ b/src/UltrasonicLite/UltrasonicLite.c
  2453. @@ -3,6 +3,7 @@
  2454. #include <math.h>
  2455. #include <stdint.h>
  2456. #include <stdlib.h>
  2457. +#include "../optimizations.h"
  2458. #define ULTRASONICLITE_URI "https://hannesbraun.net/ns/lv2/airwindows/ultrasoniclite"
  2459. @@ -18,13 +19,11 @@ typedef struct {
  2460. const float* input[2];
  2461. float* output[2];
  2462. double biquadA[15];
  2463. - uint32_t fpdL;
  2464. - uint32_t fpdR;
  2465. } UltrasonicLite;
  2466. static LV2_Handle instantiate(
  2467. const LV2_Descriptor* descriptor,
  2468. - double rate,
  2469. + realdouble rate,
  2470. const char* bundle_path,
  2471. const LV2_Feature* const* features)
  2472. {
  2473. @@ -58,10 +57,6 @@ static void activate(LV2_Handle instance)
  2474. for (int x = 0; x < 15; x++) {
  2475. ultrasoniclite->biquadA[x] = 0.0;
  2476. }
  2477. - ultrasoniclite->fpdL = 1.0;
  2478. - while (ultrasoniclite->fpdL < 16386) ultrasoniclite->fpdL = rand() * UINT32_MAX;
  2479. - ultrasoniclite->fpdR = 1.0;
  2480. - while (ultrasoniclite->fpdR < 16386) ultrasoniclite->fpdR = rand() * UINT32_MAX;
  2481. }
  2482. static void run(LV2_Handle instance, uint32_t sampleFrames)
  2483. @@ -90,8 +85,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  2484. while (sampleFrames-- > 0) {
  2485. double inputSampleL = *in1;
  2486. double inputSampleR = *in2;
  2487. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = ultrasoniclite->fpdL * 1.18e-17;
  2488. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = ultrasoniclite->fpdR * 1.18e-17;
  2489. double outSampleL = ultrasoniclite->biquadA[2] * inputSampleL + ultrasoniclite->biquadA[3] * ultrasoniclite->biquadA[7] + ultrasoniclite->biquadA[4] * ultrasoniclite->biquadA[8] - ultrasoniclite->biquadA[5] * ultrasoniclite->biquadA[9] - ultrasoniclite->biquadA[6] * ultrasoniclite->biquadA[10];
  2490. ultrasoniclite->biquadA[8] = ultrasoniclite->biquadA[7];
  2491. @@ -107,20 +100,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  2492. ultrasoniclite->biquadA[14] = ultrasoniclite->biquadA[13];
  2493. ultrasoniclite->biquadA[13] = inputSampleR; //DF1 right
  2494. - //begin 32 bit stereo floating point dither
  2495. - int expon;
  2496. - frexpf((float)inputSampleL, &expon);
  2497. - ultrasoniclite->fpdL ^= ultrasoniclite->fpdL << 13;
  2498. - ultrasoniclite->fpdL ^= ultrasoniclite->fpdL >> 17;
  2499. - ultrasoniclite->fpdL ^= ultrasoniclite->fpdL << 5;
  2500. - inputSampleL += (((double)ultrasoniclite->fpdL - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  2501. - frexpf((float)inputSampleR, &expon);
  2502. - ultrasoniclite->fpdR ^= ultrasoniclite->fpdR << 13;
  2503. - ultrasoniclite->fpdR ^= ultrasoniclite->fpdR >> 17;
  2504. - ultrasoniclite->fpdR ^= ultrasoniclite->fpdR << 5;
  2505. - inputSampleR += (((double)ultrasoniclite->fpdR - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  2506. - //end 32 bit stereo floating point dither
  2507. -
  2508. *out1 = (float) inputSampleL;
  2509. *out2 = (float) inputSampleR;
  2510. diff --git a/src/UltrasonicMed/UltrasonicMed.c b/src/UltrasonicMed/UltrasonicMed.c
  2511. index 2231697..29d91be 100644
  2512. --- a/src/UltrasonicMed/UltrasonicMed.c
  2513. +++ b/src/UltrasonicMed/UltrasonicMed.c
  2514. @@ -3,6 +3,7 @@
  2515. #include <math.h>
  2516. #include <stdint.h>
  2517. #include <stdlib.h>
  2518. +#include "../optimizations.h"
  2519. #define ULTRASONICMED_URI "https://hannesbraun.net/ns/lv2/airwindows/ultrasonicmed"
  2520. @@ -19,13 +20,11 @@ typedef struct {
  2521. float* output[2];
  2522. double biquadA[15];
  2523. double biquadB[15];
  2524. - uint32_t fpdL;
  2525. - uint32_t fpdR;
  2526. } UltrasonicMed;
  2527. static LV2_Handle instantiate(
  2528. const LV2_Descriptor* descriptor,
  2529. - double rate,
  2530. + realdouble rate,
  2531. const char* bundle_path,
  2532. const LV2_Feature* const* features)
  2533. {
  2534. @@ -61,10 +60,6 @@ static void activate(LV2_Handle instance)
  2535. ultrasonicMed->biquadA[x] = 0.0;
  2536. ultrasonicMed->biquadB[x] = 0.0;
  2537. }
  2538. - ultrasonicMed->fpdL = 1.0;
  2539. - while (ultrasonicMed->fpdL < 16386) ultrasonicMed->fpdL = rand() * UINT32_MAX;
  2540. - ultrasonicMed->fpdR = 1.0;
  2541. - while (ultrasonicMed->fpdR < 16386) ultrasonicMed->fpdR = rand() * UINT32_MAX;
  2542. }
  2543. static void run(LV2_Handle instance, uint32_t sampleFrames)
  2544. @@ -105,8 +100,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  2545. while (sampleFrames-- > 0) {
  2546. double inputSampleL = *in1;
  2547. double inputSampleR = *in2;
  2548. - if (fabs(inputSampleL) < 1.18e-23) inputSampleL = ultrasonicMed->fpdL * 1.18e-17;
  2549. - if (fabs(inputSampleR) < 1.18e-23) inputSampleR = ultrasonicMed->fpdR * 1.18e-17;
  2550. double outSampleL = ultrasonicMed->biquadA[2] * inputSampleL + ultrasonicMed->biquadA[3] * ultrasonicMed->biquadA[7] + ultrasonicMed->biquadA[4] * ultrasonicMed->biquadA[8] - ultrasonicMed->biquadA[5] * ultrasonicMed->biquadA[9] - ultrasonicMed->biquadA[6] * ultrasonicMed->biquadA[10];
  2551. ultrasonicMed->biquadA[8] = ultrasonicMed->biquadA[7];
  2552. @@ -136,20 +129,6 @@ static void run(LV2_Handle instance, uint32_t sampleFrames)
  2553. ultrasonicMed->biquadB[14] = ultrasonicMed->biquadB[13];
  2554. ultrasonicMed->biquadB[13] = inputSampleR; //DF1 right
  2555. - //begin 32 bit stereo floating point dither
  2556. - int expon;
  2557. - frexpf((float)inputSampleL, &expon);
  2558. - ultrasonicMed->fpdL ^= ultrasonicMed->fpdL << 13;
  2559. - ultrasonicMed->fpdL ^= ultrasonicMed->fpdL >> 17;
  2560. - ultrasonicMed->fpdL ^= ultrasonicMed->fpdL << 5;
  2561. - inputSampleL += (((double)ultrasonicMed->fpdL - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  2562. - frexpf((float)inputSampleR, &expon);
  2563. - ultrasonicMed->fpdR ^= ultrasonicMed->fpdR << 13;
  2564. - ultrasonicMed->fpdR ^= ultrasonicMed->fpdR >> 17;
  2565. - ultrasonicMed->fpdR ^= ultrasonicMed->fpdR << 5;
  2566. - inputSampleR += (((double)ultrasonicMed->fpdR - (uint32_t)0x7fffffff) * 5.5e-36l * pow(2, expon + 62));
  2567. - //end 32 bit stereo floating point dither
  2568. -
  2569. *out1 = (float) inputSampleL;
  2570. *out2 = (float) inputSampleR;
  2571. diff --git a/src/optimizations.h b/src/optimizations.h
  2572. new file mode 100644
  2573. index 0000000..8670aea
  2574. --- /dev/null
  2575. +++ b/src/optimizations.h
  2576. @@ -0,0 +1,25 @@
  2577. +#include <math.h>
  2578. +#include <stdint.h>
  2579. +#include <stdlib.h>
  2580. +
  2581. +// force doubles into floats
  2582. +typedef double realdouble;
  2583. +#define double float
  2584. +#define asin asinf
  2585. +#define atan2 atan2f
  2586. +#define cos cosf
  2587. +#define exp expf
  2588. +#define exp2 exp2f
  2589. +#define fabs fabsf
  2590. +#define log2 log2f
  2591. +#define log10 log10f
  2592. +#define pow powf
  2593. +#define sin sinf
  2594. +#define tan tanf
  2595. +
  2596. +// ensure denormal things is unused
  2597. +#define fpdL error-if-fpdL-is-used
  2598. +#define fpdR error-if-fpdR-is-used
  2599. +
  2600. +// ensure 32bit dithering is unused
  2601. +#define frexpf error-if-frexpf-is-used