Difference between revisions of "Signály"
From RoboWiki
(→Harmonické signály) |
(→Harmonické signály) |
||
Line 21: | Line 21: | ||
=== Harmonické signály === | === Harmonické signály === | ||
+ | |||
+ | * [http://www.jhu.edu/signals/listen-new/listen-newindex.htm Počúvanie fázového posunu] | ||
+ | |||
V nasledujúcom príklade vytvoríme v Matlabe/Octave harmonický signál a jeho rôzne kombinácie. | V nasledujúcom príklade vytvoríme v Matlabe/Octave harmonický signál a jeho rôzne kombinácie. | ||
− | |||
<gallery> | <gallery> | ||
Line 38: | Line 40: | ||
% Okrem vykreslovania mozeme spravit export do .wav suboru a potom | % Okrem vykreslovania mozeme spravit export do .wav suboru a potom | ||
% si vysledne zvuky prehravat a prezerat napriklad v Audacity | % si vysledne zvuky prehravat a prezerat napriklad v Audacity | ||
− | |||
% | % | ||
% (c) Richard Balogh, 30. 5. 2008 | % (c) Richard Balogh, 30. 5. 2008 | ||
Line 54: | Line 55: | ||
freq = 440; % Komorne A4 = 440 Hz | freq = 440; % Komorne A4 = 440 Hz | ||
A = 0.9; % Amplituda je z intervalu <-1,1> | A = 0.9; % Amplituda je z intervalu <-1,1> | ||
+ | fi = 0; % Fazovy posun | ||
− | A4 = A * sin(2*pi*freq*time); | + | A4 = A * sin(2*pi*freq*time + fi); |
% plot(A4); % Mozeme si aj nakreslit | % plot(A4); % Mozeme si aj nakreslit | ||
Line 91: | Line 93: | ||
Tone = (A4 + Cis5 + E5)/3; % Aby amplituda bola <-1,1> | Tone = (A4 + Cis5 + E5)/3; % Aby amplituda bola <-1,1> | ||
wavwrite(Tone',f_sample,16,"chordA4_44k.wav"); | wavwrite(Tone',f_sample,16,"chordA4_44k.wav"); | ||
+ | |||
% %%%%%%%%%%%%% Signal 5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | % %%%%%%%%%%%%% Signal 5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
Line 100: | Line 103: | ||
</source> | </source> | ||
− | |||
− | |||
[[Category:DSP]] | [[Category:DSP]] |
Revision as of 13:35, 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
%
% (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>
fi = 0; % Fazovy posun
A4 = A * sin(2*pi*freq*time + fi);
% 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");