RawEEGRaw_EEG_PlotServoTab_Interfacepyramid
Last change
on this file since cb3655b was
cb3655b,
checked in by dorabot <dorabot@…>, 10 years ago
|
add comment to script
|
-
Property mode set to
100644
|
File size:
858 bytes
|
Line | |
---|
1 | function wave = halfSineGenDirect(dir,halfPeriod_in_samples,zero,amp,sps) |
---|
2 | |
---|
3 | % dir: 'u' means UP, 'd' means down. |
---|
4 | % halfPeriod: half period of sine signal[us]. |
---|
5 | % zero: zero level of cosine signal. |
---|
6 | % amp: amplitude of cosine signal, in percentage. |
---|
7 | |
---|
8 | halfPeriod=halfPeriod_in_samples/sps; |
---|
9 | |
---|
10 | bps = 16; % bits per sample |
---|
11 | %sps = 960000; % sample rate [samples/s] |
---|
12 | period = halfPeriod*2; %period of [s] |
---|
13 | freq = floor(sps/(halfPeriod_in_samples*2)); % frequency of the tone [Hz] |
---|
14 | |
---|
15 | %linspace is an octave function that generates a sequence with certain step. |
---|
16 | time = linspace(1/sps, halfPeriod, halfPeriod_in_samples); |
---|
17 | if (dir== 'u') |
---|
18 | wave = sin(time*2*pi*freq)'.*amp+zero;%'u' indicates above zero line |
---|
19 | elseif (dir=='d') |
---|
20 | wave = sin((time+halfPeriod)*2*pi*freq)'.*amp+zero;%'d' indicates below zero line |
---|
21 | endif |
---|
22 | |
---|
23 | %wavwrite(wave, sps, bps, 'audio.wav'); |
---|
Note: See
TracBrowser
for help on using the repository browser.