%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Multimedia Signal Synthesis at CTU Prague % by Roman Cmejla %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Suggestions for 10th laboratory: % Granular synthesis % December 4, 2015 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Recommended links: % http://en.wikipedia.org/wiki/Granular_synthesis % http://music.columbia.edu/cmc/musicandcomputers/chapter4/04_08.php % http://www.sfu.ca/~truax/gsample.html % http://www.soundonsound.com/sos/dec05/articles/granularworkshop.htm % http://www.cs.cf.ac.uk/Dave/Multimedia/PDF/05_Audio_Synthesis.pdf, pp/ 77-90 % http://ses.library.usyd.edu.au/handle/2123/9142 % http://www.granularsynthesis.com/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % EXAMPLE 1: Granular synthesis close all; clear all; fs = 20000; delka_zrna = 0.01; tg = [0:1/fs:delka_zrna-1/fs]; sigma = 0.001; mu = 0.005; doba = 2; mezera_mezi_zrny = 0.015; krok = mezera_mezi_zrny*fs; t = [0:1/fs:doba-1/fs]; y=zeros(1,doba*fs); sp=doba/mezera_mezi_zrny; for m=0:round(sp)-1 for n=1:delka_zrna*fs; f=1000; % konstrukce zrna A=1/(sigma*sqrt(2*pi))*exp(-(tg-mu).^2/(2*sigma^2)); yg=A.*cos(2*pi*f*tg); % přidání zrna ke vzorkum y(m*krok+n)=yg(n); end end %% % EXAMPLE 2: Granular synthesis in spectral domain % bw ............. sirka pasma (pocet spektralnich car) % f_c ............ centralni frekvence (poradi spektralni cary) % d .............. hustota zrn % nfft ........... počet bodů FFT % n_seg .......... počet segmentů bw = 20; f_c = 30; d = .5; nfft = 512; n_seg = 1000; %% % EXAMPLE 3: Concatenation synthesis clear all; fs=8000; % TVORBA DATABAZE load nula.asc; load jedna.asc; load dve.asc; load tri.asc; load ctyri.asc; load pet.asc; load sest.asc; load sedum.asc; load osum.asc;load devet.asc; xx0=nula'; xx1=jedna'; xx2=dve'; xx3=tri'; xx4=ctyri'; xx5=pet'; xx6=sest'; xx7=sedum'; xx8=osum'; xx9=devet'; % SYNTEZA % TEXT = input('Vlozte posloupnost cisel, ktera bude prevedena na rec: \n','s'); TEXT='612561256125'; rec=[]; for i=1:length(TEXT) eval(['rec=[rec xx',TEXT(i),'];']); end; soundsc(rec,fs); subplot(211), plot(rec,'k'), axis tight subplot(212), specgram(rec), colormap (1-gray) %% % EXAMPLE 4: Decimation %% % EXAMPLE 5: Interpolation %% % EXAMPLE 6: Interpolation in frequency domain % Signal generation clear, t=0:.005:0.2-0.01; x=0.5*cos(2*pi*30*t)+0.5*sin(2*pi*60*t);