Mercurial > hg > smallbox
view util/classes/@audio/plot.m @ 162:88578ec2f94a danieleb
Updated grassmannian function and minor debugs
author | Daniele Barchiesi <daniele.barchiesi@eecs.qmul.ac.uk> |
---|---|
date | Wed, 31 Aug 2011 13:52:23 +0100 |
parents | e3035d45d014 |
children | 1495bdfa13e9 |
line wrap: on
line source
function plot(obj) %% Plot the time domain signal s = obj.s; fs = obj.fs; figure, plot((1:length(s))/fs,s); title('Audio signal') xlabel('time (s)'); axis tight player = audioplayer(s,fs); set(player,'StartFcn',@plotTransportBar); set(player,'TimerFcn',@updateTransportBar); set(player,'StopFcn',@deleteTransportBar); %% Add playbaack controls playButtonH = uicontrol(gcf,'Style','pushbutton','String','play','Units',... 'Normalized','Position',[0.02 + 0.39 0 0.1 0.05]); stopButtonH = uicontrol(gcf,'Style','pushbutton','String','stop','Units',... 'Normalized','Position',[0.12 + 0.39 0 0.1 0.05]); set(playButtonH,'Callback',@play_callback); set(stopButtonH,'Callback',@stop_callback); function play_callback(~,~) if strcmpi(get(playButtonH,'String'),'play') play(player,player.CurrentSample); set(playButtonH,'String','pause'); else pause(player) set(playButtonH,'String','play'); end end function stop_callback(~,~) stop(player); end %% Transport Bar functions function plotTransportBar(~,~) global tbH xLim = get(gca,'Xlim'); yLim = get(gca,'YLim'); tbH = line([xLim(1) xLim(1)],yLim,'Color','k'); end function updateTransportBar(hObject,~) global tbH currentSample = hObject.CurrentSample; pos = currentSample/fs; set(tbH,'XData',[pos pos]); end function deleteTransportBar(~,~) global tbH delete(tbH); end end