Microsoft Small Basic

Program Listing: SXM582
' Music Composer Sample
' Copyright © 2017 Nonki Takahashi. The MIT License.
' Last update 2017-12-22

GraphicsWindow.Title = "MML Composer"
LF = Text.GetCharacter(10)
notes = "0=R4 ;1=O4C4 ;2=O4D4 ;3=O4E4 ;4=O4F4 ;5=O4G4 ;6=O4A4 ;7=O4B4 ;8=O4C4 ;"
gw = 598
gh = 428
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
GraphicsWindow.BackgroundColor = "LightGray"
GraphicsWindow.BrushColor = "Black"
GraphicsWindow.FontName = "Consolas"
tbox = Controls.AddMultiLineTextBox(10, 10)
Controls.SetSize(tbox, gw - 20, gh - 20)
While "True"
For j = 1 To 16
i = Math.Remainder(j, 9)
note = notes[i]
buf = buf + note
Controls.SetTextBoxText(tbox, buf)
Sound.PlayMusic(note)
EndFor
buf = buf + LF
Controls.SetTextBoxText(tbox, buf)
For j = 1 To 16
i = Math.GetRandomNumber(9) - 1
note = notes[i]
buf = buf + note
Controls.SetTextBoxText(tbox, buf)
Sound.PlayMusic(note)
EndFor
buf = buf + LF
Controls.SetTextBoxText(tbox, buf)
EndWhile