write and reading array from 2 functions files at the same time

Hi All,
I am new with matlab, i am building a small program, where it reading an audio file and start to divide it to blocks using (For Loop), at the same time (when i create the blocks array) i want to use this blocks in another function to be in real time and not to wait till (For Loop)to finish.

1 件のコメント

Jan
Jan 2012 年 2 月 14 日
You forgot to ask a question. Do you have any troubles with building this program?

回答 (2 件)

Honglei Chen
Honglei Chen 2012 年 2 月 14 日

0 投票

Looks like you want to do stream processing. I would suggest you to take a look at the example in the following page
You can replace the playing part with any processing you want to do, but the example shows a framework of dividing things into small blocks and then process them in real time.
adel
adel 2012 年 2 月 15 日

0 投票

hi Jan Simon,
my question is who to read from the array at the same time when i am creating it in other function
hi Honglei Chen, thanks for the example, and u r right i am doing a stream process, but at the same time i wanna use the blocks in another process, where the size of block will change and i will re-block them again. during this process i have another process waiting for these blocks to work. u can see the code here
function SRCFAR
global X
X=[];
% The Signal
[v, fs] = wavread('v.wav');
n = 1:length(v);
%resample the signal
K = 5;
fsi = fs;
fso = 8000;
blk=2048;
a=(1:blk);
Qblk=1;
Qlen=1;
% stream the audio file to be resampled by ASRC as blocks
for k=1:blk:length(n)-blk
j=k+blk-1;
% should be change to use SRC
x = asrc_lagrange(xfar(k:j).', fsi/fso, 0, zeros(1, K), K);
% recollect new size blocks
for i=1:length(x)
if (Qblk>blk)
Qblk=1;
% put in the array
X(Qlen,:) = a;
a (Qblk)= x(i);
Qlen=Qlen+1;
else
a (Qblk)= x(i);
Qblk=Qblk+1;
end;
end;
end;

この質問は閉じられています。

質問済み:

2012 年 2 月 14 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by