## Classes
Uttori Pad Info - Utility to manipulate the PAD_INFO.BIN file for SP-404 series of samplers.
Optional diagnostics; importing the parser does not load the debug package by default.
Decode known boolean codes while retaining unexpected bytes for damaged-file diagnostics.
Reject truncation, coercion and wrapping before writing an unsigned device field.
Encode boolean flags without silently interpreting damaged numeric flags as true.
Convert BPM to the unsigned fixed-point field, rejecting non-finite values and overflow.
Array.<SP404Pad> | Parsed Pads |
* [SP404PadInfo](#SP404PadInfo)
* [new SP404PadInfo([input])](#new_SP404PadInfo_new)
* _instance_
* [.pads](#SP404PadInfo+pads)
* [.parse()](#SP404PadInfo+parse)
* _static_
* [.fromFile(data)](#SP404PadInfo.fromFile) ⇒ [SP404PadInfo](#SP404PadInfo)
* [.encodePad([data])](#SP404PadInfo.encodePad) ⇒ Buffer
* [.checkDefault([pad], [strict])](#SP404PadInfo.checkDefault) ⇒ boolean
* [.getPadLabel(index)](#SP404PadInfo.getPadLabel) ⇒ string
* [.getPadIndex(label)](#SP404PadInfo.getPadIndex) ⇒ number
### new SP404PadInfo([input])
Creates an instance of SP404PadInfo.
| Param | Type | Description |
| --- | --- | --- |
| [input] | Array.<number> \| ArrayBuffer \| Buffer \| DataBuffer \| Int8Array \| Int16Array \| Int32Array \| number \| string \| Uint8Array \| Uint16Array \| Uint32Array \| undefined | The data to process. Omitted input creates an empty instance. Partial records and more than 120 pads are rejected. |
**Example** *(SP404PadInfo)*
```js
import fs from 'fs';
const data = fs.readFileSync('./PAD_INFO.bin');
const { pads } = new SP404PadInfo(data);
fs.writeFileSync('./output.json', JSON.stringify(pads, null, 2));
console.log('Pads:', pads);
➜ [
{
"avaliable": false,
"label": "A1",
"filename": "A0000001.WAV",
"originalSampleStart": 512,
"originalSampleEnd": 385388,
"userSampleStart": 512,
"userSampleEnd": 385388,
"volume": 87,
"lofi": false,
"loop": false,
"gate": false,
"reverse": true,
"format": "WAVE",
"channels": "Stereo",
"tempoMode": "Off",
"originalTempo": 109.9,
"userTempo": 109.9
},
...,
{
"avaliable": false,
"label": "J12",
"filename": "J0000012.WAV",
"originalSampleStart": 512,
"originalSampleEnd": 53424,
"userSampleStart": 512,
"userSampleEnd": 53424,
"volume": 127,
"lofi": false,
"loop": false,
"gate": true,
"reverse": false,
"format": "WAVE",
"channels": "Stereo",
"tempoMode": "Off",
"originalTempo": 100,
"userTempo": 100
}
]
```
### sP404PadInfo.pads
Parsed Pads in bank order; short files may contain fewer than 120 complete records.
**Kind**: instance property of [SP404PadInfo](#SP404PadInfo)
### sP404PadInfo.parse()
Parse the PAD_INFO.BIN file, decoding the supported pad info.
This is stored alongside the samples in PAD_INFO.BIN and contains 120 × 32-byte records, one for each pad from A1 to J12.
In this file, values are stored in big-endian order.
Reparse from byte zero; invalid record layouts throw before replacing pads.
**Kind**: instance method of [SP404PadInfo](#SP404PadInfo)
### SP404PadInfo.fromFile(data) ⇒ [SP404PadInfo](#SP404PadInfo)
Creates and parses a PAD_INFO.BIN file from binary data.
**Kind**: static method of [SP404PadInfo](#SP404PadInfo)
**Returns**: [SP404PadInfo](#SP404PadInfo) - The parsed PAD_INFO helper.
| Param | Type | Description |
| --- | --- | --- |
| data | Array.<number> \| ArrayBuffer \| Buffer \| DataBuffer \| Int8Array \| Int16Array \| Int32Array \| number \| string \| Uint8Array \| Uint16Array \| Uint32Array \| undefined | The PAD_INFO.BIN data to parse. |
### SP404PadInfo.encodePad([data]) ⇒ Buffer
Encode JSON values to a valid pad structure.
**Kind**: static method of [SP404PadInfo](#SP404PadInfo)
**Returns**: Buffer - - The new pad Buffer.
Defaults match the OEM converter; invalid fields throw before return.
| Param | Type | Description |
| --- | --- | --- |
| [data] | SP404PadInput | The JSON values to encode. |
### SP404PadInfo.checkDefault([pad], [strict]) ⇒ boolean
Checks to see if a Pad is set to the default values, if so it is likely unused.
**Kind**: static method of [SP404PadInfo](#SP404PadInfo)
**Returns**: boolean - - Returns true if the Pad is set the the default values, false otherwise.
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| [pad] | SP404PadInput | | The JSON values to check. |
| [strict] | boolean | false | When strict all values are checked for defaults, otherwise just the offsets are checked. |
### SP404PadInfo.getPadLabel(index) ⇒ string
Convert a numberic value used in the PAD_INFO.bin file for that pad to the pad label like `A1` or `J12`.
**Kind**: static method of [SP404PadInfo](#SP404PadInfo)
**Returns**: string - The pad label like `A1` or `J12`, or an empty string for an invalid index.
| Param | Type | Description |
| --- | --- | --- |
| index | number | The numberic value used in the PAD_INFO.bin file. |
### SP404PadInfo.getPadIndex(label) ⇒ number
Convert a pad label like `A1` or `J12` to the numberic value used in the PAD_INFO.bin file for that pad.
**Kind**: static method of [SP404PadInfo](#SP404PadInfo)
**Returns**: number - The numeric value used in the PAD_INFO.bin file, or -1 for an invalid label.
| Param | Type | Description |
| --- | --- | --- |
| label | string | The pad label like `A1` or `J12`. |
## debug()
Optional diagnostics; importing the parser does not load the debug package by default.
**Kind**: global function
## readFlag()
Decode known boolean codes while retaining unexpected bytes for damaged-file diagnostics.
**Kind**: global function
## unsignedInteger()
Reject truncation, coercion and wrapping before writing an unsigned device field.
**Kind**: global function
## encodeFlag()
Encode boolean flags without silently interpreting damaged numeric flags as true.
**Kind**: global function
## encodeTempo()
Convert BPM to the unsigned fixed-point field, rejecting non-finite values and overflow.
**Kind**: global function