• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

hrtfvirtualsurroundmatlab实现

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

将5.1 ch的数据经过hrtf处理,然后downmix到2ch,使得2ch的数据有virtual surround的效果。

 

function output = hrir_process(input)

hrtf = load("E:\CIPIC_hrtf_database\standard_hrir_database\subject_21\hrir_final.mat");

Ls = [1 9];

L = [8 9];

R= [17 9];

Rs = [25 9];

C = [13 9]

%source from 5.1 to L ch

h_l_l = squeeze(hrtf.hrir_l(L(1), L(2), :));

h_r_l = squeeze(hrtf.hrir_l(R(1), R(2), :));

h_ls_l = squeeze(hrtf.hrir_l(Ls(1), Ls(2), :));

h_rs_l = squeeze(hrtf.hrir_l(Rs(1), Rs(2), :));

h_c_l = squeeze(hrtf.hrir_l(C(1), C(2), :));

%source from 5.1 to R ch

h_l_r = squeeze(hrtf.hrir_r(L(1), L(2), :));

h_r_r = squeeze(hrtf.hrir_r(R(1), R(2), :));

h_ls_r = squeeze(hrtf.hrir_r(Ls(1), Ls(2), :));

h_rs_r = squeeze(hrtf.hrir_r(Rs(1), Rs(2), :));

h_c_r = squeeze(hrtf.hrir_r(C(1), C(2), :));

[input, fs] = wavread('input.wav');

h_l = zeros(length(h_l_l), 6);

h_l(:, 1) = h_l_l;

h_l(:, 2) = h_r_l;

h_l(:, 3) = h_c_l;

h_l(:, 5) = h_ls_l;

h_l(:, 6) = h_rs_l;

h_r = zeros(length(h_l_r), 6);

h_r(:, 1) = h_l_r;

h_r(:, 2) = h_r_r;

h_r(:, 3) = h_c_r;

h_r(:, 5) = h_ls_r;

h_r(:, 6) = h_rs_r;

hrir_out_l = zeros(length(input(:, 1), length(1, :));

hrir_out_r = zeros(length(input(:, 1), length(1, :));

for ch = 1:1:6

  hrir_out_l(:, ch) = filter(h_l(:, ch), 1, input(:, ch));

  hrir_out_r(:, ch) = filter(h_r(:, ch), 1, input(:, ch));

 end

cmix = 0.707/2;

surmix = 1.0 / 2;

xsurmix = 0.5 /2;

%downmix to 2ch.

%output(:,1) = hrir_out_l(:, 1) + hrir_out_l(:, 3) * cmix - hrir_out_l(:, 5) * surmix - hrir_out_l(:, 6) * xsurmix ;

%output(:,2) = hrir_out_r(:, 2) + hrir_out_r(:, 3) * cmix +hrir_out_r(:, 6) * surmix + hrir_out_r(:, 5) * xsurmix;

%output(:,1) = hrir_out_l(:, 1) + hrir_out_l(:, 3) * cmix + hrir_out_l(:, 5) * surmix + hrir_out_l(:, 2) * xsurmix ;

%output(:,2) = hrir_out_r(:, 2) + hrir_out_r(:, 3) * cmix +hrir_out_r(:, 6) * surmix + hrir_out_r(:, 1) * xsurmix;

output(:,1) = hrir_out_l(:, 1) + hrir_out_l(:, 3) * cmix +hrir_out_l(:, 5) * surmix;

output(:,2) = hrir_out_r(:, 2) + hrir_out_r(:, 3) * cmix +hrir_out_r(:, 6) * surmix;

end

 

 

function [loro ltrt] = downmix(input)

cmix = 0.707/2;

surmix = 1.0 / 2;

xsurmix = 0.5 /2;

L = input(:, 1);

R = input(:, 2);

C = input(: 3);

Ls = input(: 5);

Rs = input(: 6);

loro(:, 1) = L + cmix * C + surmix * Ls;

loro(:, 2) = R + cmix * C + surmix * Rs;

ltrt(:, 1) = L + cmix* C - surmix* Ls - xsurmix * Rs;

ltrt(:, 2) = R + cmix * C + surmix * Ls + xsurmix * Rs;

end

 

 

main.m:

clc:

clear all;

[input, fs] = wavread('input.wav');

y = hrir_process(input);

[loro ltrt] = dowmix('input.wav');

wavwrite(y, fs, 'output.wav');

wavwrite(loro, fs, 'loro.wav');

wavwrite(ltrt, fs, 'ltrt.wav');

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap