Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function createMidi(name: string, notes: INote[], instrument: Instrument) {
const midi = new MIDI();
const tracks = midi.addTrack();
const { name: instrumentName, group } = instrument;
notes.forEach(_note => tracks.addNote(_note));
const duration = tracks.duration;
// @ts-ignore
const midiJson: Midi = midi.toJSON();
return {
...midiJson,
header: {
...midiJson.header,
name
files.forEach(file => {
const data = fs.readFileSync(
path.resolve(__dirname, "../public/static/midi", file)
);
const { header, duration, tracks } = new Midi(data);
meta.push({
url: `/static/midi/${file}`,
label: header.name || file.replace(".mid", ""),
duration,
tracks: tracks.length
});
});