关于left / right / stereo / mono

机顶盒音频设置解析
本文详细解释了机顶盒中音频设置的工作原理,包括Left、Right、Stereo和Mono模式下不同节目源的处理方式,并通过图表清晰展示各种设置下的音频输出效果。
部署运行你感兴趣的模型镜像

机顶盒、DVD等类似的家庭娱乐多媒体产品里有音频设置:Left / Right / Stereo / Mono,简单说说在机顶盒里是如何处理的。

1)如果节目源是立体声(Stereo)的。有左(L)右(R)两个声道。

1.1)机顶盒设置为Stereo模式。
机顶盒把左声道数据送到音频输出(譬如莲花端子RCA)的左声道(譬如RCA的白色端口,标记L),把右声道数据送到音频输出的右声道(RCA的红色端口,标记R)。输出到电视上收听时,有立体声效果。

1.2)机顶盒设置为Left模式。
机顶盒把左声道数据同时送到音频输出的左右两个声道。这时只能收听到左声道声音。

1.3)机顶盒设置为Right模式。
机顶盒把右声道数据同时送到音频输出的左右两个声道。这时只能收听到右声道声音。

1.4)机顶盒设置为Mono模式。
机顶盒把左右声道数据复合(我不知道用复合这个词是否准确),同时送到音频输出的左右两个声道。这时,能听到左右声道的声音,但是没有立体声效果。

2)如果节目源只有左声道音频。

2.1)机顶盒设置为Stereo模式。
机顶盒把左声道数据送到音频输出的左声道,右声道没有数据,音频输出的右声道没有声音。

1.2)机顶盒设置为Left模式。
机顶盒把左声道数据同时送到音频输出的左右两个声道。右声道输出能听到左声道的声音。

1.3)机顶盒设置为Right模式。
右声道没有数据,音频输出的左右两个声道都没有声音。这时听不到声音。

1.4)机顶盒设置为Mono模式。
机顶盒把左右声道数据复合,这里等于只有左声道数据,同时送到音频输出的左右两个声道。音频输出的左右声道都有声音。

下面用两张表来重复描述上述情况。音频输出左和音频输出右分别表示只连接左或者右某一个输出端口测试结果。Y表示有声音,N表示没有声音。

节目源STB设置STB音频输出左STB音频输出右
LLeftY(L)Y(L)
LRightN(R)N(R)
LStereoY(L)N(R)
LMonoY(L+0)Y(L+0)

 

 

 

 

 

 

 

 

节目源STB设置STB音频输出左STB音频输出右
R+LLeftLL
R+LRightRR
R+LStereoLR
R+LMonoR+LR+L

 

 

 

 

 

 

 

参考链接:
RCA端子:http://zh.wikipedia.org/zh-cn/RCA%E7%AB%AF%E5%AD%90
关于立体声收音机的“SETREO—MONO”开关:http://blog.sina.com.cn/s/blog_59b9faf10100ag2n.html
RCA:http://en.wikipedia.org/wiki/RCA
Sound Systems:Mono versus Stereo:http://www.mcsquared.com/mono-stereo.htm

您可能感兴趣的与本文相关的镜像

Stable-Diffusion-3.5

Stable-Diffusion-3.5

图片生成
Stable-Diffusion

Stable Diffusion 3.5 (SD 3.5) 是由 Stability AI 推出的新一代文本到图像生成模型,相比 3.0 版本,它提升了图像质量、运行速度和硬件效率

enum AudioChannelLayout: uint64_t { CH_LAYOUT_UNKNOWN = 0ULL, /** Channel count: 1*/ CH_LAYOUT_MONO = FRONT_CENTER, /** Channel count: 2*/ CH_LAYOUT_STEREO = FRONT_LEFT | FRONT_RIGHT, CH_LAYOUT_STEREO_DOWNMIX = STEREO_LEFT | STEREO_RIGHT, /** Channel count: 3*/ CH_LAYOUT_2POINT1 = CH_LAYOUT_STEREO | LOW_FREQUENCY, CH_LAYOUT_3POINT0 = CH_LAYOUT_STEREO | BACK_CENTER, CH_LAYOUT_SURROUND = CH_LAYOUT_STEREO | FRONT_CENTER, /** Channel count: 4*/ CH_LAYOUT_3POINT1 = CH_LAYOUT_SURROUND | LOW_FREQUENCY, CH_LAYOUT_4POINT0 = CH_LAYOUT_SURROUND | BACK_CENTER, CH_LAYOUT_QUAD_SIDE = CH_LAYOUT_STEREO | SIDE_LEFT | SIDE_RIGHT, CH_LAYOUT_QUAD = CH_LAYOUT_STEREO | BACK_LEFT | BACK_RIGHT, CH_LAYOUT_2POINT0POINT2 = CH_LAYOUT_STEREO | TOP_SIDE_LEFT | TOP_SIDE_RIGHT, /** Channel count: 5*/ CH_LAYOUT_4POINT1 = CH_LAYOUT_4POINT0 | LOW_FREQUENCY, CH_LAYOUT_5POINT0 = CH_LAYOUT_SURROUND | SIDE_LEFT | SIDE_RIGHT, CH_LAYOUT_5POINT0_BACK = CH_LAYOUT_SURROUND | BACK_LEFT | BACK_RIGHT, CH_LAYOUT_2POINT1POINT2 = CH_LAYOUT_2POINT0POINT2 | LOW_FREQUENCY, CH_LAYOUT_3POINT0POINT2 = CH_LAYOUT_2POINT0POINT2 | FRONT_CENTER, /** Channel count: 6*/ CH_LAYOUT_5POINT1 = CH_LAYOUT_5POINT0 | LOW_FREQUENCY, CH_LAYOUT_5POINT1_BACK = CH_LAYOUT_5POINT0_BACK | LOW_FREQUENCY, CH_LAYOUT_6POINT0 = CH_LAYOUT_5POINT0 | BACK_CENTER, CH_LAYOUT_HEXAGONAL = CH_LAYOUT_5POINT0_BACK | BACK_CENTER, CH_LAYOUT_3POINT1POINT2 = CH_LAYOUT_3POINT1 | TOP_FRONT_LEFT | TOP_FRONT_RIGHT, CH_LAYOUT_6POINT0_FRONT = CH_LAYOUT_QUAD_SIDE | FRONT_LEFT_OF_CENTER | FRONT_RIGHT_OF_CENTER, /** Channel count: 7*/ CH_LAYOUT_6POINT1 = CH_LAYOUT_5POINT1 | BACK_CENTER, CH_LAYOUT_6POINT1_BACK = CH_LAYOUT_5POINT1_BACK | BACK_CENTER, CH_LAYOUT_6POINT1_FRONT = CH_LAYOUT_6POINT0_FRONT | LOW_FREQUENCY, CH_LAYOUT_7POINT0 = CH_LAYOUT_5POINT0 | BACK_LEFT | BACK_RIGHT, CH_LAYOUT_7POINT0_FRONT = CH_LAYOUT_5POINT0 | FRONT_LEFT_OF_CENTER | FRONT_RIGHT_OF_CENTER, /** Channel count: 8*/ CH_LAYOUT_7POINT1 = CH_LAYOUT_5POINT1 | BACK_LEFT | BACK_RIGHT, CH_LAYOUT_OCTAGONAL = CH_LAYOUT_5POINT0 | BACK_CENTER | BACK_LEFT | BACK_RIGHT, CH_LAYOUT_5POINT1POINT2 = CH_LAYOUT_5POINT1 | TOP_SIDE_LEFT | TOP_SIDE_RIGHT, CH_LAYOUT_7POINT1_WIDE = CH_LAYOUT_5POINT1 | FRONT_LEFT_OF_CENTER | FRONT_RIGHT_OF_CENTER, CH_LAYOUT_7POINT1_WIDE_BACK = CH_LAYOUT_5POINT1_BACK | FRONT_LEFT_OF_CENTER | FRONT_RIGHT_OF_CENTER, /** Channel count: 10*/ CH_LAYOUT_5POINT1POINT4 = CH_LAYOUT_5POINT1 | TOP_FRONT_LEFT | TOP_FRONT_RIGHT | TOP_BACK_LEFT |TOP_BACK_RIGHT, CH_LAYOUT_7POINT1POINT2 = CH_LAYOUT_7POINT1 | TOP_SIDE_LEFT | TOP_SIDE_RIGHT, /** Channel count: 12*/ CH_LAYOUT_7POINT1POINT4 = CH_LAYOUT_7POINT1 | TOP_FRONT_LEFT | TOP_FRONT_RIGHT | TOP_BACK_LEFT | TOP_BACK_RIGHT, CH_LAYOUT_10POINT2 = FRONT_LEFT | FRONT_RIGHT | FRONT_CENTER | TOP_FRONT_LEFT | TOP_FRONT_RIGHT | BACK_LEFT | BACK_RIGHT | BACK_CENTER | SIDE_LEFT | SIDE_RIGHT | WIDE_LEFT | WIDE_RIGHT, /** Channel count: 14*/ CH_LAYOUT_9POINT1POINT4 = CH_LAYOUT_7POINT1POINT4 | WIDE_LEFT | WIDE_RIGHT, /** Channel count: 16*/ CH_LAYOUT_9POINT1POINT6 = CH_LAYOUT_9POINT1POINT4 | TOP_SIDE_LEFT | TOP_SIDE_RIGHT, CH_LAYOUT_HEXADECAGONAL = CH_LAYOUT_OCTAGONAL | WIDE_LEFT | WIDE_RIGHT | TOP_BACK_LEFT | TOP_BACK_RIGHT | TOP_BACK_CENTER | TOP_FRONT_CENTER | TOP_FRONT_LEFT | TOP_FRONT_RIGHT, /** HOA: fitst order*/ CH_LAYOUT_HOA_ORDER1_ACN_N3D = (CHANNEL_MDOE_AMBISONIC << CH_MODE_OFFSET) | (HOA_ORDNUM_1 << CH_HOA_ORDNUM_OFFSET) | (HOA_COMORD_ACN << CH_HOA_COMORD_OFFSET) | (HOA_NOR_N3D << CH_HOA_NOR_OFFSET), CH_LAYOUT_HOA_ORDER1_ACN_SN3D = (CHANNEL_MDOE_AMBISONIC << CH_MODE_OFFSET) | (HOA_ORDNUM_1 << CH_HOA_ORDNUM_OFFSET) | (HOA_COMORD_ACN << CH_HOA_COMORD_OFFSET) | (HOA_NOR_SN3D << CH_HOA_NOR_OFFSET), CH_LAYOUT_HOA_ORDER1_FUMA = (CHANNEL_MDOE_AMBISONIC << CH_MODE_OFFSET) | (HOA_ORDNUM_1 << CH_HOA_ORDNUM_OFFSET) | (HOA_COMORD_FUMA << CH_HOA_COMORD_OFFSET), /** HOA: second order*/ CH_LAYOUT_HOA_ORDER2_ACN_N3D = (CHANNEL_MDOE_AMBISONIC << CH_MODE_OFFSET) | (HOA_ORDNUM_2 << CH_HOA_ORDNUM_OFFSET) | (HOA_COMORD_ACN << CH_HOA_COMORD_OFFSET) | (HOA_NOR_N3D << CH_HOA_NOR_OFFSET), CH_LAYOUT_HOA_ORDER2_ACN_SN3D = (CHANNEL_MDOE_AMBISONIC << CH_MODE_OFFSET) | (HOA_ORDNUM_2 << CH_HOA_ORDNUM_OFFSET) | (HOA_COMORD_ACN << CH_HOA_COMORD_OFFSET) | (HOA_NOR_SN3D << CH_HOA_NOR_OFFSET), CH_LAYOUT_HOA_ORDER2_FUMA = (CHANNEL_MDOE_AMBISONIC << CH_MODE_OFFSET) | (HOA_ORDNUM_2 << CH_HOA_ORDNUM_OFFSET) | (HOA_COMORD_FUMA << CH_HOA_COMORD_OFFSET), /** HOA: third order*/ CH_LAYOUT_HOA_ORDER3_ACN_N3D = (CHANNEL_MDOE_AMBISONIC << CH_MODE_OFFSET) | (HOA_ORDNUM_3 << CH_HOA_ORDNUM_OFFSET) | (HOA_COMORD_ACN << CH_HOA_COMORD_OFFSET) | (HOA_NOR_N3D << CH_HOA_NOR_OFFSET), CH_LAYOUT_HOA_ORDER3_ACN_SN3D = (CHANNEL_MDOE_AMBISONIC << CH_MODE_OFFSET) | (HOA_ORDNUM_3 << CH_HOA_ORDNUM_OFFSET) | (HOA_COMORD_ACN << CH_HOA_COMORD_OFFSET) | (HOA_NOR_SN3D << CH_HOA_NOR_OFFSET), CH_LAYOUT_HOA_ORDER3_FUMA = (CHANNEL_MDOE_AMBISONIC << CH_MODE_OFFSET) | (HOA_ORDNUM_3 << CH_HOA_ORDNUM_OFFSET) | (HOA_COMORD_FUMA << CH_HOA_COMORD_OFFSET), };这段代码是啥意思
08-19
import os import numpy as np from scipy.ndimage.interpolation import shift from seld_ambisonics.decoder import AmbiDecoder from seld_ambisonics.hrir import CIPIC_HRIR from seld_ambisonics.position import MovingSource, Position, PositionalSource from seld_ambisonics.tdesigns import get_tDesign C = 343. # Speed of sound [m/s] class VirtualMics(object): def __init__(self, mic_pos, delay=False, a=0.1, c=C): self.mic_pos = mic_pos self.delay = delay self.a = a self.c = c def binauralize(self, sources): if isinstance(sources, PositionalSource): sources = [sources] signals = [0 for _ in range(len(self.mic_pos))] for src in sources: for i, mic in enumerate(self.mic_pos): dist = np.sqrt( ((src.position.coords('cartesian') - mic.coords('cartesian'))**2).sum()) mic_vec = mic.coords('cartesian') in_vec = mic_vec - src.position.coords('cartesian') cos_angle = (mic_vec * in_vec).sum() / \ ((mic_vec**2).sum() * (in_vec**2).sum())**0.5 dir_att = (1 - cos_angle * (1 - self.a) + self.a) / 2. # Time delay if self.delay: delay = int(dist / self.c * src.sample_rate) signal = shift(src.signal, delay, cval=0.) else: signal = src.signal # Attenuation is frequency dependent, but lets simplify. attn = 1 / (1. + dist) signals[i] += dir_att * attn * signal / len(sources) return np.stack(signals, axis=1) class AmbisonicDecoder(object): def __init__(self, ambi_format, mic_pos, method='projection', td_order=5, **kwargs): self.source_decoder = VirtualMics(mic_pos, **kwargs) self.fmt = ambi_format self.method = method # Initialize speakers if self.method == 'pseudoinv': self.speaker_pos = list(map(lambda x: Position( x[0], x[1], x[2], 'cartesian'), get_tDesign(td_order))) # self.speaker_pos = list(map(lambda x: Position(x[0], x[1], x[2], 'cartesian'), get_tDesign(self.fmt.order))) elif self.method == 'projection': speakers_phi = (2. * np.arange(2*self.fmt.num_channels) / float(2*self.fmt.num_channels) - 1.) * np.pi self.speaker_pos = list(map(lambda x: Position( x, 0, self.fmt.radius, 'polar'), speakers_phi)) else: raise ValueError( 'Unknown decoding method. Options: projection and pseudoinv') self.n_speakers = len(self.speaker_pos) self.ambi_decoder = AmbiDecoder( self.speaker_pos, self.fmt, method=self.method) def binauralize(self, ambi): # Decode ambisonics into speakers speakers = self.ambi_decoder.decode(ambi) # Binauralize speaker as if they were point sources sources = list(map(lambda i: PositionalSource( speakers[i], self.speaker_pos[i], self.fmt.sample_rate), range(self.n_speakers))) stereo = self.source_decoder.binauralize(sources) return stereo class VirtualStereoMic(object): def __init__(self, radius=0.1): self.radius = radius self.lmic_pos = Position(0, radius, 0, 'cartesian') self.rmic_pos = Position(0, -radius, 0, 'cartesian') def binauralize(self, sources): if isinstance(sources, PositionalSource): sources = [sources] l_signal, r_signal = 0, 0. for src in sources: l_dist = np.sqrt( ((src.position.coords('cartesian') - self.lmic_pos.coords('cartesian'))**2).sum()) r_dist = np.sqrt( ((src.position.coords('cartesian') - self.rmic_pos.coords('cartesian'))**2).sum()) # Time delay l_delay, r_delay = int( l_dist / C * src.sample_rate), int(r_dist / C * src.sample_rate) # Attenuation is frequency dependent, but lets simplify. l_attn, r_attn = 1 / (1. + l_dist), 1 / (1. + r_dist) l_signal += l_attn * \ shift(src.signal, l_delay, cval=0.) / len(sources) r_signal += r_attn * \ shift(src.signal, r_delay, cval=0.) / len(sources) return np.stack((l_signal, r_signal), axis=1) def binauralize_frame(self, sources, output, frame_no): if isinstance(sources, PositionalSource): sources = [sources] for src in sources: l_dist = np.sqrt( ((src.position.coords('cartesian') - self.lmic_pos.coords('cartesian'))**2).sum()) r_dist = np.sqrt( ((src.position.coords('cartesian') - self.rmic_pos.coords('cartesian'))**2).sum()) # Time delay l_delay, r_delay = int( l_dist / C * src.sample_rate), int(r_dist / C * src.sample_rate) # Attenuation is frequency dependent, but lets simplify. l_attn, r_attn = 1 / (1. + l_dist), 1 / (1. + r_dist) if frame_no-l_delay >= 0: output[frame_no, 0] += l_attn * \ src.signal[frame_no-l_delay] / len(sources) if frame_no-r_delay >= 0: output[frame_no, 1] += r_attn * \ src.signal[frame_no-r_delay] / len(sources) class Convolvotron(object): def __init__(self, cipic_dir): assert os.path.exists(cipic_dir) self.hrir_db = CIPIC_HRIR(cipic_dir) def binauralize(self, sources): if isinstance(sources, PositionalSource): sources = [sources] num_frames = max([src.signal.shape[0] for src in sources]) stereo = np.zeros((num_frames, 2)) for src in sources: left_hrir, right_hrir = self.hrir_db.get_closest(src.position)[1:] left_signal = np.convolve( src.signal, np.flip(left_hrir, axis=0), 'valid') right_signal = np.convolve( src.signal, np.flip(right_hrir, axis=0), 'valid') n_valid, i_start = left_signal.shape[0], left_hrir.shape[0] - 1 stereo[i_start:(i_start + n_valid), 0] += left_signal stereo[i_start:(i_start + n_valid), 1] += right_signal return stereo def binauralize_frame(self, sources, output, frame_no): if isinstance(sources, PositionalSource): sources = [sources] for src in sources: left_hrir, right_hrir = self.hrir_db.get_closest(src.position)[1:] i_start = frame_no - left_hrir.size + 1 if frame_no >= left_hrir.size else 0 i_end = frame_no + 1 i_range = i_end - i_start output[frame_no, 0] = ( src.signal[i_start:i_end] * left_hrir[-i_range:]).sum() output[frame_no, 1] = ( src.signal[i_start:i_end] * right_hrir[-i_range:]).sum() class SourceBinauralizer(object): def __init__(self, use_hrtfs=True, cipic_dir=None): self.use_hrts = use_hrtfs if use_hrtfs: self.convolvotron = Convolvotron(cipic_dir) else: self.stereo_mic = VirtualStereoMic() def binauralize(self, sources): if isinstance(sources, PositionalSource): sources = [sources] assert isinstance(sources, list) and all( [isinstance(src, PositionalSource) for src in sources]) assert all( [src.sample_rate == sources[0].sample_rate for src in sources]) if self.use_hrts: return self.convolvotron.binauralize(sources) else: return self.stereo_mic.binauralize(sources) def binauralize_frame(self, sources, output, frame_no): if isinstance(sources, PositionalSource): sources = [sources] assert isinstance(sources, list) and all( [isinstance(src, PositionalSource) for src in sources]) assert all( [src.sample_rate == sources[0].sample_rate for src in sources]) if self.use_hrts: return self.convolvotron.binauralize_frame(sources, output, frame_no) else: return self.stereo_mic.binauralize_frame(sources, output, frame_no) class AmbisonicBinauralizer(object): def __init__(self, ambi_format, method='projection', use_hrtfs=False, cipic_dir=None): self.source_bin = SourceBinauralizer( cipic_dir=cipic_dir, use_hrtfs=use_hrtfs) self.fmt = ambi_format self.method = method # Initialize speakers if self.method == 'pseudoinv': self.speaker_pos = map(lambda x: Position( x[0], x[1], x[2], 'cartesian'), get_tDesign(self.fmt.order)) map(lambda p: p.set_radius(self.fmt.radius), self.speaker_pos) # speakers_phi = (2. * np.arange(2*self.fmt.num_channels) / float(2*self.fmt.num_channels) - 1.) * np.pi # self.speaker_pos = map(lambda x: Position(x, 0, self.fmt.radius, 'polar'), speakers_phi) elif self.method == 'projection': speakers_phi = (2. * np.arange(2*self.fmt.num_channels) / float(2*self.fmt.num_channels) - 1.) * np.pi self.speaker_pos = list(map(lambda x: Position( x, 0, self.fmt.radius, 'polar'), speakers_phi)) else: raise ValueError( 'Unknown decoding method. Options: projection and pseudoinv') self.n_speakers = len(self.speaker_pos) self.ambi_decoder = AmbiDecoder( self.speaker_pos, self.fmt, method=self.method) def binauralize(self, ambi): # Decode ambisonics into speakers speakers = self.ambi_decoder.decode(ambi) # Binauralize speaker as if they were point sources sources = list(map(lambda i: PositionalSource(speakers[:, i], self.speaker_pos[i], self.fmt.sample_rate), range(self.n_speakers))) stereo = self.source_bin.binauralize(sources) return stereo class DirectAmbisonicBinauralizer(object): def __init__(self, ambi_format, method='projection'): self.fmt = ambi_format self.method = method # Initialize ear position self.ear_pos = [Position(0, 0.1, 0, 'cartesian'), Position(0, -0.1, 0, 'cartesian')] self.ambi_decoder = AmbiDecoder( self.ear_pos, self.fmt, method=self.method) def binauralize(self, ambi): return self.ambi_decoder.decode(ambi) def test_convolvotron(): from seld_ambisonics.iolib.audio import load_wav, save_wav convolvotron = Convolvotron('hrtfs/cipic_subj3') mono, rate = load_wav('wav_test/piano.wav') mono = mono[:, 0] positions = [[float(num) for num in l.strip().split()] for l in open('wav_test/piano_stat_position.txt', 'r')] positions = [Position(p[0], p[1], p[2], 'polar') for p in positions] source = PositionalSource(mono, positions[0], rate) stereo = convolvotron.binauralize([source]) save_wav('/tmp/output.wav', stereo, rate) os.system('play /tmp/output.wav') os.remove('/tmp/output.wav') positions = [[float(num) for num in l.strip().split()] for l in open('wav_test/piano_mov_position.txt', 'r')] positions = [Position(p[0], p[1], p[2], 'polar') for p in positions] source = MovingSource(mono, positions, rate) stereo = np.zeros((mono.shape[0], 2)) while source.tic(): convolvotron.binauralize_frame([source], stereo, source.cur_idx) save_wav('/tmp/output.wav', stereo, rate) os.system('play /tmp/output.wav') os.remove('/tmp/output.wav') def test_virtual_mic(): from seld_ambisonics.iolib.audio import load_wav, save_wav mic = VirtualStereoMic() mono, rate = load_wav('wav_test/piano.wav') mono = mono[:, 0] positions = [[float(num) for num in l.strip().split()] for l in open('wav_test/piano_stat_position.txt', 'r')] positions = [Position(p[0], p[1], p[2], 'polar') for p in positions] source = PositionalSource(mono, positions[0], rate) stereo = mic.binauralize([source]) save_wav('/tmp/output.wav', stereo, rate) os.system('play /tmp/output.wav') os.remove('/tmp/output.wav') positions = [[float(num) for num in l.strip().split()] for l in open('wav_test/piano_mov_position.txt', 'r')] positions = [Position(p[0], p[1], p[2], 'polar') for p in positions] source = MovingSource(mono, positions, rate) stereo = np.zeros((mono.shape[0], 2)) while source.tic(): mic.binauralize_frame([source], stereo, source.cur_idx) save_wav('/tmp/output.wav', stereo, rate) os.system('play /tmp/output.wav') os.remove('/tmp/output.wav') def test_source_binauralizer(): from seld_ambisonics.iolib.audio import load_wav, save_wav from seld_ambisonics.iolib.position import read_position_file # binauralizer = SourceBinauralizer(use_hrtfs=True, cipic_dir='hrtfs/cipic_subj3') binauralizer = SourceBinauralizer(use_hrtfs=False) # Static source sample = 'wav_test/gen_synthetic-S1' positions, wav_fns, _, sample_ids = read_position_file( sample+'-position.txt') mono, rate = load_wav(wav_fns[sample_ids[0]]) source = PositionalSource(mono[:, 0], positions[sample_ids[0]][0], rate) stereo = binauralizer.binauralize([source]) save_wav('/tmp/output.wav', stereo / np.abs(stereo).max(), rate) os.system('play /tmp/output.wav') os.remove('/tmp/output.wav') # Moving source sample = 'wav_test/gen_synthetic-M1' positions, wav_fns, _, sample_ids = read_position_file( sample+'-position.txt') mono, rate = load_wav(wav_fns[sample_ids[0]]) source = MovingSource(mono[:, 0], positions[sample_ids[0]], rate) stereo = np.zeros((mono.shape[0], 2)) while source.tic(): binauralizer.binauralize_frame([source], stereo, source.cur_idx) save_wav('/tmp/output.wav', stereo / np.abs(stereo).max(), rate) os.system('play /tmp/output.wav') os.remove('/tmp/output.wav') def test_ambisonics_binauralizer(): from seld_ambisonics.common import AmbiFormat from seld_ambisonics.iolib.audio import load_wav, save_wav sample = 'wav_test/gen_synthetic-S1' ambi, rate = load_wav(sample+'-ambix.wav') fmt = AmbiFormat(1, rate) binauralizer = DirectAmbisonicBinauralizer(fmt, method='pseudoinv') # binauralizer = AmbisonicBinauralizer(fmt, method='projection', use_hrtfs=True, cipic_dir='hrtfs/cipic_subj3') stereo = binauralizer.binauralize(ambi) save_wav('/tmp/output.wav', stereo / np.abs(stereo).max(), rate) os.system('play /tmp/output.wav') os.remove('/tmp/output.wav') sample = 'wav_test/gen_synthetic-M1' ambi, rate = load_wav(sample+'-ambix.wav') stereo = binauralizer.binauralize(ambi) save_wav('/tmp/output.wav', stereo / np.abs(stereo).max(), rate) os.system('play /tmp/output.wav') os.remove('/tmp/output.wav') if __name__ == '__main__': # test_ambisonics_binauralizer() test_source_binauralizer() # test_convolvotron() # test_virtual_mic() 这个代码是怎么做双耳解码的,用的是什么算法
最新发布
10-17
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值