【发布时间】:2017-03-30 04:56:41
【问题描述】:
我是 MATLAB 新手,如果问题非常基本,敬请见谅。我需要一个 .wav 声音文件以在单个特定通道中播放——比如说左通道。事实上,我的代码读入了声音文件,并添加了一列零来取消我不想要的频道,如下所示:
currentDir = pwd;
soundFile = [currentDir '\sound1.wav']; % load the file
[y, Fs] = audioread(soundFile); % read the file in
soundData(:,1) = y(:,1); % keeps sound for the left channel
soundData(:,2) = 0; % nullifies the right channel
sound = audioplayer(soundData,Fs);
play(sound);
就目前而言,代码当前在左扬声器中产生的声音是全音量,在右扬声器中产生一半音量(但仍然可以听到)。我已经用至少 20 个 .wav 文件进行了尝试,结果相同。
如果相关,即使我编写的代码明确匹配 0 中声音变量的长度也会发生这种情况,如下所示:
[y, Fs] = audioread(soundFile);
silentChannel = zeros(size(y));
soundData(:,1) = y(:,1); % keeps sound for the left channel
soundData(:,2) = silentChannel(:,2); % nullifies the right channel
有人知道我做错了什么,或者有什么想法吗?
【问题讨论】: