Solved

play a sound

Posted on 2009-05-06
3
1,674 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
split53 challenge 7 96
Non-recursive backtracking, using a stack 1 130
Problem to open text file 11 108
Problem to Alipay 10 21
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
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.
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 be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

776 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