Solved

play a sound

Posted on 2009-05-06
3
1,669 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
Comment Utility
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
Comment Utility
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
Comment Utility
Try this (not tested).
'Callback', 'deng=wavread(''deng.wav'');wavplay(deng);');

Open in new window

0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
countTriple  challenge 8 70
method argument as final 1 62
countX 22 68
groovy example issue 10 65
Navigation is an important part of web design from a usability perspective. But it is often a pain when it comes to a developer’s perspective. By navigation, it often means menuing. This is less theory and more practical of how to get a specific gro…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now