Ejemplo n.º 1
0
void I_LoadSound (struct sfxinfo_struct *sfx)
{
	if (!sound_initialized)
		return;
	
	if (!sfx->data)
	{
		DPrintf ("loading sound \"%s\" (%d)\n", sfx->name, sfx->lumpnum);
		getsfx (sfx);
	}
}
Ejemplo n.º 2
0
void I_InitSound()
{ 
  int i;
  
  fprintf( stderr, "I_InitSound: ");
  SDL_Init(SDL_INIT_AUDIO);
  I_InitMusic();
  Mix_AllocateChannels(NUM_CHANNELS);
  Mix_ReserveChannels(3);

  // Initialize external data (all sounds) at start, keep static.
 
  for (i=1 ; i<NUMSFX ; i++)
  { 
    // Alias? Example is the chaingun sound linked to pistol.
    if (!S_sfx[i].link)
    {
      // Load data from WAD file.
      S_sfx[i].data = getsfx( S_sfx[i].name, &lengths[i] );

      // Samples now 16bit LE stereo, upsampled to double length and padded
      S_sfx[i].chunk = Mix_QuickLoad_RAW( S_sfx[i].data, lengths[i] );
    }	
    else
    {
      // Previously loaded already?
      S_sfx[i].data = S_sfx[i].link->data;
      lengths[i] = lengths[(S_sfx[i].link - S_sfx)/sizeof(sfxinfo_t)];
      S_sfx[i].chunk = Mix_QuickLoad_RAW( S_sfx[i].data, lengths[i] );
    }
  }

  fprintf( stderr, " pre-cached all sound data\n");
  
  // Finished initialization.
  fprintf(stderr, "I_InitSound: sound module ready\n");
  SDL_PauseAudio(0);
}