-
Notifications
You must be signed in to change notification settings - Fork 0
/
RealTimeAudio.m
42 lines (36 loc) · 1.2 KB
/
RealTimeAudio.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
addpath('./audio');
frameLength = 256;
frameLength = 64;
fileReader = dsp.AudioFileReader( ...
'gunshot_dry.wav', ...
'SamplesPerFrame',frameLength);
% fileReader = audioDeviceReader;
playRec = audioPlayerRecorder;
deviceWriter = audioDeviceWriter( ...
'SampleRate',fileReader.SampleRate);
scope = timescope( ...
'SampleRate',fileReader.SampleRate, ...
'TimeSpan',2, ...
'BufferLength',fileReader.SampleRate*2*2, ...
'YLimits',[-1,1], ...
'TimeSpanOverrunAction',"Scroll");
reverb = reverberator( ... %<--- new lines of code
'SampleRate',fileReader.SampleRate, ... %<---
'PreDelay',0, ... %<---
'WetDryMix',0.4); %<---
tic
while toc < 10
% while ~isDone(fileReader)
% signal = fileReader();
% reverbSignal = reverb(signal); %<---
% % outSignal = filter(b,a,signal);
% deviceWriter(reverbSignal); %<---
audioToDevice = reverb(audioFromDevice);
audioFromDevice = playRec(audioToDevice);
scope([audioFromDevice,mean(audio,2)]) %<---
end
% release(fileReader)
% release(deviceWriter)
release(playRec)
release(reverb) %<---
release(scope)