Solved

play a sound

Posted on 2009-05-06
3
1,676 Views
Last Modified: 2013-11-25
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

0
Comment
Question by:ferman-k
  • 2
3 Comments
 
LVL 15

Expert Comment

by:yuk99
ID: 24318779
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.
0
 

Author Comment

by:ferman-k
ID: 24321345
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)
0
 
LVL 15

Accepted Solution

by:
yuk99 earned 500 total points
ID: 24322015
Try this (not tested).
'Callback', 'deng=wavread(''deng.wav'');wavplay(deng);');

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question