Skip to content

Commit

Permalink
Document MML, fix MML stopping
Browse files Browse the repository at this point in the history
  • Loading branch information
jkotlinski committed Apr 16, 2014
1 parent 71efe06 commit 1f2be36
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 3 deletions.
5 changes: 5 additions & 0 deletions docs/intro.tex
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,8 @@ \subsection{Fractals}

The fractals can then be shown by typing \texttt{koch weed1 bush1 bush2}. When a fractal have finished drawing, press any key to continue.

\subsection{Music}

The mmldemo package demonstrates the MML music capabilities. To run:

\texttt{s" mmldemo" load frere-jaques sarias-song}
1 change: 1 addition & 0 deletions docs/manual.tex
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
\input{editor.tex}
\input{forth.tex}
\input{gfx.tex}
\input{mml.tex}
\appendix
\input{asm.tex}
\input{memmap.tex}
Expand Down
25 changes: 25 additions & 0 deletions docs/mml.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
\chapter{Music}

\section{Music Macro Language}

Music Macro Language (MML) has been used since the 1970s to sequence music on computer and video game systems. MML support is included in durexForth, starting with version 1.3. The package is loaded with \texttt{s" mml" load"}. Two demonstration songs can be found in the \texttt{mmldemo} package.

MML songs are played using the Forth word \texttt{play-mml} which takes three strings, one MML melody for each of the three SID voices. An example song is as follows:

\begin{verbatim}
: frere-jaques
s" o3l4fgaffgafab->c&c<ab->c&cl8cdc<b-l4af>l8cdc<b-l4affcf&ffcf&f"
s" r1o3l4fgaffgafab->c&c<ab->c&cl8cdc<b-l4af>l8cdc<b-l4affcf&ffcf&f"
s" " play-mml ;
\end{verbatim}

\section{Commands}

\begin{description}
\item[cdefgab] The letters \texttt{c} to \texttt{b} represent musical notes. Sharp notes are produced by appending a \texttt{+}, flat notes are produced by appending a \texttt{-}. The length of a note is specified by appending a number representing its length as a fraction of a whole note -- for example, \texttt{c8} represents a C eight note, and \texttt{f+2} an F\# half note. Appending a \texttt{.} increases the duration of the note by half of its value.
\item[o] Followed by a number, \texttt{o} selects the octave the instrument will play in.
\item[r] A rest. The length of the rest is specified in the same manner as the length of a note.
\item[$<$,$>$] Used to step down or up one octave.
\item[l] Followed by a number, specifies the default length used by notes or rests which do not explicitly specify one.
\item[\&] Ties two notes together.
\end{description}
14 changes: 13 additions & 1 deletion forth_src/mml.fs
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,23 @@ default-pause lda, default-pause 3 + sta,
:- sid lda,y d400 sta,y
dey, -branch bpl, ;asm

:asm notdone
dex, dex,
0 lda,# voice sta,
.strget jsr, 0 ora,# +branch bne,
voice inc,
.strget jsr, 0 ora,# +branch bne,
voice inc,
.strget jsr, 0 ora,# +branch bne,
0 lda,# 0 sta,x 1 sta,x ;asm
:+ :+ :+
0 sta,x ;asm

: play
voice0 do-commands
voice1 do-commands
voice2 do-commands voicedone
a2 c@ wait begin strget while
a2 c@ wait begin notdone while
voice0 voicetick
voice1 voicetick
voice2 voicetick voicedone
Expand Down
7 changes: 5 additions & 2 deletions forth_src/mmldemo.fs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@


s" mml" load
: mmldemo
# saria's song (zelda lost woods theme)
: frere-jaques
s" o3l4fgaffgafab->c&c<ab->c&cl8cdc<b-l4af>l8cdc<b-l4affcf&ffcf&f"
s" r1o3l4fgaffgafab->c&c<ab->c&cl8cdc<b-l4af>l8cdc<b-l4affcf&ffcf&f"
s" " play-mml ;
: sarias-song
s" l16o3f8o4crcrcro3f8o4crcrcro3f8o4crcrcro3f8o4crcro3cre8o4crcrcro3e8o4crcrcro3e8o4crcrcro3e8o4crcro3c8f8o4crcrcro3f8o4crcrcro3f8o4crcrcro3f8o4crcro3cro3e8o4crcrcro3e8o4crcrcro3e8o4crcrcro3e8o4crcrc8o3drardraro2gro3gro2gro3grcro4cro3cro4cro2aro3aro2aro3aro3drardraro2gro3gro2gro3grcro4cro3cro4cro2aro3aro2aro3aro3drardraro2gro3gro2gro3grcro4cro3cro4cro2aro3aro2aro3aro3drararrrdrararrrcrbrbrrrcrbrbrrrerarrrarerarrrarerg+rg+rg+rg+rrre&er"
s" l16o5frarb4frarb4frarbr>erd4<b8>cr<brgre2&e8drergre2&e4frarb4frarb4frarbr>erd4<b8>crer<brg2&g8brgrdre2&e4r1r1frgra4br>crd4e8frg2&g4r1r1<f8era8grb8ar>c8<br>d8cre8drf8er<b>cr<ab1&b2r4e&e&er"
s" l16r1r1r1r1r1r1r1r1o4drerf4grarb4>c8<bre2&e4drerf4grarb4>c8dre2&e4<drerf4grarb4>c8<bre2&e4d8crf8erg8fra8grb8ar>c8<br>d8crefrde1&e2r4"
Expand Down

0 comments on commit 1f2be36

Please sign in to comment.