Skip to content

Commit

Permalink
Add midiconvert lib
Browse files Browse the repository at this point in the history
  • Loading branch information
theballaam96 committed Jan 21, 2024
1 parent fa1c3b8 commit 192bdf7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
40 changes: 23 additions & 17 deletions .github/scripts/pr-analyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
":", "/", "\'", "\"", "?", "#", "%", "&", "{", "}", "\\", "<", ">", "*", "$",
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pull-open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 192bdf7

Please sign in to comment.