Keep getting error using sound command
10 views (last 30 days)
Show older comments
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 Comments
Answers (2)
Image Analyst
on 30 Apr 2022
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 Comments
Walter Roberson
on 30 Apr 2022
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 Comments
See Also
Categories
Find more on Audio and Video Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!