get_audio_loop.m 714 Bytes
Newer Older
Martin Karlsson's avatar
update    
Martin Karlsson committed
1
figure;
Martin Karlsson's avatar
Martin Karlsson committed
2

Martin Karlsson's avatar
update    
Martin Karlsson committed
3
4
allAudioLeft = [];
allAudioRight = [];
Martin Karlsson's avatar
Martin Karlsson committed
5
6
7
lastLastIndex = 0;
lastIndex = 0;
count = 0;
Martin Karlsson's avatar
update    
Martin Karlsson committed
8
while count < 50
Martin Karlsson's avatar
Martin Karlsson committed
9
10
11
12
    p = bass.Audio();
    if count == 0
        fs = p.Audio.sampleRate;
    end
Martin Karlsson's avatar
update    
Martin Karlsson committed
13
    pause(0.1)
Martin Karlsson's avatar
Martin Karlsson committed
14
15
    lastIndex = p.Audio.lastFrameIndex;
    diffIndex = lastIndex - lastLastIndex;
Martin Karlsson's avatar
update    
Martin Karlsson committed
16
17
18
19
20
21
22
    tempLeft = cell2mat(p.Audio.left);
    tempLeft = tempLeft(max(end-diffIndex+1,1):end);
    allAudioLeft = [allAudioLeft; tempLeft];
    
    tempRight = cell2mat(p.Audio.right);
    tempRight = tempRight(max(end-diffIndex+1,1):end);
    allAudioRight = [allAudioRight; tempRight];
Martin Karlsson's avatar
Martin Karlsson committed
23
24
25
    
    lastLastIndex = lastIndex;
    count = count+1
Martin Karlsson's avatar
update    
Martin Karlsson committed
26
27
28
29
30
31
    
    plot(tempLeft);
    set(gca,'ylim',[-2^16/2 2^16/2])
    drawnow
    
end