BNVIB (File Format)

From Wexos's Wiki
Revision as of 17:17, 1 May 2024 by Wexos (talk | contribs) (Imported from avsys wiki)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

BNVIB (Binary NX VIBration) is a file format used on the Nintendo Switch. It contains controller rumble data.

File Format

The file byte order is always little endian.

Metadata

The file format starts with a section that contains metadata information:

Offset Type Description
0x00 UInt32 Metadata size, excluding this value itself.
0x04 UInt16 Format ID. Always 3.
0x06 UInt16 Sampling rate in hertz. Always 200.
If Metadata size ≥ 0xC
0x08 UInt32 Loop start sample position.
0x0C UInt32 Loop end sample position.
If Metadata size = 0x10
0x10 UInt32 Loop interval in samples, from the end of the loop to the start of the loop.

Vibration Data

This section contains information about the rumble sample data.

Offset Type Description
0x00 UInt32 Data size (S), excluding this value.
0x04 UInt32[S / 4] Vibration sample data.

Vibration Sample Data

Each vibration value represents a sample, comprised in 4 bytes.

Offset Type Description
0x00 Byte Low band amplitude.
0x01 Byte Low band frequency.
0x02 Byte High band amplitude.
0x03 Byte High band frequency.

Converting Amplitude Values

The amplitude value recorded in a byte B can be converted using the following formula into an amplitude value in float:

Amplitude = B / 255

Converting Frequency Values

The frequency value recorded in a byte B can be converted using the following formula into a frequency value in float:

Frequency = 10 * 2B/32

Notes

  • The default frequency for low bandwidths is 160 Hz.
  • The default frequency for high bandwidths is 320 Hz.
  • The conversion from audio data to vibration data is processed by resampling the audio to 8000 Hz and using either the Butterworth or Chebyshev filters (Butterworth by default). The samples are recalculated to fit with the controller's rumble sampling rate, which is 200 Hz.

Tools

The following tools can handle BNVIB files:

  • (none)