diff options
Diffstat (limited to 'apps/dsp.c')
-rw-r--r-- | apps/dsp.c | 38 |
1 files changed, 14 insertions, 24 deletions
diff --git a/apps/dsp.c b/apps/dsp.c index 7aab8f5c37..7292328212 100644 --- a/apps/dsp.c +++ b/apps/dsp.c | |||
@@ -137,8 +137,8 @@ struct eq_state | |||
137 | struct compressor_menu | 137 | struct compressor_menu |
138 | { | 138 | { |
139 | int threshold; /* dB - from menu */ | 139 | int threshold; /* dB - from menu */ |
140 | bool auto_gain; /* 0 = off, 1 = auto */ | ||
140 | int ratio; /* from menu */ | 141 | int ratio; /* from menu */ |
141 | int gain; /* dB - from menu */ | ||
142 | bool soft_knee; /* 0 = hard knee, 1 = soft knee */ | 142 | bool soft_knee; /* 0 = hard knee, 1 = soft knee */ |
143 | int release; /* samples - from menu */ | 143 | int release; /* samples - from menu */ |
144 | }; | 144 | }; |
@@ -1542,11 +1542,12 @@ void dsp_set_replaygain(void) | |||
1542 | 1542 | ||
1543 | /** SET COMPRESSOR | 1543 | /** SET COMPRESSOR |
1544 | * Called by the menu system to configure the compressor process */ | 1544 | * Called by the menu system to configure the compressor process */ |
1545 | void dsp_set_compressor(int c_threshold, int c_ratio, int c_gain, | 1545 | void dsp_set_compressor(int c_threshold, int c_gain, int c_ratio, |
1546 | int c_knee, int c_release) | 1546 | int c_knee, int c_release) |
1547 | { | 1547 | { |
1548 | bool changed = false; | 1548 | bool changed = false; |
1549 | bool active = (c_threshold < 0); | 1549 | bool active = (c_threshold < 0); |
1550 | bool new_auto_gain = (c_gain == 1); | ||
1550 | const int comp_ratio[] = {2, 4, 6, 10, 0}; | 1551 | const int comp_ratio[] = {2, 4, 6, 10, 0}; |
1551 | int new_ratio = comp_ratio[c_ratio]; | 1552 | int new_ratio = comp_ratio[c_ratio]; |
1552 | bool new_knee = (c_knee == 1); | 1553 | bool new_knee = (c_knee == 1); |
@@ -1560,32 +1561,22 @@ void dsp_set_compressor(int c_threshold, int c_ratio, int c_gain, | |||
1560 | c_menu.threshold, active ? "Yes" : "No"); | 1561 | c_menu.threshold, active ? "Yes" : "No"); |
1561 | } | 1562 | } |
1562 | 1563 | ||
1563 | if (c_menu.ratio != new_ratio) | 1564 | if (c_menu.auto_gain != new_auto_gain) |
1564 | { | 1565 | { |
1565 | changed = true; | 1566 | changed = true; |
1566 | c_menu.ratio = new_ratio; | 1567 | c_menu.auto_gain = new_auto_gain; |
1567 | if (c_menu.ratio) | 1568 | logf(" Compressor Makeup Gain: %s", |
1568 | { | 1569 | c_menu.auto_gain ? "Auto" : "Off"); |
1569 | logf(" Compressor Ratio: %d:1", c_menu.ratio); | ||
1570 | } | ||
1571 | else | ||
1572 | { | ||
1573 | logf(" Compressor Ratio: Limit"); | ||
1574 | } | ||
1575 | } | 1570 | } |
1576 | 1571 | ||
1577 | if (c_menu.gain != c_gain) | 1572 | if (c_menu.ratio != new_ratio) |
1578 | { | 1573 | { |
1579 | changed = true; | 1574 | changed = true; |
1580 | c_menu.gain = c_gain; | 1575 | c_menu.ratio = new_ratio; |
1581 | if (c_menu.gain >= 0) | 1576 | if (c_menu.ratio) |
1582 | { | 1577 | { logf(" Compressor Ratio: %d:1", c_menu.ratio); } |
1583 | logf(" Compressor Makeup Gain: %d dB", c_menu.gain); | ||
1584 | } | ||
1585 | else | 1578 | else |
1586 | { | 1579 | { logf(" Compressor Ratio: Limit"); } |
1587 | logf(" Compressor Makeup Gain: Auto"); | ||
1588 | } | ||
1589 | } | 1580 | } |
1590 | 1581 | ||
1591 | if (c_menu.soft_knee != new_knee) | 1582 | if (c_menu.soft_knee != new_knee) |
@@ -1731,9 +1722,8 @@ void dsp_set_compressor(int c_threshold, int c_ratio, int c_gain, | |||
1731 | #endif | 1722 | #endif |
1732 | 1723 | ||
1733 | /* if using auto peak, then makeup gain is max offset - .1dB headroom */ | 1724 | /* if using auto peak, then makeup gain is max offset - .1dB headroom */ |
1734 | int32_t db_makeup = (c_menu.gain == -1) ? | 1725 | comp_makeup_gain = c_menu.auto_gain ? |
1735 | -(db_curve[3].offset) - 0x199A : c_menu.gain << 16; | 1726 | fp_factor(-(db_curve[3].offset) - 0x199A, 16) << 8 : UNITY; |
1736 | comp_makeup_gain = fp_factor(db_makeup, 16) << 8; | ||
1737 | logf("Makeup gain:\t%.6f", (float)comp_makeup_gain / UNITY); | 1727 | logf("Makeup gain:\t%.6f", (float)comp_makeup_gain / UNITY); |
1738 | 1728 | ||
1739 | /* calculate per-sample gain change a rate of 10db over release time */ | 1729 | /* calculate per-sample gain change a rate of 10db over release time */ |