Beispiel #1
0
static int
getTable (TextTable **table, const char *name) {
  const char *directory = opt_tablesDirectory;

  *table = NULL;

  if (strcmp(name, tableName_unicode) != 0) {
    char *allocated = NULL;

    if (strcmp(name, tableName_autoselect) == 0) {
      if (!(name = allocated = selectTextTable(directory))) {
        logMessage(LOG_ERR, "cannot find text table for current locale");
      }
    }

    if (name) {
      char *path = makeTextTablePath(directory, name);

      if (path) {
        *table = compileTextTable(path);
        free(path);
      }
    }

    if (allocated) free(allocated);
     if (opt_noBaseCharacters) setTryBaseCharacter(*table, 0);
    if (!*table) return 0;
  }

  return 1;
}
Beispiel #2
0
int
main(int argc, char const *argv[])
{
  std::locale::global(std::locale(""));

  {
    char *localeTable = selectTextTable(TABLES_DIRECTORY);
    if (localeTable) {
      replaceTextTable(TABLES_DIRECTORY, localeTable);
      free(localeTable);
    }
  }

  std::istreambuf_iterator<wchar_t> wcin_begin(std::wcin.rdbuf()), wcin_end;
  std::wstring source(wcin_begin, wcin_end);
  typedef std::wstring::const_iterator iterator_type;

  iterator_type iter = source.begin();
  iterator_type const end = source.end();
  typedef music::braille::error_handler<iterator_type> error_handler_type;
  error_handler_type error_handler(iter, end);
  typedef music::braille::score_grammar<iterator_type> parser_type;
  parser_type parser(error_handler);
  boost::spirit::traits::attribute_of<parser_type>::type score;

  bool const success = parse(iter, end, parser, score);

  if (success and iter == end) {
    music::braille::compiler<error_handler_type> compile(error_handler);
    if (compile(score)) {
      std::thread player;

      if (argc == 2 and strcmp(argv[1], "-p") == 0)
        player = std::thread(music::fluidsynth(SOUNDFONT_PATH), score);

      music::lilypond_output_format(std::cout);
      //music::include_locations_for_lilypond(std::cout);
      std::cout << score;

      if (player.joinable()) player.join();

      return EXIT_SUCCESS;
    }
  }

  return EXIT_FAILURE;
}