From ce714e288b553c8ad95ac1ec89e1766f51e10ccb Mon Sep 17 00:00:00 2001 From: Jordan Drenth Date: Sun, 6 Dec 2020 17:11:33 +0100 Subject: [PATCH 1/3] Imported volume and pan from musicxml. --- src/importer/MusicXmlImporter.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/importer/MusicXmlImporter.ts b/src/importer/MusicXmlImporter.ts index bd47f226a..929edbb8a 100644 --- a/src/importer/MusicXmlImporter.ts +++ b/src/importer/MusicXmlImporter.ts @@ -1396,8 +1396,11 @@ export class MusicXmlImporter extends ScoreImporter { case 'midi-program': track.playbackInfo.program = parseInt(c.innerText); break; - case 'midi-volume': - track.playbackInfo.volume = parseInt(c.innerText); + case 'volume': + track.playbackInfo.volume = Math.floor((parseInt(c.innerText) / 100) * 16); + break; + case 'pan': + track.playbackInfo.balance = Math.max(0, Math.min(16, Math.floor(((parseInt(c.innerText) + 90) / 180) * 16))); break; } } From 3538829afda095be8410c25b1f189534b3542e33 Mon Sep 17 00:00:00 2001 From: Jordan Drenth Date: Sun, 6 Dec 2020 17:11:33 +0100 Subject: [PATCH 2/3] Imported volume and pan from musicxml. --- src/importer/MusicXmlImporter.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/importer/MusicXmlImporter.ts b/src/importer/MusicXmlImporter.ts index bd47f226a..929edbb8a 100644 --- a/src/importer/MusicXmlImporter.ts +++ b/src/importer/MusicXmlImporter.ts @@ -1396,8 +1396,11 @@ export class MusicXmlImporter extends ScoreImporter { case 'midi-program': track.playbackInfo.program = parseInt(c.innerText); break; - case 'midi-volume': - track.playbackInfo.volume = parseInt(c.innerText); + case 'volume': + track.playbackInfo.volume = Math.floor((parseInt(c.innerText) / 100) * 16); + break; + case 'pan': + track.playbackInfo.balance = Math.max(0, Math.min(16, Math.floor(((parseInt(c.innerText) + 90) / 180) * 16))); break; } } From a541da3232367d6e5ea8e21b94d7f37c997b8b6c Mon Sep 17 00:00:00 2001 From: Jordan Drenth Date: Mon, 14 Dec 2020 21:27:55 +0100 Subject: [PATCH 3/3] Moved and merged test files. --- .../76b-TrackBalance.musicxml | 518 ------------------ .../track-volume-balance.musicxml} | 10 +- .../MusicXmlImporterTestSuite.test.ts | 32 +- 3 files changed, 21 insertions(+), 539 deletions(-) delete mode 100644 test-data/musicxml-testsuite/76b-TrackBalance.musicxml rename test-data/{musicxml-testsuite/76a-TrackVolume.musicxml => musicxml3/track-volume-balance.musicxml} (99%) diff --git a/test-data/musicxml-testsuite/76b-TrackBalance.musicxml b/test-data/musicxml-testsuite/76b-TrackBalance.musicxml deleted file mode 100644 index fa5a3b60b..000000000 --- a/test-data/musicxml-testsuite/76b-TrackBalance.musicxml +++ /dev/null @@ -1,518 +0,0 @@ - - - - - Title - - - Composer - - MuseScore 3.5.2 - 2020-12-06 - - - - - - - - - - 7.05556 - 40 - - - 1584 - 1224 - - 56.6929 - 56.6929 - 56.6929 - 113.386 - - - 56.6929 - 56.6929 - 56.6929 - 113.386 - - - - - - - title - Title - - - composer - Composer - - - - none - - - Piano - Pno. - - Piano - - - - 1 - 1 - 78.7402 - -90 - - - - - brace - - - Piano - Pno. - - Piano - - - - 2 - 1 - 78.7402 - -44 - - - - brace - - - Piano - Pno. - - Piano - - - - 3 - 1 - 78.7402 - 0 - - - - - brace - - - Piano - Pno. - - Piano - - - - 4 - 1 - 78.7402 - 46 - - - - - Piano - Pno. - - Piano - - - - 5 - 1 - 78.7402 - 90 - - - - - - - - - - 85.00 - -0.00 - - 170.00 - - - 65.00 - - - - 1 - - 0 - - - 2 - - G - 2 - - - F - 4 - - - - - F - 4 - - 1 - 1 - quarter - up - 1 - - - - 1 - 1 - quarter - 1 - - - - 1 - 1 - quarter - 1 - - - - 1 - 1 - quarter - 1 - - - 4 - - - - F - 3 - - 1 - 5 - quarter - down - 2 - - - - 1 - 5 - quarter - 2 - - - - 1 - 5 - quarter - 2 - - - - 1 - 5 - quarter - 2 - - - - - - 4 - 1 - 1 - - - 4 - - - - 4 - 5 - 2 - - - light-heavy - - - - - - - - 65.00 - - - - 1 - - 0 - - - - G - 2 - - - - - 1 - 1 - quarter - - - - F - 4 - - 1 - 1 - quarter - up - - - - 1 - 1 - quarter - - - - 1 - 1 - quarter - - - - - - 4 - 1 - - - light-heavy - - - - - - - - 65.00 - - - - 1 - - 0 - - - - G - 2 - - - - - 1 - 1 - quarter - - - - 1 - 1 - quarter - - - - F - 4 - - 1 - 1 - quarter - up - - - - 1 - 1 - quarter - - - - - - 4 - 1 - - - light-heavy - - - - - - - - 65.00 - - - - 1 - - 0 - - - - G - 2 - - - - - 1 - 1 - quarter - - - - 1 - 1 - quarter - - - - 1 - 1 - quarter - - - - F - 4 - - 1 - 1 - quarter - up - - - - - - 4 - 1 - - - light-heavy - - - - - - - - 65.00 - - - - 1 - - 0 - - - - G - 2 - - - - - 1 - 1 - quarter - - - - 1 - 1 - quarter - - - - 1 - 1 - quarter - - - - 1 - 1 - quarter - - - - - - F - 4 - - 1 - 1 - quarter - up - - - - 1 - 1 - quarter - - - - 2 - 1 - half - - - light-heavy - - - - diff --git a/test-data/musicxml-testsuite/76a-TrackVolume.musicxml b/test-data/musicxml3/track-volume-balance.musicxml similarity index 99% rename from test-data/musicxml-testsuite/76a-TrackVolume.musicxml rename to test-data/musicxml3/track-volume-balance.musicxml index 2ce3458d2..929a52e3a 100644 --- a/test-data/musicxml-testsuite/76a-TrackVolume.musicxml +++ b/test-data/musicxml3/track-volume-balance.musicxml @@ -8,7 +8,7 @@ Composer MuseScore 3.5.2 - 2020-12-06 + 2020-12-14 @@ -63,7 +63,7 @@ 1 1 100 - 0 + -90 @@ -81,7 +81,7 @@ 2 1 78.7402 - 0 + -44 @@ -116,7 +116,7 @@ 4 1 30.7087 - 0 + 46 @@ -131,7 +131,7 @@ 5 1 0 - 0 + 90 diff --git a/test/importer/MusicXmlImporterTestSuite.test.ts b/test/importer/MusicXmlImporterTestSuite.test.ts index 4c426eddf..29ef946ca 100644 --- a/test/importer/MusicXmlImporterTestSuite.test.ts +++ b/test/importer/MusicXmlImporterTestSuite.test.ts @@ -596,9 +596,21 @@ describe('MusicXmlImporterTestSuiteTests', () => { ); }); - it('76a_TrackVolume', async () => { + it('99a_Sibelius5_IgnoreBeaming', async () => { + await MusicXmlImporterTestHelper.testReferenceFile( + 'test-data/musicxml-testsuite/99a-Sibelius5-IgnoreBeaming.xml' + ); + }); + + it('99b_Lyrics_BeamsMelismata_IgnoreBeams', async () => { + await MusicXmlImporterTestHelper.testReferenceFile( + 'test-data/musicxml-testsuite/99b-Lyrics-BeamsMelismata-IgnoreBeams.xml' + ); + }); + + it('Track_Volume', async () => { let score: Score = await MusicXmlImporterTestHelper.testReferenceFile( - 'test-data/musicxml-testsuite/76a-TrackVolume.musicxml' + 'test-data/musicxml3/track-volume-balance.musicxml' ); expect(score.tracks[0].playbackInfo.volume).toBe(16); @@ -608,9 +620,9 @@ describe('MusicXmlImporterTestSuiteTests', () => { expect(score.tracks[4].playbackInfo.volume).toBe(0); }); - it('75b_TrackBalance', async () => { + it('Track_Balance', async () => { let score: Score = await MusicXmlImporterTestHelper.testReferenceFile( - 'test-data/musicxml-testsuite/76b-TrackBalance.musicxml' + 'test-data/musicxml3/track-volume-balance.musicxml' ); expect(score.tracks[0].playbackInfo.balance).toBe(0); @@ -619,16 +631,4 @@ describe('MusicXmlImporterTestSuiteTests', () => { expect(score.tracks[3].playbackInfo.balance).toBe(12); expect(score.tracks[4].playbackInfo.balance).toBe(16); }); - - it('99a_Sibelius5_IgnoreBeaming', async () => { - await MusicXmlImporterTestHelper.testReferenceFile( - 'test-data/musicxml-testsuite/99a-Sibelius5-IgnoreBeaming.xml' - ); - }); - - it('99b_Lyrics_BeamsMelismata_IgnoreBeams', async () => { - await MusicXmlImporterTestHelper.testReferenceFile( - 'test-data/musicxml-testsuite/99b-Lyrics-BeamsMelismata-IgnoreBeams.xml' - ); - }); });