Solved

play a sound

Posted on 2009-05-06
3
1,679 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: 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…
This article will show, step by step, how to integrate R code into a R Sweave document
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

695 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