Playing an array as sound and recording its output in parallel

时光怂恿深爱的人放手 提交于 2019-12-10 18:56:20

问题


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;

回答1:


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')



来源:https://stackoverflow.com/questions/7923137/playing-an-array-as-sound-and-recording-its-output-in-parallel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!