Sum sound signals with different size

1 回表示 (過去 30 日間)
Raquel Lucena Peris
Raquel Lucena Peris 2020 年 10 月 23 日
コメント済み: Mohamad 2020 年 10 月 25 日
Hello,
I want to produce a sound from a sound_signal, but I don't know how to create the sound signal.
I have a cell sequence like that as input
{'0'} {'111'} {'0'} {'111'} {'0'} {'0'} {'0'} {'1'} {'0'} {'111'} {'0'}
Now my code looks like this:
dot_duration = 0.1
sampling_freq = 1000
tone_freq = 700
t_dot=0:1/sampling_freq:dot_duration;
t_dash=0:1/sampling_freq:3*dot_duration;
t_code_space=0:1/sampling_freq:dot_duration;
y_dot=cos(2*pi*tone_freq*t_dot);
y_dash=cos(2*pi*tone_freq*t_dash);
y_code_space=0*t_code_space;
input = reshape(pulse_sequential, 1, 1, length(input));
%with the reshape I avoid the use of loops
soundsignal1 = ismember(input(:), '1')*y_dot;
soundsignal2 = ismember(input(:), '111')*y_dash;
soundsignal3 = ismember(input(:), '0')*y_code_space;
soundsignal = soundsignal1+soundsignal2+soundsignal3
My problem is in the sum of the soundsignal1, soundsignal2 and soundsignal3, but obviously I can not add those elements because the Matrix dimensions do not agree.
I don't know how to solve this error, I understand it, (y_dot, y_dash and y_code_space have different size).
If you could help me I would grateful

回答 (1 件)

Mohamad
Mohamad 2020 年 10 月 24 日
y_dot=[y_dot zeros(1,length(y_dash)-length(y_dot))];% pad zeros
y_code_space=[y_code_space zeros(1,length(y_dash)-length(y_code_space))];% pad zeros
Now all vectors of same length , can be added .
  4 件のコメント
Raquel Lucena Peris
Raquel Lucena Peris 2020 年 10 月 24 日
the size is
ans =
84 48001
Mohamad
Mohamad 2020 年 10 月 25 日
Why the matrix has 48001 columns ?
sound command will allow playing the sound for a matrix of 2 columns only ( i.e 1st channel and 2 ed channel ) .

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

カテゴリ

Help Center および File ExchangeAudio I/O and Waveform Generation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by