Code covered by the BSD License  

Highlights from
nplay

Be the first to rate this file! 4 Downloads (last 30 days) File Size: 1.81 KB File ID: #11221

nplay

by Naor Movshovitz

 

29 May 2006 (Updated 14 Jun 2006)

Plays a musical tune given notes and durations. (REQUIRES nsound.m)

| Watch this File

File Information
Description

NPLAY(music) plays a tune on the speakers using the nsound function to create pitch vectors for each note and MATLAB's sound function to play
the notes on the speakers. Each row of the cell array music represents one note to be played, and the duration to play it. The notes are specified using standard English notation, e.g., C, D#, etc. Supported notes are those recognized by nsound.m. Can you thing of a more convenient write short musical tunes? Contact me.

MATLAB release MATLAB 7 (R14)
Other requirements nsound.m (also in this category)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
19 Apr 2007 Ekaterina Vinnik

to avoid clicks in the end and the beginning of each tone, add the following lines:

%% fading the vector to avoid clicks

fadetime=.01; %sec
fadein=0:1/(Fs*fadetime):1;
fadeout=1:(-1/(Fs*fadetime)):0;

y(1:(length(fadein)))=y(1:(length(fadein))).*fadein;

y(length(y)+1-(length(fadein)):length(y))=y(length(y)+1-(length(fadein)):length(y)).*fadeout;

after generating the vector itself
%% --- Create a pitch vector ---

Fs=8100; % Sampling frequency.
t=0:1/Fs:duration;
y=sin(2*pi*f*t);

Please login to add a comment or rating.
Updates
14 Jun 2006

should be in category utilities>sound

Tag Activity for this File
Tag Applied By Date/Time
sound Naor Movshovitz 22 Oct 2008 08:27:10
music play Naor Movshovitz 22 Oct 2008 08:27:10
musical tune Naor Movshovitz 22 Oct 2008 08:27:10
notes Naor Movshovitz 22 Oct 2008 08:27:10
speakers Naor Movshovitz 22 Oct 2008 08:27:10

Contact us at files@mathworks.com