Exemple #1
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;
}
Exemple #2
0
int
main()
{
  std::string fileName = "test.ly";
  std::locale::global(std::locale(""));

  textTable = compileTextTable("ttb/Tables/de.ttb");

  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();
  music::braille::error_handler<iterator_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 && iter == end) {
    music::braille::compiler compile(error_handler);
    if (compile(score)) {
      //      std::wcout << source;
      std::thread player(music::toLily(), score);

      
      
      player.join();

      return 0;
    }
  }

  return 1;
}