コード例 #1
0
def main():
  score = abjad.Score([]);
  measures = 2;
  beats = 4 * measures
  
  tempo = abjad.Tempo(abjad.Duration(1, 4), 240)
  abjad.attach(tempo, score)
  
  scale1 = Scale(D, name="minor_pentatonic");
  scale2 = Scale(G, name="minor_pentatonic");
  part1 = []
  for i in xrange(0,beats):
    part1.append(choose_random_note_in_range(scale1.notes))
  score = add_to_score(part1,score)

  part2 = []
  for i in xrange(0,beats):
    part2.append(choose_random_note_in_range(scale2.notes))
  score = add_to_score(part2,score)

  abjad_renderer = RendererAbjad(clean=True, verbose=True)
  abjad_renderer.render(score, preview=False)
  audio_renderer = RendererAudioFluidsynth();  
  file_audio = audio_renderer.render(abjad_renderer.file_midi)
  audio_player = AudioPlayer();
  audio_player.play(file_audio)
コード例 #2
0
def main():
  score = abjad.Score([]);
  measures = 50;
  beats = 4 * measures
  
  tempo = abjad.Tempo(abjad.Duration(1, 4), 240)
  abjad.attach(tempo, score)
  
  chord1 = Chord(C, name="major_major7");
  chord2 = Chord(G, name="major_minor7");
  part1 = []
  for i in xrange(0,beats):
    if i % 3:
      part1.append(choose_random_note_in_range(chord2.notes_all))
    else:
      part1.append(choose_random_note_in_range(chord1.notes_all))
  score = add_to_score(part1,score)

  part2 = []
  for i in xrange(0,beats):
    if i % 3:
      part2.append(choose_random_note_in_range(chord2.notes_all))
    else:
      part2.append(choose_random_note_in_range(chord1.notes_all))
  score = add_to_score(part2,score)

  abjad_renderer = RendererAbjad(clean=True, verbose=True)
  abjad_renderer.render(score, preview=False)
  audio_renderer = RendererAudioFluidsynth();  
  file_audio = audio_renderer.render(abjad_renderer.file_midi)
  audio_player = AudioPlayer();
  audio_player.play(file_audio)
コード例 #3
0
 def play(audio_file):
   audio_player = AudioPlayer();
   audio_player.player(audio_file);