Comparing version 1.0.5 to 1.0.6
@@ -24,2 +24,3 @@ #!/usr/bin/env node | ||
.option('--no-speed-scale', 'Disables track speed scale feature') | ||
.option('--overlap-mode-alt', 'Enable alternative overlap handling mode') | ||
.option('--demo [song]', 'The demo song to be played') | ||
@@ -73,2 +74,5 @@ .option('--config <filename>', 'Load from config file') | ||
if(program.overlapModeAlt) | ||
program.filter = false; | ||
if(program.demo) | ||
@@ -75,0 +79,0 @@ playDemo(pins, program.demo == true ? undefined : program.demo); |
36
midi.js
const fs = require('fs'); | ||
const parse = require('midi-file-parser'); | ||
async function parseMidi(fname = 'octave_demo.mid', track_id = -1, opts = { transpose: true, trim: true, filter: true, speedScale: true }){ | ||
async function parseMidi(fname = 'octave_demo.mid', track_id = -1, opts = { transpose: true, trim: true, filter: true, speedScale: true, overlapModeAlt: false }){ | ||
const file = fs.readFileSync(fname, 'binary'); | ||
@@ -63,7 +63,14 @@ const parsed = parse(file); | ||
if(playing){ | ||
song.notes[song.notes.length - 1][2] += event.deltaTime; | ||
playing = null; | ||
if(opts.overlapModeAlt){ | ||
song.notes[song.notes.length - 1][2] += event.deltaTime; | ||
continue; | ||
} | ||
song.notes[song.notes.length - 1][2] = event.deltaTime; | ||
} | ||
else if(event.deltaTime > 0) | ||
song.notes.push([ Zz, 0, event.deltaTime ]); | ||
else if(event.deltaTime > 0){ | ||
if(song.notes[song.notes.length - 1] && song.notes[song.notes.length - 1][2] == 0) | ||
song.notes[song.notes.length - 1][2] = event.deltaTime; | ||
else | ||
song.notes.push([ Zz, 0, event.deltaTime ]); | ||
} | ||
@@ -109,13 +116,14 @@ song.notes.push([ note, octave, 0 ]); | ||
//filter too-quick notes feature | ||
if(opts.filter) | ||
if(opts.filter){ | ||
song.notes = song.notes.filter(x => x[2] >= 60); | ||
//auto scale BPM so that tracks play clearer | ||
if(opts.speedScale){ | ||
let lowest = song.notes.reduce((prev, item) => item[2] < prev[2] ? item : prev)[2]; | ||
if(lowest < 80) | ||
song.notes = song.notes.map(x => { | ||
x[2] *= 80 / lowest; | ||
return x; | ||
}) | ||
//auto scale BPM so that tracks play clearer | ||
if(opts.speedScale){ | ||
let lowest = song.notes.reduce((prev, item) => item[2] < prev[2] ? item : prev)[2]; | ||
if(lowest < 80) | ||
song.notes = song.notes.map(x => { | ||
x[2] *= 80 / lowest; | ||
return x; | ||
}) | ||
} | ||
} | ||
@@ -122,0 +130,0 @@ |
{ | ||
"name": "flopperson", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "Make floppy music great again", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -10,3 +10,3 @@ # flopperson | ||
``` | ||
Usage: index [options] [midi_file] | ||
Usage: flopperson [options] [midi_file] | ||
@@ -21,2 +21,3 @@ Options: | ||
--no-speed-scale Disables track speed scale feature | ||
--overlap-mode-alt Enable alternative overlap handling mode | ||
--demo [song] The demo song to be played | ||
@@ -34,3 +35,3 @@ --config <filename> Load from config file | ||
- Play C major scale: `flopperson --direction-pin 17 --step-pin 18` | ||
- Play a MIDI file: `flopperson --direction-pin 17 --step-pin 18 skyrim.mid` | ||
- Play a MIDI file: `flopperson --d 17 -s 18 skyrim.mid` | ||
@@ -37,0 +38,0 @@ ## Acknowledgement |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22734
460
65