#ATMlib
ATMlib stands for **Arduboy Tracker Music** and is based on [_**Squawk**_](https://github.com/stg/Squawk "Squawk Github Page") a minimalistic 8-bit software synthesizer & playroutine library for Arduino, created by Davey Taylor aka STG.
While _Squawk_ provides a very nice synth, it wasn't optimized for a small footprint. Songs are not very efficient in size, so Joeri Gantois aka JO3RI asked Davey to help him work on a new songformat and so ATMlib was born.
Contributers:
* Davey Taylor - ATMsynth - Effects
* Joeri Gantois - Effects
### FILE/ARRAY FORMAT DESCRIPTION
|**Section** | **Field** | **Type** | **Description**
|--- | --- | ---------------- | ---
|**Track table** | | | **Number of tracks and their addresses**
| | Track count | UBYTE (8-bits) | Number of tracks in the file/array
| | Address track 1 | UWORD (16-bits) | Location in the file/array for track 1
| | … | … | …
| | Address track *__N__* | UWORD (16-bits) | Location in the file/array for track *__N__ (0 … 255)*
| | | |
|**Channel entry tracks** | | | **For each channel, track to start with**
| | Channel 0 track | UBYTE (8-bits) | Starting track index for channel 0
| | … | … | …
| | Channel 3 track | UBYTE (8-bits) | Starting track index for channel 3
| | | |
|**Track 0** | | | **Commands and parameters for track 0**
| | Command 0 | UBYTE (8-bits) | See command list
| | *and its* Parameters | none/variable | *See __parameter list__ for each command*
| | … | … | …
| | Command N | UBYTE (8-bits) |
| | *and its* Parameters | none/variable |
|**…** | **…** | **…** | **…**
|**Track _N_** | | | **Commands and parameters for track _N_** *(0-255)*
### COMMAND LIST
|**Command (_X_)** | **Parameter** | **Type** | **Description**
|--- | --- | ------------------ | ---
|**0
0x00** | | | Stop playing
| | | |
|**1…63
0x00+__X__** | note *(__X__)* | UBYTE (8-bits) | Start playing note *[__X__]* where 1 is a C1.
See [Frequency to Tone](./extras/frequencyToTone.md "Frequency to Tone table")
**_Note:_** everytime a note is played, volume is re-triggered
| | | |
|**64…159
0x40…0x9F** | | | Configure effects (fx)
| | *See __fx list__* | none/variable | Effect is *[__X__ - 64]*
| | | |
|**160…223
0x9F+__t__** | Ticks (*__t__*) | UBYTE (8-bits) | Delay for *[__X__ - 159]* or *[__t__]* ticks
**_Note:_** delay of 0 does not exist and maximum is 64 ticks
| | | |
|**224, __Y__
0xE0, __Y__** | Ticks (*__Y__*) | VLE (8/16-bits) | Long delay for *[__Y__ + 65]* ticks
**_Note:_** LONG delay starts at 1 higher than SHORT delay
| | | |
|**~~225…251~~** | | | ~~RESERVED~~
| | | |
|**252, N
0xFC, N** | Track *__N__* | UBYTE (8-bits) | Call/run/goto specified track
Track index where *__N__* is the number of the track to go to
| | | |
|**253, Y, N
0xFD, Y, N** | | | Repeated call/run/goto specified track
| | Loop count (*__Y__*) | UBYTE (8-bits) | Repeat *[__Y__ + 1]* times (total)
| | Track *__N__* | UBYTE (8-bits) | Track index where *__N__* is the number of the track to go to
| | | |
|**254
0xFE** | | | Return/end of track marker
| | | |
|**255, L, D
0xFF, L, D** | | | Binary data
| | Length *__L__* | VLE (8/16-bits) | Length in bytes of data to follow
| | Data *__D__* | variable | Binary data chunk (notify host application)
### FX LIST
|**Effect** | **Parameter** | **Type** | **Description**
|--- | ------------------------ | --------------------------- | ---
|**64+0
64
0x40** | set Volume (*__X__*) | UBYTE (8-bit) | Set volume to *[__X__]*.
**_Note:_** If the combined volume of all channels
exceed 255 there may be rollover distortion. This
should not be disallowed, as it may be usesful as|
an effects hack for the musician. There should
however be a non-interfering warning when a
musician enters a value above 63 for ch 1-3 or 32
for ch 4 (noise). ch 4 the volume is counted double,
so 32 is actually 64.
|**64+1
65
0x41** | slide Volume ON (*__X__*) | UBYTE (8-bit) | Slide the volume with an amount (positive or
negative) of *[__X__]* for every tick.
**_Note:_** This results in a fade-in or fade-out
effect. There should be a non-|interfering warning
when sliding would result in exceeding 63 for
ch 1-3 and 32 for ch 4.
|**64+2
66
0x42** | slide Volume ON
advanced (*__X__*) (*__Y__*) | UBYTE (8-bit)
UBYTE (8-bit) | Slide the volume with an amount (positive or
negative) of *[__X__]* for every [*__Y__*] ticks.
*[__Y__]* includes 2 parameters: RRtttttt
R = reserved and t = ticks.
|**64+3
67
0x43** | slide Volume OFF | | Stops the volume slide
|**64+4
68
0x44** | slide Frequency ON (*__X__*) | UBYTE (8-bit) | Slide the frequency with an amount (positive or
negative) of *[__X__]* for every tick.
**_Note:_** The amount of slide is limited
between -127 to 127
|**64+5
69
0x45** | slide Frequency ON
advanced (*__X__*) (*__Y__*) | UBYTE (8-bit)
UBYTE (8-bit) | Slide the frequency with an amount (positive or
negative) of *[__X__]* for every [*__Y__*] ticks.
*[__Y__]* includes 2 parameters: RRtttttt
R = reserved and t = ticks.
|**64+6
70
0x46** | slide Frequency OFF | | Stops the frequency slide
|**64+7
71
0x47** | set Arpeggio (*__X__*)(*__Y__*) | UBYTE (8-bit)
UBYTE (8-bit) | Next to the current playing note, play a second
and third note *[__X__]* for every *[__Y__]* ticks.
*[__X__]* includes 2 parameters: AAAABBBB, where
AAAA = base + amount to |second note and
BBBB = second note + amount to third note.
*[__Y__]* includes 4 parameters: FEDttttt,
where F = reserved, E = toggle no third note,
D = toggle retrigger, ttttt = tick amount.
**_Note:_** Arpeggio is used for playing 3 notes
out of a chord indivually
|**64+8
72
0x48** | Arpeggio OFF | | Stops the arpeggio
|**64+9
73
0x49** | SET Retriggering noise ON (*__X__*) | UBYTE (8-bit) | Noise channel consists of white noise. By setting
retriggering *[__X__]* it swithes the entrypoint at
a given speed. *[__X__]* includes 2 parameters:
AAAAAABB , where AAAAAA |= entry point and
BB = speed (0 = fastest, 1 = faster , 2 = fast)
|**64+10
74
0x4A** | Retriggering noise OFF | | Stops the retriggering for the noise on channel 3
|**64+11
75
0x4B** | add Transposition (*__X__*) | UBYTE (8-bit) | Shifts the played notes by adding *[__X__]* to
the existing transposition for all playing notes.
**_Note:_** The amount of shift is limited
between -127 to 127. However there |should be
a non-interfering warning when transposing would
result in exceeding 63 or get lower than 0
|**64+12
76
0x4C** | set Transposition (*__X__*) | UBYTE (8-bit) | Shifts the played notes by setting the transposition
to [__X__]* for all playing notes.
**_Note:_** The amount of shift is limited
between -127 to 127. However there should |be a
non-interfering warning when transposing would
result in exceeding 63 or get lower than 0
|**64+13
77
0x4D** | Transposition OFF | | Stops the transposition
|**64+14
78
0x4E** | set Tremolo (*__X__*)(*__Y__*) | UBYTE (8-bit)
UBYTE (8-bit) | *[__X__]* sets Depth.
*[__Y__]* includes 4 parameters
RxxBBBBB R = Retrig, x = reserved , B = rate
**_Note:_** Tremolo and Vibrato can **NOT**
be combined in the same |stack
|**64+15
79
0x4F** | Tremolo OFF | | Stops the tremolo
|**64+16
80
0x50** | set Vibrato (*__X__*)(*__Y__*) | UBYTE (8-bit)
UBYTE (8-bit) | *[__X__]* sets Depth.
*[__Y__]* includes 4 parameters
RxxBBBBB R = Retrig, x = reserved , B = rate
**_Note:_** Tremolo and Vibrato can **NOT**
be combined in the same |stack
|**64+17
81
0x51** | Vibrato OFF | | Stops the vibrato
|**64+18
82
0x52** | SET Glissando (*__X__*) | UBYTE (8-bit) | *[__X__]* includes 2 parameters: Vttttttt
V = value ( 0 = go 1 note up, 1 = go 1 note down)
and t = amount of ticks, between each step
|**64+19
83
0x53** | Glissando OFF | | Stops the Glissando
|**64+20
84
0x54** | SET Note Cut (*__X__*) | UBYTE (8-bit) | *[__X__]* sets the equal amount of ticks
between note ON and OFF
|**64+21
85
0x55** | Note Cut OFF | | Stops the Note Cut
|**…** | **…** | **…** | **…**
|**64+92
156
0x9C** | ADD song tempo (*__X__*) | UBYTE (8-bit) | adds *[__X__]* to the tempo of the song.
Total value should be between 0 - 127
**_Note:_** the higher the tempo to more CPU it takes.
|**64+93
157
0x9D** | SET song tempo (*__X__*) | UBYTE (8-bit) | (re-)sets *[__X__]* as the tempo of the song.
Standard is 25. Value should be between 0 - 127
**_Note:_** the higher the tempo to more CPU it takes.
|**64+94
158
0x9E** | GOTO advanced
(*__W__*)
(*__X__*)
(*__Y__*)
(*__Z__*) |
UBYTE (8-bit)
UBYTE (8-bit)
UBYTE (8-bit)
UBYTE (8-bit) | **_Note:_** handy command for having an intro
and a repeating song part
For channel __0__ go to track __W__
For channel __1__ go to track __X__
For channel __2__ go to track __Y__
For channel __3__ go to track __Z__
|**64+95
159
0x9F** | STOP current channel | | channel is no longer being processed
**_Note:_** if all channels have reached STOP, the song ends
|~~TBD~~ | ~~TBD~~ | ~~TBD~~ | ~~TBD~~
#### Thoughts on effects:
**Note:** These are the primitives to be implemented in the playroutine effects processor. Most will have several effect command numbers associated with them for various aspects of the same primitive. Effects can be combined but not stacked, but some combinations may have undesired/interesting interference.
* Volume slide: a gradual increasing or decreasing of the volume.
* Frequency slide: a gradual increasing or decreasing of the [frequency](https://en.wikipedia.org/wiki/Frequency "frequency wikipedia").
* Arpeggio: a group of [notes](https://en.wikipedia.org/wiki/Musical_note "note wikipedia") which are rapidly and automatically played one after the other.
* Retriggering (on [note](https://en.wikipedia.org/wiki/Musical_note "note wikipedia") or by automation): oscillators are restarted either automatically or at the start of each new note.
* Transposition (also for microtonals): play [notes](https://en.wikipedia.org/wiki/Musical_note "note wikipedia") in a different key, or fine tune notes to provide microtonals; frequencies that are in between notes.
* Tremolo: a slight, rapid and regular fluctuation in the amplitude/volume of a [note](https://en.wikipedia.org/wiki/Musical_note "note wikipedia").
* Vibrato: a slight, rapid and regular fluctuation in the [pitch](https://en.wikipedia.org/wiki/Pitch_(music) "pitch wikipedia") of a [note](https://en.wikipedia.org/wiki/Musical_note "note wikipedia").
* Glissando: controls if and how a gradual frequency slide "snaps" to adjacent notes.
* Note cut (with delay and automation): provides a method to stutter and adjust note timing.