audiovector = [ Cnotes pauseVec Dnotes pauseVec Enotes pauseVec ... ];Since several sinusoidal signals are being added together, the amplitude range of
audiovector
will exceed the range of -1 to 1, and
hence, using the sound
command will result in clipping.
For playback, you could either
soundsc
command, OR
audiovector = audiovector - mean(audiovector); audiovector = audiovector / (max(abs(audiovector));and then play the vector using the
sound
command.
If you were use the sound
command for each note and the
pause
command for each pause, the timing will be off
because you'll be experiencing variable delays from the operating system
to send data to the playback subsystem and for the playback subsystem to
complete the playback on the vector of samples, and variable delays in
implementing the pause duration.
You can also save the scaled vector to a wave file using the command
audiowrite(filename, audiovector, fs);and play it back as a file on your laptop independent of Matlab. The wave format is desirable because it does not apply any compression to the signal.
The audiowrite
command will clip amplitude values outside the range of -1 and 1.