CRI ADX  Last Updated: 2024-07-17 10:48 p
插入DSP(时间拉伸)

示例目录

/cri/pc/samples/criatomex/insertion_dsp_time_stretch


示例描述

在不更改音高的情况下更改播放速度的时间拉伸功能示例。
由于时间拉伸会更改时间的长度,因此不能设置为DSP总线效果。
必须附加到Voice中才能使用。

使用时间拉伸功能的步骤如下。
  1. 使用::criAtomExVoicePool_AttachDspTimeStretch函数为Voice池添加时间拉伸功能
  2. 使用::criAtomExPlayer_SetVoicePoolIdentifier函数为Player设置带有时间拉伸的Voice池标识符
  3. 使用::criAtomExPlayer_SetDspParamteter函数为Player设置时间拉伸的参数。
  4. 用Player执行播放。
时间拉伸的参数如下。
使用时间拉伸功能的示例代码如下。
#define TIME_STRETCH_VOICEPOOL 0x02
/* 设置Voice池的配置 */
voice_pool_config.identifier = TIME_STRETCH_VOICEPOOL;
/* 创建Voice池 */
app_obj->voice_pool = criAtomExVoicePool_AllocateStandardVoicePool(&voice_pool_config, NULL, 0);
/* 设置时间拉伸的配置 */
CriAtomExDspTimeStretchConfig time_stretch_config;
time_stretch_config.num_dsp = voice_pool_config.num_voices;
time_stretch_config.max_channels = voice_pool_config.player_config.max_channels;
time_stretch_config.max_sampling_rate = voice_pool_config.player_config.max_sampling_rate;
/* 添加时间拉伸 */
criAtomExVoicePool_AttachDspTimeStretch(&app_obj->voice_pool, &time_stretch_config, NULL, 0);
/* 设置Voice池标识符 */
criAtomExPlayer_SetVoicePoolIdentifier(app_obj->player, TIME_STRETCH_VOICEPOOL);
/* 将时间延长1.2倍(减慢) */
/* 开始播放 */
criAtomExPlayer_Start(app_obj->player);
#define criAtomExVoicePool_SetDefaultConfigForDspTimeStretch(p_config)
Assign the default values to the configuration structure used to attach a time-streching DSP
Definition: cri_le_atom_ex.h:1141
void criAtomExVoicePool_AttachDspTimeStretch(CriAtomExVoicePoolHn pool, const CriAtomExDspTimeStretchConfig *config, void *work, CriSint32 work_size)
Attach a time-stretching DSP
void criAtomExPlayer_SetVoicePoolIdentifier(CriAtomExPlayerHn player, CriAtomExVoicePoolIdentifier identifier)
Specify the Voice Pool identifier
CriAtomExPlaybackId criAtomExPlayer_Start(CriAtomExPlayerHn player)
Start the playback
void criAtomExPlayer_SetDspParameter(CriAtomExPlayerHn player, CriSint32 param_id, CriFloat32 param_val)
Set a DSP parameter
#define criAtomExVoicePool_SetDefaultConfigForStandardVoicePool(p_config)
Assign the default values to the configuration structure used to create a standard Voice Pool
Definition: cri_le_atom_ex.h:564
CriAtomExVoicePoolHn criAtomExVoicePool_AllocateStandardVoicePool(const CriAtomExStandardVoicePoolConfig *config, void *work, CriSint32 work_size)
Create a standard Voice Pool
@ CRIATOMDSP_TIMESTRETCH_PARAM_RATIO
Stretch ratio
Definition: cri_le_atom.h:2775
Configuration structure used to attach a time-stretching effect
Definition: cri_le_atom_ex.h:4934
CriSint32 num_dsp
Number of DSPs created
Definition: cri_le_atom_ex.h:4940
CriSint32 max_sampling_rate
Maximum sampling rate used for DSP
Definition: cri_le_atom_ex.h:4956
CriSint32 max_channels
Maximum number of channels for DSP
Definition: cri_le_atom_ex.h:4948
Configuration structure used when creating a standard Voice Pool
Definition: cri_le_atom_ex.h:3255
注意
无法为HCA-MX的声音应用时间拉伸。

要使用时间拉伸功能时,请使用ADX或HCA。


示例使用的数据中AtomCraft项目的目录

/cri/tools/criatomex/examples/tutorial_data_for_runtime