Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 1.6.0 #398

Open
wants to merge 226 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
226 commits
Select commit Hold shift + click to select a range
ba0266d
parse fingering info from MusicXML
CarlosCancino-Chacon Apr 5, 2024
e0ed514
allow to_matched_score to use note arrays as inputs
CarlosCancino-Chacon Apr 9, 2024
10ad1a5
added fingering support in MEI export.
manoskary Apr 25, 2024
ea5bc08
first draft for importing romantext annotations.
manoskary May 1, 2024
417c88c
some edits on Rntxt parser for import.
manoskary May 2, 2024
4551bff
Merge branch 'dcml_annotation_parser' into rntxt
manoskary May 2, 2024
8a87047
Rntxt parser first draft complete.
manoskary May 2, 2024
5b5d358
minor changes on RN parser.
manoskary May 7, 2024
a71a692
some changes and first rntxt test draft.
manoskary May 11, 2024
700474e
Minor Changes for Roman Numeral Checking.
manoskary May 11, 2024
4e03cd1
Better loading for rntxt format.
manoskary May 11, 2024
cb14c20
Test case for rntxt import.
manoskary May 11, 2024
eae4542
fix 358
sildater Jul 19, 2024
50d3343
add check for empty note array
sildater Jul 19, 2024
cbc9f48
improve documentation performance note_array
sildater Jul 19, 2024
d366f60
Merge pull request #360 from CPJKU/fix358
sildater Jul 22, 2024
693b2c4
Format code with black (bot)
sildater Jul 22, 2024
30ffdc4
Merge pull request #361 from CPJKU/fix_356
sildater Jul 23, 2024
42423e0
Merge pull request #362 from CPJKU/fix_349
sildater Jul 23, 2024
1e80195
fix bug, update documentation
sildater Jul 25, 2024
498995e
Corrected Offsets for tied notes.
manoskary Aug 1, 2024
e06b975
Correction for staff line 2 as int.
manoskary Aug 3, 2024
75b7213
Removed unused code and added comments.
manoskary Aug 6, 2024
df54d0c
Merge pull request #366 from CPJKU/kern_tied_offset_bug
sildater Aug 7, 2024
9d480d9
Merge pull request #364 from CPJKU/fix_363
huispaty Aug 8, 2024
8dccc0a
Format code with black (bot)
huispaty Aug 8, 2024
f532be4
update tutorial with correct import
sildater Aug 13, 2024
3929f98
Merge remote-tracking branch 'origin/develop' into rntxt
manoskary Aug 19, 2024
26d30c5
Edits to support or remove editorials.
manoskary Aug 28, 2024
0a139f2
Removed unnecessary code.
manoskary Aug 28, 2024
bedc78d
Naive solution for estimate_symbolic_duration
manoskary Sep 5, 2024
ffeb587
Update for symbolic estimation function to cover most cases from 0-4 …
manoskary Sep 9, 2024
0e77947
Test for symbolic duration estimator.
manoskary Sep 9, 2024
d401dcb
estimate_voice_info now default to false
fosfrancesco Sep 16, 2024
ed0e8bb
int casting
sildater Sep 23, 2024
35d56a7
update docstring load_match
sildater Sep 23, 2024
699738e
remove unused match line base class imports
sildater Sep 23, 2024
ac9b64a
removed more unused imports
sildater Sep 23, 2024
98e9086
fix typing
sildater Sep 23, 2024
fb64f4f
refactor bar lines
sildater Sep 23, 2024
bb363d8
compute bar times wip
sildater Sep 23, 2024
125e1d2
barline in quarters wip
sildater Sep 23, 2024
b68d120
on_off_scale debug
sildater Sep 23, 2024
c24062f
add measures
sildater Sep 23, 2024
4eafa93
cleanup
sildater Sep 23, 2024
4ed8241
measure number starts at 1
sildater Sep 23, 2024
7c4a695
remove anacrusis measure conditional
sildater Sep 24, 2024
f8120dc
note_array_to_score measure number and name
sildater Sep 24, 2024
0eee6a8
measure export musicxml
sildater Sep 24, 2024
f69b983
reformat symbolic duration in match test file
sildater Sep 24, 2024
c0668c7
clean imports
sildater Sep 24, 2024
13e0ced
Merge pull request #373 from CPJKU/import_lakh
sildater Sep 24, 2024
5a1a6a8
Format code with black (bot)
sildater Sep 24, 2024
07eb9ed
use typing tuple
sildater Sep 24, 2024
5784c1c
find closest straight duration below
sildater Sep 24, 2024
c3e35ce
remove duplicate sym durs
sildater Sep 24, 2024
7ab8b3f
set test to eighth note quintuplets
sildater Sep 24, 2024
e51b3e3
duration test estimation
sildater Sep 24, 2024
3056e0a
file formatting
sildater Sep 24, 2024
1e76b64
measure feature wip
sildater Sep 25, 2024
e5d8938
single measure wip
sildater Sep 25, 2024
de5cc0b
rework default wip
sildater Sep 25, 2024
7db9f9b
fill measure info wip
sildater Sep 25, 2024
4306340
measure feature complete
sildater Sep 25, 2024
3fdfd39
fix time maps import
sildater Oct 1, 2024
69f8945
add warning
sildater Oct 1, 2024
6d24b6a
explainer in warning
sildater Oct 1, 2024
9754a90
correct formatting
sildater Oct 1, 2024
2d96acf
basic feature
sildater Oct 2, 2024
cec10ff
clef feature wip
sildater Oct 2, 2024
cc8c25c
clef dictionary wip
sildater Oct 2, 2024
01c0ecf
clef interpolator wip
sildater Oct 2, 2024
726ff82
compute note-wise clef features wip
sildater Oct 2, 2024
4ae870d
numerical clef signs
sildater Oct 2, 2024
788e743
add some defaults and safety
sildater Oct 2, 2024
ace407d
cleanup and documentation
sildater Oct 2, 2024
435edc1
add safety for part without clef
sildater Oct 2, 2024
9c23a9e
extrapolate
sildater Oct 2, 2024
c159bc9
Update globals.py
manoskary Oct 2, 2024
14d2d77
fix for notes with reonset during sustain pedal on
huispaty Oct 2, 2024
824a39b
Merge pull request #368 from CPJKU/fix-import348
CarlosCancino-Chacon Oct 2, 2024
3520066
Merge pull request #379 from CPJKU/fix_issue_378
CarlosCancino-Chacon Oct 2, 2024
ca3ce79
Merge pull request #372 from CPJKU/estimate_symbolic_duration_fix
manoskary Oct 2, 2024
00f6329
Format code with black (bot)
manoskary Oct 2, 2024
b61d8bf
updated performance features test
huispaty Oct 2, 2024
91ee519
Update importkern.py
manoskary Oct 2, 2024
ee8dfd3
Update importkern.py
manoskary Oct 2, 2024
1ca009c
Merge pull request #370 from CPJKU/kern_fixes
manoskary Oct 2, 2024
f424010
Format code with black (bot)
manoskary Oct 2, 2024
90ae765
Add clef_map
leleogere Oct 3, 2024
7d2623e
Fix a typing issue
leleogere Oct 3, 2024
b585213
Add a test
leleogere Oct 3, 2024
b2a8f5d
add test file
sildater Oct 4, 2024
446340c
remove initial clefs
sildater Oct 4, 2024
a59cf1d
tidy test files wip
sildater Oct 4, 2024
05e955b
test setup wip
sildater Oct 4, 2024
340b6f9
test case extraction wip
sildater Oct 4, 2024
e9d3845
another try
sildater Oct 4, 2024
d7c6008
Merge pull request #376 from CPJKU/measure_refactor_match
fosfrancesco Oct 7, 2024
1ddc259
Format code with black (bot)
fosfrancesco Oct 7, 2024
682f668
Relax assertion for tuplets parsing in musicxml
manoskary Oct 10, 2024
307f09d
Relax conditions for ChordSymbols by accepting empty kind.
manoskary Oct 10, 2024
4c9679d
clef feature ordered by na
sildater Oct 14, 2024
d3947ad
articulation feature ordered
sildater Oct 14, 2024
58e9b6a
ornament feature ordered
sildater Oct 14, 2024
acd8829
metrical feature ordered
sildater Oct 14, 2024
d81788c
require note ids in tests
sildater Oct 14, 2024
c77e5db
...
sildater Oct 14, 2024
b5abc4c
Added support for stem direction in musicxml import/export
manoskary Oct 14, 2024
c85acf9
measure feature ordered
sildater Oct 15, 2024
115d3a7
measure test and data
sildater Oct 15, 2024
5f265a2
add measure feature asserts
sildater Oct 15, 2024
7ff737e
disable cost-based merging of non-note attributes
sildater Oct 17, 2024
2a80fbc
documentation
sildater Oct 17, 2024
3f88474
sign test
sildater Oct 17, 2024
aaaa242
all attributes
sildater Oct 17, 2024
b2d4106
full test unmerged
sildater Oct 17, 2024
24dc6b5
full test including merging
sildater Oct 17, 2024
ea79e9d
support for stem direction in MEI.
manoskary Oct 18, 2024
97f7930
restricted values for the support of stem direction in MEI.
manoskary Oct 18, 2024
fad521c
Testing musicxml import with stems.
manoskary Oct 18, 2024
73a9620
adding stem information in target test files for unfolding.
manoskary Oct 18, 2024
55daed4
updated the position of stem in test file.
manoskary Oct 18, 2024
37cc068
Merge pull request #391 from CPJKU/fix_issue_390
sildater Oct 22, 2024
187e594
Format code with black (bot)
sildater Oct 22, 2024
9044296
Merge pull request #387 from CPJKU/relax_assertion_tuplet
manoskary Oct 22, 2024
c8d3bff
Format code with black (bot)
manoskary Oct 22, 2024
f0146a7
unique ID warning
sildater Oct 24, 2024
36b8423
unique rest ID warning
sildater Oct 24, 2024
1376edc
Merge pull request #382 from CPJKU/clef-feature
manoskary Oct 25, 2024
65ec4c5
Format code with black (bot)
manoskary Oct 25, 2024
faa6b52
Merge pull request #384 from leleogere/add_clef_map
sildater Oct 29, 2024
3bed493
refactor test
sildater Oct 29, 2024
865ca57
always check for starting clef
sildater Oct 29, 2024
dc424fa
default to none
sildater Oct 29, 2024
8cfc020
refactor clef feature
sildater Oct 29, 2024
733a926
typing
sildater Oct 29, 2024
8701d84
multipart and missing clef test
sildater Oct 29, 2024
17a89c5
error in CI
sildater Oct 29, 2024
fc480bf
remove typing for CI test
sildater Oct 29, 2024
bf5355d
Merge pull request #396 from CPJKU/clef_map_testing
sildater Oct 29, 2024
725861d
Format code with black (bot)
sildater Oct 29, 2024
50c52ce
fix typo
sildater Oct 29, 2024
af0f1cb
remove extra lines
sildater Oct 30, 2024
07225bc
Merge pull request #392 from CPJKU/stem_direction
manoskary Oct 30, 2024
37811e0
Format code with black (bot)
manoskary Oct 30, 2024
f2a1698
update MEI example to be valid. Previous one had a wrong staff defini…
fosfrancesco Oct 30, 2024
c460088
adding the "auto"mode on merge_parts, which mimic the voice handling …
fosfrancesco Oct 30, 2024
88fcd5a
mei import now takes voice and staff number from the score informatio…
fosfrancesco Oct 30, 2024
89ce10d
updated tests
fosfrancesco Oct 30, 2024
471e65f
give default values to staves and voice if they are mising in the MEI…
fosfrancesco Nov 3, 2024
94b0566
Merge pull request #397 from CPJKU/cross_staff_voices
manoskary Nov 5, 2024
975d300
Format code with black (bot)
manoskary Nov 5, 2024
3309554
Merge pull request #377 from CPJKU/measure_feature
sildater Nov 5, 2024
e5bf2e1
Format code with black (bot)
sildater Nov 5, 2024
f72cf19
Minor doc correction for nakamura corresp.
manoskary Nov 6, 2024
3f15113
Merge pull request #399 from CPJKU/performance_pedal_fix
CarlosCancino-Chacon Nov 11, 2024
46895d9
Format code with black (bot)
CarlosCancino-Chacon Nov 11, 2024
598af13
remove spurious musicxml file, add version
sildater Nov 14, 2024
af6aeab
Add a parameter that will ignore objects with the attribute `print-ob…
leleogere Nov 26, 2024
1c88e59
Merge remote-tracking branch 'origin/develop' into fingering
manoskary Dec 2, 2024
ac8d050
Merge remote-tracking branch 'origin/develop' into rntxt
manoskary Dec 2, 2024
578e41d
Update for load from url.
manoskary Dec 2, 2024
d209908
New version for RNTXT import.
manoskary Dec 3, 2024
19cf164
Removed rntxt refs.
manoskary Dec 3, 2024
86117e8
minor corrections.
manoskary Dec 3, 2024
27a0e16
Remove an old attempt, support MuseScore invisible notes, add tests
leleogere Dec 13, 2024
03e062b
Sort exported notes by step when same midi_pitch
leleogere Dec 19, 2024
f4930b5
Merge pull request #407 from leleogere/patch-1
fosfrancesco Dec 19, 2024
9b82412
Format code with black (bot)
fosfrancesco Dec 19, 2024
bb1adac
Merge pull request #403 from CPJKU/fingering
fosfrancesco Dec 19, 2024
9c31c5b
Format code with black (bot)
fosfrancesco Dec 19, 2024
59a2dfe
swap concatenation for hstack for numpy>1.21 compatibility
huispaty Dec 23, 2024
e1787fc
set to dlt temp file after url loading
manoskary Dec 24, 2024
59c148c
delete on close fix.
manoskary Dec 24, 2024
e41185f
yet another fix for delete on close.
manoskary Dec 24, 2024
108a4a6
fixed temp file delete in url load
manoskary Dec 27, 2024
8f07f95
force_new option for segment creation
sildater Jan 10, 2025
e822cbf
Merge branch 'develop' into force-new-seg
sildater Jan 10, 2025
2e41396
equal duration for all chord notes
huispaty Jan 10, 2025
31faf74
Merge pull request #404 from CPJKU/url_loading
manoskary Jan 10, 2025
356429d
Format code with black (bot)
manoskary Jan 10, 2025
1a55eb1
add tick units
sildater Jan 13, 2025
2a42b54
Updates on kern support:
manoskary Jan 13, 2025
8522a41
force same part for loading kern scores.
manoskary Jan 13, 2025
f42e579
updated voice handling for joined parts.
manoskary Jan 14, 2025
fc8c75f
Improved documentation.
manoskary Jan 14, 2025
187dc49
Simplified parser loop for readbility.
manoskary Jan 14, 2025
f329b48
New special durations.
manoskary Jan 15, 2025
f0594e9
added X clef as percussion
manoskary Jan 15, 2025
2ce5296
update on extended rhythm representation in kern.
manoskary Jan 15, 2025
aa7cb61
removed unused globals.
manoskary Jan 15, 2025
f2cd101
Minor edit to avoid bug with string to float.
manoskary Jan 15, 2025
0a96b59
Add optional attributes to tuplets rythmic modifications for MusicXML…
leleogere Jan 17, 2025
0680726
fix issue parsing incorrectly formatted fingering in MusicXML
CarlosCancino-Chacon Jan 18, 2025
672f6ee
Merge pull request #416 from CPJKU/bug/issue_415
CarlosCancino-Chacon Jan 19, 2025
b8b1322
Format code with black (bot)
CarlosCancino-Chacon Jan 19, 2025
5b7c011
Fix typo and add documentation to duration_multiplier
leleogere Jan 20, 2025
856f686
Use `get_value_from_tag` when parsing <tuplet> tag
leleogere Jan 20, 2025
b4d3eb0
fix condition and add docstring
sildater Jan 20, 2025
ab426ee
Documentation about why we want every single attribute filled or none…
leleogere Jan 20, 2025
c99422a
Replaced deprecated scipy derivative implementation with local equiva…
manoskary Jan 20, 2025
ff6eb30
Merge pull request #413 from CPJKU/kern_fixes
fosfrancesco Jan 20, 2025
20228a8
Format code with black (bot)
fosfrancesco Jan 20, 2025
aa582c9
Avoid using a diff on the string-formatted score when testing
leleogere Jan 20, 2025
18cfd3d
Merge pull request #412 from CPJKU/tick-units
sildater Jan 21, 2025
0122040
Merge pull request #401 from leleogere/support_print-object
sildater Jan 21, 2025
5b62cbd
Format code with black (bot)
sildater Jan 21, 2025
3669127
resolve conflicts
huispaty Jan 21, 2025
f52038e
fix indent level
huispaty Jan 21, 2025
027d700
Merge branch 'develop' into xml_chord
sildater Jan 21, 2025
6762dbc
Merge pull request #408 from CPJKU/numpy_version_fix
huispaty Jan 21, 2025
fe19cf9
Merge pull request #418 from CPJKU/xml_chord
huispaty Jan 21, 2025
f882d53
Merge branch 'develop' into add_tuplet_attributes
leleogere Jan 21, 2025
cd0e308
Fix the tuplet attribute parser in case of actual-type != normal-type
leleogere Jan 22, 2025
889f519
updated derivative doc to reflect source and simplifications.
manoskary Jan 23, 2025
72ed377
Fixed unrelated cadence parsing error.
manoskary Jan 23, 2025
cb21270
Merge pull request #414 from leleogere/add_tuplet_attributes
manoskary Jan 23, 2025
d86cd22
Format code with black (bot)
manoskary Jan 23, 2025
d1f95f6
Added link to scipy docs.
manoskary Jan 23, 2025
6e82c27
Code simplification.
manoskary Jan 23, 2025
e204c08
Merge pull request #417 from CPJKU/scipy_derivative_deprecation
fosfrancesco Jan 24, 2025
8b06aee
Merge pull request #410 from CPJKU/force-new-seg
huispaty Jan 27, 2025
9e7c651
Format code with black (bot)
huispaty Jan 27, 2025
49023bc
fix typo and add tests for PerformedNote
CarlosCancino-Chacon Jan 28, 2025
9606a32
Merge pull request #422 from CPJKU/bug/issue_421
manoskary Jan 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
186 changes: 93 additions & 93 deletions docs/source/Tutorial/notebook.ipynb

Large diffs are not rendered by default.

81 changes: 47 additions & 34 deletions partitura/assets/score_example.mei
Original file line number Diff line number Diff line change
@@ -1,52 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="https://music-encoding.org/schema/4.0.0/mei-all.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="https://music-encoding.org/schema/4.0.0/mei-all.rng" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<mei xmlns="http://www.music-encoding.org/ns/mei" meiversion="4.0.0">
<meiHead>
<fileDesc>
<titleStmt>
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="https://music-encoding.org/schema/5.0/mei-all.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="https://music-encoding.org/schema/5.0/mei-all.rng" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<mei xmlns="http://www.music-encoding.org/ns/mei" meiversion="5.0">
<meiHead xml:id="m21agkk">
<fileDesc xml:id="f1x9ud6p">
<titleStmt xml:id="t1pe4slb">
<title />
<respStmt />
</titleStmt>
<pubStmt></pubStmt>
<pubStmt xml:id="p1kxcrok">
<date isodate="2024-10-30" type="encoding-date">2024-10-30</date>
</pubStmt>
</fileDesc>
<encodingDesc xml:id="encodingdesc-2o9bqo">
<appInfo xml:id="appinfo-j7rtco">
<application xml:id="application-hc9py4" isodate="2021-12-09T11:27:15" version="3.8.0-dev-45c3f2c">
<name xml:id="name-symba1">Verovio</name>
<p xml:id="p-roup2t">Transcoded from MusicXML</p>
<encodingDesc xml:id="e1xr2zpp">
<appInfo xml:id="a1wyxc5n">
<application xml:id="a1t43ge2" isodate="2024-10-30T10:56:32" version="4.3.1-3b8cc17">
<name xml:id="n1cp60l4">Verovio</name>
<p xml:id="p13nndma">Transcoded from MusicXML</p>
</application>
</appInfo>
</encodingDesc>
</meiHead>
<music>
<body>
<mdiv xml:id="mhblkrl">
<score xml:id="ssc72wy">
<scoreDef xml:id="s3uaoz5">
<staffGrp xml:id="sjczhy0">
<staffDef xml:id="P1" n="1" lines="5" ppq="12">
<label xml:id="lezfcog">Piano</label>
<meterSig xml:id="mhw0sp2" count="4" unit="4" />
</staffDef>
<mdiv xml:id="muo97v6">
<score xml:id="suneqlv">
<scoreDef xml:id="sz00r05">
<staffGrp xml:id="s1h35kps">
<staffGrp xml:id="P1" bar.thru="true">
<grpSym xml:id="g1eji31e" symbol="brace" />
<label xml:id="l8lirjj">Piano</label>
<instrDef xml:id="iggd40h" midi.channel="0" midi.instrnum="0" midi.volume="78.00%" />
<staffDef xml:id="sbpks8p" n="1" lines="5" ppq="1">
<clef xml:id="c1p7nrnw" shape="G" line="2" />
<keySig xml:id="ki5anqv" sig="0" />
<meterSig xml:id="m1vpw2w2" count="4" unit="4" />
</staffDef>
<staffDef xml:id="s1g416nz" n="2" lines="5" ppq="1">
<clef xml:id="cezkswz" shape="G" line="2" />
<keySig xml:id="kk41xfz" sig="0" />
<meterSig xml:id="m7alo7s" count="4" unit="4" />
</staffDef>
</staffGrp>
</staffGrp>
</scoreDef>
<sb xml:id="st1gphw" />
<section xml:id="swgpvx8">
<pb xml:id="paw6v6b" />
<measure xml:id="mz87quy" n="1">
<staff xml:id="sxxu2aq" n="1">
<layer xml:id="llktcv2" n="1">
<note xml:id="n01" dur.ppq="48" dur="1" staff="2" oct="4" pname="a" />
</layer>
<layer xml:id="lgap59p" n="2">
<rest xml:id="r01" dur.ppq="24" dur="2" />
<chord xml:id="carc8ao" dur.ppq="24" dur="2">
<note xml:id="n02" oct="5" pname="c" />
<note xml:id="n03" oct="5" pname="e" />
<section xml:id="suu4o7p">
<measure xml:id="m1e358qx" n="1">
<staff xml:id="s1ufvigy" n="1">
<layer xml:id="l1r7cvga" n="1">
<rest xml:id="ro1o7cb" dur.ppq="2" dur="2" />
<chord xml:id="c1c1r6b7" dur.ppq="2" dur="2" stem.dir="down">
<note xml:id="n6dpu2p" oct="5" pname="c" />
<note xml:id="njfgcwp" oct="5" pname="e" />
</chord>
</layer>
</staff>
<staff xml:id="s710zw2" n="2">
<layer xml:id="leffrs2" n="5">
<note xml:id="n1txt37q" dur.ppq="4" dur="1" oct="4" pname="a" />
</layer>
</staff>
</measure>
</section>
</score>
Expand Down
44 changes: 36 additions & 8 deletions partitura/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"""
from typing import Union
import os

import urllib.request
from urllib.parse import urlparse
import tempfile
from .importmusicxml import load_musicxml
from .importmidi import load_score_midi, load_performance_midi
from .musescore import load_via_musescore
Expand All @@ -32,6 +34,14 @@ class NotSupportedFormatError(Exception):
pass


def is_url(input):
try:
result = urlparse(input)
return all([result.scheme, result.netloc])
except ValueError:
return False


@deprecated_alias(score_fn="filename")
@deprecated_parameter("ensure_list")
def load_score(filename: PathLike, force_note_ids="keep") -> Score:
Expand All @@ -57,11 +67,29 @@ def load_score(filename: PathLike, force_note_ids="keep") -> Score:
scr: :class:`partitura.score.Score`
A score instance.
"""
if is_url(filename):
url = filename
# Send a GET request to the URL
with urllib.request.urlopen(url) as response:
data = response.read()

# Extract the file extension from the URL
extension = os.path.splitext(url)[-1]

# Create a temporary file
temp_file = tempfile.NamedTemporaryFile(suffix=extension, delete=True)

# Write the content to the temporary file
with open(temp_file.name, "wb") as f:
f.write(data)

filename = temp_file.name
else:
extension = os.path.splitext(filename)[-1].lower()

extension = os.path.splitext(filename)[-1].lower()
if extension in (".mxl", ".xml", ".musicxml"):
# Load MusicXML
return load_musicxml(
score = load_musicxml(
filename=filename,
force_note_ids=force_note_ids,
)
Expand All @@ -71,15 +99,15 @@ def load_score(filename: PathLike, force_note_ids="keep") -> Score:
assign_note_ids = False
else:
assign_note_ids = True
return load_score_midi(
score = load_score_midi(
filename=filename,
assign_note_ids=assign_note_ids,
)
elif extension in [".mei"]:
# Load MEI
return load_mei(filename=filename)
score = load_mei(filename=filename)
elif extension in [".kern", ".krn"]:
return load_kern(
score = load_kern(
filename=filename,
force_note_ids=force_note_ids,
)
Expand Down Expand Up @@ -107,7 +135,7 @@ def load_score(filename: PathLike, force_note_ids="keep") -> Score:
".gp",
]:
# Load MuseScore
return load_via_musescore(
score = load_via_musescore(
filename=filename,
force_note_ids=force_note_ids,
)
Expand All @@ -117,11 +145,11 @@ def load_score(filename: PathLike, force_note_ids="keep") -> Score:
filename=filename,
create_score=True,
)
return score
else:
raise NotSupportedFormatError(
f"{extension} file extension is not supported. If this should be supported, consider editing partitura/io/__init__.py file"
)
return score


def load_score_as_part(filename: PathLike) -> Part:
Expand Down
9 changes: 7 additions & 2 deletions partitura/io/exportmatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from partitura.io.matchlines_v1 import (
make_info,
make_scoreprop,
make_section,
MatchSnote,
MatchNote,
MatchSnoteNote,
Expand Down Expand Up @@ -313,6 +312,7 @@ def matchfile_from_alignment(
staff = getattr(snote, "staff", None)
ornaments = getattr(snote, "ornaments", None)
fermata = getattr(snote, "fermata", None)
technical = getattr(snote, "technical", None)

if voice is not None:
score_attributes_list.append(f"v{voice}")
Expand All @@ -329,6 +329,11 @@ def matchfile_from_alignment(
if fermata is not None:
score_attributes_list.append("fermata")

if technical is not None:
for tech_el in technical:
if isinstance(tech_el, score.Fingering):
score_attributes_list.append(f"fingering{tech_el.fingering}")

if isinstance(snote, score.GraceNote):
score_attributes_list.append("grace")

Expand Down Expand Up @@ -417,7 +422,7 @@ def matchfile_from_alignment(
duplicates[tuple(v)] = idx
voice_overlap_note_ids = []
if len(duplicates) > 0:
duplicate_idx = np.concatenate(np.array(list(duplicates.values()))).flatten()
duplicate_idx = np.hstack(list(duplicates.values()))
voice_overlap_note_ids = list(sna[duplicate_idx]["id"])

for al_note in alignment:
Expand Down
43 changes: 35 additions & 8 deletions partitura/io/exportmei.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import math
from collections import defaultdict
from lxml import etree
import lxml
import partitura.score as spt
from operator import itemgetter
from itertools import groupby
Expand Down Expand Up @@ -225,6 +226,7 @@ def _handle_measure(self, measure, measure_el):
self._handle_harmony(measure_el, start=measure.start.t, end=measure.end.t)
self._handle_fermata(measure_el, start=measure.start.t, end=measure.end.t)
self._handle_barline(measure_el, start=measure.start.t, end=measure.end.t)
self._handle_fingering(measure_el, start=measure.start.t, end=measure.end.t)
return measure_el

def _handle_chord(self, chord, xml_voice_el):
Expand Down Expand Up @@ -277,6 +279,9 @@ def _handle_note(self, note, xml_voice_el):
elif note.tie_prev is not None:
note_el.set("tie", "t")

if note.stem_direction in ["up", "down"]:
note_el.set("stem.dir", note.stem_direction)

if note.alter is not None:
if (
note.step.lower() + ALTER_TO_MEI[note.alter]
Expand All @@ -292,7 +297,7 @@ def _handle_note(self, note, xml_voice_el):
note_el.set("grace", "acc")
return duration

def _handle_tuplets(self, measure_el, start, end):
def _handle_tuplets(self, measure_el: lxml.etree._Element, start: int, end: int):
for tuplet in self.part.iter_all(spt.Tuplet, start=start, end=end):
start_note = tuplet.start_note
end_note = tuplet.end_note
Expand Down Expand Up @@ -349,7 +354,7 @@ def _handle_tuplets(self, measure_el, start, end):
for el in xml_el_within_tuplet:
tuplet_el.append(el)

def _handle_beams(self, measure_el, start, end):
def _handle_beams(self, measure_el: lxml.etree._Element, start: int, end: int):
for beam in self.part.iter_all(spt.Beam, start=start, end=end):
# If the beam has only one note, skip it
if len(beam.notes) < 2:
Expand Down Expand Up @@ -397,7 +402,9 @@ def _handle_beams(self, measure_el, start, end):
if note_el.getparent() != beam_el:
beam_el.append(note_el)

def _handle_clef_changes(self, measure_el, start, end):
def _handle_clef_changes(
self, measure_el: lxml.etree._Element, start: int, end: int
):
for clef in self.part.iter_all(spt.Clef, start=start, end=end):
# Clef element is parent of the note element
if clef.start.t == 0:
Expand All @@ -418,7 +425,7 @@ def _handle_clef_changes(self, measure_el, start, end):
clef_el.set("shape", str(clef.sign))
clef_el.set("line", str(clef.line))

def _handle_ks_changes(self, measure_el, start, end):
def _handle_ks_changes(self, measure_el: lxml.etree._Element, start: int, end: int):
# For key signature changes, we add a new scoreDef element at the beginning of the measure
# and add the key signature element as attributes of the scoreDef element
for key_sig in self.part.iter_all(spt.KeySignature, start=start, end=end):
Expand Down Expand Up @@ -448,7 +455,7 @@ def _handle_ks_changes(self, measure_el, start, end):
parent = measure_el.getparent()
parent.insert(parent.index(measure_el), score_def_el)

def _handle_ts_changes(self, measure_el, start, end):
def _handle_ts_changes(self, measure_el: lxml.etree._Element, start: int, end: int):
# For key signature changes, we add a new scoreDef element at the beginning of the measure
# and add the key signature element as attributes of the scoreDef element
for time_sig in self.part.iter_all(spt.TimeSignature, start=start, end=end):
Expand All @@ -464,7 +471,7 @@ def _handle_ts_changes(self, measure_el, start, end):
score_def_el.set("count", str(time_sig.beats))
score_def_el.set("unit", str(time_sig.beat_type))

def _handle_harmony(self, measure_el, start, end):
def _handle_harmony(self, measure_el: lxml.etree._Element, start: int, end: int):
"""
For harmonies we add a new harm element at the beginning of the measure.
The position doesn't really matter since the tstamp attribute will place it correctly
Expand Down Expand Up @@ -505,7 +512,7 @@ def _handle_harmony(self, measure_el, start, end):
# text is a child element of harmony but not a xml element
harm_el.text = "|" + harmony.text

def _handle_fermata(self, measure_el, start, end):
def _handle_fermata(self, measure_el: lxml.etree._Element, start: int, end: int):
for fermata in self.part.iter_all(spt.Fermata, start=start, end=end):
if fermata.ref is not None:
note = fermata.ref
Expand All @@ -524,7 +531,7 @@ def _handle_fermata(self, measure_el, start, end):
# Set the fermata to be above the staff (the highest staff)
fermata_el.set("staff", "1")

def _handle_barline(self, measure_el, start, end):
def _handle_barline(self, measure_el: lxml.etree._Element, start: int, end: int):
for end_barline in self.part.iter_all(
spt.Ending, start=end, end=end + 1, mode="ending"
):
Expand All @@ -543,6 +550,26 @@ def _handle_barline(self, measure_el, start, end):
):
measure_el.set("left", "rptstart")

def _handle_fingering(self, measure_el: lxml.etree._Element, start: int, end: int):
"""
For fingering we add a new fing element at the end of the measure.
The position doesn't really matter since the startid attribute will place it correctly
"""
for note in self.part.iter_all(spt.Note, start=start, end=end):
if note.technical is not None:
for technical_notation in note.technical:
if (
isinstance(technical_notation, score.Fingering)
and note.id is not None
):
fing_el = etree.SubElement(measure_el, "fing")
fing_el.set(XMLNS_ID, "fing-" + self.elc_id())
fing_el.set("startid", note.id)
# Naive way to place the fingering notation
fing_el.set("place", ("above" if note.staff == 1 else "below"))
# text is a child element of fingering but not a xml element
fing_el.text = technical_notation.fingering


@deprecated_alias(parts="score_data")
def save_mei(
Expand Down
Loading
Loading