Difference between revisions of "Signály"
From RoboWiki
(→Testovacie signály) |
|||
Line 17: | Line 17: | ||
Toto nefunguje (a asi ani nebude): {{mfile|signaly.m|signaly.m}} | Toto nefunguje (a asi ani nebude): {{mfile|signaly.m|signaly.m}} | ||
+ | |||
+ | |||
+ | |||
+ | === Harmonické signály === | ||
+ | |||
+ | V nasledujúcom príklade vytvoríme v Matlabe/Octave harmonický signál a jeho rôzne kombinácie. | ||
+ | |||
+ | |||
+ | <gallery> | ||
+ | Image:A4.png|[[Media:sinusA4_44k.wav Komorné A (A4)]] | ||
+ | Image:ChordA4.png|[[Media:chordA4_44k.wav A-durovy kvintakord (A+Cis+E)]] | ||
+ | Image:NoiseA4.png|[[Media:noiseA4_44k.wav Zašumené A4]] | ||
+ | </gallery> | ||
+ | |||
Revision as of 13:06, 19 June 2008
Budeme sa zaoberať nasledovnými typmi signálov:
- umelé,
- prírodné,
- audio,
- video.
Testovacie signály
Na testovanie sa používajú umelé signály
- impulz
- skok
- harmonický signál
- šum
Toto nefunguje (a asi ani nebude): http://virtuallab.kar.elf.stuba.sk/robowiki/images/5/52/Mfile_icon.png signaly.m
Harmonické signály
V nasledujúcom príklade vytvoríme v Matlabe/Octave harmonický signál a jeho rôzne kombinácie.
% Priklad na vytvaranie harmonickych signalov
%
% Okrem vykreslovania mozeme spravit export do .wav suboru a potom
% si vysledne zvuky prehravat a prezerat napriklad v Audacity
% zaujimave su aj spektralne charakteristiky signalov
%
% (c) Richard Balogh, 30. 5. 2008
%
%
%
% %%%%%%%%%%%%% Signal 1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
f_sample = 8000; % [Hz] - pre telefony OK
duration = 1; % [s] - jedna sekunda
time = 0 : (1/f_sample) : duration;
% time = linspace(0,duration,f_sample); % Alternativa zapisu
freq = 440; % Komorne A4 = 440 Hz
A = 0.9; % Amplituda je z intervalu <-1,1>
A4 = A * sin(2*pi*freq*time);
% plot(A4); % Mozeme si aj nakreslit
wavwrite(A4',"sinusA4_8k.wav"); % A4' - wavwrite potrebuje stlpec
% %%%%%%%%%%%%% Signal 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A = 1.9; % To iste, ale zvacsime apmplitudu
A4 = A * sin(2*pi*freq*time);
wavwrite(A4',"sinusA4_8k_orez.wav"); % Orezany signal, ma vyssie harmonicke
% %%%%%%%%%%%%% Signal 3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
f_sample = 44100; % [Hz] - CD audio
duration = 1; % [s] - jedna sekunda
time = 0 : (1/f_sample) : duration;
freq = 440; % Komorne A4 = 440 Hz
A = 0.9; % Vratime zasa naspat
A4 = A * sin(2*pi*freq*time);
wavwrite(A4',f_sample,16,"sinusA4_44k.wav"); % Musime zadat, ak f_sample != 8k
% %%%%%%%%%%%%% Signal 4 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Akord A4 + C5# + E5
% A4 = 440 Hz
% C5# = 554,37
% E5 = 659,26
% http://www.phy.mtu.edu/~suits/notefreqs.html
%
A4 = A * sin(2*pi*440.00*time);
Cis5 = A * sin(2*pi*554.37*time);
E5 = A * sin(2*pi*659.26*time);
Tone = (A4 + Cis5 + E5)/3; % Aby amplituda bola <-1,1>
wavwrite(Tone',f_sample,16,"chordA4_44k.wav");
% %%%%%%%%%%%%% Signal 5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Pridame k tonu sumovu zlozku
%
noise = 0 + 0.2 * randn(size(time)); % \mu = 0, \sigma = 0.2
Tone = (A4 + noise)/2; % Aby amplituda bola <-1,1>
wavwrite(Tone',f_sample,16,"noiseA4_44k.wav");