generate signals with analog output generator
this topic shows how to use the analog output generator app to define and generate signals from an audio device.
to open the analog output generator, on the matlab® toolstrip, on the apps tab, in the test and measurement section, click analog output generator.
upon opening, the analog output generator attempts to find all your attached analog and audio output devices.
note
opening the analog output generator deletes all your existing dataacquisition interfaces in matlab.
the dataacquisition interface created by the analog output generator is not accessible from the matlab command line.
if you plug in a device while the app is open, you must refresh the listing for access to that device. on the devices tab, click refresh. use the same procedure to remove a device from the listing after unplugging it.
select the device you want to use in the device list. by default, the app immediately displays a preview of a test signal.
use the following steps to produce an audio output of the "hallelujah" chorus from handel's messiah.
select the device for your output. this might be the primary sound driver, speakers, or a headset.
load the sound data into the workspace with the following command in matlab:
load handel
this loads two variables into your workspace. the sound data is contained in array named
y
. the sampling rate is contained in the variablefs
. you will need to know the sampling rate, so display its value.fs
8192
in the signal type section of the analog output generator toolstrip, select workspace variable. in the adjacent selection list, choose
y
. this indicates the source of the data for the generator to output.enter the
fs
value of8192
in the rate text box in the analog output generator. this indicates the sampling rate. the app should now look something like this.click generate to produce the sound output.
if you were successful in producing a sound output, try experimenting with some of the settings in the app. for example, modify the rate value or the number of cycles.
tip
if you could not hear any sound, use the test signal option to generate a constant tone. check all your hardware connections and different devices in the app until you hear the tone.
in the analog output generator, click generate script for the app to open the matlab editor and display the code for producing the signal. the code is generated for the finite (non-continuous) output of this example.