フィルターのクリア

How can i mix two .wav files ..iam using this code as show in figure but it gives an error?

1 回表示 (過去 30 日間)
  3 件のコメント
Muhammad Saim Nasir Siddiqui
Muhammad Saim Nasir Siddiqui 2015 年 5 月 4 日
編集済み: Walter Roberson 2024 年 3 月 19 日
hey.. i modify this code just recently and it play two wav files one by one i want to play these at a same time (mix)so here is the code
[y1,fs,bits] = wavread('C:\Users\Sid\Desktop\sid1.wav'); [y2,fs,bits] = wavread('C:\Users\Sid\Desktop\sid2.wav'); y3 = [y1; y2];
% To Listen: sound(y3,fs);
wavwrite(y3,fs,bits,'file3.wav');
Muhammad Saim Nasir Siddiqui
Muhammad Saim Nasir Siddiqui 2015 年 5 月 4 日
編集済み: Walter Roberson 2024 年 3 月 19 日
Thanks for guiding ..here is the code which adds both .wav files
%Sid --on the floor clc clear all close all
[y,Fs,nb]=wavread('C:\Users\Sid\Desktop\sid1.wav'); [z,Fs1,nb1]=wavread('C:\Users\Sid\Desktop\sid2.wav');
audioplayer(y, Fs,nb)
audioplayer(z, Fs,nb)
audioplayer(x, Fs,nb)
lenY = size(y, 1); % Or is this the 2nd dimension?
lenZ = size(z, 1);
len = max(lenY, lenZ);
S = zeros(len, size(y, 2));
S(1:lenY, :) = y;
S(1:lenZ, :) = S(1:lenZ, :) + z;
maxValue = max(abs(S(:)));
S = S / maxValue;
sound(S,Fs,nb)
%This codes works but when i introduce more than 2 .wav files and also do some changing in your code:
%Sid --on the floor
clc
clear all
close all
[y,Fs,nb]=wavread('C:\Users\Sid\Desktop\sid1.wav');
[z,Fs1,nb1]=wavread('C:\Users\Sid\Desktop\sid2.wav');
[x,Fs2,nb2]=wavread('C:\Users\Sid\Desktop\sid3.wav');
audioplayer(y, Fs,nb)
audioplayer(z, Fs1,nb1)
audioplayer(x, Fs2,nb2)
lenY = size(y, 1); % Or is this the 2nd dimension?
lenZ = size(z, 1);
lenX = size(x, 1);
len = max(lenY, lenZ);
S = zeros(len, size(y, 2));
S(1:lenY, :) = y;
S(1:lenZ, :) = S(1:lenZ, :) + z;
S(1:lenX, :) = S(1:lenX, :) + x;
maxValue = max(abs(S(:)));
S = S / maxValue;
sound(S,Fs,nb)
It merges three .wav files but their amplitude is not high .. so the resulting sound is not much loud ..i want to increase its amplitude as well

サインインしてコメントする。

採用された回答

Jan
Jan 2015 年 5 月 4 日
It seems like y and z have different lengths. How do you want to handle this? Do you want to crop the longer signal or to pad the shorter signal with zeros? How do you want to treat amplitudes higher than 1.0 after the addition? Any kind or normalization?
Perhaps this helps:
lenY = size(y, 1); % Or is this the 2nd dimension?
lenZ = size(z, 1);
len = max(lenY, lenZ);
S = zeros(len, size(y, 2));
S(1:lenY, :) = y;
S(1:lenZ, :) = S(1:lenZ, :) + z;
mavValue = max(abs(S(:));
S = S \ maxValue;
  2 件のコメント
Muhammad Saim Nasir Siddiqui
Muhammad Saim Nasir Siddiqui 2015 年 5 月 4 日
hey.. i modify this code just recently and it play two wav files one by one i want to play these at a same time (mix)so here is the code
[y1,fs,bits] = wavread('C:\Users\Sid\Desktop\sid1.wav'); [y2,fs,bits] = wavread('C:\Users\Sid\Desktop\sid2.wav'); y3 = [y1; y2];
% To Listen: sound(y3,fs);
wavwrite(y3,fs,bits,'file3.wav');

サインインしてコメントする。

その他の回答 (1 件)

BOUGOSSA HADJER
BOUGOSSA HADJER 2024 年 3 月 19 日
close all
clear all
clc
[y1,fs,bits] = wavread('C:\Users\Sid\Desktop\sid1.wav');
'wavread' has been removed. With appropriate code changes, use 'audioread' instead.

Caused by:
Unrecognized function or variable 'wavread'.
sound(y3,fs);

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by