Ignore:
Timestamp:
11/27/12 18:00:23 (7 years ago)
Author:
AzureViolin <zhanghaotz@…>
Branches:
master, RawEEG, Raw_EEG_Plot, Servo, Tab_Interface, pyramid
Children:
3322dad
Parents:
22d5a76
Message:

generated working iPad init Code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • octave/GenerateAudioCommand/finalCodeAudioGen.m

    r6aa182f r0edc9d8  
    1 function finalCodeAudioGen(code,audioFileName,sps,repeatTime)  
     1function finalCodeAudioGen(code,audioFileName,sps,repeatTime,Multiplyer,flipOrNot)  
    22 
    33% code: array of 1s and 0s. 1 means bit "1", 0 means bit "0". 
    44% audioFileName: like 'audio.wav'. 
    5  
     5% Multiplyer: value around 1, to change "carrier" period. 
    66bps = 16;       % bits per sample 
    77%sps = 96000;     % sample rate [samples/s] 
    88 
    9 codeWave=[halfSineGen('u',800,0,1,sps);halfSineGen('d',400,0,1,sps);halfSineGen('u',800,0,1,sps);halfSineGen('d',400,0,1,sps)]; 
     9longHIGH=875; 
     10longLOW=729; 
     11shortHIGH=458; 
     12shortLOW=333; 
    1013 
     14codeWave=[halfSineGen('u',longHIGH,0,1,sps);zeros(floor(shortLOW*sps/1e6),1);halfSineGen('u',longHIGH,0,1,sps);zeros(floor(shortLOW*sps/1e6),1)]; %starting 5 half period 
     15 
     16% notice that the "code" here should be a 28 bit binary array. 
    1117for i=1:size(code,2) 
    12         codeWave = [codeWave; bitGen(code(i),1,sps)]; 
     18        codeWave = [codeWave; bitGenHDMI(code(i),1,sps)]; 
    1319endfor 
     20 
     21codeWave=[codeWave; halfSineGen('u',longHIGH,0,1,sps)]; %last half period 
     22 
     23if(exist("flipOrNot","var")) 
     24        codeWave=-codeWave; 
     25endif 
    1426 
    1527fullCodeWave=[]; 
     
    1830endfor 
    1931 
     32%Multiplyer=1; 
     33shift=0; 
    2034%special wave form for carrier 
    21 carrierWave=[halfPeriodGen('u',30*1.215,-0.353,0.723,sps); 
    22 halfPeriodGen('d',22*1.215,-0.015,0.384,sps); 
    23 halfPeriodGen('u',31*1.215,0.261,0.661,sps); 
    24 halfPeriodGen('d',28*1.215,0.392,0.530,sps); 
    25 halfPeriodGen('u',25*1.215,0.246,0.384,sps); 
    26 halfPeriodGen('d',32*1.215,-0.092,0.723,sps); 
    27 halfPeriodGen('u',25*1.215,-0.430,0.384,sps); 
    28 halfPeriodGen('d',26*1.215,-0.515,0.469,sps)]; 
     35carrierWave=[halfCosineGen('u',30*Multiplyer,-0.353,0.723,sps,shift); 
     36halfCosineGen('d',22*Multiplyer,-0.015,0.384,sps,shift); 
     37halfCosineGen('u',31*Multiplyer,0.261,0.661,sps,shift); 
     38halfCosineGen('d',28*Multiplyer,0.392,0.530,sps,shift); 
     39halfCosineGen('u',25*Multiplyer,0.246,0.384,sps,shift); 
     40halfCosineGen('d',32*Multiplyer,-0.092,0.723,sps,shift); 
     41halfCosineGen('u',25*Multiplyer,-0.430,0.384,sps,shift); 
     42halfCosineGen('d',26*Multiplyer,-0.515,0.469,sps,shift)]; 
    2943 
    30 fullCodeWave=[fullCodeWave fullCodeWave].*0.5; 
     44fullCodeWave=[fullCodeWave fullCodeWave].*1; 
     45carrierWave=carrierWave.*0.8;%double the amplitude of CodeWave 
    3146 
    3247sizeCW=size(carrierWave,1); 
Note: See TracChangeset for help on using the changeset viewer.