MATLAB Playing a Music File from Matlab

Click For Summary
The discussion centers on using MATLAB's audioplayer functionality to play a sound alert when a calculation converges, particularly in the context of a non-linear least squares problem. The user references the MATLAB documentation and an example involving Handel's "Hallelujah Chorus," which demonstrates how to load and play an audio file using the audioplayer function. Key points include the need to load an audio file, define the sample rate, and ensure the audio plays upon convergence of the calculation. Suggestions for alternative tunes are welcomed, and resources for creating custom music in MATLAB are also provided. The user seeks clarity on implementing the code effectively to achieve the desired outcome.
brydustin
Messages
201
Reaction score
0
I would like to run a calculation so that when it has converged, a song will play... to alert me from the other room (for example).

http://www.mathworks.co.uk/help/techdoc/ref/audioplayer.html

I found this but can't quite put it together? Their example was:

Examples

Load and play a sample audio file of Handel's "Hallelujah Chorus:"

load handel;
player = audioplayer(y, Fs);
play(player);

I'm not clear on this... Okay, so any explanations greatly appreciated; also, you are welcome to suggest a tune to play once convergence is met (its a non-linear least squares problem, maybe it will inspire the tune :O)
 
Physics news on Phys.org
sound(y,Fs)

where y is the wavefile you want to play and Fs is the sample rate.

you can write your own music:
http://www.lifeorange.com/MATLAB/MATLAB_music.htm

or you can load the handel edxample that comes with matlab, which comes with its own "y" and "Fs"

load handel.mat;
sound(y, Fs);
 

Similar threads

Replies
1
Views
4K
  • · Replies 3 ·
Replies
3
Views
48K