next up previous contents index
Next: Loops: Up: List of primitives Previous: Multiturtle Mode   Contents   Index

Play music

Primitives Arguments Utilisation
seq, sequence a: list Put in memory the sequence in the list. Read after this table to learn how to write a sequence.
play none Play the sequence in memory.
instr, instrument none Returns the number that corresponds to the selected instrument.
sinstr, setinstrument a: number The selected instrument is now the instrument number a. You can see the list of all available instruments in menu Options-Preferences-Tab Sound.
indseq, indexsequence none Returns where the cursor is located in the current sequence.
sindseq, setindexsequence a: number Put the cursor to index a in the current sequence in memory.
delseq, deletesequence none Delete the current sequence in memory.


If you want to play music, you must put the notes in memory in a list called sequence. To create the sequence, you can use the primitive seq or sequence. These are rules to follow to create a valid sequence:
do re mi fa sol la si : the usual notes of the first octave.
To make a sharp re, we note re +
To make a flat re, we note re -
If you want to go up or down and octave, we use symbol ":" followed by + or -. E.g. After :++ in the sequence, all the notes will be played two octaves up (two ++) .
By default, notes are played for a duration of one. If you want to increase or decrease, you write the number that corresponds to the duration of notes. E.g. seq [sol 0.5 la si]. will play sol with a duration 1 and la si with a duration 0.5 (twice faster).
If you want to play this example:
\includegraphics{pics/partition.eps}

to tabac
# create the sequence of notes
seq [0.5 sol la si sol 1 la 0.5 la si 1 :+ do do :- si si 0.5 sol la si sol
          1 la 0.5 la si 1 :+ do re 2 :- sol ]
seq [:+ 1 re 0.5 re do 1 :- si 0.5 la si 1 :+ do re 2 :- la ]
seq [:+ 1 re 0.5 re do 1 :- si 0.5 la si 1 :+ do re 2 :- la ]
seq [0.5 sol la si sol 1 la 0.5 la si 1 :+ do do :- si si 0.5 sol la si sol
          1 la 0.5 la si 1 :+ do re 2 :- sol ]
end

To hear music, launch the command: tabac play
Now, we can see an interesting application of the primitive sindseq. Write those commands:

delseq       # Delete the sequence in memory
tabac       # Put in memory the notes
sindseq 2   # Put the cursor on the second "la".
tabac       # Put in memory the same sequence but translated of 2.
play        # Great!

You can choose you instrument with the primitive sinstr or with the menu Options-Preferences-Tab sound. You will find the list of all available instruments with their associated number.


next up previous contents index
Next: Loops: Up: List of primitives Previous: Multiturtle Mode   Contents   Index
Loïc 2008-06-08