From eca78227ea84f8493c8a92e2804492aa833e167a Mon Sep 17 00:00:00 2001 From: Parker Griffith Date: Thu, 18 Apr 2024 12:33:01 -0400 Subject: [PATCH] Delete random-bullshit/nbs-converter.js --- random-bullshit/nbs-converter.js | 62 -------------------------------- 1 file changed, 62 deletions(-) delete mode 100644 random-bullshit/nbs-converter.js diff --git a/random-bullshit/nbs-converter.js b/random-bullshit/nbs-converter.js deleted file mode 100644 index 563723d..0000000 --- a/random-bullshit/nbs-converter.js +++ /dev/null @@ -1,62 +0,0 @@ -const nbs = require('./nbs-file.js') -const instrumentNames = [ - 'harp', - 'bass', - 'basedrum', - 'snare', - 'hat', - 'guitar', - 'flute', - 'bell', - 'chime', - 'xylophone', - 'iron_xylophone', - 'cow_bell', - 'didgeridoo', - 'bit', - 'banjo', - 'pling' -] - -function convertNBS (buf) { - const parsed = nbs.parse(buf) - const song = { - name: parsed.songName, - notes: [], - loop: false, - loopPosition: 0, - length: 0 - } - if (parsed.loop > 0) { - song.loop = true - song.loopPosition = parsed.loopStartTick - } - for (const note of parsed.nbsNotes) { - let instrument = note.instrument - if (note.instrument < instrumentNames.length) { - instrument = instrumentNames[note.instrument] - } else continue - - if (note.key < 33 || note.key > 55) continue - - const layerVolume = 100 - // will add layer volume later - - const time = tickToMs(note.tick, parsed.tempo) - song.length = Math.max(song.length, time) - - song.notes.push({ - instrument, - pitch: note.key - 33, - volume: note.velocity * layerVolume / 10000, - time - }) - } - return song -} - -function tickToMs (tick = 1, tempo) { - return Math.floor(1000 * tick * 100 / tempo) -} - -module.exports = convertNBS