Beispiel #1
0
OpenALSoundSource*
SoundManager::intern_create_sound_source(const std::string& filename)
{
  assert(sound_enabled);

  std::auto_ptr<OpenALSoundSource> source (new OpenALSoundSource());

  ALuint buffer;

  // reuse an existing static sound buffer
  SoundBuffers::iterator i = buffers.find(filename);
  if(i != buffers.end()) {
    buffer = i->second;
  } else {
    // Load sound file
    std::auto_ptr<SoundFile> file (load_sound_file(filename));

    if(file->size < 100000) {
      buffer = load_file_into_buffer(file.get());
      buffers.insert(std::make_pair(filename, buffer));
    } else {
      StreamSoundSource* source = new StreamSoundSource();
      source->set_sound_file(file.release());
      return source;
    }

    log_debug << "Uncached sound \"" << filename << "\" requested to be played" << std::endl;
  }

  alSourcei(source->source, AL_BUFFER, buffer);
  return source.release();
}
SoundSource*
SoundManager::create_sound_source(const std::string& filename)
{
  if(!sound_enabled)
    return 0;

  ALuint buffer;
  
  // reuse an existing static sound buffer            
  SoundBuffers::iterator i = buffers.find(filename);
  if(i != buffers.end()) {
    buffer = i->second;
  } else {
    // Load sound file
    std::auto_ptr<SoundFile> file (load_sound_file(filename));

    if(file->size < 100000) {
      buffer = load_file_into_buffer(file.get());
      buffers.insert(std::make_pair(filename, buffer));
    } else {
      StreamSoundSource* source = new StreamSoundSource();
      source->set_sound_file(file.release());
      return source;
    }
  }
  
  SoundSource* source = new SoundSource();
  alSourcei(source->source, AL_BUFFER, buffer);
  return source;  
}
SoundSource*
SoundManager::create_sound_source(const std::string& filename)
{
  if(!sound_enabled)
    return 0;

  ALuint buffer;
  
  // reuse an existing static sound buffer            
  SoundBuffers::iterator i = buffers.find(filename);
  if(i != buffers.end()) {
    buffer = i->second;
  } else {
    buffer = load_file_into_buffer(filename);
    buffers.insert(std::make_pair(filename, buffer));
  }
  
  SoundSource* source = new SoundSource();
  alSourcei(source->source, AL_BUFFER, buffer);
  return source;  
}
Beispiel #4
0
/**
 * Loads SMF file.
 *
 * \param file Open file.
 * \return SMF or NULL, if loading failed.
 */
smf_t *
smf_load(FILE *file)
{
	size_t file_buffer_length;
	void *file_buffer;
	smf_t *smf;

	if (load_file_into_buffer(&file_buffer, &file_buffer_length, file))
		return (NULL);

	smf = smf_load_from_memory(file_buffer, file_buffer_length);

	memset(file_buffer, 0, file_buffer_length);
	free(file_buffer);

	if (smf == NULL)
		return (NULL);

	smf_rewind(smf);

	return (smf);
}
Beispiel #5
0
void
SoundManager::preload(const std::string& filename)
{
  if(!sound_enabled)
    return;

  SoundBuffers::iterator i = buffers.find(filename);
  // already loaded?
  if(i != buffers.end())
    return;
  try {
    std::auto_ptr<SoundFile> file (load_sound_file(filename));
    // only keep small files
    if(file->size >= 100000)
      return;

    ALuint buffer = load_file_into_buffer(file.get());
    buffers.insert(std::make_pair(filename, buffer));
  } catch(std::exception& e) {
    log_warning << "Error while preloading sound file: " << e.what() << std::endl;
  }
}
Beispiel #6
0
int main(int argc, char *argv[]) {
	char data[1000] = "";
	char moredata[1000] = "";
	char url[255] = "";

	init_curl();

	//init_curl(events_callback, exitEventsCallback);

	if (strncmp(argv[1], "XML", 3) == 0) {
		if (argc != 3) {
			printf("wrong number of args for get xml\n");
			exit - 1;
		}
		//printf("%s\n", url);
		strcat(url, argv[2]);
		strcat(url, "?x=1");
		char *get_data = http_get_function(url);
		//char *value = get_value_from_xml_value(get_data);
		//printf("%s\n", value);
		printf("%s\n", get_data);

	} else if (strncmp(argv[1], "GET", 3) == 0) {
		if (argc != 3) {
			printf("wrong number of args for get\n");
			exit - 1;
		}

		if (strncmp(argv[2], "FILE", 4) == 0) {
			load_file_into_buffer(url, "mainSD-OUTPUT.url");
		} else
			strcpy(url, argv[2]);

		//printf("%s\n", url);
		char *get_data = http_get_function(url);
		char *value = get_value_from_xml_value(get_data);
		//		printf("%s\n", value);
		//printf("%s\n", get_data);

	} else if (strncmp(argv[1], "PUT", 5) == 0) {

		if (argc != 4) {
			printf("wrong number of args for put\n");
			exit - 1;
		}

		if (strncmp(argv[2], "FILE", 4) == 0) {
			load_file_into_buffer(url, "mainSD-OUTPUT.url");
		} else
			strcpy(url, argv[2]);

		strcpy(data, argv[3]);

		char * xml = get_xml_value(data); //

		//xml = http_put_function(url, xml);// "<?xml ?><value> 29000</value>"
		//strcpy(data, xml); "   //  /Bridge/Livingroom/switch/0"
		char ipaddr[20] = "";
		char port[20] = "";
		char page[250] = "";

		spliturl(url, ipaddr, port, page);

		//	    printf("ip = \"%s\"\n", ipaddr);
		//	    printf("port = \"%s\"\n", port);
		//	    printf("page = \"%s\"\n", page);

		httpput(ipaddr, port, page, xml, moredata);
		//free(xml);

		char *value = get_value_from_xml_value(moredata);

		printf("%s\n", value);

	} else
		printf("Command not supported\n");

	return 0;
}
Beispiel #7
0
int main()
{
	int c;

// Initialize
	game_init();
	
	printf("PSXsnake\n");
	printf("(c) 2009 Giuseppe Gatta\n");
	printf("Made with PSXSDK\n\n");
	
	load_file_into_buffer("cdrom:FONT.TIM;1");
	GsImageFromTim(&game_image, file_buffer);
	
	GsUploadImage(&game_image);
	
	game_clut[0] = 0x0;
	game_clut[1] = 0x7fff;
	
	LoadImage(game_clut, 640, 24, 16, 1);
	
	GsSetVideoMode(320, 240, EXAMPLES_VMODE);
	
	vmode = pal_or_ntsc_selection();
	
	//printf("vmode = %d\n", vmode);
	
	GsSetVideoMode(320, 240, vmode);
	
	
	load_file_into_buffer("cdrom:BACKGRND.TIM;1");
	GsImageFromTim(&game_image, file_buffer);
	
	GsUploadImage(&game_image);
	
	sample_pos[0] = SPU_DATA_BASE_ADDR;
	c = load_file_into_buffer("cdrom:MUSIC.RAW;1");
	SsUpload(file_buffer, c, sample_pos[0]);
	
	if(c&0x7)
	{
		c|=0x7;
		c++;
	}
	
	sample_pos[1] = c + sample_pos[0];
	c = load_file_into_buffer("cdrom:BOMB.RAW;1");
	SsUpload(file_buffer, c, sample_pos[1]);
	
	/* ... */
	if(c&0x7)
	{
		c|=0x7;
		c++;
	}
	
	sample_pos[2] = c + sample_pos[1];
	c = load_file_into_buffer("cdrom:APPLE.RAW;1");
	SsUpload(file_buffer, c, sample_pos[2]);
	
	SsVoiceStartAddr(0, sample_pos[0]);
	SsVoiceStartAddr(1, sample_pos[1]);
	SsVoiceStartAddr(2, sample_pos[2]);
	
	SsVoiceVol(0, 0x3fff, 0x3fff);
	SsVoiceVol(1, 0x3fff, 0x3fff);
	SsVoiceVol(2, 0x3fff, 0x3fff);
	
	SsVoicePitch(0, 0x1000 / (44100 / 11025));
	SsVoicePitch(1, 0x1000 / (44100 / 11025));
	SsVoicePitch(2, 0x1000);
	
	game_setup();
	
	SetVBlankHandler(game_vblank_handler);
	
	
	while(1)
		game_run();
		
	return 0;
}