source: orbit/octave/GenerateAudioCommand/bitGen.m @ 6aa182f

RawEEGRaw_EEG_PlotServoTab_Interfacepyramid
Last change on this file since 6aa182f was 6aa182f, checked in by AzureViolin <zhanghaotz@…>, 7 years ago

add octave script

  • Property mode set to 100644
File size: 620 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
7if (bit==0)     bit = 2; endif % data of bit "0" stores in second column in a matrix
8 
9bps = 16;       % bits per sample
10%sps = 960000;     % sample rate [samples/s]
11period = [0.0016 0.0008];   %period of bit "1" and bit "0", respectively [s]
12freq = floor(1./period);       % frequency of the tone [Hz]
13
14nsecs = num*period(bit);      % number of seconds of the audio file
15nsamples = sps*nsecs;
16
17time = linspace(0, nsecs, nsamples);
18wave = sin(time*2*pi*freq(bit))';
19
Note: See TracBrowser for help on using the repository browser.