source: orbit/octave/GenerateAudioCommand/codeGenAndroid.m @ f22b7ab

RawEEGRaw_EEG_PlotServoTab_Interfacepyramid
Last change on this file since f22b7ab 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: 1.5 KB
RevLine 
[a0b523e]1function fullCodeWave=flyCommand(code,space,audioFileName,sps,repeatTime,AndroidOriOS,flipOrNot)
2
3% code: array of 1s and 0s. 1 means bit "1", 0 means bit "0".
4% audioFileName: like 'audio.wav'.
5% space: space between codes [samples]
6bps = 16;       % bits per sample
7%sps = 96000;     % sample rate [samples/s]
8
9
10if code=='demo1'
11        code=[1 0 1 1 0 1 1 1 0 1 0 0 1 1 0 0 1 0 0 1 1 1 1 1 0 1 1 0];%minimum rotating throttle
12elseif code=='demo2'
13        code=[1 1 1 1 1 1 1 1 0 1 0 0 0 1 1 0 1 0 0 1 1 1 1 1 0 0 0 0];%maximum throttle
14endif
15
16if (AndroidOriOS=='iOS')
17longHIGH=875;longHIGH_s=floor(longHIGH*sps/1e6)+1;%longHIGH[us] longHIGH_s[sample]
18longLOW=729;longLOW_s=floor(longLOW*sps/1e6);
19shortHIGH=458;shortHIGH_s=floor(shortHIGH*sps/1e6)+1;
20shortLOW=333;shortLOW_s=floor(shortLOW*sps/1e6);
21
22codeWave=[halfSineGenDirect('u',longHIGH_s,0,1,sps);zeros(shortLOW_s,1);halfSineGenDirect('u',longHIGH_s,0,1,sps);zeros(shortLOW_s,1)]; %starting 5 half period
23
24% notice that the "code" here should be a 28 bit binary array.
25for i=1:size(code,2)
26        codeWave = [codeWave; bitGenHDMI(code(i),1,sps,longHIGH_s,longLOW_s,shortHIGH_s,shortLOW_s)];
27endfor
28
29codeWave=[codeWave; halfSineGenDirect('u',longHIGH_s,0,1,sps)]; %last half period
30
31if(flipOrNot=='flip')
32        codeWave=-codeWave;
33endif
34
35fullCodeWave=[];
36for i=1:repeatTime
37        fullCodeWave=[fullCodeWave; codeWave; zeros(space,1)];
38endfor
39
40
41%fullCodeWave=[fullCodeWave zeros(sizeof(fullCodeWave))];
42
43elseif AndroidOrioS=='Android'
44endif %if AndroidOriOS=='iOS'
45
46wavwrite(fullCodeWave, sps, bps, audioFileName);
Note: See TracBrowser for help on using the repository browser.