History

new lookup table generation for skewed parameters

Jeffrey Snyder committed 4 years ago

Commit d8a0ee61 parent e66fa0c1 file · +10 −10Browse files

Unified · Split

leaf/Src/leaf-math.c+10−10
@@ -556,7 +556,7 @@ void LEAF_generate_square(float* buffer, float basefreq, int size, LEAF* const l · 555 unmodified lines
556//0.001 base gives a good curve that goes from 1 to near zero556//0.001 base gives a good curve that goes from 1 to near zero
557void LEAF_generate_exp(float* buffer, float base, float start, float end, float offset, int size)557void LEAF_generate_exp(float* buffer, float base, float start, float end, float offset, int size)
558{558{
559 float increment = (end - start) / (float)size;559 float increment = (end - start) / (float)(size-1);
560 float x = start;560 float x = start;
561 for (int i = 0; i < size; i++)561 for (int i = 0; i < size; i++)
562 {562 {
@@ -565,17 +565,17 @@ void LEAF_generate_exp(float* buffer, float base, float start, float end, float · 2 unmodified lines
565 }565 }
566}566}
567 567
568//0.001 base gives a good curve that goes from 1 to near zero568//
569void LEAF_generate_table_skew_non_sym(float* buffer, float start, float end, float center, int size)569void LEAF_generate_table_skew_non_sym(float* buffer, float start, float end, float center, int size)
570{570{
571 float skew = logf (0.5f) / logf ((center - start) / (end - start));571 double skew = log (0.5) / log ((center - start) / (end - start));
572 float increment = (end - start) / (float)size;572 double increment = 1.0 / (double)(size-1);
573 float x = start;573 double x = 0.0;
574 float proportion = 0;574 double proportion = 0.0;
575 for (int i = 0; i < size; i++)575 for (int i = 0; i < size; i++)
576 {576 {
577 proportion = expf (logf (x) / skew);577 proportion = exp (log(x) / skew);
578 buffer[i] = start + (end - start) * proportion;578 buffer[i] = (float)(start + (end - start) * proportion);
579 x += increment;579 x += increment;
580 }580 }
581}581}
@@ -583,7 +583,7 @@ void LEAF_generate_table_skew_non_sym(float* buffer, float start, float end, flo · 1 unmodified line
583 583
584void LEAF_generate_atodb(float* buffer, int size)584void LEAF_generate_atodb(float* buffer, int size)
585{585{
586 float increment = 1.0f / (float)size;586 float increment = 1.0f / (float)(size-1);
587 float x = 0.0f;587 float x = 0.0f;
588 for (int i = 0; i < size; i++)588 for (int i = 0; i < size; i++)
589 {589 {
@@ -595,7 +595,7 @@ void LEAF_generate_atodb(float* buffer, int size) · 5 unmodified lines
595 595
596void LEAF_generate_atodbPositiveClipped(float* buffer, float lowerThreshold, float range, int size)596void LEAF_generate_atodbPositiveClipped(float* buffer, float lowerThreshold, float range, int size)
597{597{
598 float increment = 1.0f / (float)size;598 float increment = 1.0f / (float)(size-1);
599 float x = 0.0f;599 float x = 0.0f;
600 float scalar = range / fastabsf(lowerThreshold);600 float scalar = range / fastabsf(lowerThreshold);
601 for (int i = 0; i < size; i++)601 for (int i = 0; i < size; i++)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t