Keep getting error using sound command
10 次查看(过去 30 天)
显示 更早的评论
Error message: Error using sound (line 76) Only one- and two-channel audio supported.
Code:
clear; clc; close all;
fs = 44100;
% [h, n] = bpw(lower_cutoff, upper_cutoff, 501, 'type');
% Num 2
[h1, n1] = bpw(0, .627, 501, 'hamm');
[h2, n2] = bpw(.627, 1.25, 501, 'hann');
[h31, n31] = bpw(1.25, 1.88, 501, 'blac');
[h32, n32] = bpw(1.25, 1.88, 501, 'rect');
[h4, n4] = bpw(1.88, 2.51, 501, 'bart');
[h5, n5] = bpw(2.51, pi, 501, 'hann');
Av1 = 1;
Av2 = 1;
Av3 = 1;
Av4 = 1;
Av5 = 1;
im1 = h1 * Av1;
im2 = h2 * Av2;
im31 = h31 * Av3;
im32 = h32 * Av3;
im4 = h4 * Av4;
im5 = h5 * Av5;
TIR = im1 + im2 + im31 + im4 + im5;
% Num 3
audio = audioread("Undone_Clip.wav");
finalSound = conv2(audio, TIR);
sound(finalSound, fs);
4 个评论
回答(2 个)
Image Analyst
2022-4-30
You sound doesn't have any signal in it. Here's an example:
[y, fs] = audioread('guitartune.wav');
size(y)
You say your y "finalsound" "is a 1x2 that has values [537146, 502]"
That means you have 537,146 samples but 502 channels. the soundsc can only take 1 or 2 channels. Can you just play 2 of the channels?
stereoSound = finalSound(:, 1:2); % Extract first two channels and ignore remaining 499 channels.
soundsc(stereoSound);
0 个评论
Walter Roberson
2022-4-30
audioread() returns something that has one row per sample, and as many columns as there are channels.
n = [-M/2:M/2];
That is a row vector, so your bpw() function returns a row vector.
finalSound = conv2(audio, TIR);
You are conv2() your N x channels with a row vector and you are not using any parameters to clip the size of the output of conv2() . When you do not use options such as 'same' or 'valid', conv2 is going to return a large output. conv2() is symmetric mathematically, so do not just think about convolving the audio with the TIR: you are also convolving the TIR with the audio, so you should expect something about the same width as the TIR as the output width.
You should probably be using conv() of the audio and a column vector TIR and should probably be using the 'same' option
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio and Video Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!