You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
compact_sets_sandbox/compact_sets_extended_simpl...

4162 lines
161 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 236,
"id": "806f6f69-1e0b-4d34-aac9-695c8531cdb1",
"metadata": {},
"outputs": [],
"source": [
"from itertools import chain, combinations, permutations, product, pairwise\n",
"from math import prod, log\n",
"from copy import deepcopy\n",
"import networkx as nx\n",
"from fractions import Fraction\n",
"import json\n",
"from operator import add\n",
"\n",
"def hs_array_to_fr(hs_array):\n",
" return prod([pow(dims[d], hs_array[d]) for d in range(len(dims))])\n",
"\n",
"def hs_array_to_cents(hs_array):\n",
" return (1200 * log(hs_array_to_fr(hs_array), 2))\n",
"\n",
"def expand_pitch(hs_array):\n",
" expanded_pitch = list(hs_array)\n",
" frequency_ratio = hs_array_to_fr(hs_array)\n",
" if frequency_ratio < 1:\n",
" while frequency_ratio < 1:\n",
" frequency_ratio *= 2\n",
" expanded_pitch[0] += 1\n",
" elif frequency_ratio >= 2:\n",
" while frequency_ratio >= 2:\n",
" frequency_ratio *= 1/2\n",
" expanded_pitch[0] += -1\n",
" return tuple(expanded_pitch)\n",
"\n",
"def expand_chord(chord):\n",
" return tuple(expand_pitch(p) for p in chord)\n",
"\n",
"def collapse_pitch(hs_array):\n",
" collapsed_pitch = list(hs_array)\n",
" collapsed_pitch[0] = 0\n",
" return tuple(collapsed_pitch)\n",
"\n",
"def collapse_chord(chord):\n",
" return tuple(collapse_pitch(p) for p in chord)\n",
"\n",
"def transpose_pitch(pitch, trans):\n",
" return tuple(map(add, pitch, trans))\n",
"\n",
"def transpose_chord(chord, trans):\n",
" return tuple(transpose_pitch(p, trans) for p in chord)\n",
"\n",
"def cent_difference(hs_array1, hs_array2):\n",
" return hs_array_to_cents(hs_array2) - hs_array_to_cents(hs_array1)\n",
"\n",
"def pitch_difference(hs_array1, hs_array2):\n",
" return transpose_pitch(hs_array1, [p * -1 for p in hs_array2])\n",
"\n",
"# this is modified for different chord sizes like original version\n",
"def grow_chords(chord, root, min_chord_size, max_chord_size):\n",
" #this could use the tranpose_pitch function\n",
" branches = [branch for alt in [-1, 1] for d in range(1, len(root)) if (branch:=(*(r:=root)[:d], r[d] + alt, *r[(d + 1):])) not in chord]\n",
" subsets = chain.from_iterable(combinations(branches, r) for r in range(1, max_chord_size - len(chord) + 1))\n",
" for subset in subsets:\n",
" extended_chord = chord + subset\n",
" if(len(extended_chord) < max_chord_size):\n",
" for branch in subset:\n",
" yield from grow_chords(extended_chord, branch, min_chord_size, max_chord_size)\n",
" if(len(extended_chord) >= min_chord_size):\n",
" yield tuple(sorted(extended_chord, key=hs_array_to_fr))\n",
"\n",
"def chords(chord, root, min_chord_size, max_chord_size):\n",
" # this will filter out the 4x dups of paths that are loops, there might be a faster way to test this\n",
" return set(grow_chords(chord, root, min_chord_size, max_chord_size))\n",
"\n",
"# this is very slow, I have an idea in mind that my be faster by simply growing the chords to max_chord_size + max_sim_diff\n",
"# technically at that point you have generated both chords and can get the second chord from the first\n",
"def edges(chords, min_symdiff, max_symdiff, max_chord_size): \n",
"\n",
" def reverse_movements(movements):\n",
" return {value['destination']:{'destination':key, 'cent_difference':value['cent_difference'] * -1} for key, value in movements.items()}\n",
"\n",
" def is_directly_tunable(intersection, diff):\n",
" # this only works for now when intersection if one element - need to fix that\n",
" return max([sum(abs(p) for p in collapse_pitch(pitch_difference(d, list(intersection)[0]))) for d in diff]) == 1\n",
"\n",
" for combination in combinations(chords, 2):\n",
" [expanded_base, expanded_comp] = [expand_chord(chord) for chord in combination]\n",
" edges = []\n",
" transpositions = set(pitch_difference(pair[0], pair[1]) for pair in set(product(expanded_base, expanded_comp)))\n",
" for trans in transpositions:\n",
" expanded_comp_transposed = transpose_chord(expanded_comp, trans)\n",
" intersection = set(expanded_base) & set(expanded_comp_transposed)\n",
" symdiff_len = sum([len(chord) - len(intersection) for chord in [expanded_base, expanded_comp_transposed]])\n",
" if (min_symdiff <= symdiff_len <= max_symdiff):\n",
" rev_trans = tuple(t * -1 for t in trans)\n",
" [diff1, diff2] = [list(set(chord) - intersection) for chord in [expanded_base, expanded_comp_transposed]]\n",
" base_map = {val: {'destination':transpose_pitch(val, rev_trans), 'cent_difference': 0} for val in intersection}\n",
" base_map_rev = reverse_movements(base_map)\n",
" maps = []\n",
" diff1 += [None] * (max_chord_size - len(diff1) - len(intersection))\n",
" perms = [list(perm) + [None] * (max_chord_size - len(perm) - len(intersection)) for perm in set(permutations(diff2))]\n",
" for p in perms:\n",
" appended_map = {\n",
" diff1[index]:\n",
" {\n",
" 'destination': transpose_pitch(val, rev_trans) if val != None else None, \n",
" 'cent_difference': cent_difference(diff1[index], val) if None not in [diff1[index], val] else None\n",
" } for index, val in enumerate(p)}\n",
" yield (tuple(expanded_base), tuple(expanded_comp), {\n",
" 'transposition': trans,\n",
" 'symmetric_difference': symdiff_len, \n",
" 'is_directly_tunable': is_directly_tunable(intersection, diff2),\n",
" 'movements': base_map | appended_map\n",
" },)\n",
" yield (tuple(expanded_comp), tuple(expanded_base), {\n",
" 'transposition': rev_trans,\n",
" 'symmetric_difference': symdiff_len, \n",
" 'is_directly_tunable': is_directly_tunable(intersection, diff1),\n",
" 'movements': base_map_rev | reverse_movements(appended_map)\n",
" },)\n",
"\n",
"def graph_from_edges(edges):\n",
" g = nx.MultiDiGraph()\n",
" g.add_edges_from(edges)\n",
" return g\n",
"\n",
"def generate_graph(chord_set, min_symdiff, max_symdiff, max_chord_size):\n",
" #chord_set = chords(pitch_set, min_chord_size, max_chord_size)\n",
" edge_set = edges(chord_set, min_symdiff, max_symdiff, max_chord_size)\n",
" res_graph = graph_from_edges(edge_set)\n",
" return res_graph\n",
"\n",
"def display_graph(graph):\n",
" show_graph = nx.Graph(graph)\n",
" pos = nx.draw_spring(show_graph, node_size=5, width=0.1)\n",
" plt.figure(1, figsize=(12,12)) \n",
" nx.draw(show_graph, pos, node_size=5, width=0.1)\n",
" plt.show()\n",
" #plt.savefig('compact_sets.png', dpi=150)\n",
"\n",
"def path_to_chords(path, start_root):\n",
" current_root = start_root\n",
" start_chord = tuple(sorted(path[0][0], key=hs_array_to_fr))\n",
" chords = ((start_chord, start_chord,),)\n",
" for edge in path:\n",
" trans = edge[2]['transposition']\n",
" movements = edge[2]['movements']\n",
" current_root = transpose_pitch(current_root, trans)\n",
" current_ref_chord = chords[-1][0]\n",
" next_ref_chord = tuple(movements[pitch]['destination'] for pitch in current_ref_chord)\n",
" next_transposed_chord = tuple(transpose_pitch(pitch, current_root) for pitch in next_ref_chord)\n",
" chords += ((next_ref_chord, next_transposed_chord,),)\n",
" return tuple(chord[1] for chord in chords)\n",
"\n",
"def write_chord_sequence(path):\n",
" file = open(\"seq.txt\", \"w+\")\n",
" content = json.dumps(path)\n",
" content = content.replace(\"[[[\", \"[\\n\\t[[\")\n",
" content = content.replace(\", [[\", \",\\n\\t[[\")\n",
" content = content.replace(\"]]]\", \"]]\\n]\")\n",
" file.write(content)\n",
" file.close()"
]
},
{
"cell_type": "code",
"execution_count": 683,
"id": "aea5215c-8551-4685-b761-11c2dc74cf22",
"metadata": {},
"outputs": [],
"source": [
"from random import choice, choices\n",
"\n",
"# This is for the static version\n",
"def stochastic_hamiltonian(graph):\n",
" \n",
" def movement_size_weights(edges):\n",
" \n",
" def max_cent_diff(edge):\n",
" res = max([abs(v) for val in edge[2]['movements'].values() if (v:=val['cent_difference']) is not None])\n",
" return res\n",
" \n",
" def min_cent_diff(edge):\n",
" res = [abs(v) for val in edge[2]['movements'].values() if (v:=val['cent_difference']) is not None]\n",
" res.remove(0)\n",
" return min(res)\n",
" \n",
" for e in edges:\n",
" yield 1000 if ((max_cent_diff(e) < 200) and (min_cent_diff(e)) > 50) else 1\n",
"\n",
" def hamiltonian_weights(edges):\n",
" for e in edges:\n",
" yield 10 if e[1] not in [path_edge[0] for path_edge in path] else 1 / graph.nodes[e[1]]['count']\n",
" \n",
" def contrary_motion_weights(edges):\n",
"\n",
" def is_contrary(edge):\n",
" cent_diffs = [v for val in edge[2]['movements'].values() if (v:=val['cent_difference']) is not None]\n",
" cent_diffs.sort()\n",
" return (cent_diffs[0] < 0) and (cent_diffs[1] == 0) and (cent_diffs[2] > 0)\n",
"\n",
" for e in edges:\n",
" yield 10 if is_contrary(e) else 1\n",
" \n",
" def is_directly_tunable_weights(edges):\n",
" for e in edges:\n",
" yield 10 if e[2]['is_directly_tunable'] else 0\n",
"\n",
" def voice_crossing_weights(edges):\n",
" \n",
" def has_voice_crossing(edge):\n",
" source = list(edge[0])\n",
" ordered_source = sorted(source, key=hs_array_to_fr) \n",
" source_order = [ordered_source.index(p) for p in source]\n",
" destination = [transpose_pitch(edge[2]['movements'][p]['destination'], edge[2]['transposition']) for p in source]\n",
" ordered_destination = sorted(destination, key=hs_array_to_fr)\n",
" destination_order = [ordered_destination.index(p) for p in destination]\n",
" return source_order != destination_order\n",
"\n",
" for e in edges:\n",
" yield 10 if not has_voice_crossing(e) else 0\n",
"\n",
" def is_bass_rooted(chord):\n",
" return max([sum(abs(p) for p in collapse_pitch(pitch_difference(chord[0], p))) for p in chord[1:]]) == 1\n",
" \n",
" check_graph = graph.copy()\n",
" next_node = choice([node for node in graph.nodes() if is_bass_rooted(node)])\n",
" check_graph.remove_node(next_node)\n",
" for node in graph.nodes(data=True):\n",
" node[1]['count'] = 1\n",
" path = []\n",
" while (nx.number_of_nodes(check_graph) > 0) and (len(path) < 5000):\n",
" out_edges = list(graph.out_edges(next_node, data=True))\n",
" #print([l for l in zip(movement_size_weights(out_edges), hamiltonian_weights(out_edges))])\n",
" factors = [\n",
" movement_size_weights(out_edges), \n",
" hamiltonian_weights(out_edges), \n",
" contrary_motion_weights(out_edges), \n",
" is_directly_tunable_weights(out_edges),\n",
" voice_crossing_weights(out_edges)\n",
" ]\n",
" weights = [prod(a) for a in zip(*factors)]\n",
" edge = choices(out_edges, weights=weights)[0]\n",
" #edge = random.choice(out_edges)\n",
" next_node = edge[1]\n",
" node[1]['count'] += 1\n",
" path.append(edge)\n",
" if next_node in check_graph.nodes:\n",
" check_graph.remove_node(next_node)\n",
" return path"
]
},
{
"cell_type": "code",
"execution_count": 684,
"id": "4e3ef738-7f64-47c3-9129-0450fd031375",
"metadata": {},
"outputs": [],
"source": [
"dims = (2, 3, 5, 7, 11)\n",
"root = (0, 0, 0, 0, 0)\n",
"chord = (root,)\n",
"chord_set = chords(chord, root, 3, 3)\n",
"graph = generate_graph(chord_set, 4, 4, 3)"
]
},
{
"cell_type": "code",
"execution_count": 685,
"id": "6e0de0e5-7973-4a15-ae90-5bbb4a1ef49d",
"metadata": {},
"outputs": [],
"source": [
"path = stochastic_hamiltonian(graph)\n",
"#for edge in path:\n",
"# print(edge)\n",
"write_chord_sequence(path_to_chords(path, root))"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "7f2d356f-6377-46cf-bbb1-32111be90f4f",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The line_profiler extension is already loaded. To reload it, use:\n",
" %reload_ext line_profiler\n"
]
}
],
"source": [
"%load_ext line_profiler"
]
},
{
"cell_type": "code",
"execution_count": 134,
"id": "7f141bf5-fdcb-4c01-a10b-3e86d3d1a7b4",
"metadata": {},
"outputs": [],
"source": [
"chord_set = chords(chord, root, 3, 3)"
]
},
{
"cell_type": "code",
"execution_count": 136,
"id": "88850b8c-a743-44d0-b863-7cd9066690d9",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Timer unit: 1e-09 s\n",
"\n",
"Total time: 0.112228 s\n",
"File: /tmp/ipykernel_515812/2679284550.py\n",
"Function: edge_data at line 74\n",
"\n",
"Line # Hits Time Per Hit % Time Line Contents\n",
"==============================================================\n",
" 74 def edge_data(chords, min_symdiff, max_symdiff, max_chord_size):\n",
" 75 990 29603044.0 29902.1 26.4 [expanded_base, expanded_comp] = [expand_chord(chord) for chord in chords]\n",
" 76 990 229527.0 231.8 0.2 edges = []\n",
" 77 990 23648371.0 23887.2 21.1 transpositions = set(pitch_difference(pair[0], pair[1]) for pair in set(product(expanded_base, expanded_comp)))\n",
" 78 9193 2315267.0 251.9 2.1 for trans in transpositions:\n",
" 79 8203 33386775.0 4070.1 29.7 expanded_comp_transposed = transpose_chord(expanded_comp, trans)\n",
" 80 8203 8393773.0 1023.3 7.5 intersection = set(expanded_base) & set(expanded_comp_transposed)\n",
" 81 8203 11812057.0 1440.0 10.5 symdiff_len = sum([len(chord) - len(intersection) for chord in [expanded_base, expanded_comp_transposed]])\n",
" 82 8203 2530596.0 308.5 2.3 if (min_symdiff <= symdiff_len <= max_symdiff):\n",
" 83 rev_trans = tuple(t * -1 for t in trans)\n",
" 84 [diff1, diff2] = [list(set(chord) - intersection) for chord in [expanded_base, expanded_comp_transposed]]\n",
" 85 base_map = {val: {'destination':transpose_pitch(val, rev_trans), 'cent_difference': 0} for val in intersection}\n",
" 86 base_map_rev = reverse_movements(base_map)\n",
" 87 tunability = is_directly_tunable(intersection, diff2)\n",
" 88 maps = []\n",
" 89 diff1 += [None] * (max_chord_size - len(diff1) - len(intersection))\n",
" 90 perms = [list(perm) + [None] * (max_chord_size - len(perm) - len(intersection)) for perm in set(permutations(diff2))]\n",
" 91 for p in perms:\n",
" 92 appended_map = {\n",
" 93 diff1[index]:\n",
" 94 {\n",
" 95 'destination': transpose_pitch(val, rev_trans) if val != None else None, \n",
" 96 'cent_difference': cent_difference(diff1[index], val) if None not in [diff1[index], val] else None\n",
" 97 } for index, val in enumerate(p)}\n",
" 98 edges.append((tuple(expanded_base), tuple(expanded_comp), {\n",
" 99 'transposition': trans,\n",
" 100 'symmetric_difference': symdiff_len, \n",
" 101 'is_directly_tunable': tunability,\n",
" 102 'movements': base_map | appended_map\n",
" 103 }))\n",
" 104 edges.append((tuple(expanded_comp), tuple(expanded_base), {\n",
" 105 'transposition': rev_trans,\n",
" 106 'symmetric_difference': symdiff_len, \n",
" 107 'is_directly_tunable': tunability,\n",
" 108 'movements': base_map_rev | reverse_movements(appended_map)\n",
" 109 }))\n",
" 110 990 308812.0 311.9 0.3 return edges if edges != [] else None"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"lprun -f edge_data edges(chord_set, 3, 3, 4)"
]
},
{
"cell_type": "code",
"execution_count": 688,
"id": "6e4ecb10-344b-4721-b2f4-68de91d712db",
"metadata": {},
"outputs": [],
"source": [
"from random import choice, choices\n",
"\n",
"# This is for the rising version / yitgadal\n",
"def stochastic_hamiltonian(graph):\n",
" \n",
" def movement_size_weights(edges):\n",
" \n",
" def max_cent_diff(edge):\n",
" res = max([v for val in edge[2]['movements'].values() if (v:=val['cent_difference']) is not None])\n",
" return res\n",
" \n",
" def min_cent_diff(edge):\n",
" res = [v for val in edge[2]['movements'].values() if (v:=val['cent_difference']) is not None]\n",
" res.remove(0)\n",
" return min(res)\n",
" \n",
" for e in edges:\n",
" yield 1000 if ((max_cent_diff(e) < 175) and (min_cent_diff(e)) >= 0) else 1\n",
"\n",
" def hamiltonian_weights(edges):\n",
" for e in edges:\n",
" yield 10 if e[1] not in [path_edge[0] for path_edge in path] else 1 / graph.nodes[e[1]]['count']\n",
" \n",
" def contrary_motion_weights(edges):\n",
"\n",
" def is_contrary(edge):\n",
" cent_diffs = [v for val in edge[2]['movements'].values() if (v:=val['cent_difference']) is not None]\n",
" cent_diffs.sort()\n",
" return (cent_diffs[0] < 0) and (cent_diffs[1] == 0) and (cent_diffs[2] > 0)\n",
"\n",
" for e in edges:\n",
" yield 2 if is_contrary(e) else 1\n",
" \n",
" def is_directly_tunable_weights(edges):\n",
" for e in edges:\n",
" yield 10 if e[2]['is_directly_tunable'] else 0\n",
"\n",
" def transposition_weight(edges):\n",
" for e in edges:\n",
" yield 1000 if 0 <= hs_array_to_cents(e[2]['transposition']) < 100 else 0\n",
"\n",
" def is_sustained_voice(edges, voice):\n",
" \n",
" def is_sustained(edge):\n",
" source = list(edge[0])\n",
" ordered_source = sorted(source, key=hs_array_to_fr) \n",
" destination = [transpose_pitch(edge[2]['movements'][p]['destination'], edge[2]['transposition']) for p in source]\n",
" ordered_destination = sorted(destination, key=hs_array_to_fr)\n",
" return ordered_source[voice] == ordered_destination[voice]\n",
"\n",
" for e in edges:\n",
" yield 10 if is_sustained(e) else 0\n",
"\n",
" def voice_crossing_weights(edges):\n",
" \n",
" def has_voice_crossing(edge):\n",
" source = list(edge[0])\n",
" ordered_source = sorted(source, key=hs_array_to_fr) \n",
" source_order = [ordered_source.index(p) for p in source]\n",
" destination = [transpose_pitch(edge[2]['movements'][p]['destination'], edge[2]['transposition']) for p in source]\n",
" ordered_destination = sorted(destination, key=hs_array_to_fr)\n",
" destination_order = [ordered_destination.index(p) for p in destination]\n",
" return source_order != destination_order\n",
"\n",
" for e in edges:\n",
" yield 10 if not has_voice_crossing(e) else 0\n",
"\n",
" def is_bass_rooted(chord):\n",
" return max([sum(abs(p) for p in collapse_pitch(pitch_difference(chord[0], p))) for p in chord[1:]]) == 1\n",
" \n",
" check_graph = graph.copy()\n",
" #next_node = choice([node for node in graph.nodes() if is_bass_rooted(node)])\n",
" next_node = choice(list(graph.nodes()))\n",
" print(next_node)\n",
" check_graph.remove_node(next_node)\n",
" for node in graph.nodes(data=True):\n",
" node[1]['count'] = 1\n",
" path = []\n",
" while (nx.number_of_nodes(check_graph) > 0) and (len(path) < 500):\n",
" out_edges = list(graph.out_edges(next_node, data=True))\n",
" #print([l for l in zip(movement_size_weights(out_edges), hamiltonian_weights(out_edges))])\n",
" factors = [\n",
" movement_size_weights(out_edges), \n",
" hamiltonian_weights(out_edges), \n",
" #contrary_motion_weights(out_edges), \n",
" #is_directly_tunable_weights(out_edges),\n",
" voice_crossing_weights(out_edges),\n",
" #transposition_weight(out_edges)\n",
" #is_sustained_voice(out_edges, 0)\n",
" ]\n",
" weights = [prod(a) for a in zip(*factors)]\n",
" #print(weights)\n",
" edge = choices(out_edges, weights=weights)[0]\n",
" #print(edge)\n",
" #edge = random.choice(out_edges)\n",
" next_node = edge[1]\n",
" node[1]['count'] += 1\n",
" path.append(edge)\n",
" if next_node in check_graph.nodes:\n",
" check_graph.remove_node(next_node)\n",
" print(len(check_graph.nodes()))\n",
" return path"
]
},
{
"cell_type": "code",
"execution_count": 34,
"id": "a76dc0f3-02e2-4739-9014-b53d3a590e3d",
"metadata": {},
"outputs": [],
"source": [
"dims = (2, 3, 5, 7, 11)\n",
"root = (0, 0, 0, 0, 0)\n",
"chord = (root,)\n",
"chord_set = chords(chord, root, 3, 3)\n",
"graph = generate_graph(chord_set, 2, 2, 3)"
]
},
{
"cell_type": "code",
"execution_count": 690,
"id": "7b76d848-fe53-4b60-b414-46cfe570f78b",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"((3, 0, 0, -1, 0), (0, 0, 0, 0, 0), (-2, 0, 0, 1, 0))\n",
"0\n"
]
},
{
"data": {
"text/plain": [
"163"
]
},
"execution_count": 690,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"path = stochastic_hamiltonian(graph)\n",
"#for edge in path:\n",
"# print(edge)\n",
"write_chord_sequence(path_to_chords(path, root))\n",
"len(path)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "91fd1700-6f41-4a4c-98cb-8355075d44d2",
"metadata": {},
"outputs": [],
"source": [
"#ffmpeg -i video.mkv -acodec pcm_s16le -ar 16000 -ac 2 bereshit_chant.wav\n",
"#sox bereshit_chant.wav bereshit_chant_snippet.wav trim 4 60"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "51be5ff2-2b7f-4350-878f-09e79d4bff1f",
"metadata": {},
"outputs": [],
"source": [
"import crepe\n",
"from scipy.io import wavfile"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "9b8e1e21-c5f5-4d77-8d1c-094b073b8322",
"metadata": {},
"outputs": [],
"source": [
"sr, audio = wavfile.read('/home/mwinter/Downloads/bereshit_chant_snippet.wav')"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "01f8f969-fc3c-46a2-acfd-b1f956e438bc",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2024-05-24 17:13:22.147078: I external/local_tsl/tsl/cuda/cudart_stub.cc:32] Could not find cuda drivers on your machine, GPU will not be used.\n",
"2024-05-24 17:13:22.471453: I external/local_tsl/tsl/cuda/cudart_stub.cc:32] Could not find cuda drivers on your machine, GPU will not be used.\n",
"2024-05-24 17:13:23.474683: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.\n",
"To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.\n",
"2024-05-24 17:13:25.296611: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1m76/76\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m36s\u001b[0m 471ms/step\n"
]
}
],
"source": [
"time, frequency, confidence, activation = crepe.predict(audio, sr, step_size = 25)\n",
"#time, frequency, confidence = [list(time), list(frequency), list(confidence)]"
]
},
{
"cell_type": "code",
"execution_count": 177,
"id": "b0d17cc2-a181-4212-aba5-72b90cab2a84",
"metadata": {},
"outputs": [],
"source": [
"from random import choice, choices\n",
"\n",
"# This is for the beginning / breysheet\n",
"def stochastic_hamiltonian(graph):\n",
"\n",
" #try making this omit the moving voice\n",
" def movement_size_weights(edges):\n",
" \n",
" def max_cent_diff(edge):\n",
" res = max([abs(v) for val in edge[2]['movements'].values() if (v:=val['cent_difference']) is not None])\n",
" return res\n",
" \n",
" def min_cent_diff(edge):\n",
" res = [abs(v) for val in edge[2]['movements'].values() if (v:=val['cent_difference']) is not None]\n",
" res.remove(0)\n",
" return min(res)\n",
" \n",
" for e in edges:\n",
" yield 4 if ((max_cent_diff(e) < 300) and (min_cent_diff(e)) >= 0) else 1\n",
"\n",
" def hamiltonian_weights(edges):\n",
" for e in edges:\n",
" yield 10 if e[1] not in [path_edge[0] for path_edge in path] else 1 / graph.nodes[e[1]]['count']\n",
" \n",
" def contrary_motion_weights(edges):\n",
"\n",
" def is_contrary(edge):\n",
" cent_diffs = [v for val in edge[2]['movements'].values() if (v:=val['cent_difference']) is not None]\n",
" cent_diffs.sort()\n",
" return (cent_diffs[0] < 0) and (cent_diffs[1] == 0) and (cent_diffs[2] > 0)\n",
"\n",
" for e in edges:\n",
" yield 2 if is_contrary(e) else 1\n",
" \n",
" def is_directly_tunable_weights(edges):\n",
" for e in edges:\n",
" yield 10 if e[2]['is_directly_tunable'] else 1\n",
"\n",
" def symdiff_weights(edges):\n",
" for e in edges:\n",
" yield 1000 if e[2]['symmetric_difference'] == 2 else 1\n",
"\n",
" def transposition_weight(edges):\n",
" for e in edges:\n",
" yield 100 if 0 <= hs_array_to_cents(e[2]['transposition']) < 100 else 1\n",
"\n",
" def is_sustained_voice(edges, voice):\n",
" \n",
" def is_sustained(edge):\n",
" source = list(edge[0])\n",
" ordered_source = sorted(source, key=hs_array_to_fr) \n",
" destination = [transpose_pitch(edge[2]['movements'][p]['destination'], edge[2]['transposition']) for p in source]\n",
" ordered_destination = sorted(destination, key=hs_array_to_fr)\n",
" return ordered_source[voice] == ordered_destination[voice]\n",
"\n",
" for e in edges:\n",
" yield 10 if is_sustained(e) else 1\n",
"\n",
" def voice_crossing_weights(edges):\n",
" \n",
" def has_voice_crossing(edge):\n",
" source = list(edge[0])\n",
" ordered_source = sorted(source, key=hs_array_to_fr) \n",
" source_order = [ordered_source.index(p) for p in source]\n",
" destination = [transpose_pitch(edge[2]['movements'][p]['destination'], edge[2]['transposition']) for p in source]\n",
" ordered_destination = sorted(destination, key=hs_array_to_fr)\n",
" destination_order = [ordered_destination.index(p) for p in destination]\n",
" return source_order != destination_order\n",
"\n",
" for e in edges:\n",
" yield 10 if not has_voice_crossing(e) else 0\n",
"\n",
" def is_bass_rooted(chord):\n",
" return max([sum(abs(p) for p in collapse_pitch(pitch_difference(chord[0], p))) for p in chord[1:]]) == 1\n",
"\n",
" def target_melody_weights(edges, target, c_devs, voice):\n",
"\n",
" def target_weight(edge, target, c_devs, voice):\n",
" candidate_diffs = []\n",
" for idx, dev in enumerate(c_devs):\n",
" if(idx == 2):\n",
" source = list(edge[0])\n",
" ordered_source = sorted(source, key=hs_array_to_fr) \n",
" candidate_diff = edge[2]['movements'][ordered_source[idx]]['cent_difference']\n",
" candidate_diffs += [abs(dev + candidate_diff - target)]\n",
" #return 1/pow(1.1, min(candidate_diffs))\n",
" return 10 if min(candidate_diffs) < 40 else 1/pow(1.1, min(candidate_diffs))\n",
" \n",
" for e in edges:\n",
" yield target_weight(e, target, c_devs, voice)\n",
" \n",
" check_graph = graph.copy()\n",
" next_node = choice(list(graph.nodes()))\n",
" check_graph.remove_node(next_node)\n",
" for node in graph.nodes(data=True):\n",
" node[1]['count'] = 1\n",
" path = []\n",
" s_next_node = sorted(next_node, key=hs_array_to_fr)\n",
" c_devs = (cent_difference(s_next_node[2], s_next_node[0]), cent_difference(s_next_node[2], s_next_node[1]), 0,)\n",
" #c_devs = (0, cent_difference(s_next_node[0], s_next_node[1]), cent_difference(s_next_node[0], s_next_node[2]),)\n",
" print(c_devs)\n",
" while (nx.number_of_nodes(check_graph) > 0) and (len(path) < len(target_melody_data)-1):\n",
" out_edges = list(graph.out_edges(next_node, data=True))\n",
" factors = [\n",
" movement_size_weights(out_edges), \n",
" #hamiltonian_weights(out_edges), \n",
" #contrary_motion_weights(out_edges), \n",
" #is_directly_tunable_weights(out_edges),\n",
" voice_crossing_weights(out_edges),\n",
" #transposition_weight(out_edges),\n",
" #is_sustained_voice(out_edges, 0),\n",
" target_melody_weights(out_edges, target_melody_data[len(path)+1][-1], c_devs, 2),\n",
" #symdiff_weights(out_edges)\n",
" ]\n",
" weights = [prod(a) for a in zip(*factors)]\n",
" edge = choices(out_edges, weights=weights)[0]\n",
" next_node = edge[1]\n",
" node[1]['count'] += 1\n",
" path.append(edge)\n",
" s_chord = tuple(sorted(edge[0], key=hs_array_to_fr))\n",
" c_devs = tuple(c_devs[pdx] + edge[2]['movements'][pitch]['cent_difference'] - target_melody_data[len(path)][-1] for pdx, pitch in enumerate(s_chord))\n",
" print(s_chord)\n",
" print(c_devs)\n",
" print(target_melody_data[len(path)][-1])\n",
" if next_node in check_graph.nodes:\n",
" check_graph.remove_node(next_node)\n",
" return path"
]
},
{
"cell_type": "code",
"execution_count": 359,
"id": "a8592bc9-7e9e-4b6a-9eaa-4c4e3b69ce91",
"metadata": {},
"outputs": [],
"source": [
"dims = (2, 3, 5)\n",
"root = (0, 0, 0)\n",
"chord = (root,)\n",
"chord_set = chords(chord, root, 3, 3)\n",
"graph = generate_graph(chord_set, 2, 4, 3)"
]
},
{
"cell_type": "code",
"execution_count": 342,
"id": "fb2ad9ad-7a8c-4f84-ab0c-9c1f1ecdb8a8",
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[(39.0, 44.0, 51.0), (39.0, 44.0, 53.0)]\n",
"51.0\n",
"2\n",
"[(39.0, 44.0, 53.0), (39.0, 44.0, 51.0)]\n",
"53.0\n",
"2\n",
"[(39.0, 44.0, 51.0), (39.0, 46.0, 51.0)]\n",
"51.0\n",
"2\n",
"[(39.0, 46.0, 51.0), (39.0, 44.0, 51.0)]\n",
"46.0\n",
"1\n",
"[(39.0, 44.0, 51.0), (39.0, 44.0, 49.0)]\n",
"44.0\n",
"1\n",
"[(39.0, 44.0, 49.0), (39.0, 44.0, 48.0)]\n",
"49.0\n",
"2\n",
"[(39.0, 44.0, 48.0), (41.0, 44.0, 48.0)]\n",
"48.0\n",
"2\n",
"[(41.0, 44.0, 48.0), (39.0, 44.0, 48.0)]\n",
"41.0\n",
"0\n",
"[(39.0, 44.0, 48.0), (39.0, 44.0, 49.0)]\n",
"39.0\n",
"0\n",
"[(39.0, 44.0, 49.0), (39.0, 42.0, 49.0)]\n",
"49.0\n",
"2\n",
"[(39.0, 42.0, 49.0), (39.0, 42.0, 51.0)]\n",
"42.0\n",
"1\n",
"[(39.0, 42.0, 51.0), (39.0, 41.0, 51.0)]\n",
"51.0\n",
"2\n",
"[(39.0, 41.0, 51.0), (39.0, 41.0, 52.0)]\n",
"41.0\n",
"1\n",
"[(39.0, 41.0, 52.0), (39.0, 41.0, 51.0)]\n",
"52.0\n",
"2\n",
"[(39.0, 41.0, 51.0), (39.0, 42.0, 51.0)]\n",
"51.0\n",
"2\n",
"[(39.0, 42.0, 51.0), (39.0, 42.0, 49.0)]\n",
"42.0\n",
"1\n",
"[(39.0, 42.0, 49.0), (39.0, 42.0, 48.0)]\n",
"49.0\n",
"2\n",
"[(39.0, 42.0, 48.0), (37.0, 42.0, 48.0)]\n",
"48.0\n",
"2\n",
"[(37.0, 42.0, 48.0), (37.0, 44.0, 48.0)]\n",
"37.0\n",
"0\n",
"[(37.0, 44.0, 48.0), (36.0, 44.0, 48.0)]\n",
"44.0\n",
"1\n",
"[(36.0, 44.0, 48.0), (36.0, 44.0, 51.0)]\n",
"36.0\n",
"0\n",
"[(36.0, 44.0, 51.0), (36.0, 45.0, 51.0)]\n",
"51.0\n",
"2\n",
"[(36.0, 45.0, 51.0), (36.0, 44.0, 51.0)]\n",
"45.0\n",
"1\n",
"[(36.0, 44.0, 51.0), (36.0, 44.0, 53.0)]\n",
"44.0\n",
"1\n",
"[(36.0, 44.0, 53.0), (36.0, 44.0, 51.0)]\n",
"53.0\n",
"2\n",
"[(36.0, 44.0, 51.0), (36.0, 42.0, 51.0)]\n",
"51.0\n",
"2\n",
"[(36.0, 42.0, 51.0), (36.0, 41.0, 51.0)]\n",
"42.0\n",
"1\n",
"[(36.0, 41.0, 51.0), (37.0, 41.0, 51.0)]\n",
"41.0\n",
"1\n",
"[(37.0, 41.0, 51.0), (37.0, 41.0, 52.0)]\n",
"37.0\n",
"0\n",
"[(37.0, 41.0, 52.0), (37.0, 41.0, 48.0)]\n",
"52.0\n",
"2\n",
"[(37.0, 41.0, 48.0), (37.0, 44.0, 48.0)]\n",
"48.0\n",
"2\n",
"[(37.0, 44.0, 48.0), (39.0, 44.0, 48.0)]\n",
"44.0\n",
"1\n",
"[(39.0, 44.0, 48.0), (39.0, 46.0, 48.0)]\n",
"39.0\n",
"0\n",
"[(39.0, 46.0, 48.0), (39.0, 46.0, 53.0)]\n",
"46.0\n",
"1\n",
"[(39.0, 46.0, 53.0), (40.0, 46.0, 53.0)]\n",
"53.0\n",
"2\n",
"[(40.0, 46.0, 53.0), (39.0, 46.0, 53.0)]\n",
"40.0\n",
"0\n",
"[(39.0, 46.0, 53.0), (39.0, 44.0, 53.0)]\n",
"39.0\n",
"0\n",
"[(39.0, 44.0, 53.0), (39.0, 44.0, 51.0)]\n",
"44.0\n",
"1\n",
"[(39.0, 44.0, 51.0), (39.0, 44.0, 49.0)]\n",
"51.0\n",
"2\n",
"[(39.0, 44.0, 49.0), (39.0, 45.0, 49.0)]\n",
"49.0\n",
"2\n",
"[(39.0, 45.0, 49.0), (39.0, 45.0, 52.0)]\n",
"45.0\n",
"1\n",
"[(39.0, 45.0, 52.0), (39.0, 45.0, 53.0)]\n",
"52.0\n",
"2\n",
"[(39.0, 45.0, 53.0), (37.0, 45.0, 53.0)]\n",
"53.0\n",
"2\n",
"[(37.0, 45.0, 53.0), (37.0, 45.0, 52.0)]\n",
"37.0\n",
"0\n",
"[(37.0, 45.0, 52.0), (36.0, 45.0, 52.0)]\n",
"52.0\n",
"2\n",
"[(36.0, 45.0, 52.0), (36.0, 41.0, 52.0)]\n",
"36.0\n",
"0\n",
"[(36.0, 41.0, 52.0), (36.0, 41.0, 51.0)]\n",
"41.0\n",
"1\n",
"[(36.0, 41.0, 51.0), (36.0, 41.0, 52.0)]\n",
"51.0\n",
"2\n",
"[(36.0, 41.0, 52.0), (36.0, 41.0, 51.0)]\n",
"52.0\n",
"2\n",
"[(36.0, 41.0, 51.0), (36.0, 41.0, 49.0)]\n",
"51.0\n",
"2\n",
"[(36.0, 41.0, 49.0), (36.0, 41.0, 48.0)]\n",
"49.0\n",
"2\n",
"[(36.0, 41.0, 48.0), (36.0, 41.0, 46.0)]\n",
"48.0\n",
"2\n",
"[(36.0, 41.0, 46.0), (36.0, 46.0, 46.0)]\n",
"46.0\n",
"2\n",
"[(36.0, 46.0, 46.0), (39.0, 46.0, 46.0)]\n",
"46.0\n",
"1\n",
"[(39.0, 46.0, 46.0), (39.0, 44.0, 46.0)]\n",
"39.0\n",
"0\n",
"[(39.0, 44.0, 46.0), (39.0, 42.0, 46.0)]\n",
"44.0\n",
"1\n",
"[(39.0, 42.0, 46.0), (39.0, 42.0, 51.0)]\n",
"42.0\n",
"1\n",
"[(39.0, 42.0, 51.0), (39.0, 42.0, 52.0)]\n",
"51.0\n",
"2\n",
"[(39.0, 42.0, 52.0), (41.0, 42.0, 52.0)]\n",
"52.0\n",
"2\n",
"[(41.0, 42.0, 52.0), (41.0, 42.0, 54.0)]\n",
"41.0\n",
"0\n",
"[(41.0, 42.0, 54.0), (41.0, 42.0, 56.0)]\n",
"54.0\n",
"2\n",
"[(41.0, 42.0, 56.0), (41.0, 42.0, 57.0)]\n",
"56.0\n",
"2\n",
"[(41.0, 42.0, 57.0), (39.0, 42.0, 57.0)]\n",
"57.0\n",
"2\n",
"[(39.0, 42.0, 57.0), (39.0, 42.0, 53.0)]\n",
"39.0\n",
"0\n",
"[(39.0, 42.0, 53.0), (39.0, 45.0, 53.0)]\n",
"53.0\n",
"2\n",
"[(39.0, 45.0, 53.0), (39.0, 46.0, 53.0)]\n",
"45.0\n",
"1\n",
"[(39.0, 46.0, 53.0), (39.0, 45.0, 53.0)]\n",
"46.0\n",
"1\n",
"[(39.0, 45.0, 53.0), (39.0, 44.0, 53.0)]\n",
"45.0\n",
"1\n",
"[(39.0, 44.0, 53.0), (39.0, 44.0, 57.0)]\n",
"44.0\n",
"1\n",
"[(39.0, 44.0, 57.0), (39.0, 44.0, 55.0)]\n",
"57.0\n",
"2\n",
"[(39.0, 44.0, 55.0), (39.0, 44.0, 54.0)]\n",
"55.0\n",
"2\n",
"[(39.0, 44.0, 54.0), (39.0, 45.0, 54.0)]\n",
"54.0\n",
"2\n",
"[(39.0, 45.0, 54.0), (39.0, 45.0, 51.0)]\n",
"45.0\n",
"1\n",
"[(39.0, 45.0, 51.0), (39.0, 44.0, 51.0)]\n",
"51.0\n",
"2\n",
"[(39.0, 44.0, 51.0), (39.0, 42.0, 51.0)]\n",
"44.0\n",
"1\n",
"[(39.0, 42.0, 51.0), (40.0, 42.0, 51.0)]\n",
"42.0\n",
"1\n",
"[(40.0, 42.0, 51.0), (40.0, 41.0, 51.0)]\n",
"40.0\n",
"0\n",
"[(40.0, 41.0, 51.0), (40.0, 39.0, 51.0)]\n",
"41.0\n",
"1\n",
"[(40.0, 39.0, 51.0), (36.0, 39.0, 51.0)]\n",
"39.0\n",
"1\n",
"[(36.0, 39.0, 51.0), (36.0, 39.0, 53.0)]\n",
"36.0\n",
"0\n",
"[(36.0, 39.0, 53.0), (36.0, 39.0, 51.0)]\n",
"53.0\n",
"2\n",
"[(36.0, 39.0, 51.0), (36.0, 44.0, 51.0)]\n",
"51.0\n",
"2\n",
"[(36.0, 44.0, 51.0), (36.0, 45.0, 51.0)]\n",
"44.0\n",
"1\n",
"[(36.0, 45.0, 51.0), (41.0, 45.0, 51.0)]\n",
"45.0\n",
"1\n",
"[(41.0, 45.0, 51.0), (41.0, 47.0, 51.0)]\n",
"41.0\n",
"0\n",
"[(41.0, 47.0, 51.0), (41.0, 47.0, 49.0)]\n",
"47.0\n",
"1\n",
"[(41.0, 47.0, 49.0), (41.0, 49.0, 49.0)]\n",
"49.0\n",
"2\n",
"[(41.0, 49.0, 49.0), (41.0, 50.0, 49.0)]\n",
"49.0\n",
"1\n",
"[(41.0, 50.0, 49.0), (41.0, 50.0, 48.0)]\n",
"50.0\n",
"1\n",
"[(41.0, 50.0, 48.0), (39.0, 50.0, 48.0)]\n",
"48.0\n",
"2\n",
"[(39.0, 50.0, 48.0), (39.0, 46.0, 48.0)]\n",
"39.0\n",
"0\n",
"[(39.0, 46.0, 48.0), (37.0, 46.0, 48.0)]\n",
"46.0\n",
"1\n",
"[(37.0, 46.0, 48.0), (37.0, 46.0, 49.0)]\n",
"37.0\n",
"0\n",
"[(37.0, 46.0, 49.0), (37.0, 46.0, 51.0)]\n",
"49.0\n",
"2\n",
"[(37.0, 46.0, 51.0), (37.0, 46.0, 50.0)]\n",
"51.0\n",
"2\n",
"[(37.0, 46.0, 50.0), (37.0, 50.0, 50.0)]\n",
"50.0\n",
"2\n",
"[(37.0, 50.0, 50.0), (37.0, 50.0, 52.0)]\n",
"50.0\n",
"1\n",
"[(37.0, 50.0, 52.0), (37.0, 50.0, 53.0)]\n",
"52.0\n",
"2\n",
"[(37.0, 50.0, 53.0), (37.0, 48.0, 53.0)]\n",
"53.0\n",
"2\n",
"[(37.0, 48.0, 53.0), (37.0, 47.0, 53.0)]\n",
"48.0\n",
"1\n",
"[(37.0, 47.0, 53.0), (37.0, 44.0, 53.0)]\n",
"47.0\n",
"1\n",
"[(37.0, 44.0, 53.0), (37.0, 44.0, 51.0)]\n",
"44.0\n",
"1\n",
"[(37.0, 44.0, 51.0), (37.0, 44.0, 55.0)]\n",
"51.0\n",
"2\n",
"[(37.0, 44.0, 55.0), (37.0, 44.0, 57.0)]\n",
"55.0\n",
"2\n",
"[(37.0, 44.0, 57.0), (37.0, 44.0, 56.0)]\n",
"57.0\n",
"2\n",
"[(37.0, 44.0, 56.0), (40.0, 44.0, 56.0)]\n",
"56.0\n",
"2\n",
"[(40.0, 44.0, 56.0), (41.0, 44.0, 56.0)]\n",
"40.0\n",
"0\n",
"[(41.0, 44.0, 56.0), (40.0, 44.0, 56.0)]\n",
"41.0\n",
"0\n",
"[(40.0, 44.0, 56.0), (40.0, 44.0, 57.0)]\n",
"40.0\n",
"0\n",
"[(40.0, 44.0, 57.0), (40.0, 44.0, 56.0)]\n",
"57.0\n",
"2\n",
"[(40.0, 44.0, 56.0), (40.0, 44.0, 53.0)]\n",
"56.0\n",
"2\n",
"[(40.0, 44.0, 53.0), (39.0, 44.0, 53.0)]\n",
"53.0\n",
"2\n",
"[(39.0, 44.0, 53.0), (39.0, 44.0, 51.0)]\n",
"39.0\n",
"0\n",
"[(39.0, 44.0, 51.0), (39.0, 46.0, 51.0)]\n",
"51.0\n",
"2\n",
"[(39.0, 46.0, 51.0), (40.0, 46.0, 51.0)]\n",
"46.0\n",
"1\n",
"[(40.0, 46.0, 51.0), (39.0, 46.0, 51.0)]\n",
"40.0\n",
"0\n",
"[(39.0, 46.0, 51.0), (39.0, 44.0, 51.0)]\n",
"39.0\n",
"0\n",
"[(39.0, 44.0, 51.0), (37.0, 44.0, 51.0)]\n",
"44.0\n",
"1\n",
"[(37.0, 44.0, 51.0), (36.0, 44.0, 51.0)]\n",
"37.0\n",
"0\n",
"[(36.0, 44.0, 51.0), (34.0, 44.0, 51.0)]\n",
"36.0\n",
"0\n",
"[(34.0, 44.0, 51.0), (34.0, 44.0, 53.0)]\n",
"34.0\n",
"0\n",
"[(34.0, 44.0, 53.0), (34.0, 44.0, 51.0)]\n",
"53.0\n",
"2\n",
"[(34.0, 44.0, 51.0), (34.0, 42.0, 51.0)]\n",
"51.0\n",
"2\n",
"[(34.0, 42.0, 51.0), (34.0, 41.0, 51.0)]\n",
"42.0\n",
"1\n",
"[(34.0, 41.0, 51.0), (39.0, 41.0, 51.0)]\n",
"41.0\n",
"1\n",
"[(39.0, 41.0, 51.0), (40.0, 41.0, 51.0)]\n",
"39.0\n",
"0\n",
"[(40.0, 41.0, 51.0), (40.0, 41.0, 48.0)]\n",
"40.0\n",
"0\n",
"[(40.0, 41.0, 48.0), (40.0, 42.0, 48.0)]\n",
"48.0\n",
"2\n",
"[(40.0, 42.0, 48.0), (40.0, 42.0, 49.0)]\n",
"42.0\n",
"1\n",
"[(40.0, 42.0, 49.0), (40.0, 44.0, 49.0)]\n",
"49.0\n",
"2\n",
"[(40.0, 44.0, 49.0), (40.0, 44.0, 46.0)]\n",
"44.0\n",
"1\n",
"[(40.0, 44.0, 46.0), (40.0, 44.0, 53.0)]\n",
"46.0\n",
"2\n",
"[(40.0, 44.0, 53.0), (40.0, 44.0, 54.0)]\n",
"53.0\n",
"2\n",
"[(40.0, 44.0, 54.0), (40.0, 44.0, 49.0)]\n",
"54.0\n",
"2\n",
"[(40.0, 44.0, 49.0), (40.0, 43.0, 49.0)]\n",
"49.0\n",
"2\n",
"[(40.0, 43.0, 49.0), (42.0, 45.0, 49.0)]\n",
"43.0\n",
"1\n",
"[(42.0, 45.0, 49.0), (42.0, 46.0, 49.0)]\n",
"42.0\n",
"0\n",
"[(42.0, 46.0, 49.0), (44.0, 46.0, 49.0)]\n",
"46.0\n",
"1\n",
"[(44.0, 46.0, 49.0), (45.0, 46.0, 49.0)]\n",
"44.0\n",
"0\n",
"[(45.0, 46.0, 49.0), (45.0, 44.0, 49.0)]\n",
"45.0\n",
"0\n",
"[(45.0, 44.0, 49.0), (41.0, 44.0, 49.0)]\n",
"44.0\n",
"1\n",
"[(41.0, 44.0, 49.0), (41.0, 48.0, 51.0)]\n",
"41.0\n",
"0\n",
"[(41.0, 48.0, 51.0), (41.0, 50.0, 51.0)]\n",
"48.0\n",
"1\n",
"[(41.0, 50.0, 51.0), (41.0, 49.0, 51.0)]\n",
"50.0\n",
"1\n",
"[(41.0, 49.0, 51.0), (41.0, 49.0, 48.0)]\n",
"49.0\n",
"1\n",
"[(41.0, 49.0, 48.0), (41.0, 50.0, 48.0)]\n",
"48.0\n",
"2\n",
"[(41.0, 50.0, 48.0), (41.0, 50.0, 51.0)]\n",
"50.0\n",
"1\n",
"[(41.0, 50.0, 51.0), (41.0, 50.0, 52.0)]\n",
"51.0\n",
"2\n",
"[(41.0, 50.0, 52.0), (41.0, 49.0, 52.0)]\n",
"52.0\n",
"2\n",
"[(41.0, 49.0, 52.0), (41.0, 49.0, 51.0)]\n",
"49.0\n",
"1\n",
"[(41.0, 49.0, 51.0), (41.0, 46.0, 51.0)]\n",
"51.0\n",
"2\n",
"[(41.0, 46.0, 51.0), (41.0, 46.0, 53.0)]\n",
"46.0\n",
"1\n",
"[(41.0, 46.0, 53.0), (41.0, 44.0, 53.0)]\n",
"53.0\n",
"2\n",
"[(41.0, 44.0, 53.0), (45.0, 44.0, 52.0)]\n",
"44.0\n",
"1\n",
"[(45.0, 44.0, 52.0), (45.0, 44.0, 51.0)]\n",
"45.0\n",
"0\n",
"[(45.0, 44.0, 51.0), (43.0, 44.0, 51.0)]\n",
"51.0\n",
"2\n",
"[(43.0, 44.0, 51.0), (42.0, 44.0, 51.0)]\n",
"43.0\n",
"0\n",
"[(42.0, 44.0, 51.0), (39.0, 44.0, 51.0)]\n",
"42.0\n",
"0\n",
"[(39.0, 44.0, 51.0), (39.0, 44.0, 49.0)]\n",
"39.0\n",
"0\n",
"[(39.0, 44.0, 49.0), (39.0, 44.0, 50.0)]\n",
"49.0\n",
"2\n",
"[(39.0, 44.0, 50.0), (39.0, 44.0, 52.0)]\n",
"50.0\n",
"2\n",
"[(39.0, 44.0, 52.0), (39.0, 44.0, 51.0)]\n",
"52.0\n",
"2\n",
"[(39.0, 44.0, 51.0), (39.0, 46.0, 51.0)]\n",
"51.0\n",
"2\n",
"[(39.0, 46.0, 51.0), (39.0, 44.0, 51.0)]\n",
"46.0\n",
"1\n",
"[(39.0, 44.0, 51.0), (39.0, 44.0, 52.0)]\n",
"44.0\n",
"1\n",
"[(39.0, 44.0, 52.0), (39.0, 44.0, 53.0)]\n",
"52.0\n",
"2\n",
"[(39.0, 44.0, 53.0), (41.0, 44.0, 53.0)]\n",
"53.0\n",
"2\n",
"[(41.0, 44.0, 53.0), (41.0, 44.0, 49.0)]\n",
"41.0\n",
"0\n",
"[(41.0, 44.0, 49.0), (39.0, 44.0, 49.0)]\n",
"49.0\n",
"2\n",
"[(39.0, 44.0, 49.0), (39.0, 41.0, 49.0)]\n",
"39.0\n",
"0\n",
"[(39.0, 41.0, 49.0), (39.0, 41.0, 56.0)]\n",
"41.0\n",
"1\n",
"[(39.0, 41.0, 56.0), (39.0, 42.0, 56.0)]\n",
"56.0\n",
"2\n",
"[(39.0, 42.0, 56.0), (39.0, 42.0, 54.0)]\n",
"42.0\n",
"1\n",
"[(39.0, 42.0, 54.0), (39.0, 42.0, 53.0)]\n",
"54.0\n",
"2\n",
"[(39.0, 42.0, 53.0), (39.0, 39.0, 53.0)]\n",
"53.0\n",
"2\n",
"[(39.0, 39.0, 53.0), (39.0, 39.0, 51.0)]\n",
"39.0\n",
"1\n",
"[(39.0, 39.0, 51.0), (39.0, 46.0, 51.0)]\n",
"51.0\n",
"2\n",
"[(39.0, 46.0, 51.0), (39.0, 47.0, 51.0)]\n",
"46.0\n",
"1\n",
"[(39.0, 47.0, 51.0), (39.0, 47.0, 53.0)]\n",
"47.0\n",
"1\n",
"[(39.0, 47.0, 53.0), (39.0, 47.0, 51.0)]\n",
"53.0\n",
"2\n",
"[(39.0, 47.0, 51.0), (39.0, 42.0, 51.0)]\n",
"51.0\n",
"2\n",
"[(39.0, 42.0, 51.0), (37.0, 42.0, 51.0)]\n",
"42.0\n",
"1\n",
"[(37.0, 42.0, 51.0), (37.0, 42.0, 49.0)]\n",
"37.0\n",
"0\n",
"[(37.0, 42.0, 49.0), (36.0, 42.0, 49.0)]\n",
"49.0\n",
"2\n",
"[(36.0, 42.0, 49.0), (36.0, 42.0, 48.0)]\n",
"36.0\n",
"0\n",
"[(36.0, 42.0, 48.0), (36.0, 44.0, 49.0)]\n",
"48.0\n",
"2\n",
"[(36.0, 44.0, 49.0), (36.0, 44.0, 51.0)]\n",
"44.0\n",
"1\n",
"[(36.0, 44.0, 51.0), (37.0, 44.0, 51.0)]\n",
"51.0\n",
"2\n",
"[(37.0, 44.0, 51.0), (37.0, 41.0, 51.0)]\n",
"37.0\n",
"0\n",
"[(37.0, 41.0, 51.0), (39.0, 41.0, 51.0)]\n",
"41.0\n",
"1\n",
"[(39.0, 41.0, 51.0), (39.0, 41.0, 52.0)]\n",
"39.0\n",
"0\n",
"[(39.0, 41.0, 52.0), (39.0, 44.0, 53.0)]\n",
"52.0\n",
"2\n",
"[(39.0, 44.0, 53.0), (39.0, 45.0, 53.0)]\n",
"44.0\n",
"1\n",
"[(39.0, 45.0, 53.0), (39.0, 45.0, 52.0)]\n",
"45.0\n",
"1\n",
"[(39.0, 45.0, 52.0), (39.0, 45.0, 51.0)]\n",
"52.0\n",
"2\n",
"[(39.0, 45.0, 51.0), (39.0, 44.0, 51.0)]\n",
"51.0\n",
"2\n",
"[(39.0, 44.0, 51.0), (39.0, 44.0, 52.0)]\n",
"44.0\n",
"1\n",
"[(39.0, 44.0, 52.0), (39.0, 46.0, 52.0)]\n",
"52.0\n",
"2\n",
"[(39.0, 46.0, 52.0), (39.0, 45.0, 52.0)]\n",
"46.0\n",
"1\n",
"[(39.0, 45.0, 52.0), (38.0, 45.0, 52.0)]\n",
"45.0\n",
"1\n",
"[(38.0, 45.0, 52.0), (40.0, 45.0, 52.0)]\n",
"38.0\n",
"0\n",
"[(40.0, 45.0, 52.0), (41.0, 45.0, 52.0)]\n",
"40.0\n",
"0\n",
"[(41.0, 45.0, 52.0), (41.0, 44.0, 52.0)]\n",
"41.0\n",
"0\n",
"[(41.0, 44.0, 52.0), (41.0, 42.0, 52.0)]\n",
"44.0\n",
"1\n",
"[(41.0, 42.0, 52.0), (39.0, 42.0, 52.0)]\n",
"42.0\n",
"1\n",
"[(39.0, 42.0, 52.0), (39.0, 43.0, 52.0)]\n",
"39.0\n",
"0\n",
"[(39.0, 43.0, 52.0), (43.0, 43.0, 52.0)]\n",
"43.0\n",
"1\n",
"[(43.0, 43.0, 52.0), (45.0, 43.0, 52.0)]\n",
"43.0\n",
"0\n",
"[(45.0, 43.0, 52.0), (44.0, 43.0, 52.0)]\n",
"45.0\n",
"0\n",
"[(44.0, 43.0, 52.0), (44.0, 45.0, 52.0)]\n",
"44.0\n",
"0\n",
"[(44.0, 45.0, 52.0), (44.0, 44.0, 52.0)]\n",
"45.0\n",
"1\n",
"[(44.0, 44.0, 52.0), (45.0, 44.0, 52.0)]\n",
"44.0\n",
"1\n",
"[(45.0, 44.0, 52.0), (44.0, 44.0, 52.0)]\n",
"45.0\n",
"0\n",
"[(44.0, 44.0, 52.0), (41.0, 44.0, 52.0)]\n",
"44.0\n",
"0\n",
"[(41.0, 44.0, 52.0), (41.0, 45.0, 52.0)]\n",
"41.0\n",
"0\n"
]
},
{
"data": {
"text/plain": [
"[(1.525, 51.0, 2, 0.0),\n",
" (0.425, 53.0, 2, 200.0),\n",
" (1.225, 51.0, 2, -200.0),\n",
" (0.65, 46.0, 1, -500.0),\n",
" (0.375, 44.0, 1, -200.0),\n",
" (0.65, 49.0, 2, 500.0),\n",
" (0.175, 48.0, 2, -100.0),\n",
" (0.925, 41.0, 0, -700.0),\n",
" (0.4, 39.0, 0, -200.0),\n",
" (0.4, 49.0, 2, 1000.0),\n",
" (0.7, 42.0, 1, -700.0),\n",
" (0.25, 51.0, 2, 900.0),\n",
" (0.625, 41.0, 1, -1000.0),\n",
" (0.1, 52.0, 2, 1100.0),\n",
" (1.175, 51.0, 2, -100.0),\n",
" (0.475, 42.0, 1, -900.0),\n",
" (0.1, 49.0, 2, 700.0),\n",
" (0.225, 48.0, 2, -100.0),\n",
" (0.625, 37.0, 0, -1100.0),\n",
" (0.525, 44.0, 1, 700.0),\n",
" (0.2, 36.0, 0, -800.0),\n",
" (0.625, 51.0, 2, 1500.0),\n",
" (0.05, 45.0, 1, -600.0),\n",
" (0.175, 44.0, 1, -100.0),\n",
" (0.65, 53.0, 2, 900.0),\n",
" (1.0, 51.0, 2, -200.0),\n",
" (0.075, 42.0, 1, -900.0),\n",
" (0.075, 41.0, 1, -100.0),\n",
" (1.2, 37.0, 0, -400.0),\n",
" (0.525, 52.0, 2, 1500.0),\n",
" (0.3, 48.0, 2, -400.0),\n",
" (0.075, 44.0, 1, -400.0),\n",
" (1.225, 39.0, 0, -500.0),\n",
" (0.325, 46.0, 1, 700.0),\n",
" (0.3, 53.0, 2, 700.0),\n",
" (0.15, 40.0, 0, -1300.0),\n",
" (0.075, 39.0, 0, -100.0),\n",
" (0.525, 44.0, 1, 500.0),\n",
" (0.225, 51.0, 2, 700.0),\n",
" (2.275, 49.0, 2, -200.0),\n",
" (0.125, 45.0, 1, -400.0),\n",
" (0.025, 52.0, 2, 700.0),\n",
" (0.225, 53.0, 2, 100.0),\n",
" (0.025, 37.0, 0, -1600.0),\n",
" (0.125, 52.0, 2, 1500.0),\n",
" (0.25, 36.0, 0, -1600.0),\n",
" (0.25, 41.0, 1, 500.0),\n",
" (0.8, 51.0, 2, 1000.0),\n",
" (0.125, 52.0, 2, 100.0),\n",
" (0.325, 51.0, 2, -100.0),\n",
" (0.275, 49.0, 2, -200.0),\n",
" (0.375, 48.0, 2, -100.0),\n",
" (0.425, 46.0, 2, -200.0),\n",
" (0.125, 46.0, 1, 0.0),\n",
" (1.1, 39.0, 0, -700.0),\n",
" (0.375, 44.0, 1, 500.0),\n",
" (0.05, 42.0, 1, -200.0),\n",
" (0.1, 51.0, 2, 900.0),\n",
" (0.4, 52.0, 2, 100.0),\n",
" (1.15, 41.0, 0, -1100.0),\n",
" (0.15, 54.0, 2, 1300.0),\n",
" (0.1, 56.0, 2, 200.0),\n",
" (0.075, 57.0, 2, 100.0),\n",
" (0.75, 39.0, 0, -1800.0),\n",
" (0.575, 53.0, 2, 1400.0),\n",
" (0.05, 45.0, 1, -800.0),\n",
" (0.325, 46.0, 1, 100.0),\n",
" (0.9, 45.0, 1, -100.0),\n",
" (0.375, 44.0, 1, -100.0),\n",
" (0.575, 57.0, 2, 1300.0),\n",
" (0.05, 55.0, 2, -200.0),\n",
" (0.125, 54.0, 2, -100.0),\n",
" (0.075, 45.0, 1, -900.0),\n",
" (0.125, 51.0, 2, 600.0),\n",
" (0.4, 44.0, 1, -700.0),\n",
" (0.275, 42.0, 1, -200.0),\n",
" (0.125, 40.0, 0, -200.0),\n",
" (0.525, 41.0, 1, 100.0),\n",
" (0.65, 39.0, 1, -200.0),\n",
" (0.975, 36.0, 0, -300.0),\n",
" (0.725, 53.0, 2, 1700.0),\n",
" (0.275, 51.0, 2, -200.0),\n",
" (0.175, 44.0, 1, -700.0),\n",
" (1.65, 45.0, 1, 100.0),\n",
" (0.7, 41.0, 0, -400.0),\n",
" (0.1, 47.0, 1, 600.0),\n",
" (0.05, 49.0, 2, 200.0),\n",
" (0.225, 49.0, 1, 0.0),\n",
" (0.4, 50.0, 1, 100.0),\n",
" (0.375, 48.0, 2, -200.0),\n",
" (0.325, 39.0, 0, -900.0),\n",
" (0.2, 46.0, 1, 700.0),\n",
" (0.225, 37.0, 0, -900.0),\n",
" (0.425, 49.0, 2, 1200.0),\n",
" (2.05, 51.0, 2, 200.0),\n",
" (0.025, 50.0, 2, -100.0),\n",
" (0.125, 50.0, 1, 0.0),\n",
" (0.075, 52.0, 2, 200.0),\n",
" (0.45, 53.0, 2, 100.0),\n",
" (0.075, 48.0, 1, -500.0),\n",
" (0.225, 47.0, 1, -100.0),\n",
" (0.075, 44.0, 1, -300.0),\n",
" (0.35, 51.0, 2, 700.0),\n",
" (0.15, 55.0, 2, 400.0),\n",
" (0.3, 57.0, 2, 200.0),\n",
" (0.175, 56.0, 2, -100.0),\n",
" (0.1, 40.0, 0, -1600.0),\n",
" (0.525, 41.0, 0, 100.0),\n",
" (0.55, 40.0, 0, -100.0),\n",
" (0.325, 57.0, 2, 1700.0),\n",
" (0.375, 56.0, 2, -100.0),\n",
" (0.075, 53.0, 2, -300.0),\n",
" (0.5, 39.0, 0, -1400.0),\n",
" (0.525, 51.0, 2, 1200.0),\n",
" (0.7, 46.0, 1, -500.0),\n",
" (0.3, 40.0, 0, -600.0),\n",
" (0.05, 39.0, 0, -100.0),\n",
" (0.55, 44.0, 1, 500.0),\n",
" (0.65, 37.0, 0, -700.0),\n",
" (0.675, 36.0, 0, -100.0),\n",
" (0.25, 34.0, 0, -200.0),\n",
" (0.7, 53.0, 2, 1900.0),\n",
" (0.85, 51.0, 2, -200.0),\n",
" (0.9, 42.0, 1, -900.0),\n",
" (1.15, 41.0, 1, -100.0),\n",
" (0.25, 39.0, 0, -200.0),\n",
" (0.025, 40.0, 0, 100.0),\n",
" (0.1, 48.0, 2, 800.0),\n",
" (0.475, 42.0, 1, -600.0),\n",
" (0.125, 49.0, 2, 700.0),\n",
" (1.0, 44.0, 1, -500.0),\n",
" (0.35, 46.0, 2, 200.0),\n",
" (0.075, 53.0, 2, 700.0),\n",
" (0.725, 54.0, 2, 100.0),\n",
" (0.3, 49.0, 2, -500.0),\n",
" (0.2, 43.0, 1, -600.0),\n",
" (0.1, 42.0, 0, -100.0),\n",
" (0.25, 46.0, 1, 400.0),\n",
" (0.2, 44.0, 0, -200.0),\n",
" (0.975, 45.0, 0, 100.0),\n",
" (0.55, 44.0, 1, -100.0),\n",
" (0.025, 41.0, 0, -300.0),\n",
" (0.225, 48.0, 1, 700.0),\n",
" (0.425, 50.0, 1, 200.0),\n",
" (0.525, 49.0, 1, -100.0),\n",
" (1.45, 48.0, 2, -100.0),\n",
" (0.025, 50.0, 1, 200.0),\n",
" (0.175, 51.0, 2, 100.0),\n",
" (0.275, 52.0, 2, 100.0),\n",
" (0.025, 49.0, 1, -300.0),\n",
" (0.35, 51.0, 2, 200.0),\n",
" (0.4, 46.0, 1, -500.0),\n",
" (0.4, 53.0, 2, 700.0),\n",
" (0.075, 44.0, 1, -900.0),\n",
" (0.7, 45.0, 0, 100.0),\n",
" (0.35, 51.0, 2, 600.0),\n",
" (0.1, 43.0, 0, -800.0),\n",
" (0.4, 42.0, 0, -100.0),\n",
" (0.175, 39.0, 0, -300.0),\n",
" (0.275, 49.0, 2, 1000.0),\n",
" (1.425, 50.0, 2, 100.0),\n",
" (0.775, 52.0, 2, 200.0),\n",
" (0.475, 51.0, 2, -100.0),\n",
" (0.85, 46.0, 1, -500.0),\n",
" (1.375, 44.0, 1, -200.0),\n",
" (0.25, 52.0, 2, 800.0),\n",
" (0.55, 53.0, 2, 100.0),\n",
" (0.075, 41.0, 0, -1200.0),\n",
" (1.425, 49.0, 2, 800.0),\n",
" (0.325, 39.0, 0, -1000.0),\n",
" (0.525, 41.0, 1, 200.0),\n",
" (0.3, 56.0, 2, 1500.0),\n",
" (0.825, 42.0, 1, -1400.0),\n",
" (0.525, 54.0, 2, 1200.0),\n",
" (0.15, 53.0, 2, -100.0),\n",
" (0.075, 39.0, 1, -1400.0),\n",
" (0.375, 51.0, 2, 1200.0),\n",
" (0.125, 46.0, 1, -500.0),\n",
" (0.05, 47.0, 1, 100.0),\n",
" (0.3, 53.0, 2, 600.0),\n",
" (0.675, 51.0, 2, -200.0),\n",
" (1.4, 42.0, 1, -900.0),\n",
" (0.9, 37.0, 0, -500.0),\n",
" (0.475, 49.0, 2, 1200.0),\n",
" (0.425, 36.0, 0, -1300.0),\n",
" (0.475, 48.0, 2, 1200.0),\n",
" (0.275, 44.0, 1, -400.0),\n",
" (1.175, 51.0, 2, 700.0),\n",
" (0.3, 37.0, 0, -1400.0),\n",
" (0.45, 41.0, 1, 400.0),\n",
" (1.375, 39.0, 0, -200.0),\n",
" (0.225, 52.0, 2, 1300.0),\n",
" (0.25, 44.0, 1, -800.0),\n",
" (0.1, 45.0, 1, 100.0),\n",
" (0.05, 52.0, 2, 700.0),\n",
" (0.15, 51.0, 2, -100.0),\n",
" (0.6, 44.0, 1, -700.0),\n",
" (0.225, 52.0, 2, 800.0),\n",
" (0.55, 46.0, 1, -600.0),\n",
" (0.45, 45.0, 1, -100.0),\n",
" (0.275, 38.0, 0, -700.0),\n",
" (0.15, 40.0, 0, 200.0),\n",
" (0.05, 41.0, 0, 100.0),\n",
" (1.45, 44.0, 1, 300.0),\n",
" (0.225, 42.0, 1, -200.0),\n",
" (0.225, 39.0, 0, -300.0),\n",
" (0.75, 43.0, 1, 400.0),\n",
" (0.25, 43.0, 0, 0.0),\n",
" (0.55, 45.0, 0, 200.0),\n",
" (0.525, 44.0, 0, -100.0),\n",
" (0.925, 45.0, 1, 100.0),\n",
" (1.4, 44.0, 1, -100.0),\n",
" (0.725, 45.0, 0, 100.0),\n",
" (0.8, 44.0, 0, -100.0),\n",
" (0.775, 41.0, 0, -300.0)]"
]
},
"execution_count": 342,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import librosa \n",
"import numpy as np\n",
"from scipy.signal import savgol_filter\n",
"import matplotlib.pyplot as plt\n",
"from random import randint\n",
"\n",
"def filter_data(time, frequency, confidence):\n",
" data = tuple(data for data in zip(list(time), list(frequency), list(confidence)) if data[2] > 0.1)\n",
" dev = 0\n",
" dur = 0\n",
" for (p1, p2) in pairwise(data):\n",
" t_diff = (p2[0] - p1[0])\n",
" dur = round(dur + (p2[0] - p1[0]), 2)\n",
" if(True):\n",
" freq1, conf1 = p1[1:3]\n",
" midi1 = librosa.hz_to_midi(freq1)\n",
" r_midi1 = np.around(midi1)\n",
" freq2, conf2 = p2[1:3]\n",
" midi2 = librosa.hz_to_midi(freq2)\n",
" r_midi2 = np.around(midi2)\n",
" #if(r_midi2 != r_midi1):\n",
" if(True):\n",
" yield(dur, freq1, conf1, midi1, r_midi1, dev * 100)\n",
" dev = r_midi2 - r_midi1\n",
" dur = 0\n",
"\n",
"def filter_data(time, frequency, confidence):\n",
" data = tuple(data for data in zip(list(time), list(frequency), list(confidence)) if data[2] > 0.9)\n",
" #durs = tuple(round(y[0]-x[0], 2) for (x, y) in pairwise(data)) + ((1,))\n",
" #data = tuple((d,) + data[i][1:] for i, d in enumerate(durs) if d > 0.01)\n",
" #print(data)\n",
" m, rm = [librosa.hz_to_midi(data[0][1]), np.around(librosa.hz_to_midi(data[0][1]))]\n",
" yield(data[0] + (m, rm, 0,))\n",
" for i, [t, f, c] in enumerate(data):\n",
" nm, nrm = [librosa.hz_to_midi(f), np.around(librosa.hz_to_midi(f))]\n",
" if((0 < i < len(data) - 1) and (nrm != rm)):\n",
" m, rm, d = [nm, nrm, nrm - rm]\n",
" yield(t, f, c, m, rm, d * 100)\n",
" \n",
"t_min = 50\n",
"t_max = 600\n",
"f_time, f_frequency, f_confidence = [time[t_min:], frequency[t_min:], confidence[t_min:]]\n",
"s_confidence = savgol_filter(f_confidence, 30, 4)\n",
"#plt.plot(f_time, f_confidence)\n",
"#plt.plot(f_time, s_confidence, color='red')\n",
"#plt.show()\n",
"\n",
"def freqs_to_midi(freqs, confs):\n",
" last_confident_value = 51\n",
" for f, c in zip(freqs, confs):\n",
" if c > 0.9:\n",
" last_confident_value = librosa.hz_to_midi(f)\n",
" yield last_confident_value\n",
" \n",
"#m_time, midi = zip(*[[t, librosa.hz_to_midi(f)] for t, f, c in zip(f_time, f_frequency, s_confidence) if c > 0.0])\n",
"#nr_midi = np.interp(f_time, m_time, midi)\n",
"#r_midi = np.interp(f_time, m_time, np.around(midi))\n",
"#midi\n",
"\n",
"#data_v2 = tuple(d + (2,) for d in zip(f_time, f_frequency, s_confidence))\n",
"#data_v1 = tuple(d + (1,) for d in zip([t + 2 for t in f_time], f_frequency, s_confidence))\n",
"#data_v0 = tuple(d + (0,) for d in zip([t + 4 for t in f_time], f_frequency, s_confidence))\n",
"\n",
"#data = data_v2 + data_v1 + data_v0\n",
"#data = sorted(data)\n",
"#f_time = tuple(d[0] for d in data)\n",
"#ins = tuple(d[-1] for d in data)\n",
"\n",
"def snap_midi(midi):\n",
" r_midi = np.around(midi)\n",
" s_midi = np.around(savgol_filter(midi, 30, 5))\n",
" last_val = s_midi[0]\n",
" for i, (r1, r2) in enumerate(pairwise(r_midi)):\n",
" if r1 != r2:\n",
" last_val = s_midi[i+5]\n",
" yield last_val\n",
" yield last_val\n",
"\n",
"def format_midi(midi):\n",
" last_val = midi[0]\n",
" dur = 1\n",
" dev = 0.0\n",
" first_flag = True\n",
" for i, (m1, m2) in enumerate(pairwise(midi)):\n",
" if m1 != m2:\n",
" #yield (dur / 40, last_val, dev * 100)\n",
" if first_flag or dur < 10:\n",
" yield (10 / 40.0, last_val, dev * 100)\n",
" first_flag = False\n",
" else:\n",
" size = int(dur / 20)\n",
" \n",
" #sep = randint(1, size)\n",
" #yield (10 / 40.0 * sep, last_val, dev * 100)\n",
" #yield (10 / 40.0 * (size - sep), last_val, 0.0)\n",
"\n",
" b_dur = randint(5, 10)\n",
" yield (randint(10, 20) / 40.0, last_val, dev * 100)\n",
" for i in range(size):\n",
" yield (randint(10, 20) / 40.0, last_val, 0.0)\n",
" \n",
" last_val = m2\n",
" dur = 1\n",
" dev = m2 - m1\n",
" else:\n",
" dur += 1\n",
"\n",
"def filter_midi(midi):\n",
" last_val = midi[0][-1]\n",
" ins = 2\n",
" dur = 1\n",
" dev = 0.0\n",
" first_flag = True\n",
" for i, (m1, m2) in enumerate(pairwise(midi)):\n",
" if m1 != m2:\n",
" print([m1, m2])\n",
" print(last_val)\n",
" print(ins)\n",
" yield (dur / 40, last_val, ins, dev * 100)\n",
"\n",
" #if first_flag or dur < 10:\n",
" # yield (10 / 40.0, last_val, ins, dev * 100)\n",
" # first_flag = False\n",
" #else:\n",
" # size = int(dur / 10)\n",
"\n",
" # b_dur = randint(5, 10)\n",
" # yield (randint(5, 10) / 40.0, last_val, ins, dev * 100)\n",
" # for i in range(size):\n",
" # yield (randint(5, 10) / 40.0, last_val, ins, 0.0)\n",
" \n",
"\n",
" ins = [i for i, m in enumerate(m1) if m1[i] != m2[i]][0]\n",
" #ins = 2\n",
" dur = 1\n",
" dev = m2[ins] - last_val\n",
" last_val = m2[ins]\n",
" else:\n",
" dur += 1\n",
"\n",
" \n",
"midi = list(freqs_to_midi(f_frequency, f_confidence))\n",
"\n",
"#plt.plot(f_time, midi)\n",
"#plt.plot(f_time, savgol_filter(midi, 30, 5), color='yellow')\n",
"#plt.plot(f_time, np.around(savgol_filter(midi, 30, 5)), color='red')\n",
"#plt.plot(f_time, np.around(midi), color='green')\n",
"#plt.plot(f_time, list(snap_midi(midi)), color='blue')\n",
"#plt.show()\n",
"\n",
"midi = tuple(snap_midi(midi))\n",
"#midi = zip(\n",
"# tuple(midi[0] - 12 for i in range(2 * 40)) + tuple(m - 12 for m in midi for r in range(2)),\n",
"# tuple(midi[0] - 7 for i in range(1 * 40)) + tuple(m - 7 for m in midi for r in range(2)) + tuple(midi[-1] - 12 for i in range(5 * 40)),\n",
"# tuple(m - 0 for m in midi) + tuple(midi[-1] - 0 for i in range(10 * 40)))\n",
"\n",
"midi = zip(\n",
" tuple(midi[0] - 12 for i in range(2 * 40)) + tuple(chain(*tuple([m - 12 for r in range(randint(2, 4))] for m in midi))),\n",
" tuple(midi[0] - 7 for i in range(1 * 40)) + tuple(chain(*tuple([m - 7 for r in range(randint(1, 3))] for m in midi))) + tuple(midi[-1] - 12 for i in range(5 * 40)),\n",
" tuple(chain(*tuple([m for r in range(randint(1, 2))] for m in midi))) + tuple(midi[-1] - 0 for i in range(10 * 40)))\n",
"\n",
"#midi = zip(\n",
"# tuple(m - 24 for m in midi) + tuple(midi[-1] - 24 for i in range(5 * 40)),\n",
"# tuple(midi[0] - 12 for i in range(3 * 40)) + tuple(m - 12 for m in midi) + tuple(midi[-1] - 12 for i in range(2 * 40)),\n",
"# tuple(midi[0] - 0 for i in range(5 * 40)) + tuple(m - 0 for m in midi))\n",
"\n",
"target_melody_data = list(filter_midi(list(midi)))\n",
"target_melody_data\n",
"\n",
"\n",
"#target_melody_data = list(filter_data(time, frequency, confidence))\n",
"#target_melody_data\n",
"#durs = tuple(round(y[0]-x[0], 2) for (x, y) in pairwise(target_melody_data)) + ((1,))\n",
"#print(durs)\n",
"#target_melody_data = tuple((d,) + target_melody_data[i][1:] for i, d in enumerate(durs) if d > 0.1)\n",
"#list(target_melody_data)"
]
},
{
"cell_type": "code",
"execution_count": 319,
"id": "2b311f14-5061-4f51-9ee7-bd19a1d938fc",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(1, 1, 2, 2, 2, 2, 3, 3, 3)"
]
},
"execution_count": 319,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"tuple(chain(*tuple([m for r in range(randint(2, 4))] for m in [1, 2, 3])))"
]
},
{
"cell_type": "code",
"execution_count": 360,
"id": "be01e4ae-e629-42ff-9d95-f77d510c13bf",
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(-813.6862861351653, -427.3725722703305, 0)\n",
"((0, 0, 0), (-2, 0, 1), (3, 0, -1))\n",
"(-1013.6862861351653, -627.3725722703305, 74.58242859505685)\n",
"2\n",
"200.0\n",
"((0, 0, 0), (-2, 0, 1), (-3, 1, 1))\n",
"(-813.6862861351653, -427.37257227033047, 0.0)\n",
"2\n",
"-200.0\n",
"((0, 0, 0), (-2, 0, 1), (3, 0, -1))\n",
"(-313.68628613516535, 1.9550008653876034, 500.0)\n",
"1\n",
"-500.0\n",
"((0, 0, 0), (1, 1, -1), (3, 0, -1))\n",
"(-113.68628613516535, -1.9550008653875466, 700.0)\n",
"1\n",
"-200.0\n",
"((0, 0, 0), (4, -1, -1), (3, 0, -1))\n",
"(-613.6862861351653, -501.95500086538755, -3.9100017307749795)\n",
"2\n",
"500.0\n",
"((0, 0, 0), (4, -1, -1), (6, -2, -1))\n",
"(-513.6862861351653, -401.95500086538755, -15.641287000552893)\n",
"2\n",
"-100.0\n",
"((0, 0, 0), (4, -1, -1), (2, -1, 0))\n",
"(-17.596287865940326, 298.04499913461245, 684.3587129994471)\n",
"0\n",
"-700.0\n",
"((3, -2, 0), (4, -1, -1), (2, -1, 0))\n",
"(-1.4210854715202004e-13, 498.04499913461245, 884.3587129994471)\n",
"0\n",
"-200.0\n",
"((2, 0, -1), (4, -1, -1), (2, -1, 0))\n",
"(-1000.0000000000001, -501.95500086538755, -3.9100017307749795)\n",
"2\n",
"1000.0\n",
"((2, 0, -1), (4, -1, -1), (6, -2, -1))\n",
"(-300.0000000000001, -5.865002596162299, 696.089998269225)\n",
"1\n",
"-700.0\n",
"((2, 0, -1), (7, -3, -1), (6, -2, -1))\n",
"(-1200.0, -905.8650025961623, -92.1787164609973)\n",
"2\n",
"900.0\n",
"((2, 0, -1), (7, -3, -1), (10, -3, -2))\n",
"(-719.5512887313275, 94.1349974038377, 907.8212835390027)\n",
"1\n",
"-1000.0\n",
"((4, -3, 0), (7, -3, -1), (10, -3, -2))\n",
"(-1819.5512887313275, -1005.8650025961623, 82.40371213405979)\n",
"2\n",
"1100.0\n",
"((4, -3, 0), (7, -3, -1), (4, -2, 0))\n",
"(-1719.5512887313275, -905.8650025961623, -21.50628959671519)\n",
"2\n",
"-100.0\n",
"((4, -3, 0), (7, -3, -1), (7, -4, 0))\n",
"(-819.5512887313275, -5.865002596162299, 1966.762425133507)\n",
"1\n",
"-900.0\n",
"((4, -3, 0), (7, -3, -1), (4, -3, 1))\n",
"(-1519.5512887313275, -705.8650025961623, 66.7624251335069)\n",
"2\n",
"700.0\n",
"((4, -3, 0), (7, -3, -1), (3, -3, 1))\n",
"(-1419.5512887313275, -605.8650025961623, 96.0899982692248)\n",
"2\n",
"-100.0\n",
"((4, -3, 0), (7, -3, -1), (6, -2, -1))\n",
"(-3.910001730774866, 494.1349974038377, 1196.089998269225)\n",
"0\n",
"-1100.0\n",
"((5, -2, -1), (7, -3, -1), (6, -2, -1))\n",
"(-703.9100017307749, -1.9550008653875466, 496.0899982692249)\n",
"1\n",
"700.0\n",
"((5, -2, -1), (4, -1, -1), (6, -2, -1))\n",
"(-15.64128700055278, 798.0449991346125, 1296.089998269225)\n",
"0\n",
"-800.0\n",
"((1, -1, 0), (4, -1, -1), (6, -2, -1))\n",
"(-1515.641287000553, -701.9550008653875, 0.0)\n",
"2\n",
"1500.0\n",
"((1, -1, 0), (4, -1, -1), (3, 0, -1))\n",
"(-915.6412870005529, -101.95500086538755, 782.4037121340598)\n",
"1\n",
"-600.0\n",
"((1, -1, 0), (4, -1, -1), (4, -2, 0))\n",
"(-2015.641287000553, -1.9550008653875466, 882.4037121340598)\n",
"1\n",
"-100.0\n",
"((0, -1, 0), (4, -1, -1), (4, -2, 0))\n",
"(-2915.641287000553, -1329.327573135718, -17.596287865940212)\n",
"2\n",
"900.0\n",
"((0, -1, 0), (-1, -1, 1), (4, -2, 0))\n",
"(-2715.641287000553, -1129.327573135718, 70.67242686428199)\n",
"2\n",
"-200.0\n",
"((0, -1, 0), (-1, -1, 1), (0, -1, 1))\n",
"(-1815.641287000553, 86.31371386483465, 970.672426864282)\n",
"1\n",
"-900.0\n",
"((0, -1, 0), (0, 0, 0), (0, -1, 1))\n",
"(-1715.641287000553, -17.596287865940297, 1070.672426864282)\n",
"1\n",
"-100.0\n",
"((0, -1, 0), (3, -2, 0), (0, -1, 1))\n",
"(-227.3725722703307, 382.4037121340597, 1470.672426864282)\n",
"0\n",
"-400.0\n",
"((-3, 0, 1), (3, -2, 0), (0, -1, 1))\n",
"(-1615.641287000553, -1117.5962878659402, -29.327573135718012)\n",
"2\n",
"1500.0\n",
"((1, -1, 0), (3, -2, 0), (0, -1, 1))\n",
"(-1215.641287000553, -717.5962878659402, -15.641287000552893)\n",
"2\n",
"-400.0\n",
"((1, -1, 0), (3, -2, 0), (2, -1, 0))\n",
"(-815.6412870005529, -1.9550008653874897, 384.3587129994471)\n",
"1\n",
"-400.0\n",
"((1, -1, 0), (4, -1, -1), (2, -1, 0))\n",
"(-1.1368683772161603e-13, 498.0449991346125, 884.3587129994471)\n",
"0\n",
"-500.0\n",
"((2, 0, -1), (4, -1, -1), (2, -1, 0))\n",
"(-700.0000000000001, 1.9550008653876603, 184.3587129994471)\n",
"1\n",
"700.0\n",
"((2, 0, -1), (1, 1, -1), (2, -1, 0))\n",
"(-1400.0, -698.0449991346123, 3.910001730774752)\n",
"2\n",
"700.0\n",
"((2, 0, -1), (1, 1, -1), (0, 2, -1))\n",
"(-100.0, 601.9550008653877, 1801.9550008653875)\n",
"0\n",
"-1300.0\n",
"((2, 0, -1), (1, 1, -1), (2, 1, -1))\n",
"(0.0, 701.9550008653877, 1403.9100017307746)\n",
"0\n",
"-100.0\n",
"((2, 0, -1), (1, 1, -1), (0, 2, -1))\n",
"(-500.0, -1.9550008653874897, 903.9100017307746)\n",
"1\n",
"500.0\n",
"((2, 0, -1), (4, -1, -1), (0, 2, -1))\n",
"(-1200.0, -701.9550008653875, -1.1368683772161603e-13)\n",
"2\n",
"700.0\n",
"((2, 0, -1), (4, -1, -1), (3, 0, -1))\n",
"(-1000.0, -501.95500086538755, -3.910001730775093)\n",
"2\n",
"-200.0\n",
"((2, 0, -1), (4, -1, -1), (6, -2, -1))\n",
"(-600.0, 9.776284404390253, 396.0899982692249)\n",
"1\n",
"-400.0\n",
"((2, 0, -1), (8, -2, -2), (6, -2, -1))\n",
"(-1300.0, -690.2237155956097, 11.731285269777345)\n",
"2\n",
"700.0\n",
"((2, 0, -1), (8, -2, -2), (7, -1, -2))\n",
"(-1400.0, -790.2237155956097, 23.46257053955526)\n",
"2\n",
"100.0\n",
"((2, 0, -1), (8, -2, -2), (11, -2, -3))\n",
"(37.14885667472072, 809.7762844043903, 1623.4625705395551)\n",
"0\n",
"-1600.0\n",
"((12, -2, -4), (8, -2, -2), (11, -2, -3))\n",
"(-1462.8511433252793, -690.2237155956097, 11.731285269777345)\n",
"2\n",
"1500.0\n",
"((12, -2, -4), (8, -2, -2), (7, -1, -2))\n",
"(25.41757140494292, 909.7762844043903, 1611.7312852697773)\n",
"0\n",
"-1600.0\n",
"((8, -1, -3), (8, -2, -2), (7, -1, -2))\n",
"(-474.5824285950571, 23.46257053955526, 1111.7312852697773)\n",
"1\n",
"500.0\n",
"((8, -1, -3), (10, -2, -3), (7, -1, -2))\n",
"(-1474.582428595057, -1088.2687147302224, 111.73128526977735)\n",
"2\n",
"1000.0\n",
"((8, -1, -3), (6, -1, -2), (7, -1, -2))\n",
"(-1574.582428595057, -374.5824285950571, 11.731285269777345)\n",
"2\n",
"100.0\n",
"((8, -1, -3), (9, -1, -3), (7, -1, -2))\n",
"(-2176.5374294604444, -274.5824285950571, 111.73128526977735)\n",
"2\n",
"-100.0\n",
"((9, -2, -3), (9, -1, -3), (7, -1, -2))\n",
"(-1976.5374294604444, -74.58242859505708, 37.148856674720605)\n",
"2\n",
"-200.0\n",
"((9, -2, -3), (9, -1, -3), (13, -2, -4))\n",
"(-1560.8961424598915, 25.41757140494292, 137.1488566747206)\n",
"2\n",
"-100.0\n",
"((10, -1, -4), (9, -1, -3), (13, -2, -4))\n",
"(-1360.8961424598915, -862.8511433252793, 337.1488566747206)\n",
"2\n",
"-200.0\n",
"((10, -1, -4), (12, -2, -4), (13, -2, -4))\n",
"(-1360.8961424598915, -49.164857190114276, 337.1488566747206)\n",
"1\n",
"0.0\n",
"((10, -1, -4), (15, -2, -5), (13, -2, -4))\n",
"(-51.119858055501254, 650.8351428098857, 1037.1488566747207)\n",
"0\n",
"-700.0\n",
"((16, -3, -5), (15, -2, -5), (13, -2, -4))\n",
"(-551.1198580555013, 39.10385754010815, 537.1488566747207)\n",
"1\n",
"500.0\n",
"((16, -3, -5), (11, -1, -4), (13, -2, -4))\n",
"(-351.11985805550125, 35.19385580933323, 737.1488566747207)\n",
"1\n",
"-200.0\n",
"((16, -3, -5), (14, -3, -4), (13, -2, -4))\n",
"(-1251.1198580555013, -864.8061441906668, -51.11985805550182)\n",
"2\n",
"900.0\n",
"((16, -3, -5), (14, -3, -4), (17, -3, -5))\n",
"(-1351.1198580555013, -649.1648571901144, -151.11985805550182)\n",
"2\n",
"100.0\n",
"((16, -3, -5), (15, -2, -5), (17, -3, -5))\n",
"(-47.20985632472639, 450.8351428098856, 948.8801419444982)\n",
"0\n",
"-1100.0\n",
"((13, -1, -5), (15, -2, -5), (17, -3, -5))\n",
"(-1347.2098563247264, -849.1648571901144, -35.47857105494927)\n",
"2\n",
"1300.0\n",
"((13, -1, -5), (15, -2, -5), (18, -2, -6))\n",
"(-1547.2098563247264, -1049.1648571901144, 39.10385754010804)\n",
"2\n",
"200.0\n",
"((13, -1, -5), (15, -2, -5), (12, -1, -4))\n",
"(-1647.2098563247264, -1260.896142459892, -60.89614245989196)\n",
"2\n",
"100.0\n",
"((13, -1, -5), (11, -1, -4), (12, -1, -4))\n",
"(41.05885840549604, 539.103857540108, 1739.103857540108)\n",
"0\n",
"-1800.0\n",
"((9, 0, -4), (11, -1, -4), (12, -1, -4))\n",
"(-1358.941141594504, -860.896142459892, -47.20985632472684)\n",
"2\n",
"1400.0\n",
"((9, 0, -4), (11, -1, -4), (14, -1, -5))\n",
"(-833.5235701895613, -60.89614245989196, 752.7901436752732)\n",
"1\n",
"-800.0\n",
"((15, -1, -6), (11, -1, -4), (14, -1, -5))\n",
"(-933.5235701895613, -49.16485719011442, 652.7901436752732)\n",
"1\n",
"100.0\n",
"((15, -1, -6), (15, -2, -5), (14, -1, -5))\n",
"(-833.5235701895613, -19.837284054396832, 752.7901436752732)\n",
"1\n",
"-100.0\n",
"((15, -1, -6), (18, -1, -7), (14, -1, -5))\n",
"(-733.5235701895613, 39.10385754010804, 852.7901436752732)\n",
"1\n",
"-100.0\n",
"((15, -1, -6), (11, -1, -4), (14, -1, -5))\n",
"(-2033.5235701895613, -1260.896142459892, -19.837284054396832)\n",
"2\n",
"1300.0\n",
"((15, -1, -6), (11, -1, -4), (19, -1, -7))\n",
"(-1833.5235701895613, -1060.896142459892, 68.43143067582582)\n",
"2\n",
"-200.0\n",
"((15, -1, -6), (11, -1, -4), (15, 0, -6))\n",
"(-1733.5235701895613, -960.896142459892, -35.47857105494927)\n",
"2\n",
"-100.0\n",
"((15, -1, -6), (11, -1, -4), (18, -2, -6))\n",
"(-833.5235701895613, -19.837284054396832, 864.5214289450507)\n",
"1\n",
"-900.0\n",
"((15, -1, -6), (18, -1, -7), (18, -2, -6))\n",
"(-1433.5235701895613, -619.8372840543968, 82.11771681099083)\n",
"2\n",
"600.0\n",
"((15, -1, -6), (18, -1, -7), (17, 0, -7))\n",
"(-733.5235701895613, -31.568569324174405, 782.1177168109908)\n",
"1\n",
"-700.0\n",
"((15, -1, -6), (14, 0, -6), (17, 0, -7))\n",
"(-533.5235701895613, -35.47857105494944, 982.1177168109908)\n",
"1\n",
"-200.0\n",
"((15, -1, -6), (17, -2, -6), (17, 0, -7))\n",
"(-221.79228491978347, 164.52142894505056, 1182.1177168109907)\n",
"0\n",
"-200.0\n",
"((19, -2, -7), (17, -2, -6), (17, 0, -7))\n",
"(-321.79228491978347, 64.52142894505056, 491.8940012153812)\n",
"1\n",
"100.0\n",
"((19, -2, -7), (17, -2, -6), (22, -2, -8))\n",
"(-121.79228491978347, -10.060999650006352, 691.8940012153812)\n",
"1\n",
"-200.0\n",
"((19, -2, -7), (23, -3, -8), (22, -2, -8))\n",
"(-96.37471351484044, 289.93900034999365, 991.8940012153812)\n",
"0\n",
"-300.0\n",
"((25, -3, -9), (23, -3, -8), (22, -2, -8))\n",
"(-1796.3747135148406, -1410.0609996500064, -98.32971438022855)\n",
"2\n",
"1700.0\n",
"((25, -3, -9), (23, -3, -8), (28, -4, -9))\n",
"(-1596.3747135148406, -1210.0609996500064, -10.060999650006238)\n",
"2\n",
"-200.0\n",
"((25, -3, -9), (23, -3, -8), (24, -3, -8))\n",
"(-896.3747135148406, -12.01600051539367, 689.9390003499938)\n",
"1\n",
"-700.0\n",
"((25, -3, -9), (25, -4, -8), (24, -3, -8))\n",
"(-996.3747135148406, -112.01600051539367, 905.5802873505462)\n",
"1\n",
"100.0\n",
"((25, -3, -9), (25, -4, -8), (25, -2, -9))\n",
"(-98.32971438022804, 287.98399948460633, 1305.5802873505463)\n",
"0\n",
"-400.0\n",
"((27, -4, -9), (25, -4, -8), (25, -2, -9))\n",
"(-698.3297143802281, 3.6252864851589948, 705.5802873505463)\n",
"1\n",
"600.0\n",
"((27, -4, -9), (26, -3, -9), (25, -2, -9))\n",
"(-898.3297143802281, -196.374713514841, -84.64342824506309)\n",
"2\n",
"200.0\n",
"((27, -4, -9), (26, -3, -9), (30, -4, -10))\n",
"(-898.3297143802281, -196.374713514841, 799.7152847543846)\n",
"1\n",
"0.0\n",
"((27, -4, -9), (26, -3, -9), (30, -5, -9))\n",
"(-998.3297143802281, -2.239716111003304, 699.7152847543846)\n",
"1\n",
"100.0\n",
"((27, -4, -9), (31, -6, -9), (30, -5, -9))\n",
"(-798.3297143802281, 197.7602838889967, 584.0739977538315)\n",
"2\n",
"-200.0\n",
"((27, -4, -9), (31, -6, -9), (29, -6, -8))\n",
"(-102.23971611100296, 1097.7602838889966, 1484.0739977538315)\n",
"0\n",
"-900.0\n",
"((30, -6, -9), (31, -6, -9), (29, -6, -8))\n",
"(-802.239716111003, 11.446570024161815, 784.0739977538315)\n",
"1\n",
"700.0\n",
"((30, -6, -9), (33, -6, -10), (29, -6, -8))\n",
"(-13.971001380780308, 911.4465700241618, 1684.0739977538315)\n",
"0\n",
"-900.0\n",
"((26, -5, -8), (33, -6, -10), (29, -6, -8))\n",
"(-1213.9710013807803, -288.5534299758382, 97.76028388899658)\n",
"2\n",
"1200.0\n",
"((26, -5, -8), (33, -6, -10), (31, -6, -9))\n",
"(-1413.9710013807803, -488.5534299758382, 9.491569158774496)\n",
"2\n",
"200.0\n",
"((26, -5, -8), (33, -6, -10), (35, -7, -10))\n",
"(-1313.9710013807803, -388.5534299758382, -2.2397161110034176)\n",
"2\n",
"-100.0\n",
"((26, -5, -8), (33, -6, -10), (31, -6, -9))\n",
"(-1202.239716111003, -388.5534299758382, -2.2397161110034176)\n",
"1\n",
"0.0\n",
"((30, -6, -9), (33, -6, -10), (31, -6, -9))\n",
"(-1402.239716111003, -588.5534299758382, -90.5084308412255)\n",
"2\n",
"200.0\n",
"((30, -6, -9), (33, -6, -10), (35, -7, -10))\n",
"(-1502.239716111003, -688.5534299758382, 13.401570889549362)\n",
"2\n",
"100.0\n",
"((30, -6, -9), (33, -6, -10), (32, -5, -10))\n",
"(-1002.239716111003, 15.356571754936795, 513.4015708895494)\n",
"1\n",
"-500.0\n",
"((30, -6, -9), (30, -4, -10), (32, -5, -10))\n",
"(-902.239716111003, 115.3565717549368, 684.0739977538313)\n",
"1\n",
"-100.0\n",
"((30, -6, -9), (30, -4, -10), (29, -6, -8))\n",
"(-602.239716111003, 99.71528475438424, 984.0739977538313)\n",
"1\n",
"-300.0\n",
"((30, -6, -9), (29, -5, -9), (29, -6, -8))\n",
"(-1302.239716111003, -600.2847152456158, 101.67028561977145)\n",
"2\n",
"700.0\n",
"((30, -6, -9), (29, -5, -9), (28, -4, -9))\n",
"(-1702.239716111003, -1000.2847152456158, -4.194716976390396)\n",
"2\n",
"400.0\n",
"((30, -6, -9), (29, -5, -9), (33, -7, -9))\n",
"(-1902.239716111003, -1200.2847152456156, -0.28471524561552997)\n",
"2\n",
"200.0\n",
"((30, -6, -9), (29, -5, -9), (30, -5, -9))\n",
"(-1802.239716111003, -602.2397161110033, 99.71528475438447)\n",
"2\n",
"-100.0\n",
"((30, -6, -9), (31, -6, -9), (30, -5, -9))\n",
"(1.670285619771903, 997.7602838889967, 1699.7152847543844)\n",
"0\n",
"-1600.0\n",
"((27, -4, -9), (31, -6, -9), (30, -5, -9))\n",
"(13.401570889549873, 897.7602838889967, 1599.7152847543844)\n",
"0\n",
"100.0\n",
"((31, -5, -10), (31, -6, -9), (30, -5, -9))\n",
"(1.670285619771903, 997.7602838889967, 1699.7152847543844)\n",
"0\n",
"-100.0\n",
"((27, -4, -9), (31, -6, -9), (30, -5, -9))\n",
"(-1200.2847152456152, -702.2397161110033, -0.28471524561564365)\n",
"2\n",
"1700.0\n",
"((29, -5, -9), (31, -6, -9), (30, -5, -9))\n",
"(-1100.2847152456152, -398.32971438022844, 99.71528475438436)\n",
"2\n",
"-100.0\n",
"((29, -5, -9), (28, -4, -9), (30, -5, -9))\n",
"(-800.2847152456152, -98.32971438022844, 13.401570889549248)\n",
"2\n",
"-300.0\n",
"((29, -5, -9), (28, -4, -9), (32, -5, -10))\n",
"(-172.91214297528495, 1301.6702856197717, 1413.4015708895492)\n",
"0\n",
"-1400.0\n",
"((33, -5, -11), (28, -4, -9), (32, -5, -10))\n",
"(-1372.912142975285, -559.2258568401201, 213.40157088954925)\n",
"2\n",
"1200.0\n",
"((33, -5, -11), (36, -5, -12), (32, -5, -10))\n",
"(-872.912142975285, 11.446570024162043, 713.4015708895492)\n",
"1\n",
"-500.0\n",
"((33, -5, -11), (33, -6, -10), (32, -5, -10))\n",
"(-90.50843084122494, 611.446570024162, 1313.4015708895492)\n",
"0\n",
"-600.0\n",
"((34, -7, -10), (33, -6, -10), (32, -5, -10))\n",
"(9.491569158775064, 711.446570024162, 1595.8052830236095)\n",
"0\n",
"-100.0\n",
"((34, -7, -10), (33, -6, -10), (33, -7, -9))\n",
"(-490.50843084122494, 7.536568293387177, 1095.8052830236095)\n",
"1\n",
"500.0\n",
"((34, -7, -10), (36, -8, -10), (33, -7, -9))\n",
"(5.581567428000199, 707.5365682933872, 1795.8052830236095)\n",
"0\n",
"-700.0\n",
"((37, -9, -10), (36, -8, -10), (33, -7, -9))\n",
"(-6.149717841777488, 807.5365682933872, 1895.8052830236095)\n",
"0\n",
"-100.0\n",
"((33, -8, -9), (36, -8, -10), (33, -7, -9))\n",
"(82.11899688844449, 1007.5365682933872, 2095.8052830236093)\n",
"0\n",
"-200.0\n",
"((29, -7, -8), (36, -8, -10), (33, -7, -9))\n",
"(-1817.8810031115554, -892.4634317066128, -78.77714557144827)\n",
"2\n",
"1900.0\n",
"((29, -7, -8), (36, -8, -10), (39, -8, -11))\n",
"(-1617.8810031115554, -692.4634317066128, -31.56728924672143)\n",
"2\n",
"-200.0\n",
"((29, -7, -8), (36, -8, -10), (28, -7, -7))\n",
"(-717.8810031115554, -15.92600224616831, 868.4327107532786)\n",
"1\n",
"-900.0\n",
"((29, -7, -8), (28, -6, -8), (28, -7, -7))\n",
"(-617.8810031115554, 84.07399775383169, 786.0289986192189)\n",
"1\n",
"-100.0\n",
"((29, -7, -8), (28, -6, -8), (27, -5, -8))\n",
"(-102.23971611100274, 284.0739977538317, 986.0289986192189)\n",
"0\n",
"-200.0\n",
"((30, -6, -9), (28, -6, -8), (27, -5, -8))\n",
"(72.34271248405446, 184.0739977538317, 886.0289986192189)\n",
"0\n",
"100.0\n",
"((24, -5, -7), (28, -6, -8), (27, -5, -8))\n",
"(-727.6572875159455, -615.9260022461683, -25.702286650559245)\n",
"2\n",
"800.0\n",
"((24, -5, -7), (28, -6, -8), (23, -4, -7))\n",
"(-127.65728751594554, -15.92600224616831, 1570.3877116186657)\n",
"1\n",
"-600.0\n",
"((24, -5, -7), (28, -6, -8), (27, -6, -7))\n",
"(-827.6572875159455, -715.9260022461683, -13.971001380781104)\n",
"2\n",
"700.0\n",
"((24, -5, -7), (28, -6, -8), (27, -5, -8))\n",
"(-327.65728751594554, -12.016000515393443, 486.0289986192189)\n",
"1\n",
"-500.0\n",
"((24, -5, -7), (25, -4, -8), (27, -5, -8))\n",
"(-527.6572875159455, -212.01600051539344, -29.61228838133428)\n",
"2\n",
"200.0\n",
"((24, -5, -7), (25, -4, -8), (26, -6, -7))\n",
"(-1227.6572875159454, -912.0160005153934, -98.329714380229)\n",
"2\n",
"700.0\n",
"((24, -5, -7), (25, -4, -8), (28, -4, -9))\n",
"(-1327.6572875159454, -584.643428245063, -198.329714380229)\n",
"2\n",
"100.0\n",
"((24, -5, -7), (30, -4, -10), (28, -4, -9))\n",
"(-827.6572875159454, -84.64342824506298, -13.971001380781217)\n",
"2\n",
"-500.0\n",
"((24, -5, -7), (30, -4, -10), (27, -5, -8))\n",
"(-227.65728751594543, 87.98399948460656, 586.0289986192188)\n",
"1\n",
"-600.0\n",
"((24, -5, -7), (25, -4, -8), (27, -5, -8))\n",
"(-15.926002246167798, 187.98399948460656, 686.0289986192188)\n",
"0\n",
"-100.0\n",
"((28, -6, -8), (25, -4, -8), (27, -5, -8))\n",
"(-415.9260022461678, -29.612288381333656, 286.0289986192188)\n",
"1\n",
"400.0\n",
"((28, -6, -8), (26, -6, -7), (27, -5, -8))\n",
"(-12.01600051539296, 170.38771161866634, 486.0289986192188)\n",
"0\n",
"-200.0\n",
"((25, -4, -8), (26, -6, -7), (27, -5, -8))\n",
"(-0.28471524561496153, 70.38771161866634, 386.0289986192188)\n",
"0\n",
"100.0\n",
"((29, -5, -9), (26, -6, -7), (27, -5, -8))\n",
"(-12.01600051539296, 170.38771161866634, 486.0289986192188)\n",
"1\n",
"-100.0\n",
"((25, -4, -8), (26, -6, -7), (27, -5, -8))\n",
"(-27.657287515945427, 470.38771161866634, 786.0289986192188)\n",
"0\n",
"-300.0\n",
"((24, -5, -7), (26, -6, -7), (27, -5, -8))\n",
"(-727.6572875159454, -25.702286650558563, 86.02899861921878)\n",
"1\n",
"700.0\n",
"((24, -5, -7), (23, -4, -7), (27, -5, -8))\n",
"(-2015.9260022461679, -225.70228665055856, -113.97100138078122)\n",
"1\n",
"200.0\n",
"((27, -6, -8), (23, -4, -7), (27, -5, -8))\n",
"(-2912.016000515393, -125.70228665055856, -13.971001380781217)\n",
"1\n",
"-100.0\n",
"((23, -4, -8), (23, -4, -7), (27, -5, -8))\n",
"(-1927.6572875159457, -25.702286650558563, 86.02899861921878)\n",
"2\n",
"-100.0\n",
"((23, -5, -7), (23, -4, -7), (27, -5, -8))\n",
"(-2127.6572875159454, -225.70228665055856, 272.34271248405344)\n",
"1\n",
"200.0\n",
"((23, -5, -7), (23, -4, -7), (25, -5, -7))\n",
"(-2227.6572875159454, -325.70228665055856, 60.61142721427552)\n",
"2\n",
"100.0\n",
"((23, -5, -7), (23, -4, -7), (21, -4, -6))\n",
"(-3141.34357365111, -425.70228665055856, -39.38857278572448)\n",
"2\n",
"100.0\n",
"((20, -5, -6), (23, -4, -7), (21, -4, -6))\n",
"(-2841.34357365111, -55.02985978627589, 260.6114272142755)\n",
"1\n",
"-300.0\n",
"((20, -5, -6), (20, -5, -5), (21, -4, -6))\n",
"(-4241.343573651111, -255.0298597862759, 60.61142721427552)\n",
"2\n",
"200.0\n",
"((19, -5, -6), (20, -5, -5), (21, -4, -6))\n",
"(-3741.343573651111, 62.566428079663694, 560.6114272142755)\n",
"1\n",
"-500.0\n",
"((19, -5, -6), (19, -3, -6), (21, -4, -6))\n",
"(-4441.343573651111, -637.4335719203364, -27.657287515946564)\n",
"2\n",
"700.0\n",
"((19, -5, -6), (19, -3, -6), (25, -5, -7))\n",
"(-3541.343573651111, 58.656426348889, 872.3427124840534)\n",
"1\n",
"-900.0\n",
"((19, -5, -6), (22, -5, -6), (25, -5, -7))\n",
"(-2827.6572875159454, -41.343573651111, 772.3427124840534)\n",
"0\n",
"100.0\n",
"((22, -5, -7), (22, -5, -6), (25, -5, -7))\n",
"(-3427.6572875159454, -641.343573651111, 60.61142721427552)\n",
"2\n",
"600.0\n",
"((22, -5, -7), (22, -5, -6), (21, -4, -6))\n",
"(-1539.3885727857232, 158.656426348889, 860.6114272142755)\n",
"0\n",
"-800.0\n",
"((19, -4, -6), (22, -5, -6), (21, -4, -6))\n",
"(-443.2985745164981, 258.656426348889, 960.6114272142755)\n",
"0\n",
"-100.0\n",
"((23, -6, -6), (22, -5, -6), (21, -4, -6))\n",
"(60.61142721427683, 558.656426348889, 1260.6114272142754)\n",
"0\n",
"-300.0\n",
"((20, -4, -6), (22, -5, -6), (21, -4, -6))\n",
"(-939.3885727857232, -441.343573651111, -55.0298597862768)\n",
"2\n",
"1000.0\n",
"((20, -4, -6), (22, -5, -6), (20, -5, -5))\n",
"(-1039.3885727857232, -541.343573651111, -43.29857451649957)\n",
"2\n",
"100.0\n",
"((20, -4, -6), (22, -5, -6), (24, -6, -6))\n",
"(-1239.3885727857232, -741.343573651111, -39.38857278572459)\n",
"2\n",
"200.0\n",
"((20, -4, -6), (22, -5, -6), (21, -4, -6))\n",
"(-1139.3885727857232, -753.0748589208888, 60.61142721427541)\n",
"2\n",
"-100.0\n",
"((20, -4, -6), (18, -4, -5), (21, -4, -6))\n",
"(-639.3885727857232, 62.566428079663694, 560.6114272142754)\n",
"1\n",
"-500.0\n",
"((20, -4, -6), (19, -3, -6), (21, -4, -6))\n",
"(-439.3885727857232, -53.0748589208888, 760.6114272142754)\n",
"1\n",
"-200.0\n",
"((20, -4, -6), (18, -4, -5), (21, -4, -6))\n",
"(-1239.3885727857232, -537.4335719203364, -39.38857278572459)\n",
"2\n",
"800.0\n",
"((20, -4, -6), (19, -3, -6), (21, -4, -6))\n",
"(-1339.3885727857232, -637.4335719203364, 64.52142894505005)\n",
"2\n",
"100.0\n",
"((20, -4, -6), (19, -3, -6), (18, -2, -6))\n",
"(64.52142894505141, 562.5664280796636, 1264.52142894505)\n",
"0\n",
"-1200.0\n",
"((17, -2, -6), (19, -3, -6), (18, -2, -6))\n",
"(-735.4785710549486, -237.43357192033636, -33.523570189562406)\n",
"2\n",
"800.0\n",
"((17, -2, -6), (19, -3, -6), (16, -1, -6))\n",
"(60.61142721427666, 762.5664280796636, 966.4764298104376)\n",
"0\n",
"-1000.0\n",
"((20, -4, -6), (19, -3, -6), (16, -1, -6))\n",
"(-139.38857278572334, -47.20985632472673, 766.4764298104376)\n",
"1\n",
"200.0\n",
"((20, -4, -6), (13, -1, -5), (16, -1, -6))\n",
"(-1639.3885727857232, -1547.2098563247268, 39.103857540107356)\n",
"2\n",
"1500.0\n",
"((20, -4, -6), (13, -1, -5), (12, -1, -4))\n",
"(-239.38857278572323, -147.20985632472684, 666.4764298104376)\n",
"1\n",
"-1400.0\n",
"((20, -4, -6), (13, -1, -5), (16, -1, -6))\n",
"(-1439.3885727857232, -1347.2098563247268, 146.9251410791103)\n",
"2\n",
"1200.0\n",
"((20, -4, -6), (13, -1, -5), (19, -4, -5))\n",
"(-1339.3885727857232, -251.1198580555017, 246.9251410791103)\n",
"2\n",
"-100.0\n",
"((20, -4, -6), (17, -3, -5), (19, -4, -5))\n",
"(60.61142721427677, 446.9251410791111, 1646.9251410791103)\n",
"1\n",
"-1400.0\n",
"((20, -4, -6), (18, -4, -5), (19, -4, -5))\n",
"(-1139.3885727857232, -753.0748589208889, 60.61142721427541)\n",
"2\n",
"1200.0\n",
"((20, -4, -6), (18, -4, -5), (21, -4, -6))\n",
"(-639.3885727857232, 62.56642807966358, 560.6114272142754)\n",
"1\n",
"-500.0\n",
"((20, -4, -6), (19, -3, -6), (21, -4, -6))\n",
"(-739.3885727857232, -37.43357192033642, 348.8801419444975)\n",
"1\n",
"100.0\n",
"((20, -4, -6), (19, -3, -6), (17, -3, -5))\n",
"(-1339.3885727857232, -637.4335719203364, 64.52142894505005)\n",
"2\n",
"600.0\n",
"((20, -4, -6), (19, -3, -6), (18, -2, -6))\n",
"(-1139.3885727857232, -437.43357192033636, 60.61142721427541)\n",
"2\n",
"-200.0\n",
"((20, -4, -6), (19, -3, -6), (21, -4, -6))\n",
"(-239.38857278572323, 146.9251410791112, 960.6114272142754)\n",
"1\n",
"-900.0\n",
"((20, -4, -6), (18, -4, -5), (21, -4, -6))\n",
"(-55.02985978627521, 646.9251410791112, 1460.6114272142754)\n",
"0\n",
"-500.0\n",
"((19, -5, -5), (18, -4, -5), (21, -4, -6))\n",
"(-1255.0298597862752, -553.0748589208888, -55.0298597862768)\n",
"2\n",
"1200.0\n",
"((19, -5, -5), (18, -4, -5), (20, -5, -5))\n",
"(44.97014021372479, 746.9251410791112, 2058.656426348888)\n",
"0\n",
"-1300.0\n",
"((19, -5, -5), (18, -4, -5), (23, -5, -6))\n",
"(-1155.0298597862752, -453.0748589208888, -66.76114505605528)\n",
"2\n",
"1200.0\n",
"((19, -5, -5), (18, -4, -5), (16, -4, -4))\n",
"(-755.0298597862752, -53.0748589208888, 1146.9251410791098)\n",
"1\n",
"-400.0\n",
"((19, -5, -5), (18, -4, -5), (19, -4, -5))\n",
"(-1455.0298597862752, -753.0748589208888, -51.11985805550296)\n",
"2\n",
"700.0\n",
"((19, -5, -5), (18, -4, -5), (17, -3, -5))\n",
"(-55.02985978627521, 850.8351428098858, 1348.8801419444972)\n",
"0\n",
"-1400.0\n",
"((19, -5, -5), (15, -2, -5), (17, -3, -5))\n",
"(-455.0298597862752, 43.015139348336334, 948.8801419444972)\n",
"1\n",
"400.0\n",
"((19, -5, -5), (21, -6, -5), (17, -3, -5))\n",
"(-143.2985745164981, 243.01513934833633, 1148.8801419444972)\n",
"0\n",
"-200.0\n",
"((23, -6, -6), (21, -6, -5), (17, -3, -5))\n",
"(-1443.298574516498, -1056.9848606516637, 143.0151393483352)\n",
"2\n",
"1300.0\n",
"((23, -6, -6), (21, -6, -5), (22, -6, -5))\n",
"(-643.2985745164981, 58.65642634888911, 943.0151393483352)\n",
"1\n",
"-800.0\n",
"((23, -6, -6), (22, -5, -6), (22, -6, -5))\n",
"(-743.2985745164981, 29.328853213171158, 843.0151393483352)\n",
"1\n",
"100.0\n",
"((23, -6, -6), (19, -6, -4), (22, -6, -5))\n",
"(-1443.298574516498, -670.6711467868288, 31.283854078557738)\n",
"2\n",
"700.0\n",
"((23, -6, -6), (19, -6, -4), (18, -5, -4))\n",
"(-1343.298574516498, -570.6711467868288, -72.62614765221736)\n",
"2\n",
"-100.0\n",
"((23, -6, -6), (19, -6, -4), (21, -7, -4))\n",
"(-643.2985745164981, -74.58114851760331, 627.3738523477826)\n",
"1\n",
"-700.0\n",
"((23, -6, -6), (22, -8, -4), (21, -7, -4))\n",
"(-1443.298574516498, -874.5811485176033, -60.894862382439555)\n",
"2\n",
"800.0\n",
"((23, -6, -6), (22, -8, -4), (25, -8, -5))\n",
"(-843.2985745164981, -29.61228838133343, 539.1051376175604)\n",
"1\n",
"-600.0\n",
"((23, -6, -6), (26, -6, -7), (25, -8, -5))\n",
"(-174.58114851760274, 70.38771161866657, 639.1051376175604)\n",
"1\n",
"-100.0\n",
"((22, -8, -4), (26, -6, -7), (25, -8, -5))\n",
"(-43.29857451649809, 770.3877116186666, 1339.1051376175606)\n",
"0\n",
"-700.0\n",
"((23, -6, -6), (26, -6, -7), (25, -8, -5))\n",
"(72.3427124840548, 570.3877116186666, 1139.1051376175606)\n",
"0\n",
"200.0\n",
"((24, -5, -7), (26, -6, -7), (25, -8, -5))\n",
"(-27.6572875159452, 470.3877116186666, 674.2977133494404)\n",
"0\n",
"100.0\n",
"((24, -5, -7), (26, -6, -7), (23, -4, -7))\n",
"(-327.6572875159452, -12.016000515393216, 374.2977133494404)\n",
"1\n",
"300.0\n",
"((24, -5, -7), (25, -4, -8), (23, -4, -7))\n",
"(-127.6572875159452, 76.25271421482881, 574.2977133494404)\n",
"1\n",
"-200.0\n",
"((24, -5, -7), (21, -3, -7), (23, -4, -7))\n",
"(-10.060999650005328, 376.2527142148288, 874.2977133494404)\n",
"0\n",
"-300.0\n",
"((23, -3, -8), (21, -3, -7), (23, -4, -7))\n",
"(-1223.7472857851708, -23.747285785171186, 474.2977133494404)\n",
"1\n",
"400.0\n",
"((20, -3, -7), (21, -3, -7), (23, -4, -7))\n",
"(-227.6572875159452, -23.747285785171186, 474.2977133494404)\n",
"0\n",
"0.0\n",
"((24, -5, -7), (21, -3, -7), (23, -4, -7))\n",
"(-427.6572875159452, -223.7472857851712, 589.9390003499931)\n",
"0\n",
"200.0\n",
"((24, -5, -7), (21, -3, -7), (24, -3, -8))\n",
"(-327.6572875159452, 486.02899861921975, 689.9390003499931)\n",
"0\n",
"-100.0\n",
"((24, -5, -7), (27, -5, -8), (24, -3, -8))\n",
"(-427.6572875159452, -41.34357365111077, 589.9390003499931)\n",
"1\n",
"100.0\n",
"((24, -5, -7), (22, -5, -6), (24, -3, -8))\n",
"(-327.6572875159452, -12.016000515393216, 689.9390003499931)\n",
"1\n",
"-100.0\n",
"((24, -5, -7), (25, -4, -8), (24, -3, -8))\n",
"(-223.7472857851707, -112.01600051539322, 589.9390003499931)\n",
"0\n",
"100.0\n",
"((21, -3, -7), (25, -4, -8), (24, -3, -8))\n",
"(-123.7472857851707, -12.016000515393216, 1686.0289986192183)\n",
"0\n",
"-100.0\n",
"((21, -3, -7), (25, -4, -8), (28, -5, -8))\n",
"(-27.6572875159452, 287.9839994846068, 1986.0289986192183)\n",
"0\n",
"-300.0\n",
"(1.525, 0.425, 1.225, 0.65, 0.375, 0.65, 0.175, 0.925, 0.4, 0.4, 0.7, 0.25, 0.625, 0.1, 1.175, 0.475, 0.1, 0.225, 0.625, 0.525, 0.2, 0.625, 0.05, 0.175, 0.65, 1.0, 0.075, 0.075, 1.2, 0.525, 0.3, 0.075, 1.225, 0.325, 0.3, 0.15, 0.075, 0.525, 0.225, 2.275, 0.125, 0.025, 0.225, 0.025, 0.125, 0.25, 0.25, 0.8, 0.125, 0.325, 0.275, 0.375, 0.425, 0.125, 1.1, 0.375, 0.05, 0.1, 0.4, 1.15, 0.15, 0.1, 0.075, 0.75, 0.575, 0.05, 0.325, 0.9, 0.375, 0.575, 0.05, 0.125, 0.075, 0.125, 0.4, 0.275, 0.125, 0.525, 0.65, 0.975, 0.725, 0.275, 0.175, 1.65, 0.7, 0.1, 0.05, 0.225, 0.4, 0.375, 0.325, 0.2, 0.225, 0.425, 2.05, 0.025, 0.125, 0.075, 0.45, 0.075, 0.225, 0.075, 0.35, 0.15, 0.3, 0.175, 0.1, 0.525, 0.55, 0.325, 0.375, 0.075, 0.5, 0.525, 0.7, 0.3, 0.05, 0.55, 0.65, 0.675, 0.25, 0.7, 0.85, 0.9, 1.15, 0.25, 0.025, 0.1, 0.475, 0.125, 1.0, 0.35, 0.075, 0.725, 0.3, 0.2, 0.1, 0.25, 0.2, 0.975, 0.55, 0.025, 0.225, 0.425, 0.525, 1.45, 0.025, 0.175, 0.275, 0.025, 0.35, 0.4, 0.4, 0.075, 0.7, 0.35, 0.1, 0.4, 0.175, 0.275, 1.425, 0.775, 0.475, 0.85, 1.375, 0.25, 0.55, 0.075, 1.425, 0.325, 0.525, 0.3, 0.825, 0.525, 0.15, 0.075, 0.375, 0.125, 0.05, 0.3, 0.675, 1.4, 0.9, 0.475, 0.425, 0.475, 0.275, 1.175, 0.3, 0.45, 1.375, 0.225, 0.25, 0.1, 0.05, 0.15, 0.6, 0.225, 0.55, 0.45, 0.275, 0.15, 0.05, 1.45, 0.225, 0.225, 0.75, 0.25, 0.55, 0.525, 0.925, 1.4, 0.725, 0.8, 0.775)\n"
]
}
],
"source": [
"path = stochastic_hamiltonian(graph)\n",
"#durs = tuple(round(y[0]-x[0], 2) for (x, y) in pairwise(target_melody_data)) + ((1,))\n",
"durs = tuple(d[0] for d in target_melody_data)\n",
"path_to_chords(path, root)\n",
"print(durs)\n",
"write_chord_sequence(list(zip(durs, path_to_chords(path, root))))"
]
},
{
"cell_type": "code",
"execution_count": 273,
"id": "57c834bf-fee7-4ef4-b648-2173099fbb56",
"metadata": {},
"outputs": [],
"source": [
"from random import choice, choices\n",
"\n",
"def hd_sum(chord):\n",
" distances = []\n",
" size = len(chord)\n",
" for i in range(size):\n",
" for j in range(i+1, size):\n",
" distances += [sum([abs(dist) * log(dims[idx], 2) for idx, dist in enumerate(pitch_difference(chord[i], chord[j]))])]\n",
" return sum(distances)\n",
" \n",
"def next_edges(source): \n",
"\n",
" def transpose_to_nearest(hs_array1, hs_array2):\n",
" expanded_pitch = hs_array2\n",
" frequency_ratio = hs_array_to_fr(list(hs_array2)) / hs_array_to_fr(list(hs_array1))\n",
" if frequency_ratio < 1:\n",
" while frequency_ratio < 1:\n",
" frequency_ratio *= 2\n",
" expanded_pitch[0] += 1\n",
" elif frequency_ratio >= 2:\n",
" while frequency_ratio >= 2:\n",
" frequency_ratio *= 1/2\n",
" expanded_pitch[0] += -1\n",
" return tuple(expanded_pitch)\n",
" \n",
" def gen_candidates(chord):\n",
" for sdx, s_pitch in enumerate(chord):\n",
" for cdx, c_pitch in enumerate(chord):\n",
" if sdx != cdx: \n",
" for ddx, dim in enumerate(c_pitch[1:]):\n",
" for alt in [-1, 1]:\n",
" new_pitch = list(c_pitch)\n",
" new_pitch[ddx+1] += alt\n",
" new_pitch_up = transpose_to_nearest(s_pitch, new_pitch)\n",
" new_pitch_down = list(new_pitch_up)\n",
" new_pitch_down[0] += -1\n",
" new_chord = list(chord)\n",
" new_chord[sdx] = tuple(new_pitch_up)\n",
" #if tuple(new_chord) != chord and max(new_pitch_up[1:]) <= 1 and min(new_pitch_up[1:]) >= 0 and sum(new_pitch_up[1:]) <= 2:\n",
" if tuple(new_chord) != chord:\n",
" yield tuple(new_chord)\n",
" new_chord[sdx] = tuple(new_pitch_down)\n",
" if tuple(new_chord) != chord:\n",
" #if tuple(new_chord) != chord and max(new_pitch_down[1:]) <= 1 and min(new_pitch_down[1:]) >= 0 and sum(new_pitch_up[1:]) <= 2:\n",
" yield tuple(new_chord)\n",
"\n",
" for candidate in gen_candidates(source):\n",
"\n",
" movements = {\n",
" pitch:\n",
" {\n",
" 'destination': candidate[index], \n",
" 'cent_difference': cent_difference(pitch, candidate[index])\n",
" } for index, pitch in enumerate(source)}\n",
" \n",
" yield (tuple(source), tuple(candidate), {'transposition': root, 'movements': movements},)\n",
"\n",
"\n",
"# This is for the beginning / breysheet - redone to calculate next chord as a function and not from the graph\n",
"def stochastic_hamiltonian(graph):\n",
"\n",
" #try making this omit the moving voice\n",
" def movement_size_weights(edges):\n",
" \n",
" def max_cent_diff(edge):\n",
" res = max([v for val in edge[2]['movements'].values() if (v:=val['cent_difference']) is not None])\n",
" return res\n",
" \n",
" def min_cent_diff(edge):\n",
" res = [v for val in edge[2]['movements'].values() if (v:=val['cent_difference']) is not None]\n",
" res.remove(0)\n",
" return min(res)\n",
" \n",
" for e in edges:\n",
" yield 10 if ((max_cent_diff(e) < 200) and (min_cent_diff(e)) >= 50) else 1\n",
"\n",
" def hamiltonian_weights(edges):\n",
" for e in edges:\n",
" yield 10 if e[1] not in [path_edge[0] for path_edge in path] else 1 / graph.nodes[e[1]]['count']\n",
" \n",
" def contrary_motion_weights(edges):\n",
"\n",
" def is_contrary(edge):\n",
" cent_diffs = [v for val in edge[2]['movements'].values() if (v:=val['cent_difference']) is not None]\n",
" cent_diffs.sort()\n",
" return (cent_diffs[0] < 0) and (cent_diffs[1] == 0) and (cent_diffs[2] > 0)\n",
"\n",
" for e in edges:\n",
" yield 2 if is_contrary(e) else 1\n",
" \n",
" def is_directly_tunable_weights(edges):\n",
" for e in edges:\n",
" yield 10 if e[2]['is_directly_tunable'] else 1\n",
"\n",
" def symdiff_weights(edges):\n",
" for e in edges:\n",
" yield 1000 if e[2]['symmetric_difference'] == 2 else 1\n",
"\n",
" def transposition_weight(edges):\n",
" for e in edges:\n",
" yield 100 if 0 <= hs_array_to_cents(e[2]['transposition']) < 100 else 1\n",
"\n",
" def in_range(edges):\n",
" for e in edges:\n",
" s_chord = sorted(e[1], key=hs_array_to_fr)\n",
" yield 5 if hs_array_to_fr(sorted(e[1], key=hs_array_to_fr)[0]) >= 0.25 else 0\n",
"\n",
" def hd_weight(edges):\n",
" for e in edges:\n",
" yield 2 * (1/pow(hd_sum(e[1]), 1))\n",
"\n",
" def is_sustained_voice(edges, voice):\n",
" \n",
" def is_sustained(edge):\n",
" source = list(edge[0])\n",
" ordered_source = sorted(source, key=hs_array_to_fr) \n",
" destination = [transpose_pitch(edge[2]['movements'][p]['destination'], edge[2]['transposition']) for p in source]\n",
" ordered_destination = sorted(destination, key=hs_array_to_fr)\n",
" return ordered_source[voice] == ordered_destination[voice]\n",
"\n",
" for e in edges:\n",
" yield 10 if is_sustained(e) else 1\n",
"\n",
" def favor_bass(edges, ins):\n",
"\n",
" def ins_check(edge, ins):\n",
" source = list(edge[0])\n",
" ordered_source = sorted(source, key=hs_array_to_fr) \n",
" destination = [transpose_pitch(edge[2]['movements'][p]['destination'], edge[2]['transposition']) for p in source]\n",
" ordered_destination = sorted(destination, key=hs_array_to_fr)\n",
" if ins == 2:\n",
" return 1\n",
" elif ins == 1 and ordered_source[0] != ordered_destination[0]:\n",
" return 1\n",
" else:\n",
" return 0\n",
"\n",
" for e in edges:\n",
" yield ins_check(e, ins)\n",
"\n",
" def voice_crossing_weights(edges):\n",
" \n",
" def has_voice_crossing(edge):\n",
" source = list(edge[0])\n",
" ordered_source = sorted(source, key=hs_array_to_fr) \n",
" source_order = [ordered_source.index(p) for p in source]\n",
" destination = [transpose_pitch(edge[2]['movements'][p]['destination'], edge[2]['transposition']) for p in source]\n",
" ordered_destination = sorted(destination, key=hs_array_to_fr)\n",
" destination_order = [ordered_destination.index(p) for p in destination]\n",
" return source_order != destination_order\n",
"\n",
" for e in edges:\n",
" yield 10 if not has_voice_crossing(e) else 0\n",
"\n",
" def is_bass_rooted(chord):\n",
" return max([sum(abs(p) for p in collapse_pitch(pitch_difference(chord[0], p))) for p in chord[1:]]) == 1\n",
"\n",
" def target_melody_weights(edges, target, c_devs, voice):\n",
"\n",
" def target_weight(edge, target, c_devs, voice):\n",
" candidate_diffs = []\n",
" for idx, dev in enumerate(c_devs):\n",
" if(idx == voice):\n",
" source = list(edge[0])\n",
" ordered_source = sorted(source, key=hs_array_to_fr) \n",
" candidate_diff = edge[2]['movements'][ordered_source[idx]]['cent_difference']\n",
" candidate_diffs += [abs(dev + candidate_diff - target)]\n",
" #return 1/pow(1.1, min(candidate_diffs))\n",
" return 10 if min(candidate_diffs) < 40 else 1/pow(1.1, min(candidate_diffs))\n",
" \n",
" for e in edges:\n",
" yield target_weight(e, target, c_devs, voice)\n",
" \n",
" check_graph = graph.copy()\n",
" next_node = choice(list(graph.nodes()))\n",
" check_graph.remove_node(next_node)\n",
" for node in graph.nodes(data=True):\n",
" node[1]['count'] = 1\n",
" path = []\n",
" s_next_node = sorted(next_node, key=hs_array_to_fr)\n",
" c_devs = (cent_difference(s_next_node[2], s_next_node[0]), cent_difference(s_next_node[2], s_next_node[1]), 0,)\n",
" #c_devs = (0, cent_difference(s_next_node[0], s_next_node[1]), cent_difference(s_next_node[0], s_next_node[2]),)\n",
" print(c_devs)\n",
" while (nx.number_of_nodes(check_graph) > 0) and (len(path) < len(target_melody_data)-1):\n",
" #out_edges = list(graph.out_edges(next_node, data=True))\n",
" out_edges = list(next_edges(next_node))\n",
" target = target_melody_data[len(path)+1][-1]\n",
" ins = target_melody_data[len(path)+1][-2]\n",
" factors = [\n",
" #movement_size_weights(out_edges), \n",
" #hamiltonian_weights(out_edges), \n",
" #contrary_motion_weights(out_edges), \n",
" #is_directly_tunable_weights(out_edges),\n",
" voice_crossing_weights(out_edges),\n",
" #transposition_weight(out_edges),\n",
" #is_sustained_voice(out_edges, 0),\n",
" target_melody_weights(out_edges, target, c_devs, ins),\n",
" #symdiff_weights(out_edges),\n",
" hd_weight(out_edges),\n",
" #favor_bass(out_edges, ins),\n",
" #in_range(out_edges)\n",
" ]\n",
" weights = [prod(a) for a in zip(*factors)]\n",
" edge = choices(out_edges, weights=weights)[0]\n",
" next_node = edge[1]\n",
" node[1]['count'] += 1\n",
" path.append(edge)\n",
" s_chord = tuple(sorted(edge[0], key=hs_array_to_fr))\n",
" c_devs = tuple(c_devs[pdx] + edge[2]['movements'][pitch]['cent_difference'] - target_melody_data[len(path)][-1] for pdx, pitch in enumerate(s_chord))\n",
" print(s_chord)\n",
" print(c_devs)\n",
" print(target_melody_data[len(path)][-2])\n",
" print(target_melody_data[len(path)][-1])\n",
" if next_node in check_graph.nodes:\n",
" check_graph.remove_node(next_node)\n",
" return path"
]
},
{
"cell_type": "code",
"execution_count": 274,
"id": "8912c650-a43d-4539-ae24-b5acf9bc543d",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(-729.2190926654876, -231.1740935308751, 0)\n",
"((0, 0, 0, 0), (2, -1, 0, 0), (5, -1, 0, -1))\n",
"(-29.21909266548755, -1.955000865387433, 700.0)\n",
"1\n",
"-700.0\n",
"((0, 0, 0, 0), (6, -2, 0, -1), (5, -1, 0, -1))\n",
"(-929.2190926654876, -901.9550008653874, 39.60681380363735)\n",
"2\n",
"900.0\n",
"((0, 0, 0, 0), (6, -2, 0, -1), (-2, 0, 0, 1))\n",
"(-729.2190926654876, -701.9550008653874, -27.26409180010012)\n",
"2\n",
"-200.0\n",
"((0, 0, 0, 0), (6, -2, 0, -1), (-1, 1, 0, 0))\n",
"(0.0, 498.04499913461257, 1172.7359081998998)\n",
"0\n",
"-1200.0\n",
"((4, -1, 0, -1), (6, -2, 0, -1), (-1, 1, 0, 0))\n",
"(-700.0, 1.955000865387433, 472.73590819989977)\n",
"1\n",
"700.0\n",
"((4, -1, 0, -1), (3, 0, 0, -1), (-1, 1, 0, 0))\n",
"(-500.0, -29.21909266548755, 672.7359081998998)\n",
"1\n",
"-200.0\n",
"((4, -1, 0, -1), (0, 0, 0, 0), (-1, 1, 0, 0))\n",
"(-1000.0, -529.2190926654876, -31.17409353087521)\n",
"2\n",
"500.0\n",
"((4, -1, 0, -1), (0, 0, 0, 0), (2, -1, 0, 0))\n",
"(39.60681380363735, 270.78090733451245, 768.8259064691248)\n",
"0\n",
"-800.0\n",
"((-3, 0, 0, 1), (0, 0, 0, 0), (2, -1, 0, 0))\n",
"(-660.3931861963626, -633.1290943962625, 68.82590646912479)\n",
"2\n",
"700.0\n",
"((-3, 0, 0, 1), (3, -2, 0, 0), (2, -1, 0, 0))\n",
"(0.0, 266.87090560373747, 968.8259064691248)\n",
"0\n",
"-900.0\n",
"((4, -1, 0, -1), (3, -2, 0, 0), (2, -1, 0, 0))\n",
"(-1029.2190926654876, -33.12909439626253, 668.8259064691248)\n",
"1\n",
"300.0\n",
"((-1, 0, 0, 0), (3, -2, 0, 0), (2, -1, 0, 0))\n",
"(-1729.2190926654876, -1617.48780739571, -31.17409353087521)\n",
"2\n",
"700.0\n",
"((-1, 0, 0, 0), (3, -1, -1, 0), (2, -1, 0, 0))\n",
"(-929.2190926654876, 39.60681380363735, 768.8259064691248)\n",
"1\n",
"-800.0\n",
"((-1, 0, 0, 0), (-3, 0, 0, 1), (2, -1, 0, 0))\n",
"(-58.438185330975216, 439.60681380363735, 1168.8259064691247)\n",
"0\n",
"-400.0\n",
"((-5, 1, 0, 1), (-3, 0, 0, 1), (2, -1, 0, 0))\n",
"(-1458.438185330975, -960.3931861963626, 8.432720272762253)\n",
"2\n",
"1400.0\n",
"((-5, 1, 0, 1), (-3, 0, 0, 1), (-5, 0, 0, 2))\n",
"(-558.4381853309751, -60.39318619636265, 641.5618146690247)\n",
"1\n",
"-900.0\n",
"((-5, 1, 0, 1), (-3, 0, 0, 1), (-4, 1, 0, 1))\n",
"(41.5618146690249, 539.6068138036374, 1472.7359081998998)\n",
"0\n",
"-600.0\n",
"((-5, 1, 0, 1), (-3, 0, 0, 1), (-1, 1, 0, 0))\n",
"(-1558.438185330975, -1060.3931861963626, 27.87552853385955)\n",
"2\n",
"1600.0\n",
"((-5, 1, 0, 1), (-3, 0, 0, 1), (-6, 1, 1, 1))\n",
"(-1458.438185330975, -960.3931861963626, 8.432720272762253)\n",
"2\n",
"-100.0\n",
"((-5, 1, 0, 1), (-3, 0, 0, 1), (-5, 0, 0, 2))\n",
"(-758.4381853309751, 6.477719407374707, 708.4327202727623)\n",
"1\n",
"-700.0\n",
"((-5, 1, 0, 1), (-4, -1, 0, 2), (-5, 0, 0, 2))\n",
"(4.522718541987388, 706.4777194073747, 1408.4327202727623)\n",
"0\n",
"-700.0\n",
"((-3, -2, 0, 2), (-4, -1, 0, 2), (-5, 0, 0, 2))\n",
"(-795.4772814580126, 18.209004677152734, 608.4327202727623)\n",
"1\n",
"800.0\n",
"((-3, -2, 0, 2), (0, -2, -1, 2), (-5, 0, 0, 2))\n",
"(-695.4772814580126, 6.47771940737465, 708.4327202727623)\n",
"1\n",
"-100.0\n",
"((-3, -2, 0, 2), (-4, -1, 0, 2), (-5, 0, 0, 2))\n",
"(-1195.4772814580126, -493.52228059262535, 4.52271854198716)\n",
"2\n",
"500.0\n",
"((-3, -2, 0, 2), (-4, -1, 0, 2), (-2, -2, 0, 2))\n",
"(-1095.4772814580126, -393.52228059262535, -7.208566727790583)\n",
"2\n",
"-100.0\n",
"((-3, -2, 0, 2), (-4, -1, 0, 2), (-6, -1, 1, 2))\n",
"(8.432720272762367, 506.47771940737465, 892.7914332722094)\n",
"0\n",
"-900.0\n",
"((-6, 0, 0, 2), (-4, -1, 0, 2), (-6, -1, 1, 2))\n",
"(20.164005542540167, 406.47771940737465, 792.7914332722094)\n",
"0\n",
"100.0\n",
"((-2, -1, -1, 2), (-4, -1, 0, 2), (-6, -1, 1, 2))\n",
"(8.432720272762367, 506.47771940737465, 892.7914332722094)\n",
"0\n",
"-100.0\n",
"((-6, 0, 0, 2), (-4, -1, 0, 2), (-6, -1, 1, 2))\n",
"(-291.56727972723763, -60.39318619636276, 592.7914332722094)\n",
"1\n",
"300.0\n",
"((-6, 0, 0, 2), (-3, 0, 0, 1), (-6, -1, 1, 2))\n",
"(-1191.5672797272377, -960.3931861963628, 8.432720272762253)\n",
"2\n",
"900.0\n",
"((-6, 0, 0, 2), (-3, 0, 0, 1), (-5, 0, 0, 2))\n",
"(-191.56727972723775, 39.60681380363724, 1625.920527668472)\n",
"1\n",
"-1000.0\n",
"((-6, 0, 0, 2), (-3, 0, 0, 1), (-4, 0, 1, 1))\n",
"(-1391.5672797272377, -1160.3931861963629, 39.606813803637124)\n",
"2\n",
"1200.0\n",
"((-6, 0, 0, 2), (-3, 0, 0, 1), (-2, 0, 0, 1))\n",
"(53.2930999388027, 439.6068138036371, 1639.6068138036371)\n",
"0\n",
"-1600.0\n",
"((-1, 0, -1, 1), (-3, 0, 0, 1), (-2, 0, 0, 1))\n",
"(-646.7069000611973, -29.21909266548778, 939.6068138036371)\n",
"1\n",
"700.0\n",
"((-1, 0, -1, 1), (0, 0, 0, 0), (-2, 0, 0, 1))\n",
"(-42.905378800652784, 770.7809073345122, 1739.6068138036371)\n",
"0\n",
"-800.0\n",
"((-3, 0, 1, 0), (0, 0, 0, 0), (-2, 0, 0, 1))\n",
"(-1542.9053788006527, -729.2190926654878, -27.264091800100232)\n",
"2\n",
"1500.0\n",
"((-3, 0, 1, 0), (0, 0, 0, 0), (-1, 1, 0, 0))\n",
"(-1042.9053788006527, -25.309090934712913, 472.73590819989977)\n",
"1\n",
"-500.0\n",
"((-3, 0, 1, 0), (-3, 2, 0, 0), (-1, 1, 0, 0))\n",
"(-27.264091800100005, 674.6909090652871, 1172.7359081998998)\n",
"0\n",
"-700.0\n",
"((-2, 1, 0, 0), (-3, 2, 0, 0), (-1, 1, 0, 0))\n",
"(-527.2640918001, -29.21909266548778, 672.7359081998998)\n",
"1\n",
"500.0\n",
"((-2, 1, 0, 0), (0, 0, 0, 0), (-1, 1, 0, 0))\n",
"(39.606813803637465, 270.7809073345122, 972.7359081998998)\n",
"0\n",
"-300.0\n",
"((-3, 0, 0, 1), (0, 0, 0, 0), (-1, 1, 0, 0))\n",
"(-1060.3931861963624, -829.2190926654878, -15.532806530322432)\n",
"2\n",
"1100.0\n",
"((-3, 0, 0, 1), (0, 0, 0, 0), (3, 0, -1, 0))\n",
"(-27.264091800099777, 470.7809073345122, 1284.4671934696776)\n",
"0\n",
"-1300.0\n",
"((-2, 1, 0, 0), (0, 0, 0, 0), (3, 0, -1, 0))\n",
"(-627.2640918000998, -17.48780739570998, 684.4671934696776)\n",
"1\n",
"600.0\n",
"((-2, 1, 0, 0), (4, -1, -1, 0), (3, 0, -1, 0))\n",
"(-227.26409180009978, 3.9100017307746384, 1084.4671934696776)\n",
"1\n",
"-400.0\n",
"((-2, 1, 0, 0), (1, 1, 0, -1), (3, 0, -1, 0))\n",
"(-1427.2640918000998, -1196.0899982692254, 3.9100017307746384)\n",
"2\n",
"1200.0\n",
"((-2, 1, 0, 0), (1, 1, 0, -1), (2, 1, 0, -1))\n",
"(-127.26409180009978, 370.7809073345122, 1303.9100017307746)\n",
"0\n",
"-1300.0\n",
"((-2, 1, 0, 0), (0, 0, 0, 0), (2, 1, 0, -1))\n",
"(-1227.2640918000998, -729.2190926654878, -27.264091800100232)\n",
"2\n",
"1100.0\n",
"((-2, 1, 0, 0), (0, 0, 0, 0), (-1, 1, 0, 0))\n",
"(41.561814669025125, 770.7809073345122, 1472.7359081998998)\n",
"0\n",
"-1500.0\n",
"((-5, 1, 0, 1), (0, 0, 0, 0), (-1, 1, 0, 0))\n",
"(-1258.4381853309749, -529.2190926654878, -31.174093530875325)\n",
"2\n",
"1300.0\n",
"((-5, 1, 0, 1), (0, 0, 0, 0), (2, -1, 0, 0))\n",
"(-958.4381853309749, 37.65181293824952, 268.8259064691247)\n",
"1\n",
"-300.0\n",
"((-5, 1, 0, 1), (-1, -1, 0, 1), (2, -1, 0, 0))\n",
"(-758.4381853309749, -29.21909266548778, 468.8259064691247)\n",
"1\n",
"-200.0\n",
"((-5, 1, 0, 1), (0, 0, 0, 0), (2, -1, 0, 0))\n",
"(-558.4381853309749, -33.12909439626273, 668.8259064691247)\n",
"1\n",
"-200.0\n",
"((-5, 1, 0, 1), (3, -2, 0, 0), (2, -1, 0, 0))\n",
"(-44.86037966603993, 66.87090560373727, 768.8259064691247)\n",
"0\n",
"-100.0\n",
"((-1, -1, 1, 0), (3, -2, 0, 0), (2, -1, 0, 0))\n",
"(-1144.86037966604, -1033.1290943962626, -64.30318792713797)\n",
"2\n",
"1100.0\n",
"((-1, -1, 1, 0), (3, -2, 0, 0), (1, -2, 0, 1))\n",
"(-1244.86037966604, -746.8153805314276, -164.30318792713797)\n",
"2\n",
"100.0\n",
"((-1, -1, 1, 0), (1, -2, 1, 0), (1, -2, 0, 1))\n",
"(-1460.5016666665927, -646.8153805314276, -64.30318792713797)\n",
"2\n",
"-100.0\n",
"((-2, -2, 2, 0), (1, -2, 1, 0), (1, -2, 0, 1))\n",
"(-48.770381396814855, 653.1846194685724, 1235.696812072862)\n",
"0\n",
"-1300.0\n",
"((2, -3, 1, 0), (1, -2, 1, 0), (1, -2, 0, 1))\n",
"(4.522718541987501, 853.1846194685724, 1435.696812072862)\n",
"0\n",
"-200.0\n",
"((-3, -2, 0, 2), (1, -2, 1, 0), (1, -2, 0, 1))\n",
"(-1395.4772814580124, -581.7909953228473, 35.69681207286203)\n",
"2\n",
"1400.0\n",
"((-3, -2, 0, 2), (0, -2, -1, 2), (1, -2, 0, 1))\n",
"(-795.4772814580124, 18.209004677152734, 790.8364324068222)\n",
"1\n",
"-600.0\n",
"((-3, -2, 0, 2), (0, -2, -1, 2), (-4, -2, 1, 2))\n",
"(-895.4772814580124, -11.118568458565164, 690.8364324068222)\n",
"1\n",
"100.0\n",
"((-3, -2, 0, 2), (-3, -3, 1, 2), (-4, -2, 1, 2))\n",
"(-795.4772814580124, 18.209004677152734, 790.8364324068222)\n",
"1\n",
"-100.0\n",
"((-3, -2, 0, 2), (0, -2, -1, 2), (-4, -2, 1, 2))\n",
"(-1395.4772814580124, -581.7909953228473, 35.69681207286203)\n",
"2\n",
"600.0\n",
"((-3, -2, 0, 2), (0, -2, -1, 2), (1, -2, 0, 1))\n",
"(-1195.4772814580124, -381.79099532284727, 4.522718541986933)\n",
"2\n",
"-200.0\n",
"((-3, -2, 0, 2), (0, -2, -1, 2), (-2, -2, 0, 2))\n",
"(-695.4772814580124, 6.47771940737465, 504.52271854198693)\n",
"1\n",
"-500.0\n",
"((-3, -2, 0, 2), (-4, -1, 0, 2), (-2, -2, 0, 2))\n",
"(-1095.4772814580124, -393.52228059262535, -7.20856672779081)\n",
"2\n",
"400.0\n",
"((-3, -2, 0, 2), (-4, -1, 0, 2), (-6, -1, 1, 2))\n",
"(-895.4772814580124, -193.52228059262535, 37.65181293824941)\n",
"2\n",
"-200.0\n",
"((-3, -2, 0, 2), (-4, -1, 0, 2), (-1, -1, 0, 1))\n",
"(20.164005542540394, 406.47771940737465, 637.6518129382493)\n",
"0\n",
"-600.0\n",
"((-2, -1, -1, 2), (-4, -1, 0, 2), (-1, -1, 0, 1))\n",
"(39.60681380363769, 306.47771940737465, 537.6518129382493)\n",
"0\n",
"100.0\n",
"((-3, 0, 0, 1), (-4, -1, 0, 2), (-1, -1, 0, 1))\n",
"(20.164005542540394, 406.47771940737465, 637.6518129382493)\n",
"0\n",
"-100.0\n",
"((-2, -1, -1, 2), (-4, -1, 0, 2), (-1, -1, 0, 1))\n",
"(-379.8359944574596, 6.47771940737465, 1206.4777194073745)\n",
"1\n",
"400.0\n",
"((-2, -1, -1, 2), (-4, -1, 0, 2), (-3, -1, 0, 2))\n",
"(-179.8359944574596, -24.696374123500362, 1406.4777194073745)\n",
"1\n",
"-200.0\n",
"((-2, -1, -1, 2), (-7, -1, 0, 3), (-3, -1, 0, 2))\n",
"(8.432720272762595, 275.3036258764996, 1706.4777194073745)\n",
"0\n",
"-300.0\n",
"((-6, 0, 0, 2), (-7, -1, 0, 3), (-3, -1, 0, 2))\n",
"(-191.5672797272374, 39.60681380363721, 1506.4777194073745)\n",
"1\n",
"200.0\n",
"((-6, 0, 0, 2), (-3, 0, 0, 1), (-3, -1, 0, 2))\n",
"(8.432720272762595, 120.16400554253991, 1706.4777194073745)\n",
"1\n",
"-200.0\n",
"((-6, 0, 0, 2), (-2, -1, -1, 2), (-3, -1, 0, 2))\n",
"(-91.5672797272374, 20.16400554253991, 1810.3877211381493)\n",
"0\n",
"100.0\n",
"((-6, 0, 0, 2), (-2, -1, -1, 2), (-6, 1, 0, 2))\n",
"(-1191.5672797272373, -1079.8359944574602, -111.01008798833539)\n",
"2\n",
"1100.0\n",
"((-6, 0, 0, 2), (-2, -1, -1, 2), (-4, -1, -1, 3))\n",
"(8.432720272762708, 239.60681380363712, 1088.9899120116647)\n",
"0\n",
"-1200.0\n",
"((-6, 0, 0, 2), (-3, 0, 0, 1), (-4, -1, -1, 3))\n",
"(-1291.5672797272373, -1060.3931861963629, -91.56727972723797)\n",
"2\n",
"1300.0\n",
"((-6, 0, 0, 2), (-3, 0, 0, 1), (-5, 0, 0, 2))\n",
"(-22.74137325811239, 439.6068138036371, 1408.432720272762)\n",
"0\n",
"-1500.0\n",
"((-9, 0, 0, 3), (-3, 0, 0, 1), (-5, 0, 0, 2))\n",
"(77.25862674188761, 539.6068138036371, 2553.2930999388027)\n",
"0\n",
"-100.0\n",
"((-9, 0, 0, 3), (-3, 0, 0, 1), (1, 0, -1, 1))\n",
"(37.65181293825026, 739.6068138036371, 2753.2930999388027)\n",
"0\n",
"-200.0\n",
"((-2, -1, 0, 1), (-3, 0, 0, 1), (1, 0, -1, 1))\n",
"(-962.3481870617497, 6.4777194073744795, 1753.2930999388027)\n",
"1\n",
"1000.0\n",
"((-2, -1, 0, 1), (-4, -1, 0, 2), (1, 0, -1, 1))\n",
"(-1062.3481870617497, 66.97938607396765, 1653.2930999388027)\n",
"1\n",
"100.0\n",
"((-2, -1, 0, 1), (2, 0, -2, 1), (1, 0, -1, 1))\n",
"(-1962.3481870617497, -833.0206139260324, -19.33432779086729)\n",
"2\n",
"900.0\n",
"((-2, -1, 0, 1), (2, 0, -2, 1), (5, 0, -3, 1))\n",
"(-2162.3481870617497, -1033.0206139260324, 6.477719407374707)\n",
"2\n",
"200.0\n",
"((-2, -1, 0, 1), (2, 0, -2, 1), (-3, -1, 0, 2))\n",
"(-2262.3481870617497, -795.4772814580131, -93.5222805926253)\n",
"2\n",
"100.0\n",
"((-2, -1, 0, 1), (-2, -2, 0, 2), (-3, -1, 0, 2))\n",
"(-1862.3481870617497, -395.47728145801307, -9.163567593177731)\n",
"2\n",
"-400.0\n",
"((-2, -1, 0, 1), (-2, -2, 0, 2), (-4, -2, 1, 2))\n",
"(35.69681207286271, 1004.5227185419869, 1390.8364324068223)\n",
"0\n",
"-1400.0\n",
"((0, -2, 0, 1), (-2, -2, 0, 2), (-4, -2, 1, 2))\n",
"(-64.30318792713729, 904.5227185419869, 1366.8709056037374)\n",
"0\n",
"100.0\n",
"((0, -2, 0, 1), (-2, -2, 0, 2), (4, -2, 0, 0))\n",
"(-764.3031879271373, -35.08409526165019, 666.8709056037374)\n",
"1\n",
"700.0\n",
"((0, -2, 0, 1), (5, -3, 0, 0), (4, -2, 0, 0))\n",
"(-964.3031879271373, 4.52271854198699, 466.87090560373736)\n",
"1\n",
"200.0\n",
"((0, -2, 0, 1), (-2, -2, 0, 2), (4, -2, 0, 0))\n",
"(-1064.3031879271373, -19.44280826109747, 366.87090560373736)\n",
"1\n",
"100.0\n",
"((0, -2, 0, 1), (6, -2, -1, 0), (4, -2, 0, 0))\n",
"(-664.3031879271373, 37.65181293824946, 766.8709056037374)\n",
"1\n",
"-400.0\n",
"((0, -2, 0, 1), (-1, -1, 0, 1), (4, -2, 0, 0))\n",
"(51.338099073415606, 437.65181293824946, 1166.8709056037374)\n",
"0\n",
"-400.0\n",
"((1, -1, -1, 1), (-1, -1, 0, 1), (4, -2, 0, 0))\n",
"(-1.9550008653869781, 237.65181293824946, 966.8709056037374)\n",
"0\n",
"200.0\n",
"((6, -2, 0, -1), (-1, -1, 0, 1), (4, -2, 0, 0))\n",
"(53.18461946857295, 137.65181293824946, 866.8709056037374)\n",
"0\n",
"100.0\n",
"((1, -2, 1, 0), (-1, -1, 0, 1), (4, -2, 0, 0))\n",
"(-1146.815380531427, -1062.3481870617507, -93.5222805926253)\n",
"2\n",
"1200.0\n",
"((1, -2, 1, 0), (-1, -1, 0, 1), (-3, -1, 0, 2))\n",
"(-946.8153805314271, -862.3481870617507, 22.010525937697366)\n",
"2\n",
"-200.0\n",
"((1, -2, 1, 0), (-1, -1, 0, 1), (-1, -2, 1, 1))\n",
"(-846.8153805314271, -762.3481870617507, -33.129094396262644)\n",
"2\n",
"-100.0\n",
"((1, -2, 1, 0), (-1, -1, 0, 1), (4, -2, 0, 0))\n",
"(39.606813803637806, 537.6518129382493, 1266.8709056037374)\n",
"0\n",
"-1300.0\n",
"((-3, 0, 0, 1), (-1, -1, 0, 1), (4, -2, 0, 0))\n",
"(-960.3931861963622, -462.34818706175065, 8.43272027276214)\n",
"2\n",
"1000.0\n",
"((-3, 0, 0, 1), (-1, -1, 0, 1), (-5, 0, 0, 2))\n",
"(-860.3931861963622, -46.7069000611977, 108.43272027276214)\n",
"1\n",
"-100.0\n",
"((-3, 0, 0, 1), (0, 0, -1, 1), (-5, 0, 0, 2))\n",
"(-660.3931861963622, 41.56181466902444, 308.43272027276214)\n",
"1\n",
"-200.0\n",
"((-3, 0, 0, 1), (-4, 1, 0, 1), (-5, 0, 0, 2))\n",
"(-560.3931861963622, 22.11900640792726, 408.43272027276214)\n",
"1\n",
"-100.0\n",
"((-3, 0, 0, 1), (-3, 0, -1, 2), (-5, 0, 0, 2))\n",
"(-260.3931861963622, -29.21909266548795, 708.4327202727621)\n",
"1\n",
"-300.0\n",
"((-3, 0, 0, 1), (0, 0, 0, 0), (-5, 0, 0, 2))\n",
"(-205.2535658624024, -129.21909266548795, 608.4327202727621)\n",
"0\n",
"100.0\n",
"((-8, 0, 1, 2), (0, 0, 0, 0), (-5, 0, 0, 2))\n",
"(-5.253565862402411, 70.78090733451205, 1039.6068138036371)\n",
"0\n",
"-200.0\n",
"((-8, 0, 1, 2), (0, 0, 0, 0), (-2, 0, 0, 1))\n",
"(-60.393186196362194, 170.78090733451205, 1139.6068138036371)\n",
"0\n",
"-100.0\n",
"((-3, 0, 0, 1), (0, 0, 0, 0), (-2, 0, 0, 1))\n",
"(8.432720272762708, 470.78090733451205, 1439.6068138036371)\n",
"0\n",
"-300.0\n",
"((-6, 0, 0, 2), (0, 0, 0, 0), (-2, 0, 0, 1))\n",
"(-2129.219092665487, -929.219092665488, 39.606813803637124)\n",
"2\n",
"1400.0\n",
"((-1, 0, 0, 0), (0, 0, 0, 0), (-2, 0, 0, 1))\n",
"(-1929.219092665487, -729.219092665488, -27.264091800100346)\n",
"2\n",
"-200.0\n",
"((-1, 0, 0, 0), (0, 0, 0, 0), (-1, 1, 0, 0))\n",
"(-1429.219092665487, -25.30909093471314, 472.73590819989965)\n",
"1\n",
"-500.0\n",
"((-1, 0, 0, 0), (-3, 2, 0, 0), (-1, 1, 0, 0))\n",
"(-1229.219092665487, -29.219092665487977, 672.7359081998997)\n",
"1\n",
"-200.0\n",
"((-1, 0, 0, 0), (0, 0, 0, 0), (-1, 1, 0, 0))\n",
"(3.9100017307753205, 270.780907334512, 972.7359081998997)\n",
"0\n",
"-300.0\n",
"((1, 1, 0, -1), (0, 0, 0, 0), (-1, 1, 0, 0))\n",
"(-796.0899982692247, -529.219092665488, -31.174093530875325)\n",
"2\n",
"800.0\n",
"((1, 1, 0, -1), (0, 0, 0, 0), (2, -1, 0, 0))\n",
"(4.547473508864641e-13, 470.780907334512, 968.8259064691247)\n",
"0\n",
"-1000.0\n",
"((4, -1, 0, -1), (0, 0, 0, 0), (2, -1, 0, 0))\n",
"(-927.2640918000997, -429.219092665488, 68.82590646912467)\n",
"2\n",
"900.0\n",
"((-2, 1, 0, 0), (0, 0, 0, 0), (2, -1, 0, 0))\n",
"(-327.26409180009966, -33.129094396262985, 668.8259064691247)\n",
"1\n",
"-600.0\n",
"((-2, 1, 0, 0), (3, -2, 0, 0), (2, -1, 0, 0))\n",
"(-1435.0840952616495, -733.129094396263, -31.174093530875325)\n",
"2\n",
"700.0\n",
"((4, -3, 0, 0), (3, -2, 0, 0), (2, -1, 0, 0))\n",
"(-1631.1740935308749, 66.87090560373701, 768.8259064691247)\n",
"1\n",
"-800.0\n",
"((0, -1, 0, 0), (3, -2, 0, 0), (2, -1, 0, 0))\n",
"(-235.08409526164962, 466.870905603737, 1168.8259064691247)\n",
"0\n",
"-400.0\n",
"((4, -3, 0, 0), (3, -2, 0, 0), (2, -1, 0, 0))\n",
"(-1464.3031879271375, -33.129094396262985, 668.8259064691247)\n",
"1\n",
"500.0\n",
"((-1, -2, 0, 1), (3, -2, 0, 0), (2, -1, 0, 0))\n",
"(68.82590646912513, 566.870905603737, 1268.8259064691247)\n",
"0\n",
"-600.0\n",
"((1, -1, 0, 0), (3, -2, 0, 0), (2, -1, 0, 0))\n",
"(-1331.1740935308749, -833.129094396263, -19.442808261097525)\n",
"2\n",
"1400.0\n",
"((1, -1, 0, 0), (3, -2, 0, 0), (6, -2, -1, 0))\n",
"(-1531.1740935308749, -1033.129094396263, -64.30318792713797)\n",
"2\n",
"200.0\n",
"((1, -1, 0, 0), (3, -2, 0, 0), (1, -2, 0, 1))\n",
"(-1631.1740935308749, -1133.129094396263, -44.86037966604056)\n",
"2\n",
"100.0\n",
"((1, -1, 0, 0), (3, -2, 0, 0), (0, -1, 1, 0))\n",
"(-31.17409353087487, 466.8709056037369, 964.9159047383497)\n",
"0\n",
"-1600.0\n",
"((1, -1, 0, 0), (3, -2, 0, 0), (5, -3, 0, 0))\n",
"(35.696812072862485, 266.8709056037369, 764.9159047383497)\n",
"0\n",
"200.0\n",
"((0, -2, 0, 1), (3, -2, 0, 0), (5, -3, 0, 0))\n",
"(-1164.3031879271375, -933.1290943962631, 35.69681207286203)\n",
"2\n",
"1200.0\n",
"((0, -2, 0, 1), (3, -2, 0, 0), (1, -2, 0, 1))\n",
"(-364.3031879271375, 22.01052593769691, 835.696812072862)\n",
"1\n",
"-800.0\n",
"((0, -2, 0, 1), (-2, -2, 1, 1), (1, -2, 0, 1))\n",
"(-564.3031879271375, 137.65181293824912, 635.696812072862)\n",
"1\n",
"200.0\n",
"((0, -2, 0, 1), (-1, -1, 0, 1), (1, -2, 0, 1))\n",
"(-433.1290943962623, 37.65181293824912, 535.696812072862)\n",
"1\n",
"100.0\n",
"((3, -2, 0, 0), (-1, -1, 0, 1), (1, -2, 0, 1))\n",
"(-1433.1290943962622, -962.3481870617509, -1.9550008653876603)\n",
"2\n",
"1000.0\n",
"((3, -2, 0, 0), (-1, -1, 0, 1), (7, -2, 0, -1))\n",
"(-233.1290943962622, -1.9550008653880013, 1198.0449991346122)\n",
"1\n",
"-1200.0\n",
"((3, -2, 0, 0), (6, -2, 0, -1), (7, -2, 0, -1))\n",
"(-103.91000173077452, 598.044999134612, 1798.0449991346122)\n",
"0\n",
"-600.0\n",
"((7, -3, 0, -1), (6, -2, 0, -1), (7, -2, 0, -1))\n",
"(11.731285269778198, 398.044999134612, 1598.0449991346122)\n",
"0\n",
"200.0\n",
"((8, -2, -1, -1), (6, -2, 0, -1), (7, -2, 0, -1))\n",
"(-88.2687147302218, 880.5571917389022, 1498.0449991346122)\n",
"0\n",
"100.0\n",
"((8, -2, -1, -1), (6, -2, -1, 0), (7, -2, 0, -1))\n",
"(-1688.2687147302217, -719.4428082610978, -17.487807395710206)\n",
"2\n",
"1600.0\n",
"((8, -2, -1, -1), (6, -2, -1, 0), (5, -1, -1, 0))\n",
"(-888.2687147302217, -31.174093530875666, 782.5121926042898)\n",
"1\n",
"-800.0\n",
"((8, -2, -1, -1), (2, -1, 0, 0), (5, -1, -1, 0))\n",
"(-1588.2687147302217, -731.1740935308757, -29.219092665488006)\n",
"2\n",
"700.0\n",
"((8, -2, -1, -1), (2, -1, 0, 0), (1, 0, 0, 0))\n",
"(-27.264091800099777, 968.8259064691243, 1670.780907334512)\n",
"0\n",
"-1700.0\n",
"((-2, 1, 0, 0), (2, -1, 0, 0), (1, 0, 0, 0))\n",
"(-1427.2640918000998, -431.17409353087567, 3.9100017307741837)\n",
"2\n",
"1400.0\n",
"((-2, 1, 0, 0), (2, -1, 0, 0), (2, 1, 0, -1))\n",
"(35.084095261650305, 568.8259064691243, 1003.9100017307742)\n",
"0\n",
"-1000.0\n",
"((4, 1, 0, -2), (2, -1, 0, 0), (2, 1, 0, -1))\n",
"(-9.776284404389969, 368.82590646912433, 803.9100017307742)\n",
"0\n",
"200.0\n",
"((-1, 1, 1, -1), (2, -1, 0, 0), (2, 1, 0, -1))\n",
"(-609.77628440439, -231.17409353087567, -5.684341886080801e-13)\n",
"2\n",
"600.0\n",
"((-1, 1, 1, -1), (2, -1, 0, 0), (5, -1, 0, -1))\n",
"(-509.77628440439, -11.731285269778482, 99.99999999999943)\n",
"1\n",
"-100.0\n",
"((-1, 1, 1, -1), (1, 0, 1, -1), (5, -1, 0, -1))\n",
"(-1.9550008653870918, 588.2687147302215, 699.9999999999994)\n",
"0\n",
"-600.0\n",
"((6, -2, 0, -1), (1, 0, 1, -1), (5, -1, 0, -1))\n",
"(-501.9550008653871, -31.174093530875666, 199.99999999999943)\n",
"1\n",
"500.0\n",
"((6, -2, 0, -1), (2, -1, 0, 0), (5, -1, 0, -1))\n",
"(-201.9550008653871, 1.9550008653868645, 499.99999999999943)\n",
"1\n",
"-300.0\n",
"((6, -2, 0, -1), (3, 0, 0, -1), (5, -1, 0, -1))\n",
"(-1.9550008653870918, 201.95500086538686, 1696.089998269225)\n",
"1\n",
"-200.0\n",
"((6, -2, 0, -1), (3, 0, 0, -1), (9, -3, 0, -1))\n",
"(9.776284404390879, 101.95500086538686, 1596.089998269225)\n",
"0\n",
"100.0\n",
"((10, -3, -1, -1), (3, 0, 0, -1), (9, -3, 0, -1))\n",
"(-1.9550008653870918, 201.95500086538686, 1696.089998269225)\n",
"0\n",
"-100.0\n",
"((6, -2, 0, -1), (3, 0, 0, -1), (9, -3, 0, -1))\n",
"(-17.5962878659397, 501.95500086538686, 1996.089998269225)\n",
"0\n",
"-300.0\n",
"((5, -3, 1, -1), (3, 0, 0, -1), (9, -3, 0, -1))\n",
"(3.410605131648481e-13, 701.9550008653869, 2196.089998269225)\n",
"0\n",
"-200.0\n",
"((4, -1, 0, -1), (3, 0, 0, -1), (9, -3, 0, -1))\n",
"(-1399.9999999999995, -698.0449991346131, 3.9100017307741837)\n",
"2\n",
"1400.0\n",
"((4, -1, 0, -1), (3, 0, 0, -1), (2, 1, 0, -1))\n",
"(-1199.9999999999995, -498.04499913461314, -5.684341886080801e-13)\n",
"2\n",
"-200.0\n",
"((4, -1, 0, -1), (3, 0, 0, -1), (5, -1, 0, -1))\n",
"(-468.8259064691247, 1.9550008653868645, 499.99999999999943)\n",
"1\n",
"-500.0\n",
"((7, -1, 0, -2), (3, 0, 0, -1), (5, -1, 0, -1))\n",
"(-268.8259064691247, -1.955000865387973, 699.9999999999994)\n",
"1\n",
"-200.0\n",
"((7, -1, 0, -2), (6, -2, 0, -1), (5, -1, 0, -1))\n",
"(31.174093530875325, 298.044999134612, 1111.7312852697773)\n",
"0\n",
"-300.0\n",
"((7, -1, 0, -2), (6, -2, 0, -1), (9, -2, -1, -1))\n",
"(4.547473508864641e-13, 498.044999134612, 1311.7312852697773)\n",
"0\n",
"-200.0\n",
"((4, -1, 0, -1), (6, -2, 0, -1), (9, -2, -1, -1))\n",
"(-999.9999999999995, -501.955000865388, -31.174093530875552)\n",
"2\n",
"1000.0\n",
"((4, -1, 0, -1), (6, -2, 0, -1), (2, -1, 0, 0))\n",
"(-199.99999999999955, 31.174093530874302, 768.8259064691244)\n",
"1\n",
"-800.0\n",
"((4, -1, 0, -1), (7, -1, 0, -2), (2, -1, 0, 0))\n",
"(-699.9999999999995, -468.8259064691257, 29.219092665487096)\n",
"2\n",
"500.0\n",
"((4, -1, 0, -1), (7, -1, 0, -2), (9, -2, 0, -2))\n",
"(-1399.9999999999995, -1168.8259064691256, 31.174093530874643)\n",
"2\n",
"700.0\n",
"((4, -1, 0, -1), (7, -1, 0, -2), (8, -1, 0, -2))\n",
"(-299.99999999999955, -68.82590646912558, 668.8259064691246)\n",
"1\n",
"-1100.0\n",
"((4, -1, 0, -1), (7, -1, 0, -2), (2, -1, 0, 0))\n",
"(-999.9999999999995, -417.48780739571026, -31.17409353087544)\n",
"2\n",
"700.0\n",
"((4, -1, 0, -1), (4, -1, -1, 0), (2, -1, 0, 0))\n",
"(68.82590646912536, 882.5121926042898, 1268.8259064691247)\n",
"0\n",
"-1300.0\n",
"((1, -1, 0, 0), (4, -1, -1, 0), (2, -1, 0, 0))\n",
"(-231.17409353087464, -4.547473508864641e-13, 968.8259064691247)\n",
"1\n",
"300.0\n",
"((1, -1, 0, 0), (4, -1, 0, -1), (2, -1, 0, 0))\n",
"(-931.1740935308746, 37.65181293824935, 268.8259064691247)\n",
"1\n",
"700.0\n",
"((1, -1, 0, 0), (-1, -1, 0, 1), (2, -1, 0, 0))\n",
"(-31.174093530874643, 937.6518129382493, 1323.9655268030845)\n",
"0\n",
"-900.0\n",
"((1, -1, 0, 0), (-1, -1, 0, 1), (-3, -1, 1, 1))\n",
"(-531.1740935308746, 10.279240667918998, 823.9655268030845)\n",
"1\n",
"500.0\n",
"((1, -1, 0, 0), (-6, -1, 2, 1), (-3, -1, 1, 1))\n",
"(37.65181293825026, 810.279240667919, 1623.9655268030845)\n",
"0\n",
"-800.0\n",
"((-2, -1, 0, 1), (-6, -1, 2, 1), (-3, -1, 1, 1))\n",
"(-44.86037966603976, 110.279240667919, 923.9655268030845)\n",
"0\n",
"700.0\n",
"((-1, -1, 1, 0), (-6, -1, 2, 1), (-3, -1, 1, 1))\n",
"(-144.86037966603976, 10.279240667918998, 241.4533341987942)\n",
"0\n",
"100.0\n",
"((-1, -1, 1, 0), (-6, -1, 2, 1), (-3, -1, 2, 0))\n",
"(-1044.8603796660398, -889.720759332081, -76.03447319691554)\n",
"2\n",
"900.0\n",
"((-1, -1, 1, 0), (-6, -1, 2, 1), (-3, -1, 1, 1))\n",
"(12.234241533307568, 510.279240667919, 1323.9655268030845)\n",
"0\n",
"-1400.0\n",
"((-8, 0, 2, 1), (-6, -1, 2, 1), (-3, -1, 1, 1))\n",
"(-1087.7657584666924, -589.720759332081, -91.67576019746821)\n",
"2\n",
"1100.0\n",
"((-8, 0, 2, 1), (-6, -1, 2, 1), (-4, -2, 2, 1))\n",
"(-687.7657584666924, 14.189242398693978, 308.3242398025318)\n",
"1\n",
"-400.0\n",
"((-8, 0, 2, 1), (-9, 1, 2, 1), (-4, -2, 2, 1))\n",
"(-387.76575846669243, -1.4520446018586313, 608.3242398025318)\n",
"1\n",
"-300.0\n",
"((-8, 0, 2, 1), (-10, 0, 3, 1), (-4, -2, 2, 1))\n",
"(-1387.7657584666924, -1001.4520446018587, -32.62613813273333)\n",
"2\n",
"1000.0\n",
"((-8, 0, 2, 1), (-10, 0, 3, 1), (-12, 0, 3, 2))\n",
"(-32.62613813273265, 198.5479553981413, 1167.3738618672667)\n",
"0\n",
"-1200.0\n",
"((-13, 0, 3, 2), (-10, 0, 3, 1), (-12, 0, 3, 2))\n",
"(-1830.6711372673453, -1101.4520446018587, -132.62613813273333)\n",
"2\n",
"1300.0\n",
"((-15, 1, 3, 2), (-10, 0, 3, 1), (-12, 0, 3, 2))\n",
"(-2201.452044601858, -1001.4520446018587, -32.62613813273333)\n",
"2\n",
"-100.0\n",
"((-11, 0, 3, 1), (-10, 0, 3, 1), (-12, 0, 3, 2))\n",
"(-2401.452044601858, -815.1383307370238, -232.62613813273333)\n",
"2\n",
"200.0\n",
"((-11, 0, 3, 1), (-12, 0, 4, 1), (-12, 0, 3, 2))\n",
"(36.199768336392026, 884.8616692629762, 1467.3738618672667)\n",
"0\n",
"-1700.0\n",
"((-16, 0, 3, 3), (-12, 0, 4, 1), (-12, 0, 3, 2))\n",
"(-763.800231663608, -34.58113899812122, 667.3738618672667)\n",
"1\n",
"800.0\n",
"((-16, 0, 3, 3), (-11, -1, 3, 2), (-12, 0, 3, 2))\n",
"(-1563.800231663608, -834.5811389981212, 22.51348220122634)\n",
"2\n",
"800.0\n",
"((-16, 0, 3, 3), (-11, -1, 3, 2), (-17, 0, 4, 3))\n",
"(-863.800231663608, 20.558481335838565, 722.5134822012263)\n",
"1\n",
"-700.0\n",
"((-16, 0, 3, 3), (-16, -1, 4, 3), (-17, 0, 4, 3))\n",
"(-763.800231663608, 8.827196066060935, 822.5134822012263)\n",
"1\n",
"-100.0\n",
"((-16, 0, 3, 3), (-20, 0, 5, 3), (-17, 0, 4, 3))\n",
"(-1463.800231663608, -691.1728039339391, -32.62613813273333)\n",
"2\n",
"700.0\n",
"((-16, 0, 3, 3), (-20, 0, 5, 3), (-12, 0, 3, 2))\n",
"(-963.800231663608, -30.67113726734624, 467.37386186726667)\n",
"1\n",
"-500.0\n",
"((-16, 0, 3, 3), (-14, 1, 3, 2), (-12, 0, 3, 2))\n",
"(-32.626138132732876, 669.3288627326538, 1167.3738618672667)\n",
"0\n",
"-700.0\n",
"((-13, 0, 3, 2), (-14, 1, 3, 2), (-12, 0, 3, 2))\n",
"(-246.312424267898, 69.32886273265376, 567.3738618672667)\n",
"1\n",
"600.0\n",
"((-15, 0, 4, 2), (-14, 1, 3, 2), (-12, 0, 3, 2))\n",
"(71.28386359804199, 569.3288627326538, 1067.3738618672667)\n",
"0\n",
"-500.0\n",
"((-16, 2, 3, 2), (-14, 1, 3, 2), (-12, 0, 3, 2))\n",
"(-828.716136401958, -330.67113726734624, -15.02985026679346)\n",
"2\n",
"900.0\n",
"((-16, 2, 3, 2), (-14, 1, 3, 2), (-13, 2, 2, 2))\n",
"(16.144243264082206, 669.3288627326538, 984.9701497332065)\n",
"0\n",
"-1000.0\n",
"((-11, 2, 2, 1), (-14, 1, 3, 2), (-13, 2, 2, 2))\n",
"(-1083.8557567359178, -430.67113726734624, -44.35742340251136)\n",
"2\n",
"1100.0\n",
"((-11, 2, 2, 1), (-14, 1, 3, 2), (-16, 1, 4, 2))\n",
"(-483.8557567359178, 14.189242398693978, 555.6425765974886)\n",
"1\n",
"-600.0\n",
"((-11, 2, 2, 1), (-9, 1, 2, 1), (-16, 1, 4, 2))\n",
"(41.95629046232415, 314.189242398694, 855.6425765974886)\n",
"0\n",
"-300.0\n",
"((-19, 1, 5, 2), (-9, 1, 2, 1), (-16, 1, 4, 2))\n",
"(-13.183329871635635, 414.189242398694, 955.6425765974886)\n",
"0\n",
"-100.0\n",
"((-14, 1, 4, 1), (-9, 1, 2, 1), (-16, 1, 4, 2))\n",
"(-213.18332987163564, 17.990763659238695, 755.6425765974886)\n",
"1\n",
"200.0\n",
"((-14, 1, 4, 1), (-11, 1, 4, 0), (-16, 1, 4, 2))\n",
"(-1213.1833298716356, -982.0092363407613, -13.183329871636147)\n",
"2\n",
"1000.0\n",
"((-14, 1, 4, 1), (-11, 1, 4, 0), (-13, 1, 4, 1))\n",
"(-313.1833298716356, -82.00923634076128, 1384.8616692629762)\n",
"1\n",
"-900.0\n",
"((-14, 1, 4, 1), (-11, 1, 4, 0), (-11, 0, 4, 1))\n",
"(86.81667012836442, 353.68757573210115, 1784.8616692629762)\n",
"0\n",
"-400.0\n",
"((-14, 1, 4, 1), (-15, 0, 4, 2), (-11, 0, 4, 1))\n",
"(-1113.1833298716356, -846.3124242678989, -32.62613813273356)\n",
"2\n",
"1200.0\n",
"((-14, 1, 4, 1), (-15, 0, 4, 2), (-12, 0, 3, 2))\n",
"(-63.800231663607974, 553.6875757321011, 1367.3738618672664)\n",
"0\n",
"-1400.0\n",
"((-16, 0, 3, 3), (-15, 0, 4, 2), (-12, 0, 3, 2))\n",
"(-863.800231663608, 69.32886273265376, 567.3738618672664)\n",
"1\n",
"800.0\n",
"((-16, 0, 3, 3), (-14, 1, 3, 2), (-12, 0, 3, 2))\n",
"(67.37386186726712, 769.3288627326538, 1267.3738618672664)\n",
"0\n",
"-700.0\n",
"((-13, 0, 3, 2), (-14, 1, 3, 2), (-12, 0, 3, 2))\n",
"(-532.6261381327329, -34.58113899812122, 667.3738618672664)\n",
"1\n",
"600.0\n",
"((-13, 0, 3, 2), (-11, -1, 3, 2), (-12, 0, 3, 2))\n",
"(-20.894852862955418, 365.4188610018788, 1067.3738618672664)\n",
"0\n",
"-400.0\n",
"((-9, -1, 2, 2), (-11, -1, 3, 2), (-12, 0, 3, 2))\n",
"(-1220.8948528629553, -834.5811389981212, -20.894852862956213)\n",
"2\n",
"1200.0\n",
"((-9, -1, 2, 2), (-11, -1, 3, 2), (-8, -1, 2, 2))\n",
"(-32.62613813273265, 465.4188610018788, 1279.1051471370438)\n",
"0\n",
"-1300.0\n",
"((-13, 0, 3, 2), (-11, -1, 3, 2), (-8, -1, 2, 2))\n",
"(-1432.6261381327326, -934.5811389981212, -1.452044601858688)\n",
"2\n",
"1400.0\n",
"((-13, 0, 3, 2), (-11, -1, 3, 2), (-9, 0, 3, 1))\n",
"(-1032.6261381327326, -534.5811389981212, -36.53613986350865)\n",
"2\n",
"-400.0\n",
"((-13, 0, 3, 2), (-11, -1, 3, 2), (-9, -2, 3, 2))\n",
"(-632.6261381327326, -22.849853728343305, 363.46386013649135)\n",
"1\n",
"-400.0\n",
"((-13, 0, 3, 2), (-7, -2, 2, 2), (-9, -2, 3, 2))\n",
"(-732.6261381327326, -30.671137267346268, 263.46386013649135)\n",
"1\n",
"100.0\n",
"((-13, 0, 3, 2), (-14, 1, 3, 2), (-9, -2, 3, 2))\n",
"(-332.62613813273265, -38.49114072889597, 663.4638601364913)\n",
"1\n",
"-400.0\n",
"((-13, 0, 3, 2), (-8, -3, 3, 2), (-9, -2, 3, 2))\n",
"(-69.66523425976993, 161.50885927110403, 863.4638601364913)\n",
"0\n",
"-200.0\n",
"((-11, -3, 3, 3), (-8, -3, 3, 2), (-9, -2, 3, 2))\n",
"(-50.222425998672634, 61.50885927110403, 763.4638601364913)\n",
"0\n",
"100.0\n",
"((-12, -2, 4, 2), (-8, -3, 3, 2), (-9, -2, 3, 2))\n",
"(-36.53613986350746, 461.50885927110403, 1163.4638601364913)\n",
"0\n",
"-400.0\n",
"((-10, -2, 3, 2), (-8, -3, 3, 2), (-9, -2, 3, 2))\n",
"(-1736.5361398635075, -1238.491140728896, -38.49114072889597)\n",
"2\n",
"1700.0\n",
"((-10, -2, 3, 2), (-8, -3, 3, 2), (-7, -3, 3, 2))\n",
"(-1236.5361398635075, -36.53613986350854, 461.50885927110403)\n",
"1\n",
"-500.0\n",
"((-10, -2, 3, 2), (-9, -2, 3, 2), (-7, -3, 3, 2))\n",
"(-1636.5361398635075, -436.53613986350854, -50.22242599867377)\n",
"2\n",
"400.0\n",
"((-10, -2, 3, 2), (-9, -2, 3, 2), (-11, -2, 4, 2))\n",
"(-1436.5361398635075, -236.53613986350854, -5.362046332633668)\n",
"2\n",
"-200.0\n",
"((-10, -2, 3, 2), (-9, -2, 3, 2), (-6, -2, 3, 1))\n",
"(-1636.5361398635075, -436.53613986350854, -50.22242599867377)\n",
"2\n",
"200.0\n",
"((-10, -2, 3, 2), (-9, -2, 3, 2), (-11, -2, 4, 2))\n",
"(-1036.5361398635075, 51.73257486671355, 549.7775740013262)\n",
"1\n",
"-600.0\n",
"((-10, -2, 3, 2), (-13, -1, 4, 2), (-11, -2, 4, 2))\n",
"(-1436.5361398635075, -348.26742513328645, 38.04628873154809)\n",
"2\n",
"400.0\n",
"((-10, -2, 3, 2), (-13, -1, 4, 2), (-15, -1, 5, 2))\n",
"(-34.581138998120196, 351.73257486671355, 738.0462887315481)\n",
"0\n",
"-700.0\n",
"((-11, -1, 3, 2), (-13, -1, 4, 2), (-15, -1, 5, 2))\n",
"(-234.5811389981202, -3.4070454672462347, 538.0462887315481)\n",
"1\n",
"200.0\n",
"((-11, -1, 3, 2), (-8, -1, 3, 1), (-15, -1, 5, 2))\n",
"(-34.581138998120196, 36.09128786616128, 738.0462887315481)\n",
"1\n",
"-200.0\n",
"((-11, -1, 3, 2), (-14, -2, 5, 2), (-15, -1, 5, 2))\n",
"(-234.5811389981202, -3.4070454672462347, 538.0462887315481)\n",
"1\n",
"200.0\n",
"((-11, -1, 3, 2), (-8, -1, 3, 1), (-15, -1, 5, 2))\n",
"(-30.77961773757545, 396.59295453275377, 938.0462887315481)\n",
"0\n",
"-400.0\n",
"((-13, -1, 5, 1), (-8, -1, 3, 1), (-15, -1, 5, 2))\n",
"(-230.77961773757545, 36.09128786616128, 738.0462887315481)\n",
"1\n",
"200.0\n",
"((-13, -1, 5, 1), (-14, -2, 5, 2), (-15, -1, 5, 2))\n",
"(69.22038226242455, 882.9066683975889, 1038.046288731548)\n",
"0\n",
"-300.0\n",
"((-13, -1, 5, 1), (-10, -1, 4, 1), (-15, -1, 5, 2))\n",
"(114.08076192846477, 1082.9066683975889, 1238.046288731548)\n",
"0\n",
"-200.0\n",
"((-8, -1, 4, 0), (-10, -1, 4, 1), (-15, -1, 5, 2))\n",
"(69.22038226242455, 882.9066683975889, 1038.046288731548)\n",
"0\n",
"200.0\n",
"((-13, -1, 5, 1), (-10, -1, 4, 1), (-15, -1, 5, 2))\n",
"(-1459.998710403063, 82.90666839758887, 238.04628873154797)\n",
"2\n",
"800.0\n",
"((-18, 0, 5, 2), (-10, -1, 4, 1), (-15, -1, 5, 2))\n",
"(114.08076192846488, 1082.9066683975889, 1238.046288731548)\n",
"0\n",
"-1000.0\n",
"((-8, -1, 4, 0), (-10, -1, 4, 1), (-15, -1, 5, 2))\n",
"(-1563.9087121338375, 182.90666839758887, 338.046288731548)\n",
"2\n",
"900.0\n",
"((-15, -2, 5, 2), (-10, -1, 4, 1), (-15, -1, 5, 2))\n",
"(-1663.9087121338375, -695.0828056647139, 238.04628873154797)\n",
"2\n",
"100.0\n",
"((-15, -2, 5, 2), (-17, -2, 5, 3), (-15, -1, 5, 2))\n",
"(-963.9087121338375, 4.917194335286126, 818.6034804704511)\n",
"1\n",
"-700.0\n",
"((-15, -2, 5, 2), (-17, -2, 5, 3), (-14, -2, 4, 3))\n",
"(-1863.9087121338375, -895.0828056647139, 38.046288731547975)\n",
"2\n",
"900.0\n",
"((-15, -2, 5, 2), (-17, -2, 5, 3), (-15, -1, 5, 2))\n",
"(-863.9087121338375, -50.22242599867354, 1038.046288731548)\n",
"1\n",
"-1000.0\n",
"((-15, -2, 5, 2), (-12, -2, 4, 2), (-15, -1, 5, 2))\n",
"(-963.9087121338375, 4.917194335286155, 938.046288731548)\n",
"1\n",
"100.0\n",
"((-15, -2, 5, 2), (-17, -2, 5, 3), (-15, -1, 5, 2))\n",
"(6.872195200674355, 504.9171943352861, 1438.046288731548)\n",
"0\n",
"-500.0\n",
"((-19, -1, 5, 3), (-17, -2, 5, 3), (-15, -1, 5, 2))\n",
"(-693.1278047993256, 8.827196066060992, 738.046288731548)\n",
"1\n",
"700.0\n",
"((-19, -1, 5, 3), (-20, 0, 5, 3), (-15, -1, 5, 2))\n",
"(-4.8590900691032175, 808.827196066061, 1538.046288731548)\n",
"0\n",
"-800.0\n",
"((-23, 0, 6, 3), (-20, 0, 5, 3), (-15, -1, 5, 2))\n",
"(6.872195200674355, 708.827196066061, 1438.046288731548)\n",
"0\n",
"100.0\n",
"((-19, -1, 5, 3), (-20, 0, 5, 3), (-15, -1, 5, 2))\n",
"(10.782196931449334, 508.827196066061, 1238.046288731548)\n",
"0\n",
"200.0\n",
"((-22, 1, 5, 3), (-20, 0, 5, 3), (-15, -1, 5, 2))\n",
"(-1289.2178030685507, -791.172803933939, 22.513482201225997)\n",
"2\n",
"1300.0\n",
"((-22, 1, 5, 3), (-20, 0, 5, 3), (-17, 0, 4, 3))\n",
"(-1389.2178030685507, -891.172803933939, 41.956290462323295)\n",
"2\n",
"100.0\n",
"((-22, 1, 5, 3), (-20, 0, 5, 3), (-18, 1, 5, 2))\n",
"(-1289.2178030685507, -791.172803933939, 22.513482201225997)\n",
"2\n",
"-100.0\n",
"((-22, 1, 5, 3), (-20, 0, 5, 3), (-17, 0, 4, 3))\n",
"(-1189.2178030685507, -691.172803933939, 10.782196931448198)\n",
"2\n",
"-100.0\n",
"((-22, 1, 5, 3), (-20, 0, 5, 3), (-21, 1, 5, 3))\n",
"(-1289.2178030685507, -791.172803933939, 22.513482201225997)\n",
"2\n",
"100.0\n",
"((-22, 1, 5, 3), (-20, 0, 5, 3), (-17, 0, 4, 3))\n",
"(-589.2178030685507, 20.558481335838678, 722.513482201226)\n",
"1\n",
"-700.0\n",
"((-22, 1, 5, 3), (-16, -1, 4, 3), (-17, 0, 4, 3))\n",
"(-689.2178030685507, 12.737197796835886, 622.513482201226)\n",
"1\n",
"100.0\n",
"((-22, 1, 5, 3), (-23, 2, 5, 3), (-17, 0, 4, 3))\n",
"(-589.2178030685507, 20.558481335838678, 722.513482201226)\n",
"1\n",
"-100.0\n",
"((-22, 1, 5, 3), (-16, -1, 4, 3), (-17, 0, 4, 3))\n",
"(-489.21780306855067, 8.827196066061049, 822.513482201226)\n",
"1\n",
"-100.0\n",
"((-22, 1, 5, 3), (-20, 0, 5, 3), (-17, 0, 4, 3))\n",
"(-589.2178030685507, 20.558481335838678, 722.513482201226)\n",
"1\n",
"100.0\n",
"((-22, 1, 5, 3), (-16, -1, 4, 3), (-17, 0, 4, 3))\n",
"(22.513482201227134, 520.5584813358387, 1222.513482201226)\n",
"0\n",
"-500.0\n",
"((-18, 0, 4, 3), (-16, -1, 4, 3), (-17, 0, 4, 3))\n",
"(34.24476747100488, 420.5584813358387, 1122.513482201226)\n",
"0\n",
"100.0\n",
"((-14, -1, 3, 3), (-16, -1, 4, 3), (-17, 0, 4, 3))\n",
"(-265.7552325289951, -34.581138998121105, 822.513482201226)\n",
"1\n",
"300.0\n",
"((-14, -1, 3, 3), (-11, -1, 3, 2), (-17, 0, 4, 3))\n",
"(-20.894852862955133, 365.4188610018789, 1222.513482201226)\n",
"0\n",
"-400.0\n",
"((-9, -1, 2, 2), (-11, -1, 3, 2), (-17, 0, 4, 3))\n",
"(-32.62613813273259, 465.4188610018789, 1322.513482201226)\n",
"0\n",
"-100.0\n",
"((-13, 0, 3, 2), (-11, -1, 3, 2), (-17, 0, 4, 3))\n",
"(-20.894852862955133, 365.4188610018789, 1222.513482201226)\n",
"0\n",
"100.0\n",
"((-9, -1, 2, 2), (-11, -1, 3, 2), (-17, 0, 4, 3))\n",
"(-32.62613813273259, 465.4188610018789, 1322.513482201226)\n",
"0\n",
"-100.0\n",
"((-13, 0, 3, 2), (-11, -1, 3, 2), (-17, 0, 4, 3))\n",
"(-732.6261381327326, -30.671137267346126, 622.513482201226)\n",
"1\n",
"700.0\n",
"((-13, 0, 3, 2), (-14, 1, 3, 2), (-17, 0, 4, 3))\n",
"(-532.6261381327326, -34.581138998121105, 822.513482201226)\n",
"1\n",
"-200.0\n",
"((-13, 0, 3, 2), (-11, -1, 3, 2), (-17, 0, 4, 3))\n",
"(34.24476747100482, 265.4188610018789, 1122.513482201226)\n",
"0\n",
"-300.0\n",
"((-14, -1, 3, 3), (-11, -1, 3, 2), (-17, 0, 4, 3))\n",
"(-32.62613813273265, 465.4188610018789, 1322.513482201226)\n",
"0\n",
"-200.0\n",
"((-13, 0, 3, 2), (-11, -1, 3, 2), (-17, 0, 4, 3))\n",
"(-332.62613813273265, 53.687575732101266, 1022.513482201226)\n",
"1\n",
"300.0\n",
"((-13, 0, 3, 2), (-15, 0, 4, 2), (-17, 0, 4, 3))\n",
"(-232.62613813273265, -1.4520446018584892, 1122.513482201226)\n",
"1\n",
"-100.0\n",
"((-13, 0, 3, 2), (-10, 0, 3, 1), (-17, 0, 4, 3))\n",
"(12.234241533307625, 398.54795539814154, 1522.513482201226)\n",
"0\n",
"-400.0\n",
"((-8, 0, 2, 1), (-10, 0, 3, 1), (-17, 0, 4, 3))\n",
"(-487.7657584666924, 10.279240667919112, 1022.513482201226)\n",
"1\n",
"500.0\n",
"((-8, 0, 2, 1), (-6, -1, 2, 1), (-17, 0, 4, 3))\n",
"(36.19976833639225, 610.2792406679191, 1622.513482201226)\n",
"0\n",
"-600.0\n",
"((-16, 0, 3, 3), (-6, -1, 2, 1), (-17, 0, 4, 3))\n",
"(-763.8002316636077, 8.827196066060992, 822.513482201226)\n",
"1\n",
"800.0\n",
"((-16, 0, 3, 3), (-20, 0, 5, 3), (-17, 0, 4, 3))\n",
"(6.872195200674355, 708.827196066061, 1522.513482201226)\n",
"0\n",
"-700.0\n",
"((-19, -1, 5, 3), (-20, 0, 5, 3), (-17, 0, 4, 3))\n",
"(-793.1278047993256, 20.558481335838678, 722.513482201226)\n",
"1\n",
"800.0\n",
"((-19, -1, 5, 3), (-16, -1, 4, 3), (-17, 0, 4, 3))\n",
"(-693.1278047993256, 8.827196066061049, 822.513482201226)\n",
"1\n",
"-100.0\n",
"((-19, -1, 5, 3), (-20, 0, 5, 3), (-17, 0, 4, 3))\n",
"(10.782196931449334, 508.82719606606105, 1322.513482201226)\n",
"0\n",
"-500.0\n",
"((-22, 1, 5, 3), (-20, 0, 5, 3), (-17, 0, 4, 3))\n",
"(22.513482201227134, 408.82719606606105, 1222.513482201226)\n",
"0\n",
"100.0\n",
"((-18, 0, 4, 3), (-20, 0, 5, 3), (-17, 0, 4, 3))\n",
"(10.782196931449334, 508.82719606606105, 1322.513482201226)\n",
"0\n",
"-100.0\n",
"((-22, 1, 5, 3), (-20, 0, 5, 3), (-17, 0, 4, 3))\n",
"(-289.21780306855067, -58.04370953767648, 1022.513482201226)\n",
"1\n",
"300.0\n",
"((-22, 1, 5, 3), (-19, 1, 5, 2), (-17, 0, 4, 3))\n",
"(-189.21780306855067, 41.95629046232352, 1241.9562904623233)\n",
"1\n",
"-100.0\n",
"((-22, 1, 5, 3), (-19, 1, 5, 2), (-18, 1, 5, 2))\n",
"(-56.088708672288135, 441.9562904623235, 1641.9562904623233)\n",
"0\n",
"-400.0\n",
"((-21, 2, 5, 2), (-19, 1, 5, 2), (-18, 1, 5, 2))\n",
"(-756.0887086722881, -26.86961600680138, 941.9562904623233)\n",
"1\n",
"700.0\n",
"((-21, 2, 5, 2), (-16, 1, 5, 1), (-18, 1, 5, 2))\n",
"(-40.5559021419657, 773.1303839931986, 1741.9562904623233)\n",
"0\n",
"-800.0\n",
"((-19, 1, 6, 1), (-16, 1, 5, 1), (-18, 1, 5, 2))\n",
"(-1040.5559021419658, 40.0012895969362, 741.9562904623233)\n",
"1\n",
"1000.0\n",
"((-19, 1, 6, 1), (-17, 0, 5, 2), (-18, 1, 5, 2))\n",
"(38.04628873154911, 740.0012895969362, 1441.9562904623233)\n",
"0\n",
"-700.0\n"
]
}
],
"source": [
"path = stochastic_hamiltonian(graph)\n",
"#durs = tuple(round(y[0]-x[0], 2) for (x, y) in pairwise(target_melody_data)) + ((1,))\n",
"durs = tuple(d[0] for d in target_melody_data)\n",
"path_to_chords(path, root)\n",
"write_chord_sequence(list(zip(durs, path_to_chords(path, root))))"
]
},
{
"cell_type": "code",
"execution_count": 185,
"id": "6a13bec1-1a48-4647-821e-f1779976d80f",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.63746202768425"
]
},
"execution_count": 185,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"hs_array_to_fr((14, -5, -3, 0, -1, 1))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python (compact sets)",
"language": "python",
"name": "compact_sets"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
}
},
"nbformat": 4,
"nbformat_minor": 5
}