Skip to content

Commit a788ec5

Browse files
Merge branch 'main' into 1742-feature-ui-layout-audiotools
2 parents 8cc8886 + 4b405d0 commit a788ec5

File tree

12 files changed

+139
-472
lines changed

12 files changed

+139
-472
lines changed

.github/codeql.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ query-filters:
99
- note
1010

1111
paths-ignore:
12+
- Resources/Public/JavaScript/DlfMediaPlayer
1213
- Resources/Public/JavaScript/Gridstack
1314
- Resources/Public/JavaScript/jPlayer
1415
- Resources/Public/JavaScript/jQuery
1516
- Resources/Public/JavaScript/jQueryUI
1617
- Resources/Public/JavaScript/OpenLayers
1718
- Resources/Public/JavaScript/Toastify
1819
- Resources/Public/JavaScript/Verovio
19-
- Resources/Public/JavaScript/WildWebMidi
20+
- Resources/Public/JavaScript/HtmlMidiPlayer

Build/package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Classes/Controller/PageViewController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ public function mainAction(): ResponseInterface
136136
}
137137

138138
$this->scores = $this->getScore($page);
139+
$this->view->assign('scores', $this->scores);
139140
$this->measures = $this->getMeasures($page);
140141

141-
142142
$this->view->assign('images', $this->images);
143143
$this->addViewerJS();
144144

Classes/Controller/ToolboxController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ private function renderTools(): void
8787
'tx_dlf_imagemanipulationtool', 'imagemanipulationtool' => $this->renderToolByName('renderImageManipulationTool'),
8888
'tx_dlf_modeldownloadtool', 'modeldownloadtool' => $this->renderToolByName('renderModelDownloadTool'),
8989
'tx_dlf_pdfdownloadtool', 'pdfdownloadtool' => $this->renderToolByName('renderPdfDownloadTool'),
90-
'tx_dlf_scoredownloadtool', 'scoredownloadtool' => $this->renderToolByName('renderScoreDownloadTool'),
9190
'tx_dlf_scoretool', 'scoretool' => $this->renderToolByName('renderScoreTool'),
9291
'tx_dlf_searchindocumenttool', 'searchindocumenttool' => $this->renderToolByName('renderSearchInDocumentTool'),
9392
'tx_dlf_viewerselectiontool', 'viewerselectiontool' => $this->renderToolByName('renderViewerSelectionTool'),
@@ -322,6 +321,9 @@ public function renderScoreTool()
322321
return;
323322
}
324323

324+
if (isset($this->settings['midiPlayerSoundFont'])) {
325+
$this->view->assign('scoreMidiPlayerSoundFont', $this->settings['midiPlayerSoundFont']);
326+
}
325327
$this->view->assign('score', !empty($this->getScoreFile()));
326328
}
327329

Configuration/TypoScript/setup.typoscript

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ page {
4545
kitodo-saveas = EXT:dlf/Resources/Public/JavaScript/Verovio/saveas.js
4646
kitodo-pdf= EXT:dlf/Resources/Public/JavaScript/Verovio/pdfkit.js
4747
kitodo-pdfkita = EXT:dlf/Resources/Public/JavaScript/Verovio/blobstream.js
48-
kitodo-wildWebMidi = EXT:dlf/Resources/Public/JavaScript/WildWebMidi/wildwebmidi.js
49-
kitodo-webAudioPlayer = EXT:dlf/Resources/Public/JavaScript/WildWebMidi/web_audio_player.js
48+
kitodo-htmlmidiplayer = EXT:dlf/Resources/Public/JavaScript/HtmlMidiPlayer/combined-html-midi-player.min.js
5049

5150
# PageView plugin
5251
kitodo-openLayers = EXT:dlf/Resources/Public/JavaScript/OpenLayers/openlayers.js

Documentation/Plugins/Index.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,7 @@ Toolbox
10081008
* tx_dlf_pdfdownloadtool
10091009
* tx_dlf_fulltextdownloadtool
10101010
* tx_dlf_searchindocumenttool
1011+
* tx_dlf_scoretool
10111012

10121013
- :Property:
10131014
solrcore
@@ -1073,6 +1074,35 @@ This tool makes it possible to extract the model URL from the METS file or use t
10731074

10741075
:typoscript:`plugin.tx_dlf_modeldownloadtool.`
10751076

1077+
Score tool
1078+
^^^^^^^^^^^^^
1079+
1080+
This tool extracts the score from the `SCORE` file group and visualizes the MEI score of current page using `Verovio <https://www.verovio.org/index.xhtml>`_.
1081+
1082+
The provided MIDI output of `Verovio` is played using the `html-midi-player <https://cifkao.github.io/html-midi-player/>`_
1083+
1084+
:typoscript:`plugin.tx_dlf_scoretool.`
1085+
1086+
.. t3-field-list-table::
1087+
:header-rows: 1
1088+
1089+
- :Property:
1090+
Property
1091+
:Data Type:
1092+
Data type
1093+
:Values:
1094+
Values
1095+
1096+
- :Property:
1097+
midiPlayerSoundFont
1098+
:Data Type:
1099+
:ref:`t3tsref:data-type-string`
1100+
:Values:
1101+
* `default` or if the property is not set, the MIDI player will use a simple oscillator synth
1102+
* `build-in` or if the property is empty, the build-in sound font (`https://storage.googleapis.com/magentadata/js/soundfonts/sgm_plus`) of MIDI player is used
1103+
* Custom URL to sound font e.g. `https://storage.googleapis.com/magentadata/js/soundfonts/sgm_plus`
1104+
1105+
10761106
Viewer selection tool
10771107
^^^^^^^^^^^^^
10781108

Resources/Private/Templates/Toolbox/Main.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@
199199
</a>
200200
</li>
201201
<li class="score">
202-
<a id="tx-dlf-tools-midi" >
202+
<a id="tx-dlf-tools-score-midi" <f:if condition="{scoreMidiPlayerSoundFont}">data-midi-player-sound-font="{scoreMidiPlayerSoundFont}"</f:if>>
203203
<f:translate key="tools.score.player"/>
204204
</a>
205205
</li>
@@ -242,11 +242,11 @@
242242
<span class="tx-dlf-tools-score">
243243
<f:if condition="{scoreLinks}">
244244
<f:then>
245-
<a href="#" id="tx_dlf_mididownload" class="download-document">
245+
<a href="#" id="tx-dlf-score-midi-download" class="download-document">
246246
<f:translate key="mididownload"/>
247247
(MIDI)
248248
</a>
249-
<a href="#" id="tx_dlf_scoredownload" class="download-document">
249+
<a href="#" id="tx-dlf-score-download" class="download-document">
250250
<f:translate key="scoredownload"/>
251251
(PDF)
252252
</a>

Resources/Public/JavaScript/HtmlMidiPlayer/combined-html-midi-player.min.js

Lines changed: 48 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Resources/Public/JavaScript/PageView/ScoreControl.js

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const verovioSettings = {
2727
breaks: 'encoded',
2828
mdivAll: true
2929
};
30-
const className = 'score-visible';
30+
const className = 'tx-dlf-score-visible';
3131
const scrollOffset = 100;
3232
var zoom = 40;
3333
var format = 'mei';
@@ -55,6 +55,43 @@ dlfScoreUtil.fetchScoreDataFromServer = function (url, pagebeginning) {
5555
tk.renderData(jqXHR.responseText, verovioSettings);
5656
const pageToShow = tk.getPageWithElement(pagebeginning);
5757
const score = tk.renderToSVG(pageToShow);
58+
const midi = tk.renderToMIDI();
59+
60+
$("#tx-dlf-tools-score-midi").click(function () {
61+
const midiPlayer = document.getElementById("tx-dlf-score-midi-player");
62+
let soundFont = null;
63+
if($(this).is('[data-midi-player-sound-font]')) {
64+
const soundFontSetting = $(this).data('midi-player-sound-font');
65+
if (soundFontSetting === '' || soundFontSetting === 'build-in') {
66+
soundFont = '';
67+
} else if (soundFontSetting !== 'default') {
68+
soundFont = soundFontSetting;
69+
}
70+
}
71+
72+
const $body = $('body');
73+
midiPlayer.src = 'data:audio/midi;base64,' + midi;
74+
midiPlayer.shadowRoot.querySelector('button[part="play-button"]').click();
75+
midiPlayer.soundFont = soundFont;
76+
midiPlayer.addEventListener('stop', (event) => {
77+
if (event.detail.finished) {
78+
$body.removeClass('tx-dlf-score-midi-active')
79+
}
80+
})
81+
$body.toggleClass('tx-dlf-score-midi-active')
82+
if ($body.hasClass('tx-dlf-score-midi-active')) {
83+
setTimeout(() => {
84+
midiPlayer.shadowRoot.querySelector('button[part="play-button"]').click();
85+
}, 500);
86+
}
87+
});
88+
89+
$("#tx-dlf-score-midi-download").click(function () {
90+
$(this).attr({
91+
"href": 'data:audio/midi;base64,' + midi,
92+
"download": getMeiTitle(tk) + ".midi"
93+
})
94+
});
5895

5996
if (score === undefined) {
6097
result.reject();
@@ -303,7 +340,7 @@ dlfViewerScoreControl.prototype.loadScoreData = function (scoreData, tk) {
303340
})
304341
);
305342

306-
$("#tx_dlf_scoredownload").click(function () {
343+
$("#tx-dlf-score-download").click(function () {
307344
if (typeof pdfBlob !== 'undefined') {
308345
saveAs(pdfBlob, getMeiTitle(tk));
309346

@@ -502,8 +539,8 @@ dlfViewerScoreControl.prototype.disableScoreSelect = function () {
502539

503540
$('#tx-dlf-score-' + this.dlfViewer.counter).removeClass(className).hide();
504541
$('#tx-dfgviewer-map-' + this.dlfViewer.counter + ' .ol-overlaycontainer-stopevent').hide();
505-
$('#tx-dfgviewer-map-' + this.dlfViewer.counter + ' ~ .score-tool #tx-dlf-tools-midi').hide();
506-
$('.document-view:not(.multiview) .document-functions #tx-dlf-tools-midi').hide();
542+
$('#tx-dfgviewer-map-' + this.dlfViewer.counter + ' ~ .score-tool #tx-dlf-tools-score-midi').hide();
543+
$('.document-view:not(.multiview) .document-functions #tx-dlf-tools-score-midi').hide();
507544

508545
$('body').removeClass(className);
509546

@@ -538,7 +575,7 @@ dlfViewerScoreControl.prototype.enableScoreSelect = function () {
538575

539576
$('body').addClass(className);
540577

541-
$('.document-view:not(.multiview) .document-functions #tx-dlf-tools-midi').show();
578+
$('.document-view:not(.multiview) .document-functions #tx-dlf-tools-score-midi').show();
542579

543580
this.scrollToPagebeginning();
544581

0 commit comments

Comments
 (0)