⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sound.c

📁 SEAL是DOS 下的32位保护模式的GUI程序
💻 C
📖 第 1 页 / 共 2 页
字号:

l_bool poll_file (p_play o)
{
   if (o->used_library)
      return((o->used_library)->poll_file(o->used_library));
}
      
/**************************************************
   Function: l_bool stop_file(p_play o)

   Stops playing.
   Returns TRUE on success, FALSE otherwise.
 **************************************************/

l_bool stop_file(p_play o)
{
   if (o->used_library)
      return(o->used_library->stop_file(o->used_library));
}

/**************************************************
   Function: l_bool pause_file(p_play o)

   Pauses/unpauses the file.
   Returns TRUE if now paused, FALSE otherwise.
 **************************************************/

l_bool pause_file(p_play o)
{
   if (o->used_library)
      return((o->used_library)->pause_file(o->used_library));
}

/*****************************************************
   Function: l_bool forward_file(p_play o, l_int time)

   Fast-forwards the file by <time> seconds.
   Returns TRUE if on success, FALSE otherwise.
 *****************************************************/
l_bool forward_file(p_play o, l_int time)
{
   if (o->used_library)
      return((o->used_library)->forward_file(o->used_library, time));
}

/****************************************************
   Function: l_bool rewind_file(p_play o, l_int time)

   Rewinds the file by <time> seconds.
   Returns TRUE on success, FALSE otherwise.
 ****************************************************/
l_bool rewind_file(p_play o, l_int relpos)
{
   if (o->used_library)
      return((o->used_library)->rewind_file(o->used_library, relpos));
}

/****************************************************
   Function: l_bool set_pos(p_play o, l_int time)

   Sets the position of the file in seconds.
   Returns TRUE on success, FALSE otherwise.
 ****************************************************/
l_bool set_pos(p_play o, l_int pos)
{
   if (o->used_library)
      return((o->used_library)->set_pos(o->used_library, pos));
}

/******************************************************
   Function: l_int get_pos(p_play o)

   Returns the current position of the file in seconds.
 ******************************************************/
l_int get_pos(p_play o)
{
   if (o->used_library)
      return((o->used_library)->get_pos(o->used_library));
}

/******************************************************
   Function: l_int get_len_file(p_play o)

   Returns the length of the file in seconds.
 ******************************************************/
l_int get_len_file(p_play o)
{
   if (o->used_library)
      return((o->used_library)->get_len_file(o->used_library));
}

/**********************************************************
   Function: l_bool get_file_info(p_play o, SFAINFO *inf)

   Returns extra information on the file. Returns TRUE on
   success, or FALSE otherwise.
 **********************************************************/

l_bool get_file_info(p_play o, SFAINFO *sfa)
{
   if (o->used_library)
      return((o->used_library)->get_file_info(o->used_library, sfa));
}

/**************************************************
   Function: l_text get_friendly_name(p_play o)

   Returns a 'friendly name' for a file.
 **************************************************/

l_text get_friendly_name(p_play o)
{
   if (o->used_library)
      return((o->used_library)->get_friendly_name(o->used_library));
}

/**************************************************
   Function: l_bool config_driver(p_play o)

   Displays a configuration dialog for the driver.
   Returns TRUE on success, or FALSE otherwise.
 **************************************************/

l_bool config_driver(p_play o)
{
   if (o->used_library)
      return((o->used_library)->config_driver(o->used_library));
}

/**************************************************
   Function: l_bool display_about(p_play o)

   Displays an about dialog for the driver.
   Returns TRUE on success, or FALSE otherwise.
 **************************************************/

l_bool display_about(p_play o)
{
   if (o->used_library)
      return((o->used_library)->display_about(o->used_library));
}

/**************************************************
   Function: l_bool close_file(p_play o)

   Closes the current file.
   Returns TRUE on success, or FALSE otherwise.
 **************************************************/

l_bool close_file(p_play o)
{
   if (o->used_library)
      return((o->used_library)->close_file(o->used_library));
}

/**************************************************
   Function: l_bool terminate_driver(p_play o)

   Shuts down this "session" of the driver.
   Returns TRUE on success, or FALSE otherwise.
 **************************************************/

l_bool terminate_driver(p_play o)
{
   if (o->used_library)
      return((o->used_library)->terminate_driver(o->used_library));
}

/**********************************************************************
   Function: l_bool send_custom_message(p_play o, l_int msg, void *extra)

   Sends a custom message to the driver.
 **********************************************************************/

l_bool send_custom_message(p_play o, l_int msg, void *extra)
{
   if (o->used_library)
      return((o->used_library)->send_custom_message(o->used_library, msg, extra));
}

l_int seal_volume = 255;
l_int seal_volume_midi = 255;
l_int count_player = 0;
l_int sound_input_installed = false;
l_int sound_installed = true;

/**************************************************
   Function: l_int get_sound_input_installed()

   Returns >1 if sound input is installed
 **************************************************/

l_int get_sound_input_installed()
{
   return(sound_input_installed);
}

/****************************************************
   Function: l_int get_sound_installed()

   Returns TRUE if the sound routines are installed.
 ****************************************************/

l_int get_sound_installed()
{
   return(sound_installed);
}



/**************************************************
   Function: void inc_count_player()

   Must be called if your program starts playing a
   file.
 **************************************************/

void inc_count_player()
{
   count_player++;
}

/***************************************************
   Function: void dec_count_player()

   Must be called if your program finishes playing a
   file.
 ***************************************************/

void dec_count_player()
{
   count_player--;
}

/**************************************************
   Function: l_int get_count_player()

   Returns the number of files playing.
 **************************************************/

l_int get_count_player()
{
   return(count_player);
}

/**************************************************
   Function: l_int get_seal_volume()

   Returns the current volume.
 **************************************************/
l_int get_seal_volume()
{
   return(seal_volume);
}

/**************************************************
   Function: l_int set_seal_volume()

   Sets the volume.
 **************************************************/

l_int set_seal_volume(l_int s_v)
{
   if (s_v < 0)
      s_v = 0;
   else if (s_v > 255)
      s_v = 255;

   seal_volume = s_v;
   set_volume(seal_volume,seal_volume_midi);

   // Write to config file
   set_config_file(GetFile("/system/allegro.cfg"));
   set_config_int("sound", "digi_volume", s_v);
}

/**************************************************
   Function: l_int get_seal_volume_midi()

   Returns the current MIDI volume.
 **************************************************/
l_int get_seal_volume_midi()
{
   return(seal_volume_midi);
}

/**************************************************
   Function: l_int set_seal_volume_midi()

   Sets the volume.
 **************************************************/

l_int set_seal_volume_midi(l_int s_v)
{
   if (s_v < 0)
      s_v = 0;
   else if (s_v > 255)
      s_v = 255;

   seal_volume_midi = s_v;
   set_volume(seal_volume,seal_volume_midi);

   // Write to config file
   set_config_file(GetFile("/system/allegro.cfg"));
   set_config_int("sound", "midi_volume", s_v);
}

#ifdef ___CPL_SUPPORT
p_cp_section get_sfa_cpl_section()
{
   return(cpl_section);
}
#endif

void ini_sound (void)
{
   p_soundformat_item k;
   l_text path = 0;
   t_rect r;

#ifdef ___CPL_SUPPORT
   cpl_section = add_cp_section(TXT_SFACPL, TXT_SFACPLSETTINGS, TXT_SFACPLINFO, NULL, load_image("bmp/cp_sfa.ico"));
#endif

   sound_format_list = list_init(_malloc(sizeof(t_list)), &free_soundformat_item, 0);
      

   k = new_soundformat_item(                      _strdup("*"),
                                                  _strdup("All Files"),
                                                  _strdup("(c) Florian Xaver GNU GPL - virtual sound file"),
                                                  &st_init_driver,
                                                  &st_init_file,
                                                  &st_play_file,
                                                  &st_poll_file,
                                                  &st_stop_file,
                                                  &st_pause_file,
                                                  &st_forward_file,
                                                  &st_rewind_file,
                                                  &st_set_pos,
                                                  &st_get_pos,
                                                  &st_get_len_file,
                                                  &st_get_file_info,
                                                  &st_get_friendly_name,
                                                  &st_config_driver,
                                                  &st_display_about,
                                                  &st_close_file,
                                                  &st_terminate_driver,
                                                  &st_send_custom_message
                                                  );




   sound_format_list->insert(sound_format_list, k);

   DEBUG_printf("Sound init: init sound...\n");
      
   /* reserve_voices is very important for the MOD player */
   reserve_voices (32, -1);
      
   DEBUG_printf("Sound init: voices reserved.\n");
   DEBUG_printf("Sound init: Installing sound...");

   if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, "") == -1)
   {
      sound_installed = false;
      seal_error(ERR_INFO, TXT_CANNOTINITSOUNDCARD, allegro_error);
      DEBUG_printf("SFA Initialisation Error: Cannnot initialise sound card: %s\n",allegro_error);

      return;
   }

   DEBUG_printf("   sound installed!\n");

   set_config_file(GetFile("/system/allegro.cfg"));
   set_seal_volume(get_config_int("sound", "digi_volume", 255));
   set_seal_volume_midi(get_config_int("sound", "midi_volume", 255));

   DEBUG_printf("Sound init: volume set");
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -