diff --git a/src/audio/volume/volume.c b/src/audio/volume/volume.c index a74ba5d4e6c4..47f15e118c5a 100644 --- a/src/audio/volume/volume.c +++ b/src/audio/volume/volume.c @@ -232,14 +232,14 @@ static inline int32_t volume_windows_fade_ramp(struct vol_data *cd, int32_t ramp { int32_t time_ratio; /* Q2.30 */ int32_t pow_value; /* Q2.30 */ - int32_t volume_delta = cd->tvolume[channel] - cd->rvolume[channel]; /* Q16.16 */ if (!cd->initial_ramp) return cd->tvolume[channel]; time_ratio = (((int64_t)ramp_time) << 30) / (cd->initial_ramp << 3); pow_value = volume_pow_175(time_ratio); - return cd->rvolume[channel] + Q_MULTSR_32X32((int64_t)volume_delta, pow_value, 16, 30, 16); + return cd->rvolume[channel] + Q_MULTSR_32X32((int64_t)cd->volume_delta[channel], + pow_value, 16, 30, 16); } #endif @@ -452,6 +452,7 @@ int volume_set_chan(struct processing_module *mod, int chan, cd->tvolume[chan] = v; cd->rvolume[chan] = cd->volume[chan]; + cd->volume_delta[chan] = v - cd->volume[chan]; cd->vol_ramp_elapsed_frames = 0; /* Check ramp type */ diff --git a/src/audio/volume/volume.h b/src/audio/volume/volume.h index b1c2bb18c817..f48b975d8097 100644 --- a/src/audio/volume/volume.h +++ b/src/audio/volume/volume.h @@ -156,6 +156,7 @@ struct vol_data { int32_t tvolume[SOF_IPC_MAX_CHANNELS]; /**< target volume */ int32_t mvolume[SOF_IPC_MAX_CHANNELS]; /**< mute volume */ int32_t rvolume[SOF_IPC_MAX_CHANNELS]; /**< ramp start volume */ + int32_t volume_delta[SOF_IPC_MAX_CHANNELS]; /**< delta volume */ int32_t ramp_coef[SOF_IPC_MAX_CHANNELS]; /**< parameter for slope */ /**< store current volume 4 times for scale_vol function */ int32_t *vol; diff --git a/src/audio/volume/volume_ipc4.c b/src/audio/volume/volume_ipc4.c index f246792c2d1e..dc575a881b37 100644 --- a/src/audio/volume/volume_ipc4.c +++ b/src/audio/volume/volume_ipc4.c @@ -171,6 +171,8 @@ int volume_init(struct processing_module *mod) target_volume[channel_cfg], vol->config[channel_cfg].curve_type, vol->config[channel_cfg].curve_duration); + + cd->volume_delta[channel] = target_volume[channel] - cd->volume[channel]; } init_ramp(cd, vol->config[0].curve_duration, target_volume[0]);