Reputation: 3389
I know Octave/MATLAB can play arrays as sound, but I was wondering if Octave can do this: I would like to cycle through a range of frequencies and have Octave play them using the speaker out on my computer, and have Octave also record the sound using the microphone input to get the max value. I'm trying to automate a way to have Octave cycle through frequencies and record the data received so I can go back later and look at the resonant frequencies. Can Octave do this type of operation in parallel?
I'm using Ubuntu Linux 10.04 64bit with a full duplex sound card
Example:
clear all
t=linspace(0,1,44100);
A = 1; % amplitude
Fs = 44100
for ii=1:1:10
freq=ii; %how many in 1 sec
T = 1/freq; % period of the signal
vertoffset=0.5;
% square
square = mod(t * A / T, A) > A / 2;
square = square - vertoffset;
sound(square,Fs);
end;
Upvotes: 3
Views: 1048
Reputation: 3389
This can be done with SOX http://sox.sourceforge.net/
example of the octave/SOX code that does this is system('play /home/a_playback.wav | rec -c 1 -r 8000 -b 16 /home/a_record.wav trim 0 00:01')
Upvotes: 1