def test_annotated_corpus(): da_corpus = DCorpus() da_corpus.append_from_db(client_id='695311d7e88d5f79b4945bf45d00cc77', selection_id='21') da_score = da_corpus.d_score_by_index(0) da_title = da_score.title() assert da_title == 'Prelude 2 (BWV 847)', "Bad fetch by index" da_score = da_corpus.d_score_by_title(da_title) assert da_title == da_score.title(), "Bad fetch by title" annotation = da_score.abcd_header() abcdf = annotation.abcdf() finger_re = re.compile('[12345]+') at_re = re.compile('@') assert finger_re.search(abcdf), "Bad abcdf" assert at_re.search(abcdf), "Bad abcdf" upper_abcdf = annotation.upper_abcdf() assert finger_re.search(upper_abcdf), "Bad upper abcdf" assert not at_re.search(upper_abcdf), "Bad upper abcdf" lower_abcdf = annotation.lower_abcdf() assert finger_re.search(lower_abcdf), "Bad upper abcdf" assert not at_re.search(lower_abcdf), "Bad upper abcdf" assert lower_abcdf != upper_abcdf, "Bad split of abcdf" abcdf_by_index = da_score.abcdf(index=0) abcdf_by_id = da_score.abcdf(identifier=1) assert abcdf_by_index == abcdf_by_id, "Bad DSCore::abcdf" upper_abcdf_by_index = da_score.upper_abcdf(index=0) upper_abcdf_by_id = da_score.upper_abcdf(identifier=1) assert upper_abcdf_by_index == upper_abcdf_by_id, "Bad DSCore::upper_abcdf" lower_abcdf_by_index = da_score.lower_abcdf(index=0) lower_abcdf_by_id = da_score.lower_abcdf(identifier=1) assert lower_abcdf_by_index == lower_abcdf_by_id, "Bad DSCore::lower_abcdf"
def test_abc2xml_2part_mono(): xml_str = DCorpus.abc2xml(abc_content=TestConstant.B_MINOR_ARPEGGIO) assert xml_str, "Failed abc2xml transform." abc_str = DCorpus.xml2abc(xml_content=xml_str) assert abc_str, "Failed xml2abc transform." print(abc_str) xml_strings = DCorpus.abc2xmlScores(BERINGER2_SCALE_CORPUS) assert len(xml_strings) == 38, "Bad parse of multi-tune file to xml" xml_strings = DCorpus.abc2xmlScores(BERINGER2_SCALE_CORPUS, skip=12, max=4) assert len(xml_strings) == 4, "Bad subset parse of multi-tune file to xml" d_corpus = DCorpus(corpus_str=TestConstant.B_MINOR_ARPEGGIO, as_xml=True) d_score = d_corpus.d_score_by_title("arpeggios_common_b_minor") part_count = d_score.part_count() assert part_count == 2, "Bad part count" lo, hi = d_corpus.pitch_range() assert lo < hi, "Bad dcorpus pitch range" d_part = d_score.combined_d_part() part_lo, part_hi = d_part.pitch_range() assert part_lo < part_hi, "Bad DPart pitch range" assert part_lo == lo, "Bad low pitch found" assert part_hi == hi, "Bad high pitch found" assert d_part is not None, "Bad DPart retrieval" assert d_part.is_monophonic() is False, "Polyphony not detected" d_upper = d_score.upper_d_part() assert d_upper, "Bad upper DPart" assert d_upper.is_monophonic() is True, "Monophonic upper part not detected" d_lower = d_score.lower_d_part() assert d_lower, "Bad lower DPart" # lower_stream = d_lower.stream() # lower_stream.show('text') assert d_lower.is_monophonic() is True, "Monophonic lower part not detected"
def test_abc_2part_mono(): d_corpus = DCorpus(corpus_path=BERINGER2_SCALE_CORPUS, as_xml=False) lo, hi = d_corpus.pitch_range() assert lo < hi, "Bad dcorpus pitch range" score_count = d_corpus.score_count() assert score_count == 38, "Bad score count" d_score = d_corpus.d_score_by_title("scales_g_minor_melodic") assert d_score is not None, "Bad score_by_title retrieval" lo, hi = d_score.pitch_range() assert lo < hi, "Bad DScore pitch range" part_count = d_score.part_count() assert part_count == 2, "Bad part count" d_part = d_score.combined_d_part() part_lo, part_hi = d_part.pitch_range() assert part_lo < part_hi, "Bad DPart pitch range" assert part_lo == lo, "Bad low pitch found" assert part_hi == hi, "Bad high pitch found" assert d_part is not None, "Bad DPart retrieval" assert d_part.is_monophonic() is False, "Polyphony not detected" d_upper = d_score.upper_d_part() assert d_upper, "Bad upper DPart" assert d_upper.is_monophonic() is True, "Monophonic upper part not detected" d_lower = d_score.lower_d_part() assert d_lower, "Bad lower DPart" # lower_stream = d_lower.stream() # lower_stream.show('text') assert d_lower.is_monophonic() is True, "Monophonic lower part not detected"