source: orbit/octave/GenerateAudioCommand/halfSineGenDirect.m @ d604d68

RawEEGRaw_EEG_PlotServoTab_Interfacepyramid
Last change on this file since d604d68 was 85e0208, checked in by AzureViolin <zhanghaotz@…>, 10 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
RevLine 
[0edc9d8]1function wave = halfSineGenDirect(dir,halfPeriod_in_samples,zero,amp,sps)
2
[85e0208]3% generate half Sine wave, at a length of certain samples.
4
[0edc9d8]5% dir: 'u' means UP, 'd' means down.
[85e0208]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.
[0edc9d8]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
[cb3655b]17%linspace is an octave function that generates a sequence with certain step.
[a0b523e]18time = linspace(1/sps, halfPeriod, halfPeriod_in_samples);
[0edc9d8]19if (dir== 'u')
[cb3655b]20        wave = sin(time*2*pi*freq)'.*amp+zero;%'u' indicates above zero line
[0edc9d8]21elseif (dir=='d')
[cb3655b]22        wave = sin((time+halfPeriod)*2*pi*freq)'.*amp+zero;%'d' indicates below zero line
[0edc9d8]23endif
24
25%wavwrite(wave, sps, bps, 'audio.wav');
Note: See TracBrowser for help on using the repository browser.