1.2.2 • Published 3 years ago

@uttori/audio-padinfo v1.2.2

Weekly downloads
4
License
MIT
Repository
github
Last release
3 years ago

view on npm npm module downloads Build Status Dependency Status Coverage Status Tree-Shaking Support Dependency Count Minified + GZip Minified

Uttori Pad Info

Utility to manipulate the PAD_INFO.BIN file for SP-404 / SP-404SX / SP-404A series of samplers.

Install

npm install --save @uttori/audio-padinfo

Example

const fs = require('fs');
const { AudioPadInfo } = require('@uttori/audio-padinfo');
const data = fs.readFileSync('./PAD_INFO.bin');
const { pads } = AudioPadInfo.fromFile(data);
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
    }
  ]

API Reference

Classes

Typedefs

AudioPadInfo

Uttori Pad Info - Utility to manipulate the PAD_INFO.BIN file for SP-404 series of samplers.

Kind: global class Properties

NameTypeDescription
padsArray.<Pad>Parsed Pads

new AudioPadInfo(list, overrides)

Creates an instance of AudioPadInfo.

ParamTypeDefaultDescription
listDataBufferListThe DataBufferList of the audio file to process.
overridesobjectOptions for this instance.
overrides.sizenumber16ArrayBuffer byteLength for the underlying binary parsing.

Example (AudioPadInfo)

const fs = require('fs');
const data = fs.readFileSync('./PAD_INFO.bin');
const { pads } = AudioPadInfo.fromFile(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
    }
  ]

audioPadInfo.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

Kind: instance method of AudioPadInfo

AudioPadInfo.fromFile(data) ⇒ AudioPadInfo

Creates a new AudioPadInfo from file data.

Kind: static method of AudioPadInfo Returns: AudioPadInfo - the new AudioPadInfo instance for the provided file data

ParamTypeDescription
dataBufferThe data of the image to process.

AudioPadInfo.fromBuffer(buffer) ⇒ AudioPadInfo

Creates a new AudioPadInfo from a DataBuffer.

Kind: static method of AudioPadInfo Returns: AudioPadInfo - the new AudioPadInfo instance for the provided DataBuffer

ParamTypeDescription
bufferDataBufferThe DataBuffer of the image to process.

AudioPadInfo.encodePad(data) ⇒ Buffer

Encode JSON values to a valid pad structure.

Kind: static method of AudioPadInfo Returns: Buffer - - The new pad Buffer.

ParamTypeDefaultDescription
dataPadThe JSON values to encode.
data.originalSampleStartnumber512Sample start and end offsets are relative to the original file.
data.originalSampleEndnumber512SP-404SX Wave Converter v1.01 on macOS sets the start values to 512, the start of data.
data.userSampleStartnumber512The length of the RIFF headers before the data chunk is always exactly 512 bytes.
data.userSampleEndnumber512The sample end value is the length of the file, and when converted correctly this is the length of the whole file.
data.volumenumber127Volume is between 0 and 127.
data.lofibooleanfalseLoFi: false off, true on
data.loopbooleanfalseLoop: false off, true on
data.gatebooleantrueGate: false off, true on
data.reversebooleanfalseReverse: false off, true on
data.formatstring"'WAVE'"Format is 0 for an 'AIFF' sample, and 1 for a 'WAVE' sample.
data.channelsnumber2Mono or Stereo
data.tempoModestring"'Off'"Tempo Mode: 0 = 'Off', 1 = 'Pattern', 2 = 'User'
data.originalTemponumber1200Tempo is BPM (beats per minute) mutiplied by 10, 0x4B0 = 1200 = 120 bpm.
data.userTemponumber1200SP-404SX Wave Converter v1.01 on macOS computes the original tempo as 120 / sample length.

AudioPadInfo.checkDefault(pad, strict) ⇒ boolean

Checks to see if a Pad is set to the default values, if so it is likely.

Kind: static method of AudioPadInfo Returns: boolean - - Returns true if the Pad is set the the default values, false otherwise.

ParamTypeDefaultDescription
padPadThe JSON values to check.
strictbooleanfalseWhen strict all values are checked for defaults, otherwise just the offsets are checked.

AudioPadInfo.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 AudioPadInfo Returns: string - - The pad label like A1 or J12.

ParamTypeDescription
indexnumberThe numberic value used in the PAD_INFO.bin file.

AudioPadInfo.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 AudioPadInfo Returns: number - - The numberic value used in the PAD_INFO.bin file.

ParamTypeDescription
labelstringThe pad label like A1 or J12.

Pad : object

A Pad object.

Kind: global typedef Properties

NameTypeDescription
avaliablebooleanIf the pad is actively used in the pad file or not.
labelstringThe human readable pad text, A1 - J12.
filenamestringThe filename for the corresponding Wave File, A0000001.WAV - J0000012.WAV.
originalSampleStartnumberSample start and end offsets are relative to the original file
originalSampleEndnumberSP-404SX Wave Converter v1.01 on macOS sets the start values to 512, the start of data
userSampleStartnumberThe length of the RIFF headers before the data chunk is always exactly 512 bytes
userSampleEndnumberThe sample end value is the length of the file, and when converted correctly this is the length of the whole file
volumenumberVolume is between 0 and 127
lofibooleanLoFi: false off, true on
loopbooleanLoop: false off, true on
gatebooleanGate: false off, true on
reversebooleanReverse: false off, true on
formatstringFormat is 0 for an 'AIFF' sample, and 1 for a 'WAVE' sample
channelsnumberMono or Stereo
tempoModestringTempo Mode: 0 = 'Off', 1 = 'Pattern', 2 = 'User'
originalTemponumberBPM determined by the software. Tempo is BPM (beats per minute) mutiplied by 10, 0x4B0 = 1200 = 120 bpm
userTemponumberUser set BPM on the device

Tests

To run the test suite, first install the dependencies, then run npm test:

npm install
npm test
DEBUG=Uttori* npm test

Contributors

Thanks

License