% Demo_2 %% The simple case as described in the paper, but with %% bell curve envelopes. % Initializations fs = 22050; % sampling frequency nu = 220; % tone (Low A) num_beats = 5; % number of "harmonics" r = 1.25; % beats per second of first "harmonic" len = 15; % number of beats of the sample (of the first "harmonic") %%% The User Interface %%% % Tone Frequency (nu) uicontrol('Style','text',... 'Units','normalized',... 'position',[.03 .95 .18 .04],... 'String','Tone Frequency'); t_tone_frequency=uicontrol('Style','edit',... % change tone frequency (nu) 'Units','normalized',... 'Position',[0.09 .91 .07 .04],... 'Min',0.1,'Max',1,... 'String',num2str(nu),... 'Callback',[... 'nu = str2num(get(gcbo,''String''));'... 'set(t_tone_frequency,''Value'', nu);'... ]); % Fundamental Frequency (r) uicontrol('Style','text',... 'Units','normalized',... 'position',[.01 .82 .23 .07],... 'String','Fundamental Frequency [beats/sec]'); t_fund_frequency=uicontrol('Style','edit',... % change fundamental frequency (r) 'Units','normalized',... 'Position',[0.09 .78 .07 .04],... 'Min',0.1,'Max',1,... 'String',num2str(r),... 'Callback',[... 'r = str2num(get(gcbo,''String''));'... 'set(t_fund_frequency,''Value'', r);'... ]); % Number of beats (num_beats) uicontrol('Style','text',... 'Units','normalized',... 'position',[.01 .68 .23 .07],... 'String','Number of Beat Patterns (Harmonics)'); t_number_beats=uicontrol('Style','edit',... % change number of beats (num_beats) 'Units','normalized',... 'Position',[0.09 .64 .07 .04],... 'Min',0.1,'Max',1,... 'String',num2str(num_beats),... 'Callback',[... 'num_beats = str2num(get(gcbo,''String''));'... 'set(t_number_beats,''Value'', num_beats);'... ]); % Length (len) uicontrol('Style','text',... 'Units','normalized',... 'position',[.01 .55 .22 .06],... 'String','Length (Number of beats of first harmonic)'); t_length=uicontrol('Style','edit',... % change length (len) 'Units','normalized',... 'Position',[0.09 .51 .07 .04],... 'Min',0.1,'Max',1,... 'String',num2str(num_beats),... 'Callback',[... 'len = str2num(get(gcbo,''String''));'... 'set(t_length,''Value'', len);'... ]); % Play Demo uicontrol('Style','pushbutton',...% Start Demo button 'Units','normalized',... 'Position',[.01 .40 .23 .07],... 'Callback','beat_demo2',... 'String','Increasing Beat Demo'); %% Show the envelopes envs = axes ('position', [0.32 0.54 0.66 0.4]); xlabel ('Percentage of Time') ylabel ('Amplitude') title ('Envelopes') %% Show the wave form wav_form = axes ('position', [0.12 0.085 0.86 0.3]); xlabel ('Percentage of Time') ylabel ('Amplitude') title ('Wave Form')