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

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

flyOrbit.m can now generate arbitry control code for play from laptop. update read.me

  • Property mode set to 100644
File size: 724 bytes
RevLine 
[0edc9d8]1function wave = halfSineGenDirect(dir,halfPeriod_in_samples,zero,amp,sps)
2
3% dir: 'u' means UP, 'd' means down.
4% halfPeriod: half period of cosine signal[us].
5% zero: zero level of cosine signal.
6% amp: amplitude of cosine signal, in percentage.
7
8halfPeriod=halfPeriod_in_samples/sps;
9
10bps = 16;       % bits per sample
11%sps = 960000;     % sample rate [samples/s]
12period = halfPeriod*2;   %period of [s]
13freq = floor(sps/(halfPeriod_in_samples*2));       % frequency of the tone [Hz]
14
15
[a0b523e]16time = linspace(1/sps, halfPeriod, halfPeriod_in_samples);
[0edc9d8]17if (dir== 'u')
18        wave = sin(time*2*pi*freq)'.*amp+zero;
19elseif (dir=='d')
20        wave = sin((time+halfPeriod)*2*pi*freq)'.*amp+zero;
21endif
22
23%wavwrite(wave, sps, bps, 'audio.wav');
Note: See TracBrowser for help on using the repository browser.