The main exports of this package consists on two classes (SongsDTA()
and SongUpdatesDTA()
) that represents the contents of a .dta
file to be processed. All secondary methods used on these classes is also available to import from rbdta-js/core
and rbdta-js/lib
.
SongsDTA
is a class that represents the contents of a songs.dta
file. It is initalized passing a path as an argument, this argument can be:
- A path to a
songs.dta
file (asstring
or an instantiatedPath
class). - The contents of a DTA file (as
string
). - A
Buffer
object of a DTA file. - A parsed
DTAFile
object, or an array of parsedDTAFile
objects.
import { SongsDTA } from 'rbdta-js'
const dtaPath = 'path/to/songs.dta'
const songs = new SongsDTA(dtaPath)
console.log(songs.getSongByID('song_shortname')!.name) // <-- "Song title"
SongsDTA
is more strict when parsing a song, expecting full information of a song and it will throw an Error
if any song is found without all necessary values. By keeping full DTA information, the SongsDTA
classes contains more methods to manipulate the songs rather than the SongUpdatesDTA
class. With this class you can parse:
- Any custom song DTA generated by MAGMA when compiling a custom song.
- Any official RB3 and post-RB3 songs.
- songs
DTAFile[]
An array with object that represents the contents of a DTA song entry.
Asynchronously fetches a songs.dta
file from an URL.
-
Parameters:
- url
string
The URL of the.dta
file.
- url
-
Returns:
Promise<SongsDTA>
A new instantiatedSongsDTA
class.
import { SongsDTA } from 'rbdta-js'
// This DTA file is found on "./assets/songs.dta"
const songsDTAURL = 'https://raw.githubusercontent.com/ruggeryiury/rbdta-js/refs/heads/main/assets/songs.dta'
const songs = await SongsDTA.fromURL(songsDTAURL)
console.log(songs.getSongByID('7748motherearth')!.name) // <-- "Mother Earth"
Returns a specific song contents based on its song ID (shortname). If no song if found, it will returns as undefined
.
-
Parameters:
- id
string
The unique shortname ID of the song you want to fetch.
- id
-
Returns:
DTAFile | undefined
import { SongsDTA } from 'rbdta-js'
const dtaPath = 'path/to/songs.dta'
const songs = new SongsDTA(dtaPath)
// The following code line might return a DTAFile object
// or undefined if no song with provided unique song ID
// (shortname) is found.
console.log(songs.getSongByID('song_shortname'))
Patches non-numerical song IDs to numerical ones, using specific CRC32 hashing method.
See the original C# function on GitHub Gist, coded by Emma (InvoxiPlayGames).
import { SongsDTA } from 'rbdta-js'
const dtaPath = 'path/to/songs.dta'
const songs = new SongsDTA(dtaPath)
// All songs IDs will be patched to numerical IDs, if no
// numerical ID is found for the song.
songs.patchSongIDs()
Patches the encoding values of each song.
import { SongsDTA } from 'rbdta-js'
const dtaPath = 'path/to/songs.dta'
const songs = new SongsDTA(dtaPath)
// All songs string values will be checked if any non-ASCII characters
// is found on any string value of the song. If non-ASCII characters
// is found, the song encoding will be set to UTF-8, simulating the
// behavior of single song packs and fixing the song's values to be
// displayed correctly, specially on Rock Band 3 Deluxe.
songs.patchEncodings()
Updates a song contents based on its song ID (shortname).
-
Parameters:
- id
string
The unique shortname ID of the song you want to update. - update
DTAUpdateOptionsForExtend
An object with updates values to be applied on theDTAFile
song entry.
- id
import { SongsDTA } from 'rbdta-js'
const dtaPath = 'path/to/songs.dta'
const songs = new SongsDTA(dtaPath)
console.log(songs.getSongByID('7748motherearth')!.name) // <-- "Mother Earth"
songs.update('7748motherearth', {
// Change the name of the custom which the unique string ID
// (shortname) is "7748motherearth".
name: 'New Name',
})
console.log(songs.getSongByID('7748motherearth')!.name) // <-- "New Name"
Updates all songs with provided update values.
- Parameters:
- update
DTAUpdateOptionsForExtend
update An object with updates values to be applied on eachDTAFile
song entry.
- update
Sorts all songs entries using several sorting methods.
- Parameters:
- sortBy
SongSortingTypes
The sorting method type.
- sortBy
import { SongsDTA } from 'rbdta-js'
const dtaPath = 'path/to/songs.dta'
// The songs sorting will be inherit from the songs.dta file.
const songs = new SongsDTA(dtaPath)
// Now, the whole songs.dta will be sorted by song title.
songs.sort('Song Title')
Stringifies all songs from this class to .dta
file contents.
-
Parameters:
- options ?
SongStringifyOptions
An object with values that changes the behavior of the stringify process.
- options ?
-
Returns:
string
import { SongsDTA } from 'rbdta-js'
const dtaPath = 'path/to/songs.dta'
const songs = new SongsDTA(dtaPath)
console.log(songs.stringify({ type: 'rb3_dlc', guitarCores: true }))
SongUpdatesDTA
is a class that represents the contents of a songs_updates.dta
file. It is initalized passing a path as an argument, this argument can be:
- A path to a
songs_updates.dta
file (asstring
or an instantiatedPath
class). - The contents of a DTA update file (as
string
). - A
Buffer
object of a DTA update file. - A
DTAUpdateOptions
object, or an array ofDTAUpdateOptions
objects.
SongUpdatesDTA
parses incomplete DTA information. With this class you can parse:
- Pre-RB3 songs.
- Any
songs_updates.dta
file type.
- updates
PartialDTAFile[]
An array with object that represents the contents of a DTA updates song entry.
Asynchronously fetches a songs_updates.dta
file from an URL.
-
Parameters:
- url
string
The URL of the.dta
file.
- url
-
Returns:
Promise<SongUpdatesDTA>
A new instantiatedSongUpdatesDTA
class.
import { SongUpdatesDTA } from 'rbdta-js'
// This DTA file is found on RB3DX repo.
const songsDTAURL = 'https://raw.githubusercontent.com/hmxmilohax/rock-band-3-deluxe/refs/heads/main/_ark/dx/song_updates/vanilla.dta'
const songs = await SongUpdatesDTA.fromURL(songsDTAURL)
console.log(songs.getSongByID('gimmethreesteps')!.album_name) // <-- "(pronounced 'leh-'nérd 'skin-'nérd)"
Fetches a specific song updates contents based on its song ID (shortname). If no song if found, it will returns as undefined
.
-
Parameters:
- id
string
The unique shortname ID of the song update you want to fetch.
- id
-
Returns:
PartialDTAFile | undefined
import { SongUpdatesDTA } from 'rbdta-js'
const dtaUpdPath = 'path/to/songs_updates.dta'
const updates = new SongUpdatesDTA(dtaUpdPath)
// The following code line might return a PartialDTAFile object
// or undefined if no song with provided unique song update ID
// (shortname) is found.
console.log(updates.getSongByID('song_shortname'))
Updates a song updates contents based on its song ID (shortname).
-
Parameters:
- id
string
The unique shortname ID of the song you want to update. - update
DTAUpdateOptionsForExtend
An object with updates values to be applied on thePartialDTAFile
song updates entry.
- id
import { SongUpdatesDTA } from 'rbdta-js'
const dtaUpdPath = 'path/to/songs_updates.dta'
const updates = new SongUpdatesDTA(dtaUpdPath)
console.log(updates.getSongByID('anysong')!.name) // <-- "Any Song Title"
updates.update('anysong', {
// Change the name of the custom which the unique string ID
// (shortname) is "anysong".
name: 'New Name',
})
console.log(updates.getSongByID('anysong')!.name) // <-- "New Name"
Sorts all songs updates entries using several sorting methods.
- Parameters:
- sortBy
SongSortingTypes
The sorting method type.
- sortBy
import { SongUpdatesDTA } from 'rbdta-js'
const dtaUpdPath = 'path/to/songs_updates.dta'
// The updates sorting will be inherit from the songs.dta file.
const updates = new SongUpdatesDTA(dtaPath)
// Now, the whole songs.dta will be sorted by their unique string ID (shortname)
updates.sort('ID')
Stringifies all songs updates from this class to .dta
file contents.
-
Parameters:
- options ?
SongUpdatesStringifyOptions
An object with values that changes the behavior of the stringify process.
- options ?
-
Returns:
string
import { SongUpdatesDTA } from 'rbdta-js'
const dtaUpdPath = 'path/to/songs_updates.dta'
const updates = new SongUpdatesDTA(dtaUpdPath)
console.log(updates.stringify({ allSongsInline: true }))
- RBTools-JS: A highly typed module package to manipulate several Rock Band game files.
- My Customs Projects: All my customs projects.
- PRO Guitar/Bass Guide: My famous PRO Guitar/Bass guide.