This function plays musical tunes. Write your own musical tune and call the function to play it.
[CDEFGAB] keys, 5 full octaves
 key/rest duration, with the default  semiquaver,  quaver,  crochet and  minim
[#] sharp / [b] flat / [.] rest / [^] raise octave / [_] lower octave
The algorithm is based on the Karplus-Strong string synthesis methods:
 Karplus & Strong, "Digital synthesis of plucked string and drum timbres", Computer Music Journal, vol. 7, no. 2, pp. 43-55, 1983.
 Jaffe & Smith, "Extensions of the Karplus-Strong plucked-string algorithm", Computer Music Journal, vol. 7, no. 2, pp. 56-69, 1983.
The musical scores for Canon in D (Pachelbel), Prelude No 1 (Bach), and The Globe Trotter are also provided.
Essential files: playtune.m
Accompanying files: canon_in_d.m, prelude_no_1.m, the_globe_trotter.m
Alan Tan (2021). PlayTune (https://www.mathworks.com/matlabcentral/fileexchange/11441-playtune), MATLAB Central File Exchange. Retrieved .
But still can be improved.
e.g: '4F4F'(command)='8F'(what i got),actually i want two F
and whatever the note is(semiquaver or quaver and so on),the duration of each note is decided by how many beats there are in one second(which is set by the composer),maybe we can add a input value to change the tempo?
Hi John, I've taken your advice and added some examples and included the notation (above) in the help of playtune.
I do wish the author had included a bit more help with playtune. For example, the notation is described in the website description, but not in the help for playtune. (Please fix this!) I've rated it a 5 anyway.
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!