# SNDInstData

## Definition

      #include <nitro/snd.h>

      typedef struct SNDInstData
      {
          u8 type;
          u8 padding_;

          struct SNDInstParam {
              u16 wave[2];
              u8 original_key;
              u8 attack;
              u8 decay;
              u8 sustain;
              u8 release;
              u8 pan;
          } param;
      } SNDInstData;

## Elements

`type` | The instrument type
`wave` | The waveform data information array
`original_key` | The original key. 60 is center node.
`attack` | The envelope's attack. Takes values in the range of 0 to 127. The larger the value, the faster the rise.
`decay` | The envelope's decay. Takes values in the range of 0 to 127. The larger the value, the faster the attenuation.
`sustain` | The envelope's sustain. Takes values in the range of 0 to 127. The larger the value, the higher the sustained gain.
`release` | The envelope's release. Takes values in the range of 0 to 127. The larger the value, the faster the attenuation. (However, when the value is `SND_BANK_DISABLE_RELEASE(=255)`, it will not release, even when the note is off.))
`pan` | The pan. Takes values in the range of 0 (left) to 64 (center) to 127 (right).

## Description

The instrument data structure. This structure stores the parameters for each instrument inside the bank data.

This structure can be obtained with the `SND_ReadInstData` function and updated with the `SND_WriteInstData` function.

The instrument type takes the following values:

TABLE: SNDInstType

Label | Description
--- | ---
SND_INST_PCM | PCM waveform data
SND_INST_PSG | PSG rectangular wave
SND_INST_NOISE | Noise
SND_INST_DIRECTPCM | PCM waveform data (direct address specification)
SND_INST_NULL | Dummy instrument (Does not sound)

The waveform information array `wave` holds information about the waveform data. The meaning of this data differs for each instrument `type`.

TABLE: Waveform Information Array

Inst Type | wave[0] | wave[1]
--- | --- | ---
SND_INST_PCM | Index number inside the Waveform Archive | Waveform Archive number inside the bank
SND_INST_PSG | Duty ratio | (Not Used)
SND_INST_NOISE | (Not Used) | (Not Used)
SND_INST_DIRECTPCM | Lower 16 bits of the address of the `SNDWaveData` structure | Upper 16 bits of the address of the `SNDWaveData` structure
SND_INST_NULL | (Not Used) | (Not Used)

## See Also

`SND_ReadInstData`, `SND_WriteInstData`, `SNDWaveData`

## Revision History

2005/05/10 Added description of operations when release is 255.
2005/03/17 Added the `SND_INST_NULL` instrument type.
2005/01/19 Added a link to `SNDWaveData`.
2004/10/21 Fixed a typo in the required include file.
2004/07/20 Initial version.

CONFIDENTIAL