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.

3201 lines
109KB

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