diff --git a/README.md b/README.md index d0f0181..ca625e0 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,11 @@ # MD_YM2413 -The YM2413, OPLL, is a cost-reduced FM synthesis sound chip manufactured -by Yamaha Corporation and based on their YM3812 (OPL2). +The YM2413, OPLL, is a cost-reduced FM synthesis sound chip manufactured by Yamaha Corporation and based on their YM3812 (OPL2). -The simplifications mean that the YM2413 can only play one user-defined -instrument at a time, with an additional 15 read-only hard-coded instrument -profiles available. The IC can operate as 9 channels of instruments or 6 -channels with melodic instruments and 5 with percussion instruments. +The simplifications mean that the YM2413 can only play one user-defined instrument at a time, with an additional 15 read-only hard-coded instrument profiles available. The IC can operate as 9 channels of instruments or 6 channels with melodic instruments and 5 with percussion instruments. -Its main historical application was the generation of music and sound effects in -microprocessor systems. It was extensively used in early game consoles, arcade games, -home computers and low-cost synthesizer keyboards. +Its main historical application was the generation of music and sound effects in microprocessor systems. It was extensively used in early game consoles, arcade games, home computers and low-cost synthesizer keyboards. -This library implements functions that manage the sound and noise generation interface -to the YM2413 IC through a clean API encapsulating the basic functionality provided -by the hardware. +This library implements functions that manage the sound generation interface to the YM2413 IC through a clean API encapsulating the basic functionality provided by the hardware. [Library Documentation](https://majicdesigns.github.io/MD_YM2413/) \ No newline at end of file diff --git a/docs/YM2413_IC.png b/docs/YM2413_IC.png new file mode 100644 index 0000000..bb1f43f Binary files /dev/null and b/docs/YM2413_IC.png differ diff --git a/docs/_m_d___y_m2413_8cpp.html b/docs/_m_d___y_m2413_8cpp.html index de6f57c..7d87f36 100644 --- a/docs/_m_d___y_m2413_8cpp.html +++ b/docs/_m_d___y_m2413_8cpp.html @@ -116,7 +116,7 @@ + +

◆ loadInstrument()

+ +
+
+ + + + + + + + +
void MD_YM2413::loadInstrument (const uint8_t * data)
+
+

Define direct parameters for a custom instrument.

+

Define the data for a custom instrument directly. The data is preformatted for the YM2413 device and will be passed through without further processing.

+

This method is used to set instrument definitions that are in OPLL format and held in the application as a compact byte sequence.

+
See also
Custom Instruments
+
Parameters
+ + +
dataan array of 8 bytes in RAM that will be written to registers 0x00 through 0x07.
+
+
+ +
+
+ +

◆ loadInstrumentOPL2()

+ +
+
+ + + + + + + + + + + + + + + + + + +
void MD_YM2413::loadInstrumentOPL2 (const uint8_t * ins,
bool fromPROGMEM = true 
)
+
+

Define the parameters for a custom instrument.

+

Define the playing envelope in OPL2/OPL3 format for the custom instrument. The parameters are in higher OPL format, which is readily available and very close to the YM2413 format (OPLL). Translations are made as required.

+
See also
Custom Instruments
+
Parameters
+ + + +
insan array of OPL2_DATA_SIZE uint8_t bytes in OPL2 format data.
fromPROGMEMtrue if the data is loaded from PROGMEM false otherwise.
+
+
+
@@ -471,7 +580,7 @@

See also
noteOn(), run()
+
See also
noteOn(), run()
Parameters
@@ -481,8 +590,8 @@

-

◆ noteOn() [1/2]

+ +

◆ noteOn() [1/2]

@@ -499,6 +608,12 @@

uint16_t 

+ + + + + + @@ -520,6 +635,7 @@

+
chanchannel number on which to stop this note [0..countChannels()-1].
freq,
uint8_t vol,
chanchannel number on which to play this note [0..countChannels()-1].
freqfrequency to play.
volvolume to set this note in range [VOL_MIN..VOL_MAX].
durationlength of time in ms for the whole note to last.
@@ -527,8 +643,8 @@

-

◆ noteOn() [2/2]

+ +

◆ noteOn() [2/2]

@@ -551,6 +667,12 @@

uint8_t  note, + + + + uint8_t  + vol, + @@ -574,6 +696,7 @@

chanchannel number on which to play this note [0..countChannels()-1]. octavethe octave block for this note [MIN_OCTAVE..MAX_OCTAVE]. notethe note number to play [0..11] as defined above. + volvolume to set this note in range [VOL_MIN..VOL_MAX]. durationlength of time in ms for the whole note to last. @@ -598,12 +721,12 @@

Run the music machine.

Runs the automatic note off timing for all channels. This should be called from the main loop() as frequently as possible to allow the library to execute the note required timing for each channel.

-

This method is not required if the application does not use durations when invoking noteOn().

+

This method is not required if the application does not use durations when invoking noteOn().

- -

◆ setInstrument()

+ +

◆ setInstrument()

@@ -623,8 +746,8 @@

- bool  - sustain = false  + uint8_t  + vol = VOL_MAX  @@ -634,15 +757,15 @@

Set the playing instrument for a channel.

-

Set the instrument for the channel to be the value specified. Valid instruments are given by the enumerated type instrument_t.

+

Set the instrument for the channel to be one the value specified. Valid instruments are given by the enumerated type instrument_t.

If percussion is not enabled, the valid range of instruments is one of the I_* values on channels [0..9]. The percussion instruments P_* are automatically set up on the channels CH_* [6..11] when percussion mode is enabled, and instruments I_* can be set up on channels [0..5].

-

The instrument's release phase can be set to a standard mid-point to override the instrument's set profile.

-
See also
setPercussion(), instrument_t, setSustain()
+

Custom instruments must be defined before they can be used.

+
See also
setPercussion(), instrument_t, setSustain(), defineInstrument()
Parameters
- +
chanchannel number on which volume is set [0..countChannels()-1].
instrone of the instruments I_* from instrument_t.
sustainmodify the release profile of the sound envelope.
volvolume to set for the specified channel in range [VOL_MIN..VOL_MAX].
@@ -666,7 +789,7 @@

Set the current library/hardware operating mode.

-

The library can operate with or without percussion instruments configured. Without percussion instruments, there are 9 channels(0..8] available for general instruments.With percussion enabled, there are 6 channels[0..5] available for general instruments and 5 channels[6..10], for a total of 11, allocated to percussion instruments.

+

The library can operate with or without percussion instruments configured. Without percussion instruments, there are 9 channels(0..8] available for general instruments. With percussion enabled, there are 6 channels[0..5] available for general instruments and 5 channels[6..10], for a total of 11, allocated to percussion instruments.

The method countChannels() will always return the total number of channels for the current configuration.

See also
isPercussion(), countChannels()
Parameters
@@ -703,13 +826,13 @@

-

Standardise the instrument release phase

-

For the specific channel, set the release vlue to a standarrised mid-point for this instance of the instrument.

-
See also
setInstrument()
+

Standardize the instrument release phase

+

For the specific channel, set the release value to a standarized mid-point for this instance of the instrument.

+
See also
setInstrument()
Parameters
- +
chanchannel number on which sustain is set [0..countChannels()-1].
sustainset true to standardise the release phase to a mid level value.
sustainset true to standardize the release phase to a mid level value.
@@ -746,7 +869,7 @@

Parameters
- +
chanchannel number on which volume is set [0..countChannels()-1].
vvolume to set for the specificed channel in range [VOL_MIN..VOL_MAX].
vvolume to set for the specified channel in range [VOL_MIN..VOL_MAX].

@@ -769,7 +892,7 @@

Set the volume for all channels.

-

Set the volume for all channels to be the speified value. Valid values are all the values in the range [VOL_MIN..VOL_MAX].

+

Set the volume for all channels to be the specified value. Valid values are all the values in the range [VOL_MIN..VOL_MAX].

Parameters
@@ -777,6 +900,43 @@

+

◆ write()

+ +
+
+

vvolume to set for all channels in range [VOL_MIN..VOL_MAX].
+ + + + + + + + + + + + + + + + + +
void MD_YM2413::write (uint8_t addr,
uint8_t data 
)
+

+

Write a byte directly to the device

+

This method should be used with caution, as it bypasses all the checks and buffering built into the library. It is provided to support applications that are a collection of register setting to be written to hardware at set time intervals (eg, VGM files).

+
Parameters
+ + + +
addrthe 8 bit device address to write the data.
datathe 8 bit data value to write to the device.
+
+
+

The documentation for this class was generated from the following files:
    @@ -790,7 +950,7 @@

      -
    diff --git a/docs/class_m_d___y_m2413.js b/docs/class_m_d___y_m2413.js index af21653..4cbdc67 100644 --- a/docs/class_m_d___y_m2413.js +++ b/docs/class_m_d___y_m2413.js @@ -1,7 +1,7 @@ var class_m_d___y_m2413 = [ [ "instrument_t", "class_m_d___y_m2413.html#a4baea9c20383d245590e2d9f1c10d6b6", [ - [ "I_ORIGINAL", "class_m_d___y_m2413.html#a4baea9c20383d245590e2d9f1c10d6b6a3baf5a4a22686e47bd06f7f5b4edc7e5", null ], + [ "I_CUSTOM", "class_m_d___y_m2413.html#a4baea9c20383d245590e2d9f1c10d6b6a21267199d42535e4600aafeae695ba43", null ], [ "I_VIOLIN", "class_m_d___y_m2413.html#a4baea9c20383d245590e2d9f1c10d6b6ada27fcde3e8d9b5aea64b37e83a6c0e1", null ], [ "I_GUITAR", "class_m_d___y_m2413.html#a4baea9c20383d245590e2d9f1c10d6b6a92957a840f1f540420b3d8dd104d2563", null ], [ "I_PIANO", "class_m_d___y_m2413.html#a4baea9c20383d245590e2d9f1c10d6b6ab9d9c0f9a4913241dde56dd60a5b139a", null ], @@ -11,12 +11,12 @@ var class_m_d___y_m2413 = [ "I_TRUMPET", "class_m_d___y_m2413.html#a4baea9c20383d245590e2d9f1c10d6b6a9f0c23901346caedc7638ca421592aa7", null ], [ "I_ORGAN", "class_m_d___y_m2413.html#a4baea9c20383d245590e2d9f1c10d6b6a8bb94f665bed8ab104ac54f2d62386c8", null ], [ "I_HORN", "class_m_d___y_m2413.html#a4baea9c20383d245590e2d9f1c10d6b6a0d1245c3eb1e557e248983a12167be26", null ], - [ "I_SYNTHESIZER", "class_m_d___y_m2413.html#a4baea9c20383d245590e2d9f1c10d6b6a8dbdc9a9d91ed32046592f29d5c97c4d", null ], - [ "I_HARPSICORD", "class_m_d___y_m2413.html#a4baea9c20383d245590e2d9f1c10d6b6a85b041af26f9e4ee8b13af02a1e9c41b", null ], + [ "I_SYNTH", "class_m_d___y_m2413.html#a4baea9c20383d245590e2d9f1c10d6b6aefef73450691e7a6df1e600871a4ef76", null ], + [ "I_HARPSICHORD", "class_m_d___y_m2413.html#a4baea9c20383d245590e2d9f1c10d6b6a9e2c2fa9dfb2ad63c26d814259ee3430", null ], [ "I_VIBRAPHONE", "class_m_d___y_m2413.html#a4baea9c20383d245590e2d9f1c10d6b6ad558fc4d61df570239af0ef4558cd629", null ], - [ "I_SYNTHESIZER_BASS", "class_m_d___y_m2413.html#a4baea9c20383d245590e2d9f1c10d6b6a5b2ee143c74afb8a208422320531989c", null ], + [ "I_SYNTH_BASS", "class_m_d___y_m2413.html#a4baea9c20383d245590e2d9f1c10d6b6a92785e6d28951df80100cbb209ac94fa", null ], [ "I_ACOUSTIC_BASS", "class_m_d___y_m2413.html#a4baea9c20383d245590e2d9f1c10d6b6a420fcafebe673e09c842413e56578ce8", null ], - [ "I_ELECTRIC_GUITAR", "class_m_d___y_m2413.html#a4baea9c20383d245590e2d9f1c10d6b6a911eef8c93d07a3a1a8c0157bb22f25c", null ], + [ "I_EGUITAR", "class_m_d___y_m2413.html#a4baea9c20383d245590e2d9f1c10d6b6aaf0ba001008b0a2838249fd27a681d1c", null ], [ "P_HI_HAT", "class_m_d___y_m2413.html#a4baea9c20383d245590e2d9f1c10d6b6afdbbdeb7c351f40c006f6a63c9a5e4a8", null ], [ "P_TOP_CYMBAL", "class_m_d___y_m2413.html#a4baea9c20383d245590e2d9f1c10d6b6ac453d111408c92f7df0f7ebbba772b0d", null ], [ "P_TOM_TOM", "class_m_d___y_m2413.html#a4baea9c20383d245590e2d9f1c10d6b6abd68f71b83caead231d1791234b1ed4d", null ], @@ -29,25 +29,31 @@ var class_m_d___y_m2413 = [ "begin", "class_m_d___y_m2413.html#a5d74b7a6fd6bf25e62f9ec3b14f7d4cb", null ], [ "countChannels", "class_m_d___y_m2413.html#a6fee9e00e148365aa11da36865b7d4dd", null ], [ "getInstrument", "class_m_d___y_m2413.html#a8535e5be552b5ce08e3977128e35823f", null ], + [ "getVolume", "class_m_d___y_m2413.html#aef374f42c43f7aadb8450868ac7b06a3", null ], [ "isIdle", "class_m_d___y_m2413.html#a694a08e22939a0076948cb762855789a", null ], [ "isPercussion", "class_m_d___y_m2413.html#a1afd692afb7666bec6f9c81e0d7af0c9", null ], [ "isPercussion", "class_m_d___y_m2413.html#a6efe87d5e0ba75cbc803751f052a15be", null ], + [ "loadInstrument", "class_m_d___y_m2413.html#a08e4130ecc42b62c0c0da34ac66714f6", null ], + [ "loadInstrumentOPL2", "class_m_d___y_m2413.html#a2fe6a255600bcf93daa4eb68054767ea", null ], [ "noteOff", "class_m_d___y_m2413.html#a72e24f108a3ee174f65ff634a2972a0d", null ], - [ "noteOn", "class_m_d___y_m2413.html#ac46aa3c1f60ccee08c2dad71328ba34f", null ], - [ "noteOn", "class_m_d___y_m2413.html#a3c6d38e535b49d7f3df7f7efed85978d", null ], + [ "noteOn", "class_m_d___y_m2413.html#a213cb511f7559347bacb967bc9e27f4a", null ], + [ "noteOn", "class_m_d___y_m2413.html#a4112f4449ae6e279977cd57fb067c6e1", null ], [ "run", "class_m_d___y_m2413.html#a3adfd20b47eea60b69b80d94366d5648", null ], - [ "setInstrument", "class_m_d___y_m2413.html#a6a0b9806303fa49f94a6c1de912f245f", null ], + [ "setInstrument", "class_m_d___y_m2413.html#a1eb6bd79f9bd3763d14fc3ddb29b7983", null ], [ "setPercussion", "class_m_d___y_m2413.html#aff04cfdc927cee5e9f9e371ce7aae8a7", null ], [ "setSustain", "class_m_d___y_m2413.html#ad6c03b3d8e478b670807542766bdf58d", null ], [ "setVolume", "class_m_d___y_m2413.html#a5b2fc9686600dfc452f670a51e0990bf", null ], [ "setVolume", "class_m_d___y_m2413.html#a5c0373ab2aa4a4c0e3391cb9b8cc12b3", null ], + [ "write", "class_m_d___y_m2413.html#a7abbf126e427a828c8b7601b77944b1a", null ], [ "CH_BD", "class_m_d___y_m2413.html#afbcc9709c0797dc9f9e77291402b23a6", null ], [ "CH_HH", "class_m_d___y_m2413.html#a8db1ee3b665d2f67ac7606e6c444aadd", null ], [ "CH_SD", "class_m_d___y_m2413.html#a053738bc460cdb5e746a6f753aff846b", null ], [ "CH_TCY", "class_m_d___y_m2413.html#a6bb4921396d8331f7a8268ce7d06ff67", null ], [ "CH_TOM", "class_m_d___y_m2413.html#ae16e4cd45a31d6c9cadce01728407f84", null ], + [ "CH_UNDEFINED", "class_m_d___y_m2413.html#a0396e7f1513a8b3772fb9600bb8115bb", null ], [ "MAX_OCTAVE", "class_m_d___y_m2413.html#a0fb3500aadac8cfa56b3b283f46dee6e", null ], [ "MIN_OCTAVE", "class_m_d___y_m2413.html#a2e26a3194804e9783b597439f73e4b2c", null ], + [ "OPL2_DATA_SIZE", "class_m_d___y_m2413.html#a9a08b789c7deac60f9f88cfa7482bf1f", null ], [ "PERC_CHAN_BASE", "class_m_d___y_m2413.html#a4f4d70b74b47e347126a1d32aa3deb1a", null ], [ "VOL_MAX", "class_m_d___y_m2413.html#a59ef0109f681e73292823edb016345ac", null ], [ "VOL_OFF", "class_m_d___y_m2413.html#a440959c72100f9004f074c8726f3c98e", null ] diff --git a/docs/classes.html b/docs/classes.html index f1b1c80..75d1da2 100644 --- a/docs/classes.html +++ b/docs/classes.html @@ -108,7 +108,7 @@