示例#1
0
    def onBeat(self,
               melody,
               beat=4,
               temperature={
                   'fx1': 0.0005,
                   'fx2': 0.0005,
                   'fx3': 0.0005,
                   'fx4': 0.0005
               },
               tryN={
                   'fx1': 1,
                   'fx2': 1,
                   'fx3': 1,
                   'fx4': 1
               }):
        effectsObj = cs.Effects()

        frame = int(beat * self._notePerBar_n / 4)
        frame_n = int(len(melody) / frame)
        score = [1, 0, 1, 0] * frame_n
        frame_mod = [0] * (len(melody) - len(score))
        score.extend(frame_mod)

        effectsObj.setPt1(
            self._accentRandom(score, 1, temperature['fx1'], tryN['fx1']))
        effectsObj.setPt2(
            self._accentRandom(score, 1, temperature['fx2'], tryN['fx2']))
        effectsObj.setPt3(
            self._accentRandom(score, 1, temperature['fx3'], tryN['fx3']))
        effectsObj.setPt4(
            self._accentRandom(score, 1, temperature['fx4'], tryN['fx4']))

        return effectsObj
示例#2
0
 def accentRandom(self,
                  melody,
                  hihat,
                  snare,
                  kick,
                  barsPerOneSection=4,
                  temperature={
                      'melody': 0.0005,
                      'hihat': 0.0005,
                      'snare': 0.0005,
                      'kick': 0.0005
                  },
                  tryN={
                      'melody': 1,
                      'hihat': 1,
                      'snare': 1,
                      'kick': 1
                  }):
     effectsObj = cs.Effects()
     effectsObj.setPt1(
         self._accentRandom(melody, barsPerOneSection,
                            temperature['melody'], tryN['melody']))
     effectsObj.setPt2(
         self._accentRandom(hihat, barsPerOneSection, temperature['hihat'],
                            tryN['hihat']))
     effectsObj.setPt3(
         self._accentRandom(snare, barsPerOneSection, temperature['snare'],
                            tryN['snare']))
     effectsObj.setPt4(
         self._accentRandom(kick, barsPerOneSection, temperature['kick'],
                            tryN['kick']))
     return effectsObj
示例#3
0
    def fill(self, keyProg):
        """
        1 barしか考えてない
        """

        fill_other = [
            0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
        ]
        fill = [0, -1, 0, -1, 0, -1, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0]

        effectsObj = cs.Effects()

        score = np.tile(fill_other, len(keyProg))
        score[-self._notePerBar_n:len(score)] = np.array(fill)

        effectsObj.setPt1(score)
        effectsObj.setPt2(score)
        effectsObj.setPt3(score)
        effectsObj.setPt4(score)

        return effectsObj
示例#4
0
    def onBeat_manual(self, keyProg):

        wholeNotes = [
            0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
        ]
        fourBeats = [
            0, -1, -1, -1, 0, -1, -1, -1, 0, -1, -1, -1, 0, -1, -1, -1
        ]
        a16Beats = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

        effectsObj = cs.Effects()

        score = np.tile(wholeNotes, len(keyProg))
        score[-4 * self._notePerBar_n:-2 * self._notePerBar_n] = np.tile(
            fourBeats, 2)
        score[-2 * self._notePerBar_n:len(score)] = np.tile(a16Beats, 2)

        effectsObj.setPt1(score)
        effectsObj.setPt2(score)
        effectsObj.setPt3(score)
        effectsObj.setPt4(score)

        return effectsObj