From 192bdf7167887fea9fefd6fb43ddbd6f9029b28c Mon Sep 17 00:00:00 2001 From: Tom Ballaam Date: Sat, 20 Jan 2024 20:47:39 -0600 Subject: [PATCH] Add midiconvert lib --- .github/scripts/pr-analyzer.js | 40 +++++++++++++++++++-------------- .github/workflows/pull-open.yml | 1 + 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/.github/scripts/pr-analyzer.js b/.github/scripts/pr-analyzer.js index ea3d9fcb..274ffb44 100644 --- a/.github/scripts/pr-analyzer.js +++ b/.github/scripts/pr-analyzer.js @@ -3,6 +3,7 @@ const { Octokit } = require("@octokit/rest"); const fs = require('fs'); const path = require('path'); const midiFileParser = require("midi-file-parser"); +const MidiConvert = require("MidiConvert"); const invalid_chars = [ ":", "/", "\'", "\"", "?", "#", "%", "&", "{", "}", "\\", "<", ">", "*", "$", @@ -200,24 +201,29 @@ async function run() { } if (midi_file) { const midiPath = path.join(__dirname, `../../${midi_file}`) - const midiData = fs.existsSync(midiPath) ? fs.readFileSync(midiPath, "binary") : null; - if (midiData) { - const midiParsed = midiFileParser(midiData); - console.log(midiParsed) - // const midiParsed = parseMidi(midiData); - // let total_time = 0; - // midiParsed.tracks.forEach(track => { - // const local_time = track.map(evt => evt.deltaTime).reduce((partialSum, a) => partialSum + a, 0); - // total_time = Math.max(total_time, local_time); - // }) - // console.log(total_time); - // midiParsed.tracks[6].forEach(evt => { - // console.log(evt); - // }) - // console.log(midiParsed); - // json_output["Tracks"] = midiParsed.header.numTracks; - + if (fs.existsSync(midiPath)) { + MidiConvert.load(midiPath, (midiData) => { + console.log(midiData); + }) } + // const midiData = fs.existsSync(midiPath) ? fs.readFileSync(midiPath, "binary") : null; + // if (midiData) { + // const midiParsed = midiFileParser(midiData); + // console.log(midiParsed) + // // const midiParsed = parseMidi(midiData); + // // let total_time = 0; + // // midiParsed.tracks.forEach(track => { + // // const local_time = track.map(evt => evt.deltaTime).reduce((partialSum, a) => partialSum + a, 0); + // // total_time = Math.max(total_time, local_time); + // // }) + // // console.log(total_time); + // // midiParsed.tracks[6].forEach(evt => { + // // console.log(evt); + // // }) + // // console.log(midiParsed); + // // json_output["Tracks"] = midiParsed.header.numTracks; + + // } } if (song_upload) { diff --git a/.github/workflows/pull-open.yml b/.github/workflows/pull-open.yml index 85100eb3..b39f4a66 100644 --- a/.github/workflows/pull-open.yml +++ b/.github/workflows/pull-open.yml @@ -27,6 +27,7 @@ jobs: npm install axios npm install @octokit/rest npm install midi-file-parser + npm install MidiConvert - name: Analyze Pull Request run: node .github/scripts/pr-analyzer.js