1 | function initWave=initCodeGenAndroid(audioFileName); |
---|
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 | sps = 48000; % sample rate [samples/s] |
---|
8 | |
---|
9 | longHIGH=45+3; |
---|
10 | longLOW=89+7; |
---|
11 | mediumLOW=21+2; |
---|
12 | shortHIGH=5; |
---|
13 | shortLOW=8; |
---|
14 | pause=480; |
---|
15 | space=4049; |
---|
16 | |
---|
17 | 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)]; |
---|
18 | |
---|
19 | initWave2=[initWave;halfSineGenDirect('d',shortLOW,0,1,sps)]; |
---|
20 | initWave=[initWave;halfSineGenDirect('d',mediumLOW,0,1,sps)]; |
---|
21 | |
---|
22 | |
---|
23 | for i=1:4 |
---|
24 | initWave=[initWave;halfSineGenDirect('u',shortHIGH,0,1,sps);halfSineGenDirect('d',shortLOW,0,1,sps);]; |
---|
25 | initWave2=[initWave2;halfSineGenDirect('u',shortHIGH,0,1,sps); halfSineGenDirect('d',shortLOW,0,1,sps);]; |
---|
26 | endfor |
---|
27 | |
---|
28 | initWave=[initWave;halfSineGenDirect('u',shortHIGH,0,1,sps);halfSineGenDirect('d',mediumLOW,0,1,sps);halfSineGenDirect('u',shortHIGH,0,1,sps)]; |
---|
29 | |
---|
30 | initWave2=[initWave2;halfSineGenDirect('u',shortHIGH,0,1,sps); halfSineGenDirect('d',mediumLOW,0,1,sps);halfSineGenDirect('u', shortHIGH,0,1,sps)]; |
---|
31 | |
---|
32 | 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)]; |
---|
33 | |
---|
34 | |
---|
35 | |
---|
36 | wavwrite(initWave, sps, bps, audioFileName); |
---|