source: orbit/octave/GenerateAudioCommand/bitGen.m @ f22b7ab

RawEEGRaw_EEG_PlotServoTab_Interfacepyramid
Last change on this file since f22b7ab was 0edc9d8, checked in by AzureViolin <zhanghaotz@…>, 8 years ago

generated working iPad init Code

  • Property mode set to 100644
File size: 677 bytes
Line 
1function wave = bitGen(bit,num,sps)
2
3% bit: 1 means bit "1", 0 means bit "0".
4% num: how many certain bit to generate.
5% audioFileName: like 'audio.wav'.
6
7longHIGH=875;
8longLOW=729;
9shortHIGH=458;
10shortLOW=333;
11
12if (bit==0)     bit = 2; endif % data of bit "0" stores in second column in a matrix
13 
14bps = 16;       % bits per sample
15%sps = 960000;     % sample rate [samples/s]
16period = [0.0016 0.0008];   %period of bit "1" and bit "0", respectively [s]
17freq = floor(1./period);       % frequency of the tone [Hz]
18
19nsecs = num*period(bit);      % number of seconds of the audio file
20nsamples = sps*nsecs;
21
22time = linspace(0, nsecs, nsamples);
23wave = sin(time*2*pi*freq(bit))';
24
Note: See TracBrowser for help on using the repository browser.