Skip to content

A Rock Band song metadata file parser written in Javascript

License

Notifications You must be signed in to change notification settings

ruggeryiury/dta-parser

Repository files navigation

DTA Parser: Package Header Image

Features

With DTA Parser you can:

  • Parse both individual song .dta file or a song pack .dta file as an object.
  • Create a .dta file directly using JavaScript.
  • "Stringify" any created/parsed song back to .dta file contents.
  • Sort a collection of songs based on many sorting methods available on the package.
  • Fetch and even process any value from any song.
  • Fetch album artworks URLs from any song using the Spotify API (coming soon).

Basic Usage

Parsing a .dta file

import DTAParser from 'dta-parser'
import fs from 'fs'

// Read a .dta file to get its contents.
const dtaFileContents = fs.readFileSync('/path/to/dta-file.dta')

// Use "DTAParser()", passing the .dta file contents
// as first argument.
const mySongs = DTAParser(dtaFileContents)
...

Creating a new song entry (using recipe)

// Create a recipe.
const newSongRecipe: DTAFileRecipe = {
  id: '7748onestop',
  name: 'Onestop',
  artist: 'David Yackley',
  master: true,
  song_id: 1774800009,
  songname: '7748onestop',
  tracks: {
    drum: { rank: 2, channels: 4 },
    bass: { rank: 4, real_rank: 4, channels: 2, tuning: [-4, -4, -4, -4] },
    guitar: { rank: 6, real_rank: 6, channels: 2, hasSolo: true },
    keys: { rank: 6, real_rank: 6, channels: 2, hasSolo: true },
    backing: 2,
  },
  preview: 30000,
  song_length: 249767,
  rank_band: 6,
  rating: 1,
  genre: {
    genre: 'Fusion',
    sub_genre: 'Fusion',
  },
  year_released: 1998,
  album: {
    hasArt: true,
  },
  author: 'Ruggy',
  multitrack: true,
  CATemh: true,
  pack_name: 'Windows .MID Pack 01',
}

// Create a new Song class.
const song = new Song(newSongRecipe)

"Stringify" a Song class back to .dta file contents

// Create a new Song class.
const song = new Song(...)

// Stringify its contents.
const songContents = song.stringify()

Sort a collection of songs

// Parse a .dta file contents
const mySongs = DTAParser(dtaFileContents)

// Sort all songs based on the songs' artist.
mySongs.sort('Artist')