Пример #1
0
void GenerateIndex(float gamma)
{
	
	std::vector<RawSample> finalSet;
	finalSet.reserve(250 * 1000);
	std::cout << "Loading samples\n";
	
	GraphManager manager(LoadSamples("samples.bin", true));

	std::cout << "Initializing edges\n";
	FILE* file = fopen("database.bin", "rb");
	file->_bufsiz = 4096 * 1024;
	unsigned char fileBuff[12];

	std::cout << "Open\n";
	int counter = 0;
	if (file)
	{
		while (fread(fileBuff, 12, 1, file))
		{
			EdgeElement di;

			uint32_t distance = (int)*(float*)&fileBuff[8];
			di.First = *(uint32_t*)&fileBuff[0] - 100000; //Also convert Id to index
			di.Second = *(uint32_t*)&fileBuff[4] - 100000;
			if (distance < gamma)
			{
				manager.AddEdge(di);
				counter++;
				if (counter % 1000000 == 0)
					std::cout << "Loaded: " << counter << std::endl;
			}
		}
		std::cout << "Done\n";
	}
	manager.FixLastEdge();
	fclose(file);
	manager.VertexCover();
	manager.Extract(finalSet);
	uint32_t* ids = new uint32_t[finalSet.size()];
	counter = 0;

	for (auto sample : finalSet)
	{
		ids[counter++] = sample.EventId + 100000; //Save index, convert Id back to canonicial form
	}

	FILE* output = fopen("index.bin", "wb");
	fwrite(ids, 4, finalSet.size(), output);
	fclose(output);
}
Пример #2
0
static void UltraPlayStart(void)
{
    int t;



    for (t = 0; t < GUS_CHANNELS; t++) {
	voices[t].flags = 0;
	voices[t].handle = 0;
	voices[t].size = 0;
	voices[t].start = 0;
	voices[t].reppos = 0;
	voices[t].repend = 0;
	voices[t].changes = 0;
	voices[t].kick = 0;
	voices[t].freq = 10000;
	voices[t].vol = 64;
	voices[t].pan = 8192;
    }

    nr_voices = md_numchn;


    if (ResetCard() == FALSE) {
	exit(-1);
    }
    LoadSamples();

    gus_queue_write_set_size(1024);
    gus_queue_read_set_size(128);

    if (gus_timer_start() < 0) {
    }
    gus_timer_tempo(50);
    ULTRA_BPM = 0;

    for (t = 0; t < nr_voices; t++) {
	gus_do_voice_pan(t, 8192);
	gus_do_voice_volume(t, 50 << 7);
    }

    if (gus_do_flush() != 0) {
    }
}
Пример #3
0
void GenerateDatabase(float gamma)
{
	
	DatabaseBuilder db(LoadSamples("samples.bin",false));
	std::vector<DistanceKey> edges;
	edges.reserve(100 * 1000 * 1000);

	db.Run(gamma, &edges);
	edges.shrink_to_fit();
	//Write out
	DistanceKey* edgesBuffer = new DistanceKey[edges.size()];
	int counter = 0;
	for (auto edge : edges)
	{
		edgesBuffer[counter++] = edge;
	}

	FILE* output = fopen("database.bin", "wb");
	fwrite(edgesBuffer, sizeof(DistanceKey), edges.size(), output);
	fclose(output);
	delete edgesBuffer;
}
Пример #4
0
////////////////////////////////////////////////////////////////////////////////
// Loads and processes the skin description file which is in fact a regular
// Allegro configuration file
MAS::Error MAS::Skin::Load(const char *file) {
   int i = 0;
   lastError = MAS::Error(MAS::Error::NONE);
   ALLEGRO_CONFIG *config;
   const char *str;
   ALLEGRO_PATH *sdp;

   if (!file) {
      lastError =  MAS::Error(MAS::Error::SKIN_INI);
      return lastError;
   }

   // Try to open the skin description file
   sdp = al_create_path(file);
   if (!al_is_path_present(sdp)) {
      al_destroy_path(sdp);
      lastError = MAS::Error(MAS::Error::SKIN_INI);
      return lastError;
   }

   config = al_load_config_file(file);

   if (skinFilePath != file) {
      delete [] skinFilePath;
      skinFilePath = new char[1+strlen(file)];
      strcpy(skinFilePath, file);
   }

   Reset();

   // Get the path to the skin configuration file (drop the filename)
   al_set_path_filename(sdp, "");

   ////////////////////////////////////////////////////////////////////////////////
   // Read the name of the dir and load the bitmap data
   bool default_bitmaps = false;

   str = al_get_config_value(config, "Skin", "main_data");
   if (str) {
      al_append_path_component(sdp, str);
      lastError = LoadData(sdp, config);
      al_drop_path_tail(sdp);
      if (lastError) {
         al_destroy_config(config);
         al_destroy_path(sdp);
         delete [] skinFilePath;
         skinFilePath = NULL;
         return lastError;
      }
   }
   else {
      default_bitmaps = true;
   }

   ////////////////////////////////////////////////////////////////////////////////
   // Read the default colors
#define GET_COLOR_STR(val, def) ((str = al_get_config_value(config, "COLORS", val)) ? str : def)
   c_face     = MAS::Color(GET_COLOR_STR("face",     "210,210,210"));
   c_font     = MAS::Color(GET_COLOR_STR("fontface", " 16, 16, 16"));
   c_shad1    = MAS::Color(GET_COLOR_STR("shad1",    "255,255,255"));
   c_shad2    = MAS::Color(GET_COLOR_STR("shad2",    " 80, 80, 80"));
   c_disable  = MAS::Color(GET_COLOR_STR("disable",  "128,128,128"));
   c_select   = MAS::Color(GET_COLOR_STR("select",   "128,192,128"));
   c_deselect = MAS::Color(GET_COLOR_STR("deselect", "224,224,224"));
   c_focus    = MAS::Color(GET_COLOR_STR("focus",    "128,192,128"));
   c_sunken   = MAS::Color(GET_COLOR_STR("sunken",   "232,232,232"));
   c_back     = MAS::Color(GET_COLOR_STR("back",     "180,180,180"));
#undef GET_COLOR_STR

   if (default_bitmaps) {
      GenerateDefaultBitmaps();
   }

   ////////////////////////////////////////////////////////////////////////////////
   // Read the cursors from another datafile
   str = al_get_config_value(config, "Skin", "cursors");
   if (str) {
      al_append_path_component(sdp, str);
      lastError = LoadCursors(sdp, config);
      al_drop_path_tail(sdp);
      if (lastError) {
         al_destroy_config(config);
         al_destroy_path(sdp);
         delete [] skinFilePath;
         skinFilePath = NULL;
         return lastError;
      }
   }

   ////////////////////////////////////////////////////////////////////////////////
   // Read the samples from another datafile
   str = al_get_config_value(config, "Skin", "sounds");
   if (str) {
      al_append_path_component(sdp, str);
      lastError = LoadSamples(sdp);
      al_drop_path_tail(sdp);
      if (lastError) {
         al_destroy_config(config);
         al_destroy_path(sdp);
         delete [] skinFilePath;
         skinFilePath = NULL;
         return lastError;
      }
   }

#define GET_CONFIG_STR(section, key, def) \
   (str = al_get_config_value(config, section, key)) ? strtol(str, NULL, 10) : def

   ////////////////////////////////////////////////////////////////////////////////
   // Now load the fonts
   const char *fonts[] = { "FONT0", "FONT1", "FONT2", "FONT3",
                           "FONT4", "FONT5", "FONT6", "FONT7" };
   const char *ttfont;
   int size;
   for (i=0; i<nFonts; i++)   {
      size = GET_CONFIG_STR(fonts[i], "size", 10);
      ttfont = al_get_config_value(config, fonts[i], "file");   // the filename of the font
      al_set_path_filename(sdp, ttfont);
	  const char *filename = al_path_cstr(sdp, ALLEGRO_NATIVE_PATH_SEP);
      fntList[i]->Load(filename, size, false);
   }

   ////////////////////////////////////////////////////////////////////////////////
   // Read the object specific data:
   //----------------------------------------------
   const char *fnames[] = { "font1", "font2", "font3", "font4" };
   const char *cnames[] = { "f_col1", "f_col2", "f_col3", "f_col4" };
   const char *snames[] = { "s_col1", "s_col2", "s_col3", "s_col4" };
   const char *def_col[] = { "0,0,0", "0,0,0", "128,128,128", "0,0,0" };
   const char *def_shd[] = { "-1", "-1", "-1", "-1" };

   // button, checkbox, radio button, etc.
   const char *info_name[] = {
      "BOX",
      "BUTTON",
      "CHECKBOX",
      "RADIO",
      "LIST",
      "WINDOW",
      "MENU",
      "TEXT",
      "EDITBOX",
      "PROGRESS",
      "HYPER",
      "TAB",
      "TOOLTIP"
   };

   for (int j=0; j<nInfoItems; j++)   {
      for (i=0; i<4; i++)   {
         fnt[j][i] = GET_CONFIG_STR(info_name[i], fnames[i], 10);
         fcol[j][i] = Color((str = al_get_config_value(config, info_name[j], cnames[i])) ? str : def_col[i]);
         scol[j][i] = Color((str = al_get_config_value(config, info_name[j], snames[i])) ? str : def_shd[i]);
      }
   }

   // wallpaper style
   wallpaperStyle = GET_CONFIG_STR("WALLPAPER", "style", 3);

   // buttons animation
   buttonDisplacement    = GET_CONFIG_STR("BUTTON", "displacement", 1);
   buttonAnimationType   = GET_CONFIG_STR("BUTTON", "animationType", 0);
   buttonAnimationLength = GET_CONFIG_STR("BUTTON", "animationLength", 0);

   // group box info
   boxX =      GET_CONFIG_STR("BOX", "offX", 6);
   boxY =      GET_CONFIG_STR("BOX", "offY", 1);
   boxAlign =  GET_CONFIG_STR("BOX", "alignment", 0);
   boxBack =   (str = al_get_config_value(config, "BOX", "backColor")) ? str : "222,222,222";

   // window
   winTextPos.x(  GET_CONFIG_STR("WINDOW", "textX", 10));
   winTextPos.y(  GET_CONFIG_STR("WINDOW", "textY", 18));
   winTextAlign = GET_CONFIG_STR("WINDOW", "alignment", 0);
   winTextBack  = GET_CONFIG_STR("WINDOW", "textBack", 0);
   winExitPos.x(  GET_CONFIG_STR("WINDOW", "exitX", -22));
   winExitPos.y(  GET_CONFIG_STR("WINDOW", "exitY", 6));
   winMaxPos.x(   GET_CONFIG_STR("WINDOW", "manX", -40));
   winMaxPos.y(   GET_CONFIG_STR("WINDOW", "manY", 6));
   winMinPos.x(   GET_CONFIG_STR("WINDOW", "minX", -56));
   winMinPos.y(   GET_CONFIG_STR("WINDOW", "minY", 6));
   winAnimationType = GET_CONFIG_STR("WINDOW", "animationType", 0);
   winAnimationLength = GET_CONFIG_STR("WINDOW", "animationLength", 0);

   // combo box
   comboAnimationType = GET_CONFIG_STR("COMBOBOX", "animationType", 0);
   comboAnimationLength = GET_CONFIG_STR("COMBOBOX", "animationLength", 0);

   // menu
   menuHeight = GET_CONFIG_STR("MENU", "height", 16);
   menuDelay =  GET_CONFIG_STR("MENU", "delay", 300);
   menuAnimationType = GET_CONFIG_STR("MENU", "animationType", 0);
   menuAnimationLength = GET_CONFIG_STR("MENU", "animationLength", 0);

   // tooltip info
   tooltipAnimationType =   GET_CONFIG_STR("TOOLTIP", "animationType", 0);
   tooltipAnimationLength = GET_CONFIG_STR("TOOLTIP", "animationLength", 0);
   tooltipBack = Color((str = al_get_config_value(config, "TOOLTIP", "backColor")) ? str : "255,255,192");
   tooltipBorder = Color((str = al_get_config_value(config, "TOOLTIP", "backColor")) ? str : "0,0,0");

   // dialog popup animation
   // ...

   // should the GUI draw dotted rectangles?
   drawDots = (str = al_get_config_value(config, "Skin", "dottedRect")) ? *str != '0' : false;

   // how the focus follows the mouse
   focus = GET_CONFIG_STR("Skin", "focus", 1);

#undef GET_CONFIG_STR

   al_destroy_path(sdp);

   return MAS::Error(MAS::Error::NONE);
}
Пример #5
0
void MainWindow::CreateConnections(QAction *load_point_set) {
	QObject::connect(check_renderer_, SIGNAL(triggered(bool)), this, SLOT(ManageRenderer(bool)));
	QObject::connect(check_spatial_stats_, SIGNAL(triggered(bool)), this, SLOT(ManageSpatialStats(bool)));
	QObject::connect(check_spectral_properties_, SIGNAL(triggered(bool)), this, SLOT(ManageSpectralProperties(bool)));
	QObject::connect(load_point_set, SIGNAL(triggered()), this, SLOT(LoadSamples()));
}
Пример #6
0
 Sample* File::GetFirstSample() {
     if (!pSamples) LoadSamples();
     if (!pSamples) return NULL;
     SamplesIterator = pSamples->begin();
     return (SamplesIterator != pSamples->end()) ? *SamplesIterator : NULL;
 }