1 | function initWave=initCodeGenAndroid(audioFileName,sps); |
---|
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. |
---|
6 | bps = 16; % bits per sample |
---|
7 | |
---|
8 | _longHIGH=1000; %[us] |
---|
9 | _longLOW=2000; |
---|
10 | _mediumLOW=500; |
---|
11 | _shortHIGH=100; |
---|
12 | _shortLOW=180; |
---|
13 | _pause=10000; |
---|
14 | _space=84354; |
---|
15 | |
---|
16 | longHIGH=floor(_longHIGH*sps/1e6)-1; |
---|
17 | longLOW=floor(_longLOW*sps/1e6)+1; |
---|
18 | mediumLOW=floor(_mediumLOW*sps/1e6)-1; |
---|
19 | shortHIGH=floor(_shortHIGH*sps/1e6)+1; |
---|
20 | shortLOW=floor(_shortLOW*sps/1e6); |
---|
21 | pause=floor(_pause*sps/1e6); |
---|
22 | space=floor(_space*sps/1e6); |
---|
23 | |
---|
24 | initWave=[halfSineGenDirect('u',longHIGH,0,1,sps);zeros(longLOW,1);halfSineGenDirect('u',longHIGH,0,1,sps);zeros(longLOW,1);halfSineGenDirect('u',longHIGH,0,1,sps);halfSineGenDirect('d',mediumLOW,0,1,sps);halfSineGenDirect('u',shortHIGH,0,1,sps)]; |
---|
25 | |
---|
26 | initWave2=[initWave;halfSineGenDirect('d',shortLOW,0,1,sps)]; |
---|
27 | initWave=[initWave;halfSineGenDirect('d',mediumLOW,0,1,sps)]; |
---|
28 | |
---|
29 | |
---|
30 | for i=1:4 |
---|
31 | initWave=[initWave;halfSineGenDirect('u',shortHIGH,0,1,sps);halfSineGenDirect('d',shortLOW,0,1,sps);]; |
---|
32 | initWave2=[initWave2;halfSineGenDirect('u',shortHIGH,0,1,sps); halfSineGenDirect('d',shortLOW,0,1,sps);]; |
---|
33 | endfor |
---|
34 | |
---|
35 | initWave=[initWave;halfSineGenDirect('u',shortHIGH,0,1,sps);halfSineGenDirect('d',mediumLOW,0,1,sps);halfSineGenDirect('u',shortHIGH,0,1,sps)]; |
---|
36 | |
---|
37 | initWave2=[initWave2;halfSineGenDirect('u',shortHIGH,0,1,sps); halfSineGenDirect('d',mediumLOW,0,1,sps);halfSineGenDirect('u', shortHIGH,0,1,sps)]; |
---|
38 | |
---|
39 | initWave=[initWave;zeros(pause,1);initWave;zeros(pause,1);initWave;zeros(pause,1);initWave2;zeros(pause,1);initWave2;zeros(pause,1);initWave2;zeros(pause,1)]; |
---|
40 | |
---|
41 | |
---|
42 | |
---|
43 | wavwrite(initWave, sps, bps, audioFileName); |
---|