Play Stephen Foster's "Beautiful Dreamer" Using MATLAB
Combine your love for math with your love for music by utilizing the exponential and sine functions in Matlab to create signals that recreate a piece of music. This example delves into the replication of Stephen Foster’s classic parlor song “Beautiful Dreamer.”
Playing “Beautiful Dreamer” on the piano requires the range of keys B3, the key immediately left to Middle C, to D5. Additionally, this song includes only one sharp note, C#4. Each note has its own unique frequency, which we can use to create sine waves on Matlab for each note at lengths we specify. How can the exponential function aid in the production of a note then? The addition of the exponential function serves to aid in the production of a more natural sounding note. Multiplying the sine waves by a negative exponential gradually quiets the sound of the note as time goes on just as a note slowly fades to silence after hitting a key on the piano.