Skip to content

Commit

Permalink
Added composition meta data for display in Pd window in offset indexer.
Browse files Browse the repository at this point in the history
  • Loading branch information
musicus committed Nov 19, 2016
1 parent c840059 commit 0effc1d
Show file tree
Hide file tree
Showing 24 changed files with 112 additions and 45 deletions.
68 changes: 62 additions & 6 deletions _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
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
4 changes: 1 addition & 3 deletions library/HintIndexer.py
Expand Up @@ -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):
Expand Down Expand Up @@ -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.
Expand Down
20 changes: 1 addition & 19 deletions 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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
2 changes: 1 addition & 1 deletion library/NoteRestIndexer.py
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion 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;
Expand All @@ -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;
Expand Down
54 changes: 42 additions & 12 deletions 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

Expand Down Expand Up @@ -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:
Expand All @@ -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(
Expand All @@ -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)

Expand All @@ -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) * "-")

4 changes: 1 addition & 3 deletions library/VintIndexer.py
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down
Binary file modified library/data/frames/vints/Jacob-Obrecht_Monad---Aeolian.pkl
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 0effc1d

Please sign in to comment.