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 comentario

You forgot to ask a question. Do you have any troubles with building this program?

Respuestas (2)

Honglei Chen
Honglei Chen el 14 de Feb. de 2012
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.
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;

La pregunta está cerrada.

Preguntada:

el 14 de Feb. de 2012

Cerrada:

el 20 de Ag. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by