This document describes MML commands for Psgino.
Command name | Summary |
---|---|
A-G | Outputs the sound of the specified note name. |
N | Specify the note number and output the sound. |
R | Insert a rest. |
T | Sets the tempo. |
L | Sets the length of the note. |
V | Sets the volume. |
S | Switch to envelope generator volume control. |
M | Specifies the envelope frequency. |
O | Specifies the octave of the note specified by A-G. |
Q | Specify the note gate time. |
H | Outputs noise sound. |
I | Sets the frequency of the noise. |
< | Decrease the octave value set by O-command. |
> | Increase the octave value set by O-command. |
, | MML is concatenated into a chord. |
& | Plays like slurs and ties. |
[],| | Specify the loop section. |
$E | Set ON/OFF of volume control by software envelope. |
$A | Specifies the attack time of the software envelope. |
$H | Specifies the hold time of the software envelope. |
$D | Specifies the software envelope decay time. |
$S | Specifies the sustain time of the software envelope. |
$F | Specifies the fade time of the software envelope. |
$M | Sets the software LFO mode. |
$J | Specifies the modulation depth of the software LFO. |
$L | Sets the modulation frequency of the software LFO. |
$T | Specifies the time from the start of sound output until the software LFO operates. |
$B | Bias the frequency of the output sound. |
$P | Smoothly increases or decreases the frequency of the output sound until output stops. |
@C | Invoke the user-defined callback function. |
Outputs the sound of the specified note name.
Values | Description |
---|---|
<accidental> | Specify the accidental symbols with "#", "+", and "-". "#" and "+" correspond to semitone up, and "-" correspond to semitone down. |
<length> | Specify the length of the sound in the range from 0 to 64. 1 represents a whole note, 4 represents a quarter note. If you omit <length>, the note length will be the value specified by the L command. It is also possible to specify 0 as the length of the note. In this case, no sound is generated. This value is primarily used for the final tone of a slur (&) string. |
<dot> | Specify the dot with ".". If you write one dot, the length of the sound will be 1.5 times (=1+0.5). If you write two, the length of the sound will be 1.75 times (= 1 + 0.5 + 0.25). Up to 3 dots can be described. |
Example:
C#2.
Specify the note number and output the sound. The note length follows the value specified with the L command.
Values | Description |
---|---|
<note-number> | Specify the note number value in the range from 0 to 95. For example, N36 corresponds to O4C and N52 corresponds to O5E. However, N0 is treated as a rest, not O1C. |
<dot> | Specifies a dot. The dot effect is the same as for A-G. |
Example:
L4O4CEG.R8 N36N40N43.R8
Insert a rest.
Values | Description |
---|---|
<length> | Specify the length of the rest in the range of 1 to 64. 1 represents a whole rest, 4 represents a quarter note rest. If this value is omitted, the rest length is determined by the value of the parameter "mode" of the method SetMML/SetSeMML() as follows: - If the 0th bit of mode is 0, the rest length is 4 (quarter rest). - If the 0th bit of mode is 1, the length of the rest will be the value specified by the L command. |
<dot> | Specifies a dot. The dot effect is the same as for A-G. |
Example:
L4
CR8 C16R16 CR
CR8 C16R16 CR
Outputs a noise sound with the frequency set by the I command.
Values | Description |
---|---|
<length> | Specifies the length of the noise in the range 1 to 64. If this value is omitted, the length of the noise is determined by the value of the parameter "mode" of the method SetMML/SetSeMML(), just like the R command. |
<dot> | Specifies a dot. The dot effect is the same as for A-G. |
Example:
HR8H16R16HR HR8H16R16HR
Sets the tempo. Tempo defaults to 120 bpm.
Values | Description |
---|---|
<tempo> | Specify a tempo value in the range 32 to 255. When performing using multiple tone channels, tempo settings must be written in the MML for each channel. |
Example:
T120CDE2T100CDE2,
T120EGB2T100EGB2
Sets the length of the sound when <length> is omitted in the A-G command. This value defaults to 4. This value can also be applied to the R and H commands depending on the value of the parameter "mode" of the SetMML/SetSeMML() function.
Values | Description |
---|---|
<length> | Specify the length of the sound from 1-128. 1 represents a whole note, 4 represents a quarter note. |
<dot> | Specifies a dot. The dot effect is the same as for A-G. |
Example:
L4CDE2L16CDECDECDE
Sets the volume of tones and noises. Volume defaults to 15. Note that the V command and S command operate exclusively, and the volume setting follows the command executed later.
Values | Description |
---|---|
<volume> | Specifies the volume from 0 to 15. |
Example:
V15A V13A V10A
Switch to volume control with an envelope generator. This value defaults to OFF. Executing this command turns on the volume control by the envelope generator. If you want to turn off this volume control, execute the V command.
Values | Description |
---|---|
<shape> | Specifies the shape of the envelope in the range 0-15. Please refer to the PSG datasheet for the shape of the envelope for each value. |
Example:
V15CDER4
L4S0M3000CDER4
V15CDER4
Specifies the envelope frequency. Envelope frequency defaults to 0.
Values | Description |
---|---|
<frequency> | Specifies the envelope frequency (EP) in the range 0 to 65535. |
Example:
L4
S0M5000CDER4
S0M1000CDER4
Specifies the octave of the note specified by A-G. Octave defaults to 4.
Values | Description |
---|---|
<octave> | Specify an octave in the range 1 to 8. |
Example:
L4
O4 CDE2
O5 CDE2
O3 CDE2
Specifies the note gate time. The default value is 8 (8/8=100%).
Values | Description |
---|---|
<gate-time> | Specify the gate time in the range of 1 to 8. For example, if the gate time is set to 3, the note duration will be 3/8 and the remaining 5/8 will be muted. |
Example:
L16CCCCCCCC
R4
Q4CCCCCCCC
Sets the noise frequency (NP) generated by the H command. The noise frequency defaults to 16.
Values | Description |
---|---|
<frequency> | Specifies the noise frequency in the range 0 to 31. |
Example:
I0H4 I8H4
Lowers the octave specified by the O command.
Example:
L4O5C<BA
Raises the octave specified by the O command.
Example:
L4AB>C
MML of each part can be concatenated with commas. Since PSG has 3 tone channels, up to 3 MMLs can be concatenated.
Example:
T120L4O4CEG,
T120L4O4EGB,
T120L4O4GB>D
By connecting A-G commands with &, you can perform slurs and ties.
Values | Description |
---|---|
<octave-settings> | You can use the O command, > and < to set the octave. The octave value set here will continue even after the performance of slurs and ties. |
Example:
A2R2 A4&A4R2 A2&>A0R2 A2&<A0R2
Loop playback of MML in []. Loops can be nested up to 3 levels. Loop symbols after the 4th level are ignored. A "|" symbol may also be inserted in the loop section. This symbol serves as a break statement for the inserted loop section. However, this symbol functions as a break statement only for the last loop.
NOTE: The primary loop of the MML registered with the SetMML() method can only be terminated using the FinishPrimaryLoop() method. When this method is called, if there are two or more remaining loop iterations, including the current one being executed, the number of remaining loop iterations is reduced to two. This method is primarily intended to be used when exiting infinite loops in BGM.
Values | Description |
---|---|
<loop-number> | Specify the loop count in the range from 0 to 255. However, if 0 is specified, it will be an infinite loop. If this value is omitted, the loop count will be 1. |
Example1:
O3[3 C&>C0]
Example2:
[4 CD|ER4] CR4
In addition to PSG's built-in envelope generator, Psgino also supports volume control using software envelopes. This feature can only be enabled if the volume is controlled with the V command rather than the S command. The shape of the envelope is set with 5 parameters (AHDSFR method without "R"). This envelope volume control can be set independently for each channel.
Sets ON/OFF of volume control by software envelope. This value defaults to OFF.
Values | Description |
---|---|
<enabled> | Set in the range from 0 to 1. 0 corresponds to OFF and 1 to ON. |
Example:
V15L4O4
$A0$H100$D100$S90$F2000
$E0
CDE2
$E1
CDE2
Specifies the rise time of the sound (the arrival time from 0 to the volume set by the V command).
Values | Description |
---|---|
<attack> | Specify in the range from 0 to 10000. The unit is ms. If 0 is specified, sound rise processing is not performed, and sound is output at the volume set with the V command. |
Sets the retention time of the volume level after attack.
Values | Description |
---|---|
<hold> | Specify in the range from 0 to 10000. The unit is ms. If 0 is specified, Decay processing will start immediately. |
Sets the time it takes for the volume to reach the Sustain value after Hold.
Values | Description |
---|---|
<decay> | Specify in the range from 0 to 10000. The unit is ms. If 0 is specified, the volume is immediately set to the Sustain value and fade processing is started. |
Sets the target volume level for Decay processing.
Values | Description |
---|---|
<sustain> | Specify in the range from 0 to 100. The unit is %. Corresponds to the percentage of the volume specified by the V command. |
Specifies the time from the Sustain value to 0 after the Decay process is complete.
Values | Description |
---|---|
<fade> | Specify in the range from 0 to 10000. The unit is ms. However, if 0 is specified, the volume will keep the Sustain value. |
Psgino has a software LFO. By enabling this function, you can output a sound with vibrato.
Sets ON/OFF for the software LFO. This value defaults to OFF.
Values | Description |
---|---|
<mode> | Sets the software LFO mode from 0 to 1. 0 corresponds to OFF and 1 to ON (modulated by triangular wave). |
Example:
V15L4O4
$J4$L80$T8
$M0
CDE2
$M1
CDE2
Sets the modulation depth. Modulation depth defaults to 0.
Values | Description |
---|---|
<depth> | Specifies the modulation depth in the range 0 to 255. If the modulation depth is n, the frequency of the sound varies from 2^(-n/360) times to 2^(n/360) times depending on the modulation function. |
Sets the modulation frequency. The default modulation frequency is 40 ( = 4.0 Hz).
Values | Description |
---|---|
<low-frequency> | Specifies the modulation frequency in the range 0 to 200. The unit is 0.1 Hz. |
Specifies the time from the start of sound output until the LFO operates. This value defaults to 0.
Values | Description |
---|---|
<delay> | Specifies the delay time of the LFO in the range from 0 to 128. If delay is non-zero, it uses the same calculations as the L command to determine the delay time. For example, if the delay is set to 4, the LFO operation will start after the time of one quarter note has passed after the start of sounding. If delay is 0, the delay time will be 0. |
<dot> | Specifies a dot. The dot effect is the same as for A-G. |
Bias the frequency of the output sound. The default value for bias is 0.
Values | Description |
---|---|
<bias> | Specify the bias in the range (-500) to 500. If the bias value is n, the frequency of the output sound will be the value multiplied by 2^(n/360). |
Example1:
V15L4O4
CDE2
$B30 CDE2
$B60 CDE2
$B360 CDE2
Example2:
V15L1O4
AA
,
V15L1O4
A$B1A
Smoothly increases or decreases the frequency of the output sound to the value specified by pitchbend-level until the output stops. This value defaults to 0.
Values | Description |
---|---|
<pitchbend-level> | Specifies the pitch bend level in the range from (-2880) to 2880. If the specified value is n, the frequency of the output sound changes smoothly up to the final value multiplied by 2^(n/360). |
Example:
V15L16O4
$P-360 CDEFGAB>C<
$P360 CDEFGAB>C<
Invoke the user-defined callback function. When decoding this command, synchronously invoke the registered callback function. The interface for the callback function is as follows:
void (*user_callback)(uint8_t ch, int32_t param);
Here, ch represents the channel number of the MML where this command is written, and param represents the parameter of this command.
The function registered with SetUserCallback() is executed for MML registered with SetMML(), and for MML registered with SetSeMML(), the function registered with SetSeUserCallback() is executed.
Values | Description |
---|---|
<data> | Specify the value to be stored in the parameter of the callback function as int32_t type. |
Example:
T120L4O4CE@C1234G,
T120L4O4EGB@C-999,
T120L4O4@C0GB>D
To add a header to the beginning of the MML, you can do the following:
:V <version-number> [ [header-command] ... ];
The header starts with a colon and ends with a semicolon. If the header section is omitted, the MML is treated as version 1.
NOTE: Currently, there is only one version of MML, which is version 1.
This command sets the mode-flags for the MML. Each field of the flags is as follows:
bit | Field | Description |
---|---|---|
15-1 | - | Reserved. |
0 | RH_LEN | Switches the default value when the R,H command omits the note length specification. - 0: The default value for note length is 4. - 1: The default note length is the value specified with the L command. |
If this command is not executed, the mode flags will be set to the value specified by the argument mode.
Example:
:V1M1;
L4O4CEG.R8 N36N40N43.R8