This example shows how to generate audio signals using a 5.1 channel sound system.
Load an audio file containing a sample of Handel's "Hallelujah Chorus."
Plot the data to identify five distinct segments. Each segment represents a "Hallelujah" in the chorus. The segments are annotated as 1 to 5.
ly = length(y); lspan = 1:ly; t = lspan/Fs; hf = figure; plot(t,y./max(y)) axis tight; title("Signal (Handel''s Hallelujah Chorus) vs Time"); xlabel("Time (s)"); ylabel("Amplitude"); markers = struct('xpos',[0.2,0.4,0.55,0.65,0.8],'string',num2str([1:5]')); for i = 1:5, annotation(hf,'textbox',[markers.xpos(i) 0.48 0.048 0.080],'String', markers.string(i),'BackgroundColor','w','FontSize',16); end
This example uses a 5.1 channel sound system with device ID
1. Create a DataAcquisition with
directsound as the vendor and add an audio output channel to it.
dd = daq("directsound"); nch = 6; addoutput(dd, "Audio2", 1:nch, "Audio");
2. Update the generation scan rate to match the audio sampling rate.
dd.Rate = Fs;
3. Generate audio signals (Handel's "Hallelujah Chorus"). "Hallelujah" should be voiced five times, one for each segment depicted in the figure on all channels of the speaker system.
4. Close the figure.