diff --git a/_Index.pd b/_Index.pd index 80e8397..9d9eaa4 100644 --- a/_Index.pd +++ b/_Index.pd @@ -1,4 +1,4 @@ -#N canvas 111 23 1140 710 10; +#N canvas 19 23 1222 711 10; #X declare -path library; #X obj 33 148 openfiles; #X obj 33 103 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 @@ -96,7 +96,7 @@ interpret)., f 65; #X text 843 241 3b) Find melodic intervals in a score.; #X text 31 685 4) We can find all melodic intervals in a score and index them., f 66; -#X text 611 796 <= Specify sample rate of overlapping windows.; +#X text 504 840 <= Specify sample rate of overlapping windows.; #X obj 137 853 IntSettings; #X floatatom 95 1019 5 0 0 0 - - -, f 5; #X obj 137 1019 DataframeStartEnd; @@ -105,7 +105,7 @@ index them., f 66; -1 -1; #X obj 33 1019 r scores; #X obj 33 1073 spigot; -#X obj 66 1046 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 +#X obj 66 1046 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1 1; #X obj 137 1163 IntSettings; #X obj 33 1258 s vint-dataframes; @@ -116,7 +116,7 @@ melodic N-Grams., f 69; index them., f 67; #X text 31 535 3d) We can look at the DataFrame at different offsets. ; -#X obj 34 621 OffsetIndexer; +#X obj 34 651 OffsetIndexer; #X obj 150 562 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X msg 180 585 1; @@ -127,9 +127,45 @@ index them., f 67; #X msg 180 562 0; #X text 212 562 <= Resets offsets.; #X obj 34 562 r nri-dataframes; -#X obj 34 590 spigot; -#X obj 101 586 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 +#X obj 34 615 spigot; +#X obj 67 591 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 1; +#X text 217 634 <= Custom offset.; +#X obj 794 827 OffsetIndexer; +#X obj 910 738 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 +-1 -1; +#X msg 940 761 1; +#X msg 970 761 2; +#X msg 1000 761 4; +#X msg 1030 761 8; +#X floatatom 940 811 5 0 0 0 - - -, f 5; +#X msg 940 738 0; +#X text 972 738 <= Resets offsets.; +#X obj 794 791 spigot; +#X obj 827 767 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1 +1; +#X text 977 810 <= Custom offset.; +#X text 791 711 4b) We can look at the DataFrame at different offsets. +; +#X obj 794 738 r hint-dataframes; +#X obj 354 1157 OffsetIndexer; +#X obj 470 1048 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 +-1 -1; +#X msg 500 1071 1; +#X msg 530 1071 2; +#X msg 560 1071 4; +#X msg 590 1071 8; +#X floatatom 500 1121 5 0 0 0 - - -, f 5; +#X msg 500 1048 0; +#X text 532 1048 <= Resets offsets.; +#X obj 354 1101 spigot; +#X obj 387 1077 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 +1 1; +#X text 537 1120 <= Custom offset.; +#X text 351 1021 5a) We can look at the DataFrame at different offsets. +; +#X obj 354 1048 r vint-dataframes; +#X text 6 1386 Fun with Pd; #X connect 0 0 45 0; #X connect 1 0 0 0; #X connect 2 0 0 1; @@ -211,3 +247,23 @@ index them., f 67; #X connect 101 0 102 0; #X connect 102 0 92 0; #X connect 103 0 102 1; +#X connect 106 0 105 1; +#X connect 107 0 111 0; +#X connect 108 0 111 0; +#X connect 109 0 111 0; +#X connect 110 0 111 0; +#X connect 111 0 105 2; +#X connect 112 0 111 0; +#X connect 114 0 105 0; +#X connect 115 0 114 1; +#X connect 118 0 114 0; +#X connect 120 0 119 1; +#X connect 121 0 125 0; +#X connect 122 0 125 0; +#X connect 123 0 125 0; +#X connect 124 0 125 0; +#X connect 125 0 119 2; +#X connect 126 0 125 0; +#X connect 128 0 119 0; +#X connect 129 0 128 1; +#X connect 132 0 128 0; diff --git a/library/HintIndexer.py b/library/HintIndexer.py index 2903620..e46de0f 100644 --- a/library/HintIndexer.py +++ b/library/HintIndexer.py @@ -56,7 +56,7 @@ def __init__(self, hint_settings=0, events=5, mto_frozen_dir=0, - df_paths=0, + df_paths=[], direction='beginning', slice_start=0, slice_end=5): @@ -116,8 +116,6 @@ def _anything_1(self,*symbolic_scores): for x in self.scores_imported] # Save NoteRestIndexed DataFrames: - self.df_paths = [] - for i in range(len(self.hints)): # Build the path names, and save into a list. diff --git a/library/NoteRestIndexer.pd b/library/NoteRestIndexer.pd index d0c62c7..e746dfb 100644 --- a/library/NoteRestIndexer.pd +++ b/library/NoteRestIndexer.pd @@ -1,4 +1,4 @@ -#N canvas 718 23 980 668 10; +#N canvas 550 23 980 668 10; #X msg 71 52 doc; #X msg 71 79 doc+; #X msg 71 106 reload; @@ -56,22 +56,11 @@ #X obj 501 433 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 1; #X obj 564 285 pyx. IndexerPak 2; -#X obj 118 611 OffsetIndexer; -#X obj 152 557 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 --1 -1; -#X msg 270 558 1; -#X msg 300 558 2; -#X msg 330 558 4; -#X msg 360 558 8; -#X floatatom 270 608 5 0 0 0 - - -, f 5; -#X msg 270 535 0; -#X text 302 535 <= Resets offsets.; #X connect 0 0 3 0; #X connect 1 0 3 0; #X connect 2 0 3 0; #X connect 3 0 28 0; #X connect 3 0 35 0; -#X connect 3 0 49 0; #X connect 3 1 31 0; #X connect 3 1 33 0; #X connect 3 2 43 0; @@ -105,10 +94,3 @@ #X connect 46 0 45 0; #X connect 47 0 46 1; #X connect 48 0 3 4; -#X connect 50 0 49 1; -#X connect 51 0 55 0; -#X connect 52 0 55 0; -#X connect 53 0 55 0; -#X connect 54 0 55 0; -#X connect 55 0 49 2; -#X connect 56 0 55 0; diff --git a/library/NoteRestIndexer.py b/library/NoteRestIndexer.py index 83c471e..a16d9ef 100644 --- a/library/NoteRestIndexer.py +++ b/library/NoteRestIndexer.py @@ -9,7 +9,7 @@ Author: Reiner Kramer Email: reiner@music.org -Updated: 11.18.2016 +Updated: 11.19.2016 @TODO: Rather than saving dataframes as pickled files in the data folder of the library directory, files should be cached via memoization diff --git a/library/OffsetIndexer.pd b/library/OffsetIndexer.pd index 7c636d4..6462e64 100644 --- a/library/OffsetIndexer.pd +++ b/library/OffsetIndexer.pd @@ -1,4 +1,4 @@ -#N canvas 266 40 527 284 10; +#N canvas 266 40 572 268 10; #X obj 182 29 inlet; #X obj 115 187 pyext OffsetIndexer Set; #X msg 61 92 doc; @@ -18,7 +18,10 @@ #X text 282 30 <= Recall previously loaded files.; #X msg 300 85 0; #X text 332 85 <= Resets offsets.; +#X obj 115 224 outlet; +#X text 164 224 <= Pass on new DataFrame; #X connect 0 0 13 0; +#X connect 1 0 18 0; #X connect 2 0 1 0; #X connect 3 0 1 0; #X connect 4 0 1 0; diff --git a/library/OffsetIndexer.py b/library/OffsetIndexer.py index 96e8eba..f0f6fe8 100644 --- a/library/OffsetIndexer.py +++ b/library/OffsetIndexer.py @@ -1,5 +1,22 @@ # -*- coding: utf-8 -*- +""" +OffsetIndexer.py +================ + +Indexes passed-in DataFrames, assigns an offset, and creates a new off- +set DataFrame. + +Author: Reiner Kramer +Email: reiner@music.org +Updated: 11.19.2016 + +@TODO: The offsets currently happen at number of occuring offsets + rather than musical offsets. This needs to be changed to + musical offsets. + +""" + import sys, os, music21, pandas, requests, vis, pyext from vis.models.indexed_piece import Importer @@ -28,8 +45,10 @@ def __init__(self, def _anything_1(self, *symbolic_scores): - - + """ + Parses a pickeled DataFrame, and applies an offset to that Data- + Frame as a new DataFrame. + """ if(len(symbolic_scores) >= 1): try: @@ -40,16 +59,11 @@ def _anything_1(self, *symbolic_scores): self.scores_imported.append( pandas.read_pickle(self.scores_paths[i])) - # Convert score paths from symbols to strings: - #self.scores_paths = [str(x) for x in symbolic_scores] - - # Create Music21 streams and index them with VIS: - #self.scores_imported = [Importer(x) for x in self.scores_paths] - - #print(self.scores_imported) - for x, y in zip(self.scores_paths,self.scores_imported): #self._generate_name(x) + + self._generate_name(x) + y.columns.set_levels(['Part'], level=0, inplace=True) y.columns.set_names(['Score','Events'], inplace=True) print(y.head(self.events).to_csv( @@ -67,11 +81,15 @@ def _anything_1(self, *symbolic_scores): print("...there were no scores...") def _anything_2(self, offset): - + """ + Takes a number to specify what type of offset to use. + Note: Check pandas documentation. + """ self.df_offset = offset for x, y in zip(self.scores_paths,self.scores_imported): - #self._generate_name(x) + + self._generate_name(x) y.columns.set_levels(['Part'], level=0, inplace=True) y.columns.set_names(['Score','Events'], inplace=True) @@ -84,3 +102,15 @@ def _anything_2(self, offset): sep='\t', na_rep='^')) + def _generate_name(self,path): + """ + Private method to generate a human readable name of a composition + from its path. + """ + file_name = os.path.split(path) + file_extr = os.path.splitext(file_name[1]) + comp_name = str(file_extr[0]).replace("-"," ").replace("_",": ") + + print("\n" + comp_name) + print(len(comp_name) * "-") + diff --git a/library/VintIndexer.py b/library/VintIndexer.py index e258fed..a53179c 100644 --- a/library/VintIndexer.py +++ b/library/VintIndexer.py @@ -51,7 +51,7 @@ def __init__(self, scores_mto=0, meta=0, vints=0, - df_paths=0, + df_paths=[], events=5, direction='beginning', slice_start=0, @@ -116,8 +116,6 @@ def _anything_1(self,*symbolic_scores): for x in self.scores_imported] # Save Vertical Indexed DataFrames: - self.df_paths = [] - for i in range(len(self.vints)): # Build the path names, and save into a list. diff --git a/library/data/frames/vints/Jacob-Obrecht_Monad---Aeolian.pkl b/library/data/frames/vints/Jacob-Obrecht_Monad---Aeolian.pkl index 1d171c6..a5d34a3 100644 Binary files a/library/data/frames/vints/Jacob-Obrecht_Monad---Aeolian.pkl and b/library/data/frames/vints/Jacob-Obrecht_Monad---Aeolian.pkl differ diff --git a/scores/monophonic/graphic/Book-1_Ave-Maria-benedicta-tu_p-146.pdf b/scores/monophonic/graphic/Book-1_Ave-Maria-benedicta-tu_p-146.pdf index fff6a7d..3a61d25 100644 Binary files a/scores/monophonic/graphic/Book-1_Ave-Maria-benedicta-tu_p-146.pdf and b/scores/monophonic/graphic/Book-1_Ave-Maria-benedicta-tu_p-146.pdf differ diff --git a/scores/monophonic/symbolic/Book-1_Ave-Maria-benedicta-tu_p-146.mei b/scores/monophonic/symbolic/Book-1_Ave-Maria-benedicta-tu_p-146.mei deleted file mode 100644 index b9e2a80..0000000 Binary files a/scores/monophonic/symbolic/Book-1_Ave-Maria-benedicta-tu_p-146.mei and /dev/null differ diff --git a/scores/monophonic/symbolic/Book-1_Benedictus-Dominus-Deus_p-148.mei b/scores/monophonic/symbolic/Book-1_Benedictus-Dominus-Deus_p-148.mei deleted file mode 100644 index f0b52ad..0000000 Binary files a/scores/monophonic/symbolic/Book-1_Benedictus-Dominus-Deus_p-148.mei and /dev/null differ diff --git a/scores/monophonic/symbolic/Book-1_Credo_pp-144-45.mei b/scores/monophonic/symbolic/Book-1_Credo_pp-144-45.mei deleted file mode 100644 index e15ced7..0000000 Binary files a/scores/monophonic/symbolic/Book-1_Credo_pp-144-45.mei and /dev/null differ diff --git a/scores/monophonic/symbolic/Book-1_Magnificat_p-148.mei b/scores/monophonic/symbolic/Book-1_Magnificat_p-148.mei deleted file mode 100644 index e26a9f5..0000000 Binary files a/scores/monophonic/symbolic/Book-1_Magnificat_p-148.mei and /dev/null differ diff --git a/scores/monophonic/symbolic/Book-1_Nos-qui-vivimus_p-147.mei b/scores/monophonic/symbolic/Book-1_Nos-qui-vivimus_p-147.mei deleted file mode 100644 index 6fdc934..0000000 Binary files a/scores/monophonic/symbolic/Book-1_Nos-qui-vivimus_p-147.mei and /dev/null differ diff --git a/scores/monophonic/symbolic/Book-1_Pater-noster_pp-143-44.mei b/scores/monophonic/symbolic/Book-1_Pater-noster_pp-143-44.mei deleted file mode 100644 index f762e1c..0000000 Binary files a/scores/monophonic/symbolic/Book-1_Pater-noster_pp-143-44.mei and /dev/null differ diff --git a/scores/polyphonic/graphic/Book-3_Jacob-Obrecht_Parce-Domine_p-327_p-328.pdf b/scores/polyphonic/graphic/Book-3_Jacob-Obrecht_Parce-Domine_p-327_p-328.pdf index b4aee7f..d26556c 100644 Binary files a/scores/polyphonic/graphic/Book-3_Jacob-Obrecht_Parce-Domine_p-327_p-328.pdf and b/scores/polyphonic/graphic/Book-3_Jacob-Obrecht_Parce-Domine_p-327_p-328.pdf differ diff --git a/scores/polyphonic/graphic/Book-3_Jacob-Obrecht_Parce-Domine_p-327_p-328_sliced.pdf b/scores/polyphonic/graphic/Book-3_Jacob-Obrecht_Parce-Domine_p-327_p-328_sliced.pdf new file mode 100644 index 0000000..5699d97 Binary files /dev/null and b/scores/polyphonic/graphic/Book-3_Jacob-Obrecht_Parce-Domine_p-327_p-328_sliced.pdf differ diff --git a/scores/polyphonic/symbolic/Book-3_Adam-von-Fulda_O-vera-lux_p-253_p-328.mei b/scores/polyphonic/symbolic/Book-3_Adam-von-Fulda_O-vera-lux_p-253_p-328.mei deleted file mode 100644 index bc41387..0000000 Binary files a/scores/polyphonic/symbolic/Book-3_Adam-von-Fulda_O-vera-lux_p-253_p-328.mei and /dev/null differ diff --git a/scores/polyphonic/symbolic/Book-3_Anonymous_Sic-unda_p-252_p-325.mei b/scores/polyphonic/symbolic/Book-3_Anonymous_Sic-unda_p-252_p-325.mei deleted file mode 100644 index 4d63529..0000000 Binary files a/scores/polyphonic/symbolic/Book-3_Anonymous_Sic-unda_p-252_p-325.mei and /dev/null differ diff --git a/scores/polyphonic/symbolic/Book-3_Damiao-de-Gois_Ne-laeteris_p-331_p-332.mei b/scores/polyphonic/symbolic/Book-3_Damiao-de-Gois_Ne-laeteris_p-331_p-332.mei deleted file mode 100644 index 4de37cc..0000000 Binary files a/scores/polyphonic/symbolic/Book-3_Damiao-de-Gois_Ne-laeteris_p-331_p-332.mei and /dev/null differ diff --git a/scores/polyphonic/symbolic/Book-3_Jacob-Obrecht_Monad_p-252_p-327.mei b/scores/polyphonic/symbolic/Book-3_Jacob-Obrecht_Monad_p-252_p-327.mei deleted file mode 100644 index 46541f6..0000000 Binary files a/scores/polyphonic/symbolic/Book-3_Jacob-Obrecht_Monad_p-252_p-327.mei and /dev/null differ diff --git a/scores/polyphonic/symbolic/Book-3_Jacob-Obrecht_Parce-Domine_p-327_p-328.mei b/scores/polyphonic/symbolic/Book-3_Jacob-Obrecht_Parce-Domine_p-327_p-328.mei deleted file mode 100644 index d4c822c..0000000 Binary files a/scores/polyphonic/symbolic/Book-3_Jacob-Obrecht_Parce-Domine_p-327_p-328.mei and /dev/null differ diff --git a/scores/polyphonic/symbolic/Book-3_Josquin_Missa-Mater-patris_Agnus-Dei-II_p-252_p-324.mei b/scores/polyphonic/symbolic/Book-3_Josquin_Missa-Mater-patris_Agnus-Dei-II_p-252_p-324.mei deleted file mode 100644 index 437e05d..0000000 Binary files a/scores/polyphonic/symbolic/Book-3_Josquin_Missa-Mater-patris_Agnus-Dei-II_p-252_p-324.mei and /dev/null differ diff --git a/scores/polyphonic/symbolic/Book-3_Josquin_Missa-sine-nomine_Sanctus_Pleni-sunt_p-252_p-325.mei b/scores/polyphonic/symbolic/Book-3_Josquin_Missa-sine-nomine_Sanctus_Pleni-sunt_p-252_p-325.mei deleted file mode 100644 index b8a4729..0000000 Binary files a/scores/polyphonic/symbolic/Book-3_Josquin_Missa-sine-nomine_Sanctus_Pleni-sunt_p-252_p-325.mei and /dev/null differ