From a21992a9015c87a17c355370f278790e1d27af8b Mon Sep 17 00:00:00 2001 From: UtaUtaUtau Date: Thu, 11 Jun 2020 19:20:15 +0800 Subject: [PATCH] Added deepcopy functions The function copy() has been added to classes Envelope, Mode1Pitch, Mode2Pitch, Vibrato, and Note --- README.md | 15 +++++++++++++++ pyutau.py | 20 +++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ef70a33..a7dc70c 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,9 @@ A class that stores note data.
set_multiple_data(self, **kwargs)
Sets multiple data because note_data is a dictionary. Just.. yeah.
+ +
copy(self)
+
Returns a deep copy of the note.
***Setters and Getters*** @@ -189,6 +192,9 @@ A class for storing envelope data. Largely based on how delta's library stores e
set_all(self, *args)
Sets all of the parameters of the envelope to the arguments. Order of arguments is p1, p2, p3, v1, v2, v3, v4, (A '%' can be here, copes with UTAU's weirdness), p4, p5, v5.
+ +
copy(self)
+
Returns a deep copy of the envelope.
Mode1Pitch @@ -233,6 +239,9 @@ A class for storing Mode1 pitchbend data. I gave my least efforts on this.
get(self)
Returns a dictionary with keys PBStart and PitchBend and values of the string representations.
+ +
copy(self)
+
Returns a deep copy of the Mode1 pitchbend data.
Mode2Pitch @@ -284,6 +293,9 @@ A class for Mode2 pitchbend data.
get(self)
Returns a dictionary with keys PBS, PBW, PBY, and PBM with its values as their corresponding data in their string representations.
+ +
copy(self)
+
Returns a deep copy of the Mode2 pitchbend data.
Vibrato @@ -323,6 +335,9 @@ A class for storing Mode2 vibrato data.
__str__(self)
get(self)
Returns the string representation of vibrato.
+ +
copy(self)
+
Returns a deep copy of the vibrato.
--- diff --git a/pyutau.py b/pyutau.py index ba514b2..f50a30c 100644 --- a/pyutau.py +++ b/pyutau.py @@ -49,6 +49,9 @@ def __str__(self): def get(self): return str(self) + def copy(self): + return Envelope(self.get()) + #Mode1 Pitch Class. Honestly, I don't really like Mode1. I feel like someone's gonna need this tho so. class Mode1Pitch: def __init__(self, PBStart = '', PitchBend = ''): @@ -73,6 +76,9 @@ def get(self): res['PBStart'] = self.get_start_time() return res + def copy(self): + return Mode1Pitch(self.get_start_time(), self.get_pitches()) + #Mode2 Pitch class. Returns a dictionary of string values for get class Mode2Pitch: def __init__(self, PBS = '-25', PBW = '50', PBY = '0', PBM = ''): @@ -123,7 +129,10 @@ def get(self): res['PBM'] = self.get_pbm() return res - + + def copy(self): + return Mode2Pitch(self.get_pbs(), self.get_pbw(), self.get_pby(), self.get_pbm()) + #Mode2 Vibrato class. This just deals with vibrato. class Vibrato: def __init__(self, VBR = ''): @@ -153,6 +162,9 @@ def __str__(self): def get(self): return str(self) + + def copy(self): + return Vibrato(self.get()) #Note class. Biggest class of all. Stores note data with corresponding classes for "special" data. @@ -170,6 +182,12 @@ def __init__(self, note_type = 'INSERT'): 'NoteNum' : '60', 'PreUtterance' : None } + + def copy(self): + res = Note(self.note_type) + res.isdeleted = self.isdeleted + res.set_multiple_data(self.note_data) + return res def delete_note(self): #Sets Note type to DELETE. This deletes the note... I hope I don't need to change note order for this.