source: orbit/octave/GenerateAudioCommand/flyOrbit.m @ cb3655b

RawEEGRaw_EEG_PlotServoTab_Interfacepyramid
Last change on this file since cb3655b was cb3655b, checked in by dorabot <dorabot@…>, 7 years ago

add comment to script

  • Property mode set to 100644
File size: 1.6 KB
Line 
1function fullCodeWave=flyOrbit(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 [uS]
6bps = 16;       % bits per sample
7%sps = 96000;     % sample rate [samples/s]
8%repeatTime: the number of same commands you want to generate
9%AndroidOriOS: 'Android' 'iOS' generates two different style of codes
10%flipOrNot: 'flip' 'notF' some android device needs a flipped signal.
11space=floor(space*48000/1e6);% turn uS into samples
12
13if length(AndroidOriOS)==3 %iOS
14fullCodeWave=[flyCommand(code,space,'temp1.wav',sps,2,AndroidOriOS,flipOrNot);initCodeGen('temp2.wav');flyCommand(code,space,'temp3.wav',sps,repeatTime,AndroidOriOS,flipOrNot)];
15
16elseif length(AndroidOriOS)==7 %Android
17
18        if AndroidOriOS=='Android'%generate android style command with init
19
20%Android style command consists of 4(any number larger than 2) command, init code, and certain repeat of command.
21%function initCodeGenAndroid can generate init
22%function flyCommand can generate command
23        fullCodeWave=[flyCommand(code,space,'temp1.wav',sps,4,AndroidOriOS,flipOrNot);initCodeGenAndroid('temp2.wav',sps);zeros(1,1);flyCommand(code,space,'temp3.wav',sps,repeatTime,AndroidOriOS,flipOrNot)];
24        elseif AndroidOriOS=='Command'%generate command only
25        fullCodeWave=[flyCommand(code,space,'temp3.wav',sps,repeatTime,AndroidOriOS,flipOrNot)];
26        endif
27
28endif
29
30sizeCode=size(fullCodeWave,1);
31time=linspace(0,sizeCode/sps,sizeCode);
32fullCodeWave = [fullCodeWave sin(time*2*pi*440)'];
33
34wavwrite(fullCodeWave, sps, bps, audioFileName);
Note: See TracBrowser for help on using the repository browser.