get_audio_loop.m 730 Bytes
Newer Older
Martin Karlsson's avatar
hej    
Martin Karlsson committed
1
2


Martin Karlsson's avatar
update    
Martin Karlsson committed
3
figure;
Martin Karlsson's avatar
Martin Karlsson committed
4

Martin Karlsson's avatar
update    
Martin Karlsson committed
5
6
allAudioLeft = [];
allAudioRight = [];
Martin Karlsson's avatar
Martin Karlsson committed
7
8
9
lastLastIndex = 0;
lastIndex = 0;
count = 0;
Martin Karlsson's avatar
Martin Karlsson committed
10
while count < 5
Martin Karlsson's avatar
Martin Karlsson committed
11
12
13
14
    p = bass.Audio();
    if count == 0
        fs = p.Audio.sampleRate;
    end
Martin Karlsson's avatar
update    
Martin Karlsson committed
15
    pause(0.1)
Martin Karlsson's avatar
Martin Karlsson committed
16
17
    lastIndex = p.Audio.lastFrameIndex;
    diffIndex = lastIndex - lastLastIndex;
Martin Karlsson's avatar
update    
Martin Karlsson committed
18
19
20
21
22
23
24
    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
25
26
27
    
    lastLastIndex = lastIndex;
    count = count+1
Martin Karlsson's avatar
update    
Martin Karlsson committed
28
29
30
31
32
33
    
    plot(tempLeft);
    set(gca,'ylim',[-2^16/2 2^16/2])
    drawnow
    
end
Martin Karlsson's avatar
Martin Karlsson committed
34
35
36
37


bass.Stop()