コード例 #1
0
 def make_song(self, p_nothing=0.6):
     for i in range(self.beats - 100):
         if i > self.chord_done:
             self.is_playing_chord = False
             self.is_playing_arp = False
         volume = random.randrange(70, 100)
         duration = random.randrange(1, 16)
         randchoice = random.random()
         if randchoice <= self.p_chord and not (self.one_handed
                                                and self.is_playing_chord):
             self.is_playing_chord = True
             self.chord_done = i + duration
             chord = self.note.make_chord()
             if random.random() < 0.7:
                 duration = random.randrange(2, 6)
                 self.chord_done = i + duration
                 self.is_playing_arp = True
                 for j, note in enumerate(chord):
                     d = j * duration / len(chord)
                     self.midi.addNote(self.track, 1, note, i + d, 2,
                                       volume + random.randrange(-20, 20))
             else:
                 for note in chord:
                     self.midi.addNote(self.track, 0, note, i, duration,
                                       volume + random.randrange(-20, 20))
         elif randchoice <= p_nothing:
             self.midi.addNote(self.track, 0, self.note.make_note(), i,
                               duration, volume)
     self.writeMidi()
コード例 #2
0
 def make_song(self, p_nothing=0.6):
     for i in range(self.beats - 100):
         volume = random.randrange(70, 100)
         duration = random.randrange(1, 16)
         randchoice = random.random()
         if randchoice <= self.p_chord:
             for note in self.note.make_chord():
                 self.midi.addNote(self.track, 0, note, i, duration,
                                   volume + random.randrange(-20, 20))
         elif randchoice <= p_nothing:
             self.midi.addNote(self.track, 0, self.note.make_note(), i,
                               duration, volume)
     self.writeMidi()
コード例 #3
0
 def add_note(self,
              note,
              time,
              duration,
              volume=random.randint(85, 100),
              channel=0):
     self.midi.addNote(self.track, channel, note, time, duration,
                       volume + random.randrange(-20, 20))
コード例 #4
0
 def add_chord(self,
               chord,
               time,
               duration,
               volume=random.randint(85, 100),
               channel=1):
     for j, note in enumerate(chord):
         self.midi.addNote(self.track, j % 12, note % 127, time, duration,
                           volume + random.randrange(-20, 20))
コード例 #5
0
 def add_arpeggio(self,
                  chord,
                  time,
                  duration,
                  volume=random.randint(85, 100),
                  channel=2):
     for j, note in enumerate(chord):
         d = j * duration / len(chord)
         print('note', note, 'dur', d)
         self.midi.addNote(self.track, j % 12, note % 127, time + d,
                           duration / len(chord),
                           volume + random.randrange(-20, 20))
コード例 #6
0
 def add_notes(self,
               notes,
               time,
               volume=random.randint(85, 100),
               channel=2):
     d = 0
     j = 0
     for note, dur in notes:
         d += dur
         j += 1
         print(f"Note {note} dur {dur}")
         self.midi.addNote(self.track, j % 12, note % 127, time + d, dur,
                           volume + random.randrange(-20, 20))