Skip to content

Commit

Permalink
Added deepcopy functions
Browse files Browse the repository at this point in the history
The function copy() has been added to classes Envelope, Mode1Pitch, Mode2Pitch, Vibrato, and Note
  • Loading branch information
UtaUtaUtau committed Jun 11, 2020
1 parent c3516b7 commit a21992a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ A class that stores note data.

<dt>set_multiple_data(self, **kwargs)</dt>
<dd>Sets multiple data because note_data is a dictionary. Just.. yeah.</dd>

<dt>copy(self)</dt>
<dd>Returns a deep copy of the note.</dd>
</dl>

***Setters and Getters***
Expand Down Expand Up @@ -189,6 +192,9 @@ A class for storing envelope data. Largely based on how delta's library stores e

<dt>set_all(self, *args)</dt>
<dd>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.</dd>

<dt>copy(self)</dt>
<dd>Returns a deep copy of the envelope.</dd>
</dl>

Mode1Pitch
Expand Down Expand Up @@ -233,6 +239,9 @@ A class for storing Mode1 pitchbend data. I gave my least efforts on this.

<dt>get(self)</dt>
<dd>Returns a dictionary with keys PBStart and PitchBend and values of the string representations.</dd>

<dt>copy(self)</dt>
<dd>Returns a deep copy of the Mode1 pitchbend data.</dd>
</dl>

Mode2Pitch
Expand Down Expand Up @@ -284,6 +293,9 @@ A class for Mode2 pitchbend data.

<dt>get(self)</dt>
<dd>Returns a dictionary with keys PBS, PBW, PBY, and PBM with its values as their corresponding data in their string representations.</dd>

<dt>copy(self)</dt>
<dd>Returns a deep copy of the Mode2 pitchbend data.</dd>
</dl>

Vibrato
Expand Down Expand Up @@ -323,6 +335,9 @@ A class for storing Mode2 vibrato data.
<dt>__str__(self)</dt>
<dt>get(self)</dt>
<dd>Returns the string representation of vibrato.</dd>

<dt>copy(self)</dt>
<dd>Returns a deep copy of the vibrato.</dd>
</dl>

---
Expand Down
20 changes: 19 additions & 1 deletion pyutau.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''):
Expand All @@ -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 = ''):
Expand Down Expand Up @@ -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 = ''):
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down

0 comments on commit a21992a

Please sign in to comment.