source: orbit/octave/GenerateAudioCommand/halfSineGenDirect.m @ 85e0208

RawEEGRaw_EEG_PlotServoTab_Interfacepyramid
Last change on this file since 85e0208 was 85e0208, checked in by AzureViolin <zhanghaotz@…>, 9 years ago

Android can now generate fly control command on the fly. With a whole lot of bugs, the screen will freeze when tap 'Manual Control'

  • Property mode set to 100644
File size: 933 bytes
Line 
1function wave = halfSineGenDirect(dir,halfPeriod_in_samples,zero,amp,sps)
2
3% generate half Sine wave, at a length of certain samples.
4
5% dir: 'u' means UP, 'd' means down.
6% halfPeriodi_in_samples: half period of sine signal[samples].
7% zero: zero level of cosine signal. DEPRECATED
8% amp: amplitude of cosine signal, in percentage.DEPRECATED
9% sps: sampling rate.
10
11halfPeriod=halfPeriod_in_samples/sps;
12
13bps = 16;       % bits per sample
14period = halfPeriod*2;   %period of [s]
15freq = floor(sps/(halfPeriod_in_samples*2));       % frequency of the tone [Hz]
16
17%linspace is an octave function that generates a sequence with certain step.
18time = linspace(1/sps, halfPeriod, halfPeriod_in_samples);
19if (dir== 'u')
20        wave = sin(time*2*pi*freq)'.*amp+zero;%'u' indicates above zero line
21elseif (dir=='d')
22        wave = sin((time+halfPeriod)*2*pi*freq)'.*amp+zero;%'d' indicates below zero line
23endif
24
25%wavwrite(wave, sps, bps, 'audio.wav');
Note: See TracBrowser for help on using the repository browser.