|
64 | 64 | /** \brief Volume trace error function. */ |
65 | 65 | #define trace_volume_error(__e) trace_error(TRACE_CLASS_VOLUME, __e) |
66 | 66 |
|
| 67 | +//** \brief Volume gain Qx.y integer x number of bits including sign bit. */ |
| 68 | +#define VOL_QXY_X 2 |
| 69 | + |
| 70 | +//** \brief Volume gain Qx.y fractional y number of bits. */ |
| 71 | +#define VOL_QXY_Y 16 |
| 72 | + |
67 | 73 | /** |
68 | | - * \brief Volume ramp time in microseconds. |
69 | | - * |
70 | | - * This should ramp from 0dB to mute in 64ms. |
71 | | - * i.e. 2^16 -> 0 in 32 * 2048 steps each lasting 2ms. |
| 74 | + * \brief Volume ramp update rate in microseconds. |
| 75 | + * Update volume gain value every 1 ms. |
72 | 76 | */ |
73 | | -#define VOL_RAMP_US 2000 |
| 77 | +#define VOL_RAMP_US 1000 |
74 | 78 |
|
75 | | -/** \brief Volume ramp step. */ |
76 | | -#define VOL_RAMP_STEP (1 << 11) |
| 79 | +/** |
| 80 | + * \brief Volume linear ramp length in milliseconds. |
| 81 | + * Use linear ramp length of 250 ms from mute to unity gain. The linear ramp |
| 82 | + * step in Q1.16 to use in vol_work function is computed from the length. |
| 83 | + */ |
| 84 | +#define VOL_RAMP_LENGTH_MS 250 |
| 85 | +#define VOL_RAMP_STEP Q_CONVERT_FLOAT(1.0 / 1000 * \ |
| 86 | + VOL_RAMP_US / VOL_RAMP_LENGTH_MS, \ |
| 87 | + VOL_QXY_Y) |
77 | 88 |
|
78 | | -/** \brief Volume maximum value. */ |
79 | | -#define VOL_MAX (1 << 16) |
| 89 | +/** |
| 90 | + * \brief Volume maximum value. |
| 91 | + * TODO: This should be 1 << (VOL_QX_BITS + VOL_QY_BITS - 1) - 1 but |
| 92 | + * the current volume code cannot handle the full Q1.16 range correctly. |
| 93 | + */ |
| 94 | +#define VOL_MAX (1 << VOL_QXY_Y) |
80 | 95 |
|
81 | 96 | /** \brief Volume minimum value. */ |
82 | 97 | #define VOL_MIN 0 |
|
0 commit comments