Created
June 16, 2011 23:06
-
-
Save zaman/1030525 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%Simple analog output | |
%define the output | |
adaptor = 'winsound'; | |
id = 0; | |
chan = 1; | |
% Analog output object Configuration. | |
% Create an analog input object with one channel. | |
ao = analogoutput(adaptor, id); | |
ch = addchannel(ao, chan); | |
% Configure the analog output rate. | |
set(ao, 'SampleRate', 44100); | |
%and trigger mode | |
set(ao, 'TriggerType', 'manual'); | |
% Object Execution. | |
% Start the analog input object. | |
for i=15:40 | |
%2000 points/output | |
x=linspace(0,2*pi,2000); | |
%make an increasing frequency sin wave | |
%The exponential puts the notes on a log scale | |
%and the final modulation eliminates end-effects | |
waveform=0.25*sin(2^(i*.125)*x).*sin(x*0.5); | |
plot(x,waveform) | |
axis([0 6.28 -.3 .3]) | |
drawnow | |
% Put it in the ouput buffer | |
%transpose waveform to make a column vector | |
putdata(ao, waveform'); | |
%start output and trigger it | |
start(ao); | |
trigger(ao); | |
%Wait until output is done | |
while strcmp(ao.Running, 'On') | |
end | |
%kill analog out | |
stop(ao) | |
end | |
delete(ao); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment