Skip to main content
Skip table of contents

Generating two tones using the DAC schedule

In our first example, we generate two 2s tones for immediate playback on DAC0 and DAC1.
Our tones are 100 and 500 Hz sine waves sampled at a rate of 2000 samples/second, generated using the MakeBeep command.

%Connect to hardware

%define our tones
tone1 = MakeBeep(100,2,200000);
tone2 = MakeBeep(500,2,200000);

These tones are formatted as a m x n matrix where m is the number of channels you wish to target (up to 4) and m is the sampling data. These are pre-loaded into VPixx hardware memory using writeDacBuffer.

%create our bufferData
bufferData(1,:) = tone1;
bufferData(2,:) = tone2;

%Write buffer
Datapixx('WriteDacBuffer', bufferData, 2e6);

A single call to setDacSchedule specifies the parameters for DAC playback of both tones. This single call sets shared properties like onset delay and playback rate. If you wish to change these parameters for a single DAC channel during multichannel playback, you will need to modify that channel signal in bufferData (e.g. by adding a manual delay).

duration = 2;
scheduleOnset = 0;
scheduleRate = 200000;
maxScheduleFrames = scheduleRate*duration;

Datapixx('SetDacSchedule', scheduleOnset, scheduleRate, maxScheduleFrames );

Our buffer contains our data, and the schedule parameters have been defined. Now we can push this information to our hardware via a register write, and then trigger playback immediately:

%push previous commands to device

%start playback immediately

Finally, we can stop the playback and close the connection via the following:


JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.