(result_queue)
Collect and display results.
Collect and display results.
Collect and display results .
def result_collector(result_queue):
  """Collect and display results."""

  def notename(n, space):
    if space:
      return [' ', '  ', ' ', ' ', '  ', ' ', '  ', ' ', ' ', '  ', ' ',
              '  '][n % 12]
    return [
        Fore.BLUE + 'A' + Style.RESET_ALL,
        Fore.LIGHTBLUE_EX + 'A#' + Style.RESET_ALL,
        Fore.GREEN + 'B' + Style.RESET_ALL,
        Fore.CYAN + 'C' + Style.RESET_ALL,
        Fore.LIGHTCYAN_EX + 'C#' + Style.RESET_ALL,
        Fore.RED + 'D' + Style.RESET_ALL,
        Fore.LIGHTRED_EX + 'D#' + Style.RESET_ALL,
        Fore.YELLOW + 'E' + Style.RESET_ALL,
        Fore.WHITE + 'F' + Style.RESET_ALL,
        Fore.LIGHTBLACK_EX + 'F#' + Style.RESET_ALL,
        Fore.MAGENTA + 'G' + Style.RESET_ALL,
        Fore.LIGHTMAGENTA_EX + 'G#' + Style.RESET_ALL,
    ][n % 12]  #+ str(n//12)

  print('Listening to results..')
  # TODO(mtyka) Ensure serial stitching of results (no guarantee that
  # the blocks come in in order but they are all timestamped)
  while True:
    result = result_queue.get()
    serial = result.audio_chunk.serial
    result_roll = result.result
    if serial > 0:
      result_roll = result_roll[4:]
    for notes in result_roll:
      for i in range(6, len(notes) - 6):
        note = notes[i]
        is_frame = note[0] > 0.0
        notestr = notename(i, not is_frame)
        print(notestr, end='')
      print('|')
def result_collector ( result_queue ) : def notename ( n , space ) : if space : return [ ' ' , '  ' , ' ' , ' ' , '  ' , ' ' , '  ' , ' ' , ' ' , '  ' , ' ' , '  ' ] [ n % 12 ] return [ Fore . BLUE + 'A' + Style . RESET_ALL , Fore . LIGHTBLUE_EX + 'A#' + Style . RESET_ALL , Fore . GREEN + 'B' + Style . RESET_ALL , Fore . CYAN + 'C' + Style . RESET_ALL , Fore . LIGHTCYAN_EX + 'C#' + Style . RESET_ALL , Fore . RED + 'D' + Style . RESET_ALL , Fore . LIGHTRED_EX + 'D#' + Style . RESET_ALL , Fore . YELLOW + 'E' + Style . RESET_ALL , Fore . WHITE + 'F' + Style . RESET_ALL , Fore . LIGHTBLACK_EX + 'F#' + Style . RESET_ALL , Fore . MAGENTA + 'G' + Style . RESET_ALL , Fore . LIGHTMAGENTA_EX + 'G#' + Style . RESET_ALL , ] [ n % 12 ] #+ str(n//12) print ( 'Listening to results..' ) # TODO(mtyka) Ensure serial stitching of results (no guarantee that # the blocks come in in order but they are all timestamped) while True : result = result_queue . get ( ) serial = result . audio_chunk . serial result_roll = result . result if serial > 0 : result_roll = result_roll [ 4 : ] for notes in result_roll : for i in range ( 6 , len ( notes ) - 6 ) : note = notes [ i ] is_frame = note [ 0 ] > 0.0 notestr = notename ( i , not is_frame ) print ( notestr , end = '' ) print ( '|' )