Exemplo n.º 1
0
def _emit_rest(t):
  note_to_emit = Note(globals.REST_NOTE)
  note_to_emit.text = t
  note_to_emit.duration = None

  # from Michelle
  if(t == ','): note_to_emit.duration = 0.25
  if(t == '.'): note_to_emit.duration = 1.0
  if(t == '?'): note_to_emit.duration = 1.0
  if(t == '!'): note_to_emit.duration = 1.0
  if(t == '-'): note_to_emit.duration = 0.25
  if(t == ':'): note_to_emit.duration = 0.125
  if(t == ';'): note_to_emit.duration = 0.5
  # for joe: TILDEROCK
  if(t == '~'): note_to_emit.duration = 0.03125

  if note_to_emit.duration == None:
    return None

  return note_to_emit
Exemplo n.º 2
0
def emit_note(t):
  if t in punctuation:
    return _emit_rest(t)

  fv = _word_to_fv(t)
  sorted_scores = _score_notes_no_octave(fv)

  note = ''
  top_scores = selection.choose_top_score(sorted_scores)
  if(len(top_scores) > 1):
    note = random.choice(top_scores)
  else:
    note = top_scores[0]

  note_to_emit = Note(note+str(octave.choose_octave(t)))
  note_to_emit.accidental = accidental.choose_accidental(fv, note_to_emit.pitch)
  note_to_emit.duration = duration.calculate_duration(t)
  note_to_emit.fv = fv
  note_to_emit.text = t

  return note_to_emit