hrtf virtual surround matlab实现
Posted fellow1988
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了hrtf virtual surround matlab实现相关的知识,希望对你有一定的参考价值。
将5.1 ch的数据经过hrtf处理,然后downmix到2ch,使得2ch的数据有virtual surround的效果。
function output = hrir_process(input)
hrtf = load("E:CIPIC_hrtf_databasestandard_hrir_databasesubject_21hrir_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‘);
以上是关于hrtf virtual surround matlab实现的主要内容,如果未能解决你的问题,请参考以下文章
哪位大侠给我讲讲c#中virtual, abstract和override的区别和用法,不胜感激,初学者,刚学这段,非常迷糊
virtualenv和conda的区别及windows 10上的部署