Beispiel #1
0
def kpdve_stream_string(kpdve, notegroup):
    '''
    info optimized for seeing terminal process.



    >>> kpdve_stream_string(np.array([0,0,0,4,2]), 0b110010000000)
    '0x0022c80 <--> 111111100000 :    C Major (tonic)    === 110010000000 : F as IV  '

    '''

    hexstring = "0x" + hex(pt_utils.minimal_bin_kpdve(notegroup,
                                                      kpdve))[2:].zfill(7)
    description_string = hexstring + " <--> "
    kpstring = format(pt_keypattern.get_binary_KP(kpdve[0], kpdve[1]),
                      "b").zfill(12)
    #description_string += "mode : "
    description_string += kpstring + " : "
    tonicstring = conv_tonic_name_for_kpdve(kpdve).rjust(4)
    patternstring = PATTERN_CONVENTIONAL_NAMES[kpdve[1]].ljust(16)
    description_string += tonicstring + " " + patternstring
    description_string += " === "
    description_string += format(pt_keypattern.get_binary_KPDVE_chord(kpdve),
                                 "b").zfill(12) + " : "
    #description_string += "chord: "
    description_string += chord_root_name_for_KPDVE(
        kpdve) + " as " + chord_function_in_key(kpdve).ljust(4)

    return description_string
Beispiel #2
0
def show_terminal_output(current_state):
    ng_fifths = pt_utils.c_chrom_to_f_circle(current_state.current_binary)
    ng_kp = pt_keypattern.get_binary_KP(current_state.current_kpdve[0],
                                        current_state.current_kpdve[1])
    print("Ob" + bin(ng_fifths)[2:].zfill(12) + "    " +
          current_state.current_root_string() + " as " +
          current_state.current_function_string())
    print("Ob" + bin(ng_kp)[2:].zfill(12) + " of " +
          current_state.current_conv_tonic_string() + " " +
          current_state.current_conv_pattern_string())
Beispiel #3
0
    def __init__(self, ref_state):
        self.current_state = ref_state

        self.window = tkinter.Tk()
        self.window.wm_title("Representations of Harmonic Process")

        self.fig, self.ax = plt.subplots(4, figsize=(12,3))

        self.chr_img = self.ax[0].imshow(np.expand_dims(self.current_state.chroma_values, axis=0), vmin=0.0, vmax=1.0)
        self.ng_img = self.ax[1].imshow(self.heatmap_axis(pt_utils.c_chrom_to_f_circle(self.current_state.current_binary)))
        self.kp_img = self.ax[2].imshow(self.heatmap_axis(pt_keypattern.get_binary_KP(self.current_state.current_kpdve[0], self.current_state.current_kpdve[1])))

        plt.show(block=False)

        self.canvas = FigureCanvasTkAgg(self.fig, master=self.window)  # A tk.DrawingArea.
        self.canvas.draw()

        self.window.update()
Beispiel #4
0
    def change_notegroup(self, notegroup, v_opt=0):
        '''
        Generate the harmonic context from a binary notegroup

        Parameters
        ----------
        notegroup : int
            a chromatic pitch-class set.

        Returns
        -------
        True if changed, False if no change is NECESSARY

        '''

        # BIG QUESTION: SHOULD THIS STAY IN THE SAME CHORD IF THE or OPERATIONS ALLOWS?
        if (notegroup == self.current_binary):
            return False

        # if ((notegroup & self.current_binary) == notegroup): # NO CHANGE IN CHORD IS *NECESSARY*
        #     self.current_binary = notegroup
        #     return False

        probe_kpdve = partita.analyze_binary_input_for_closest_KPDVE(
            notegroup, self.current_kpdve)
        self.valid_state = (np.array_equal(probe_kpdve,
                                           pt_utils.MODVALS) == False)

        if self.valid_state:
            self.current_kpdve = np.copy(probe_kpdve)
            self.current_binary = notegroup
            ng_fifths = pt_utils.c_chrom_to_f_circle(self.current_binary)
            ng_kp = pt_keypattern.get_binary_KP(self.current_kpdve[0],
                                                self.current_kpdve[1])
            if (ng_fifths & ng_kp != ng_fifths):
                print("mismatch in fifths/kp")
            return True

        return False
Beispiel #5
0
 def update_window_for_state(self):
     self.chr_img.set_data(np.expand_dims(pt_utils.numpy_chrom_to_circle(self.current_state.chroma_values), axis=0))
     self.ng_img.set_data(self.heatmap_axis(pt_utils.c_chrom_to_f_circle(self.current_state.current_binary)))
     self.kp_img.set_data(self.heatmap_axis(pt_keypattern.get_binary_KP(self.current_state.current_kpdve[0], self.current_state.current_kpdve[1])))
     self.fig.canvas.flush_events()