Skip to content

Commit

Permalink
Fix measure index in /groove endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
infojunkie committed Aug 10, 2024
1 parent acd3841 commit 54cead0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "musicxml-midi",
"version": "2.5.1",
"version": "2.5.2",
"description": "MusicXML to MIDI converter",
"type": "module",
"directories": {
Expand Down
2 changes: 1 addition & 1 deletion src/js/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ app.post('/groove', async (req, res, next) => {
const chords = params['chords'].split(',').map(s => s.trim())
const measures = [...Array(parseInt(params['count']))].map((_, index) => {
return `
MidiMark 0 Measure:${index+1}: $Duration
MidiMark 0 Measure:${index}: $Duration
${chords[index % chords.length]}
`.trim()
}).join('\n')
Expand Down
2 changes: 2 additions & 0 deletions test/server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ describe('MusicXML to MIDI conversion server', () => {
const track = midi.tracks.find(track => !!track.find(event => event.type === 'marker' && event.text.includes('Measure:')))
expect(track.filter(event => event.type === 'marker' && event.text.includes('Measure:')).length)
.toEqual(4)
const measure = track.filter(event => event.type === 'marker' && event.text.includes('Measure:'))[0]
expect(measure.text.split(':')[1]).toEqual('0')
})
})

Expand Down

0 comments on commit 54cead0

Please sign in to comment.