Link to home
Start Free TrialLog in
Avatar of ferman-k
ferman-kFlag for United Kingdom of Great Britain and Northern Ireland

asked on

play a sound

hi,,, i am in the midle of a work to play a sound on MATLAB through a GUI that i have already created. i tryed to perform the final operation but the system can't play the sound, it there anyone please who can help me to either correct my code or let me know a different line of code that can play the sound file i have

ps/// i have a button on the GUI, and i am using call back method to play the file...
thank you
function Sound_Filter
 
set(0, 'Units', 'normalized');
%Get screen size so gui can be centered
Ssize = get(0, 'Screensize');
 
H.gui = dialog('WindowStyle', 'normal', ...
                'Resize', 'on', ...
                'Name', 'Sound_Filter', ...
                'Units', 'normalized', ...
                'Position', [Ssize(3) / 4 Ssize(4) / 4 0.5 0.5]); 
 %***********************
            
DefOutPos = get(H.gui, 'OuterPosition');
set(H.gui, 'UserData', DefOutPos);
 
%Create top-level Menu
Hm = uimenu('Parent', H.gui, 'Label', 'Menu Example');
uimenu('Parent', Hm, ...
        	 'Label', 'Close', ...
       	 'Callback', 'close(gcbf)');
     %***********************
 
Hbutton = uicontrol('Parent', H.gui, ...
                    'Style', 'pushbutton', ...
                    'Units', 'normalized', ...
                    'Position', [0.4 0.1 0.2 0.1], ...
                    'String', 'Play!', ...
                    'Callback', 'play(deng, f)');

Open in new window

Avatar of yuk99
yuk99
Flag of United States of America image

The problem is in the last line. Where do you set variables deng and f?
Try to replace it with
'Callback', 'load gong;wavplay(y,Fs);');
:)
Do you want an user to set a sound or it will be fixed? Is it a wav file? Or will it be recorded?
You can use wavread to read the file and wavplay to play it.
Avatar of ferman-k

ASKER

i have a sound file, and i want to play that only, i have tryed through command window, using commands, i could manage to play it, but when i played your code in the through my GUI, i was getting different sound which was not my file, can you please send me a code that read my sound file that i have and called (deng.wav)
ASKER CERTIFIED SOLUTION
Avatar of yuk99
yuk99
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial