def _pickUpAccent(self, melody, notePerBar_n=16): output = np.zeros(0) oneBar = np.zeros(len(melody)) for j in range(int(len(melody) / notePerBar_n)): for i in range(notePerBar_n): if melody[notePerBar_n * j + i] > -1: oneBar[notePerBar_n * j + i] = oneBar[notePerBar_n * j + i] + 1 output = np.r_[output, func.softmax(oneBar)] return output
def _pickUpSectionAccent(self, melody, notePerBar_n=16, barsPerOneSection=4): output = np.zeros(0) oneBar = np.zeros(notePerBar_n) # minimum beat length sixteen-beat and then 16 for j in range(int(len(melody) / notePerBar_n)): for i in range(notePerBar_n): if melody[j * notePerBar_n + i] > -1: oneBar[i] = oneBar[i] + 1 if j % barsPerOneSection == barsPerOneSection - 1: for k in range(barsPerOneSection): output = np.r_[output, func.softmax( oneBar)] #ランダム性はコントロールできる。*3でいけないのか。 oneBar = np.zeros(notePerBar_n) return output
def _accentRandom(self, score, barsPerOneSection=4, temperature=0.0005, n=2): merge = self._pickUpAccent( score, self._notePerBar_n) * self._pickUpSectionAccent( score, self._notePerBar_n, barsPerOneSection) output = np.zeros(0) oneBar = np.full(self._notePerBar_n, -1) for j in range(int(len(merge) / self._notePerBar_n)): for i in range(self._notePerBar_n): oneBar[i] = merge[j * self._notePerBar_n + i] output = np.r_[output, func.softmax(oneBar, t=temperature)] #0.0005がちょうどよい oneBar = np.zeros(self._notePerBar_n) return self._tranBinary(output, n) #変数にしなくていいのか