[0edc9d8] | 1 | function initWave=initCodeGen(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 | _1stHIGH=14; |
---|

| 10 | _1stLOW=131; |
---|

| 11 | _3rdLOW=16; |
---|

| 12 | _4to9HIGH=12; |
---|

| 13 | _4to9LOW=3; |
---|

[3322dad] | 14 | space=4049; |
---|

[0edc9d8] | 15 | |
---|

| 16 | initWave=[halfSineGenDirect(**'u'**,_1stHIGH,0,1,sps);zeros(_1stLOW,1);halfSineGenDirect(**'u'**,_1stHIGH,0,1,sps);zeros(_1stLOW,1);halfSineGenDirect(**'u'**,_1stHIGH,0,1,sps);zeros(_3rdLOW,1)]; |
---|

| 17 | |
---|

| 18 | **for** i=1:6 |
---|

| 19 | initWave=[initWave;halfSineGenDirect(**'u'**,_4to9HIGH,0,1,sps);zeros(_4to9LOW,1)]; |
---|

| 20 | endfor |
---|

| 21 | |
---|

| 22 | initWave=[initWave;zeros(space,1);initWave;zeros(space,1)]; |
---|

| 23 | |
---|

| 24 | |
---|

| 25 | _3rd_4thHIGH=12; |
---|

| 26 | _3rd_4thLOW=18; |
---|

| 27 | |
---|

| 28 | _3rdInitWave=[halfSineGenDirect(**'u'**,_1stHIGH,0,1,sps);zeros(_1stLOW,1);halfSineGenDirect(**'u'**,_1stHIGH,0,1,sps);zeros(_1stLOW,1);halfSineGenDirect(**'u'**, _3rd_4thHIGH,0,1,sps);zeros(_3rd_4thLOW,1);halfSineGenDirect(**'u'**, _3rd_4thHIGH,0,1,sps);zeros(_3rd_4thLOW,1)]; |
---|

| 29 | |
---|

| 30 | **for** i=1:5 |
---|

| 31 | _3rdInitWave=[_3rdInitWave;halfSineGenDirect(**'u'**,_4to9HIGH,0,1,sps);zeros(_4to9LOW, 1)]; |
---|

| 32 | endfor |
---|

| 33 | |
---|

| 34 | initWave=[initWave;_3rdInitWave;zeros(space,1);_3rdInitWave;zeros(space,1)]; |
---|

| 35 | |
---|

| 36 | |
---|

| 37 | **wavwrite**(initWave, sps, bps, audioFileName); |
---|