间纹
3-D与头部相关的传输函数(HRTF)插值
Syntax
描述
returns the interpolated head-related transfer function (HRTF) at the desired position.InterpolatedHrtf
= InterpalyHrtf(HRTF
,源定位s
,所需的信息
)
specifies options using one or moreInterpolatedHrtf
= InterpalyHrtf(___,名称,价值
)名称,价值
配对参数。
例子
在耳机上渲染3-D音频
通过与头部相关的传输功能(HRTF)对声音文件进行过滤,修改声音文件的3-D音频图像。通过指定所需的方位角和高程来设置声源的位置。
load'ReferenthHrtf.mat'HRTFDATA源定位HRTFDATA= permute(double(hrtfData),[2,3,1]); sourcePosition = sourcePosition(:,[1,2]);
使用所需源位置的VBAP算法计算与头部相关的脉冲响应(HRIR)。分开输出,interpolatedIR
,进入左耳和右耳的冲动反应。
desiredAz = 110; desiredEl = -45; desiredPosition = [desiredAz desiredEl]; interpolatedIR = interpolateHRTF(hrtfData,sourcePosition,desiredPosition,。。。"Algorithm","VBAP");leftir = squeeze(interpolatedir(:,1,1,:))';Rightir = Squeeze(Interpolatedir(:,2,:))';
Create adsp.AudioFileReader
对象逐帧读取文件。创建一个AudioDeviceWriter
对象可以通过框架播放音频到您的声卡。创建两个dsp.FIRFilter
objects and specify the filter coefficients using the head-related transfer function interpolated impulse responses.
filereader = dsp.audiofilereader('Rockdrums-48-Stereo-11secs.mp3');deviceWriter = audioDeviceWriter ('SampleRate',fileReader.mamplater);leftFilter = dsp.firfilter('Numerator',左);RightFilter = DSP.Firfilter('Numerator',rightIR);
在音频流循环中:
在音频数据框架中阅读。
Feed the stereo audio data through the left and right HRIR filters, respectively.
加入左右通道,并将音频写入输出设备。
尽管〜ISDONE(FILEREADER)AUDIOIN = FILEREADER();leftChannel = leftFilter(Audioin(:,1));RightChannel = RightFilter(Audioin(:,2));DeviceWriter([[leftChannel,RightChannel]);结尾
As a best practice, release your System objects when complete.
release(deviceWriter) release(fileReader)
Model Moving Source Using HRIR Filtering
Create arrays of head-related impulse responses corresponding to desired source positions. Filter mono input to model a moving source.
Load the ARI HRTF dataset. Cast theHRTFDATA
要键入double,然后将其重塑为所需的维度:(源位置的数量) - by-2-by-(HRTF样本数)。使用的前两列源定位
matrix only, which correspond to the azimuth and elevation of the source in degrees.
load'ReferenthHrtf.mat'HRTFDATA源定位HRTFDATA= permute(double(hrtfData),[2,3,1]); sourcePosition = sourcePosition(:,[1,2]);
指定所需的源位置,然后使用该位置计算HRTF间纹
function. Separate the output,interpolatedIR
,进入左耳和右耳的冲动反应。
desiredAz = [-120;-60;0;60;120;0;-120;120]; desiredEl = [-90;90;45;0;-45;0;45;45]; desiredPosition = [desiredAz desiredEl]; interpolatedIR = interpolateHRTF(hrtfData,sourcePosition,desiredPosition); leftIR = squeeze(interpolatedIR(:,1,:)); rightIR = squeeze(interpolatedIR(:,2,:));
创建一个audio file sampled at 48 kHz for compatibility with the HRTF dataset.
Desiredfs = 48e3;[音频,fs] = Audioread('Counting-16-44p1-mono-15secs.wav');音频= 0.8*resplame(音频,desiredfs,fs);AudioWrite('Counting-16-48-Mono-15secs.wav',音频,Desiredfs);
Create adsp.AudioFileReader
对象逐帧读取文件。创建一个AudioDeviceWriter
对象可以通过框架播放音频到您的声卡。创建两个dsp.FIRFilter
对象NumeratorSource
调成Input port
。SettingNumeratorSource
toInput port
enables you to modify the filter coefficients while streaming.
filereader = dsp.audiofilereader('Counting-16-48-Mono-15secs.wav');deviceWriter = audioDeviceWriter ('SampleRate',fileReader.mamplater);leftFilter = dsp.firfilter('NumeratorSource','Input port');RightFilter = DSP.Firfilter('NumeratorSource','Input port');
在音频流循环中:
在音频数据框架中阅读。
Feed the audio data through the left and right HRIR filters.
加入左右通道,并将音频写入输出设备。如果您有立体声输出硬件(例如耳机),则可以随着时间的推移听到源位置的位置。
通过更新过滤器系数,以2秒的间隔修改所需的源位置。
durationPerPosition = 2; samplesPerPosition = durationPerPosition*fileReader.SampleRate; samplesPerPosition = samplesPerPosition - rem(samplesPerPosition,fileReader.SamplesPerFrame); sourcePositionIndex = 1; samplesRead = 0;尽管〜ISDONE(FILEREADER)AUDIOIN = FILEREADER();samplesRead = samplesRead + filereader.samplesperframe;leftChannel = leftFilter(audioin,leftir(sourcePositionIndex,:));RightChannel = RightFilter(Audioin,Rightir(sourcePositionIndex,:));DeviceWriter([[leftChannel,RightChannel]);如果mod(samplesRead,samplesperposition)== 0 sourcePositionIndex = sourcePositionIndex + 1;结尾结尾
As a best practice, release your System objects when complete.
release(deviceWriter) release(fileReader)
输入参数
HRTF
—在源位置测得的HRTF值
N-by-2-by-M大批
在源位置测量的HRTF值,指定为N-by-2-by-M大批。
N- - 已知的HRTF对数量
M- - 每个已知HRTF中的样品数量
如果指定HRTF
with real numbers, the function assumes that the input represents an impulse response, andMcorresponds to the length of the impulse response. If you specifyHRTF
with complex numbers, the function assumes that the input represents a transfer function, andM对应于频率响应中的垃圾箱数量。输出间纹
function has the same complexity and interpretation as the input.
数据类型:single
|双倍的
Complex Number Support:Yes
源定位s
—对应于测得的HRTF值的源位置
N-by-2矩阵
对应于测得的HRTF值的源位置, specified as aN-by-2矩阵。Nis the number of known HRTF pairs. The two columns correspond to the azimuth and elevation of the source in degrees, respectively.
方位角必须在[-180,360]范围内。您可以使用-180至180惯例或0至360惯例。
Elevation must be in the range [−90,180]. You can use the −90 to 90 convention or the 0 to 180 convention.
数据类型:single
|双倍的
所需的信息
—HRTF插值的所需源位置
P-by-2矩阵
Desired source position for HRTF interpolation, specified as aP-by-2矩阵。P是所需的源位置的数量。这些列分别对应于所需的方位角和源的高度。
方位角必须在[-180,360]范围内。您可以使用-180至180惯例或0至360惯例。
Elevation must be in the range [−90,180]. You can use the −90 to 90 convention or the 0 to 180 convention.
数据类型:single
|双倍的
Name-Value Arguments
将可选的参数对Name1=Value1,...,NameN=ValueN
, 在哪里Name
is the argument name and价值
是相应的值。名称值参数必须在其他参数之后出现,但是对的顺序并不重要。
Before R2021a, use commas to separate each name and value, and encloseName
用引号。
例子:'算法','vbap'
Output Arguments
InterpolatedHrtf
— Interpolated HRTF
P-by-2-by-M
插值HRTF,返回为P-by-2-by-M大批。
InterpolatedHrtf
has the same complexity and interpretation as the input. If you specify the input,HRTF
, with real numbers, the function assumes that the input represents an impulse response. If you specify the input with complex numbers, the function assumes that the input represents a transfer function.
数据类型:single
|双倍的
Complex Number Support:Yes
参考
[1] F.P.Freeland,L.W.P。Biscainho和P.S.R.Diniz,“与头部相关转移功能(HRTFS)的插值:一种多源方法”。2004 12th European Signal Processing Conference。维也纳,2004年,第1761–1764页。
[2]普尔基,维尔。“使用基于矢量的振幅平移的虚拟声源定位。”Journal of Audio Engineering Society。卷。45.第6期,第456–466页。
Extended Capabilities
C/C ++代码生成
使用MATLAB®CODER™生成C和C ++代码。
Version History
matlab命令
You clicked a link that corresponds to this MATLAB command:
通过在MATLAB命令窗口中输入该命令。Web浏览器不支持MATLAB命令。万博1manbetx
选择一个网站
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:。
您还可以从以下列表中选择一个网站:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
美洲
- AméricaLatina(Español)
- 加拿大(英语)
- 美国(英语)