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
556556 //0.001 base gives a good curve that goes from 1 to near zero
557557 void LEAF_generate_exp(float* buffer, float base, float start, float end, float offset, int size)
558558 {
559− float increment = (end - start) / (float)size;
559+ float increment = (end - start) / (float)(size-1);
560560 float x = start;
561561 for (int i = 0; i < size; i++)
562562 {
@@ -565,17 +565,17 @@ void LEAF_generate_exp(float* buffer, float base, float start, float end, float · 2 unmodified lines
565565 }
566566 }
567567
568−//0.001 base gives a good curve that goes from 1 to near zero
568+//
569569 void LEAF_generate_table_skew_non_sym(float* buffer, float start, float end, float center, int size)
570570 {
571− float skew = logf (0.5f) / logf ((center - start) / (end - start));
572− float increment = (end - start) / (float)size;
573− float x = start;
574− float proportion = 0;
571+ double skew = log (0.5) / log ((center - start) / (end - start));
572+ double increment = 1.0 / (double)(size-1);
573+ double x = 0.0;
574+ double proportion = 0.0;
575575 for (int i = 0; i < size; i++)
576576 {
577− proportion = expf (logf (x) / skew);
578− buffer[i] = start + (end - start) * proportion;
577+ proportion = exp (log(x) / skew);
578+ buffer[i] = (float)(start + (end - start) * proportion);
579579 x += increment;
580580 }
581581 }
@@ -583,7 +583,7 @@ void LEAF_generate_table_skew_non_sym(float* buffer, float start, float end, flo · 1 unmodified line
583583
584584 void LEAF_generate_atodb(float* buffer, int size)
585585 {
586− float increment = 1.0f / (float)size;
586+ float increment = 1.0f / (float)(size-1);
587587 float x = 0.0f;
588588 for (int i = 0; i < size; i++)
589589 {
@@ -595,7 +595,7 @@ void LEAF_generate_atodb(float* buffer, int size) · 5 unmodified lines
595595
596596 void LEAF_generate_atodbPositiveClipped(float* buffer, float lowerThreshold, float range, int size)
597597 {
598− float increment = 1.0f / (float)size;
598+ float increment = 1.0f / (float)(size-1);
599599 float x = 0.0f;
600600 float scalar = range / fastabsf(lowerThreshold);
601601 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