www.gusucode.com > 声音的处理有:LPC,FFT,共振峰,频谱源码程序 > siganlandsystemusingMatlab/SSUM/ssumfn.m

    %
function ssumfn(action)

    if nargin < 1
        action='init';
    end

	name = mfilename;
    figname = ['ssum_fig'];
    f=findobj('Tag',figname);
    handles = get(f,'UserData');

    switch action
        case 'help'
			display_help(figname);
        case 'init'
			setwindow(f);
			handles.applications = {
				'aliasexpo', {'Audio Aliasing Explorer', 'Make an audio signal alias'}, {'sound'}, ...
				'birds', {'Additive Synthesis Forest', 'Bird song synthesized with a few sinewaves'}, {'sound'}, ...
				'complexpo', {'Complex Number Explorer','Learn phasors, adding and mulitplying'}, {'sound','image'},...
				'convexpo', {'Convolution Explorer','Convolve two signals'},{'sound','image'}, ...
				'denoise', {'Denoise Explorer','Experiment with denoising an audiosignal'},{'sound'}, ...
				'dtwexpo', {'Dynamic Time Warping Explorer','Experiment with dynamic time alignment of two speech signals'},{'sound'}, ...
				'endpointexpo', {'Speech Endpoint Explorer','Demonstration of endpointing a speech signal'},{'sound'}, ...
				'fdeqexpo', {'Finite Difference Equation Explorer','Plots frequency, phase, and impulse response of given FDE'},{'sound','image'}, ...
				'featurexpo', {'Signal Feature Explorer','Explore statistic features in signals'},{'sound'}, ...
				'firexpo', {'FIR Filter Explorer','Apply FIR filters to sounds'},{'sound'}, ...
				'formantexpo', {'Formant Explorer','Sweep a window accross a sound and watch its spectrum, formant, and cepstrum change in real-time'},{'sound'}, ...
				'fourierexpo', {'Fourier Explorer','Sweep a window accross a sound and watch its spectrum change in real-time'},{'sound'}, ...
				'fseriesexpo', {'Fourier Series Explorer','Inspect the Fourier series of a periodic step signal','Contributed by Jim Squire'},{'sound'}, ...
				'iirexpo', {'IIR Filter Explorer','Apply IIR filters to sounds'},{'sound'}, ...
				'imgaliasexpo', {'Image Aliasing Explorer','Make an image alias'}, {'image'}, ...
				'imganalsynth', {'Image Analysis/Construction','Analyze image in frequency domain and reconstruct it using original or altered values for magnitudes and phases'}, {'image'}, ...
				'imgfilterexpo', {'Image Filter Explorer','Apply filters to images'}, {'image'}, ...
				'imgspectrumexpo', {'Image Spectrum Explorer','Learn the spatial frequencies'}, {'image'}, ...
				'ksstringexpo', {'Karplus-Strong String Explorer','Physical model of the musical string'}, {'sound'}, ...
				'lpcexpo', {'LPC Explorer','Explore linear prediction'}, {'sound'}, ...
				'modelexpo', {'Communication Model Explorer','Explore different models of communication systems and error rates'}, {'image'}, ...
				'modexpo', {'Modulation Explorer','Modulate two signals using amplitude modulation'},{'sound'}, ...
				'pzexpo', {'Pole-Zero Explorer','Design filters using interactive pole-zero plot'},{'sound'}, ...
				'pzfilterexpo', {'Pole-Zero Filter Explorer','Apply pole-zero filters to sounds'},{'sound'}, ...
				'samplexpo', {'Sampling Explorer','Learn sampling, interpolation, and quantization'}, {'sound'}, ...
				'reverbexpo', {'Reverberation Explorer','Reverberate signals with a cascade of up to three all-pass filters'}, {'sound'}, ...
				'sinexpo', {'Sinewave Explorer','Learn about sinewaves'}, {'sound'}, ...
				'sndanalsynth', {'Sound Analysis/Synthesis','Analyze a signal in frequency domain and resynthesize using original or altered values for magnitudes and phases'},{'sound'}, ...
				'sonoexpo', {'Sonogram Explorer','See the sonogram of a sound'},{'sound'}, ...
				'spectrumexpo', {'Spectrum Explorer','Learn about the spectrum of pure signals'}, {'image'}, ...
				'stocho', {'Catastochastic Composition Machine','Application for composing random music using additive synthesis'},{'sound'}, ...
				'stringexpo', {'String Explorer','Solution to the 1-D wave equation'}, {'sound'}, ...
				'swsexpo', {'Sinewave Speech Synthesis','Approximation of speech using four sinewaves'},{'sound'}, ...
				'wavexpo', {'Wavegenerator','Create different waveforms using fifteen sinewaves'}, {'sound'}, ...
				'vqexpo', {'Vector Quantization Explorer','Experiment with vector quantizing of a speech signal'},{'sound'}, ...
				'xsynthexpo', {'Cross-Synthesis Explorer','Cross-synthesize two signals using convolution, amplitude modulation, or LPC'},{'sound'}
			};
			set(handles.application,'String',handles.applications(1:3:end));
			app = get(handles.application,'Value');
			set(handles.description,'String',handles.applications{app*3-1});
		case 'app'
			contents = get(handles.application,'String');
			app = contents{get(handles.application,'Value')};
			appnum = find(strcmp(handles.applications,app));
			set(handles.description,'String',handles.applications{appnum+1});
		case 'run'
			contents = get(handles.application,'String');
            app = contents{get(handles.application,'Value')};
			eval([app 'gui']);
		case 'selection'
			set(handles.application,'Value',1);
			if get(handles.all,'Value')
				app = handles.applications(1:3:end);
			elseif get(handles.sound,'Value')
				app = {};
				counter = 1;
				for i=1:length(handles.applications)/3
					desc = handles.applications(i*3);
					if sum(strcmp(desc{:},'sound'))
						app{counter} = handles.applications{i*3-2};
						counter = counter + 1;
					end
				end
				set(handles.application,'String',app);
			else
				app = {};
				counter = 1;
				for i=1:length(handles.applications)/3
					desc = handles.applications(i*3);
					if sum(strcmp(desc{:},'image'))
						app{counter} = handles.applications{i*3-2};
						counter = counter + 1;
					end
				end
			end
			set(handles.application,'String',app);
			ssumfn 'app';
		case 'close'
			close_figure(f,figname(1:end-4));
            return;
	end
	set(f,'UserData',handles);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	
function setwindow(f)
	width = 433;
    height = 270;
	x = ones(height,width,3);
    col = ceil(3*rand);
    x(:,:,col) = rand(height,width);
    mask = linspace(0,1,width);
    t = repmat(mask,height,1);
    x(:,:,col) = x(:,:,col).*t;
    col = ceil(3*rand);
    mask = linspace(1,0,height).^0.5;
    t = repmat(mask,width,1)';
    x(:,:,col) = x(:,:,col).*t;
    clear mask t;

	set(f,'number','off',...
            'DoubleBuffer','on','MenuBar','none','Units','Pixels',...
			'Position',[0 0 width+27 height+120],'Color', [0 0 0]);
	h_axis=axes('pos',[0 0 1 1]);
    himage = image(x);
	axis image;
	set(h_axis,'visible','off');

	y = -25;
	offset = 10;
	switch computer
        case {'GLNX86','MAC'}
            text(15.5,y,'\Sigma:',...
                'fontsize',36,...
                'fontweight','bold',...
                'fontangle','italic',...
                'color','blue');
            text(15.5,y-1,'s',...
                'fontsize',28,...
                'fontangle','italic',...
                'color','green');
            text(55.5,y+2,'Signals and Systems Using MATLAB',...
                'fontsize',22,...
                'fontweight','bold',...
                'color',[1 1 1]);
            text(20.5,y+height+50,'\copyright',...
                'fontsize',26,...
                'fontweight','bold',...
                'color',[1 1 1]);
            text(50.5,y+height+51,'2003 University of California, Santa Barbara',...
                'fontsize',18,...
                'fontweight','bold',...
                'color',[1 1 1]);
		case 'PCWIN'
            text(8.5,y,'\Sigma:',...
                'fontsize',36,...
                'fontweight','bold',...
                'fontangle','italic',...
                'color','blue');
            text(16.5,y-1,'s',...
                'fontsize',22,...
                'fontangle','italic',...
                'color','green');
            text(60.5,y+2,'Signals and Systems Using MATLAB',...
                'fontsize',16,...
                'fontweight','bold',...
                'color',[1 1 1]);
            text(20.5,y+height+50,'\copyright',...
                'fontsize',20,...
                'fontweight','bold',...
                'color',[1 1 1]);
            text(50.5,y+height+51,'2003 University of California, Santa Barbara',...
                'fontsize',14,...
                'fontweight','bold',...
                'color',[1 1 1]);
	end