File Exchange

image thumbnail


version 1.0 (1.81 KB) by

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

1 Download


View License

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.

Comments and Ratings (1)

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



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

Fs=8100; % Sampling frequency.

MATLAB Release
MATLAB 7 (R14)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video