Matlab - very simple GUI, audiorecorder, help

Status
Not open for further replies.

stepan89

Newbie level 4
Joined
Aug 16, 2010
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Czech Republic
Activity points
1,339
Hello everyone,
I am new with matlab and I need your help. I tried to create a very simple gui. When push the button start - it should start to record, when pause it should pause, graf - show the graph from getaudiodata(),... It doesnt work. Dont know why. Thanks for your help. ©tìpán
Code:
function audio(par)

if nargin == 0
f = figure;
set(f, 'Units', 'Pixels',...
        'Position', [300 250 520 480],...
        'NumberTitle', 'off',...
        'Name', 'Audio Panel',...
        'MenuBar', 'none',...
        'Tag', 'figure');

u1 = uicontrol;
set(u1, 'Units', 'Pixels',...
        'Style', 'Push',...
        'Position', [15 15 70 30],...
        'String', 'Start',...
        'Tag', 'button1',...
        'Callback', 'audio button1');

u2 = uicontrol;
set(u2, 'Units', 'Pixels',...
        'Style', 'Push',...
        'Position', [150 15 70 30],...
        'String', 'Pause',...
        'Tag', 'button2',...
        'Callback', 'audio button2');

u3 = uicontrol;
set(u3, 'Units', 'Pixels',...
        'Style', 'Push',...
        'Position', [285 15 70 30],...
        'String', 'Graf',...
        'Tag', 'button2',...
        'Callback', 'audio button3');
    
u4 = uicontrol;
set(u4, 'Units', 'Pixels',...
        'Style', 'Push',...
        'Position', [435 15 70 30],...
        'String', 'Konec',...
        'Tag', 'button2',...
        'Callback', 'audio button4');
else
     s = audiorecorder(44100, 16, 1);
     switch(par)    
        case('button1')
            record(s);
        case('button2')
            stop(s);
        case('button3')
            data = getaudiodata(s, 'double');
            plot(data);
        case('button4')
            close all;
    end
end
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…