A.11 Play music

A.11.1 Playing music using MIDI synthetizer

sequence, seq list

Put in memory the sequence in the list. Read after this table how to write a sequence.


Play the sequence in memory.

instrument, instr

Returns the number that corresponds to the selected instrument.

setinstrument, sinstr n

The selected instrument is now the instrument number n. You can see the list of all available instruments in menu Options-Preferences-Tab Sound.

indexsequence, indseq

Returns where the cursor is located in the current sequence.

setindexsequence, sindseq n

Put the cursor to index n in the current sequence in memory.

deletesequence, delseq

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 the 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 (twic as fast).
If you want to play this example:
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 ]  

To hear music, launch the command: tabac play
Now, we can see/hear 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 your 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.

A.11.2 Playing MP3

mp3play word1

Reads the mp3 file word1. This file has to be located in the current folder, you can access a network path too. Here are some examples:
mp3play file.mp3
mp3play http://website.com/file.mp3


Stops to play the current mp3 file.