source: orbit/octave/GenerateAudioCommand/dualIRLEDAudioGen.m @ 655a816

RawEEGRaw_EEG_PlotServoTab_Interfacepyramid
Last change on this file since 655a816 was a0b523e, checked in by AzureViolin <zhanghaotz@…>, 8 years ago

flyOrbit.m can now generate arbitry control code for play from laptop. update read.me

  • Property mode set to 100644
File size: 975 bytes
Line 
1function dualIRLEDAudioGen(code,audioFileName,sps,repeatTime,Multiplyer,flipOrNot)
2
3% code: array of 1s and 0s. 1 means bit "1", 0 means bit "0".
4% audioFileName: like 'audio.wav'.
5% Multiplyer: value around 1, to change "carrier" period.
6bps = 16;       % bits per sample
7%sps = 96000;     % sample rate [samples/s]
8
9
10shortLOW=floor(0.0008*sps/2)+1;
11shortHIGH=floor(0.0008*sps/2)-1;
12longHIGH=floor(0.0016*sps/2)-1;
13longLOW=floor(0.0016*sps/2)+2;
14codeWave=[ones(longHIGH,1);zeros(shortLOW,1);ones(longHIGH,1);zeros(shortLOW,1)];
15
16% notice that the "code" here should be a 28 bit binary array.
17for i=1:size(code,2)
18        codeWave = [codeWave; dualBitGenDirect(code(i),shortHIGH,shortLOW,longHIGH,longLOW)];
19endfor
20
21codeWave=[codeWave; ones(longHIGH,1)]; %last half period
22
23
24if(exist("flipOrNot","var"))
25        codeWave=-codeWave;
26endif
27
28fullCodeWave=[];
29for i=1:repeatTime
30        fullCodeWave=[fullCodeWave; codeWave; zeros(4049,1)];
31endfor
32
33
34wavwrite(fullCodeWave, sps, bps, audioFileName);
Note: See TracBrowser for help on using the repository browser.