Пример #1
0
 def test_append_dir():
     d_corpus = DCorpus()
     d_corpus.append_dir(corpus_dir=TestConstant.BERINGER2_ANNOTATED_ARPEGGIO_DIR)
     # d_corpus.append_dir(corpus_dir=TestConstant.BERINGER2_ANNOTATED_SCALE_DIR)
     d_corpus.append_dir(corpus_dir=TestConstant.BERINGER2_ANNOTATED_BROKEN_CHORD_DIR)
     score_count = d_corpus.score_count()
     assert score_count > 48, "Bad score count"
     for i in range(score_count):
         d_score = d_corpus.d_score_by_index(i)
         assert d_score.title() is not None, "Missing title at {0}".format(i)
         assert d_score.is_fully_annotated(indices=[0]), "Missing annotation in {}".format(d_score.title())
Пример #2
0
    def get_corpus(self, corpus_name):
        if corpus_name == 'pig':
            the_corpus = DCorpus()
            the_corpus.append_dir(corpus_dir=PIG_DIR, split_header_extension='abcd')
            return the_corpus

        if corpus_name == 'scales':
            the_corpus = DCorpus()
            the_corpus.append_dir(corpus_dir=SCALES_DIR)
            return the_corpus

        if corpus_name == 'arpeggios':
            the_corpus = DCorpus()
            the_corpus.append_dir(corpus_dir=ARPEGGIOS_DIR)
            return the_corpus

        if corpus_name == 'broken':
            the_corpus = DCorpus()
            the_corpus.append_dir(corpus_dir=BROKEN_DIR)
            return the_corpus

        if corpus_name == 'beringer':
            the_corpus = DCorpus()
            for subdir in [SCALES_DIR, ARPEGGIOS_DIR, BROKEN_DIR]:
                the_corpus.append_dir(corpus_dir=subdir)
            return the_corpus

        if corpus_name == 'layer_one':
            the_corpus = DCorpus()
            piece_query = LAYER_ONE_QUERY
            the_corpus.assemble_and_append_from_db(db='diii', port=3307, user='******', passwd='Pha_Lang35',
                                                   piece_query=piece_query, fingering_query=QUERY[corpus_name])
            return the_corpus

        piece_query = FRAGMENT_ABC_QUERY
        if corpus_name in ('full_american', 'full_american_by_annotator'):
            piece_query = FULL_ABC_QUERY
        the_corpus = DCorpus()
        the_corpus.assemble_and_append_from_db(piece_query=piece_query,
                                               fingering_query=QUERY[corpus_name])
        return the_corpus
Пример #3
0
 def __init__(self, *args, **kwargs):
     super(SayeghTest, self).__init__(*args, **kwargs)
     if not os.path.isfile(SayeghTest.PICKLE_PATH):
         sayegh = Sayegh()
         d_corpus = DCorpus()
         d_corpus.append_dir(
             corpus_dir=TestConstant.BERINGER2_ANNOTATED_ARPEGGIO_DIR)
         d_corpus.append_dir(
             corpus_dir=TestConstant.BERINGER2_ANNOTATED_SCALE_DIR)
         d_corpus.append_dir(
             corpus_dir=TestConstant.BERINGER2_ANNOTATED_BROKEN_CHORD_DIR)
         sayegh.train(d_corpus, annotation_indices=[0])
         sayegh.retain(pickle_path=SayeghTest.PICKLE_PATH)
Пример #4
0
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.

import copy
import re
import sys
from pydactyl.dcorpus.DCorpus import DCorpus, DAnnotation
from pydactyl.dactyler.Parncutt import Parncutt
from pydactyl.dcorpus.PigIn import PigIn
# import scamp

# s = scamp.Session()
# print(s.get_available_midi_output_devices())
# exit(0)

## pig_eater = PigIn()
## pig_eater.transform()

staff = 'upper'
k = 5
corpus_dir = "/Users/dave/tb2/didactyl/dd/corpora/pig/PianoFingeringDataset_v1.00/abcd/"
d_corpus = DCorpus()
d_corpus.append_dir(corpus_dir=corpus_dir, split_header_extension='abcd')

model = Parncutt()
model.load_corpus(d_corpus=d_corpus)
advice = model.generate_advice(staff=staff, score_index=0, k=k)
print(advice)
Пример #5
0
def aggregate_pair_counts(aggregate, pair_counts):
    for pair in pair_counts:
        if pair not in aggregate:
            aggregate[pair] = 0
        aggregate[pair] += pair_counts[pair]


def total_notes(pair_counts):
    total = 0
    for pair in pair_counts:
        total += pair_counts[pair]
    return total


da_corpus = DCorpus()
da_corpus.append_dir(corpus_dir=INTERP_DIR)

interpolated = {"2": ["14", "15"], "3": ["16", "17"]}

annotated = [
    "1",  # Justin
    "7",  # Anne
]

one_interp_agg = {
    'full': {
        'upper': [],
        'lower': [],
        'both': []
    },
    'segregated': {