コード例 #1
0
ファイル: music.c プロジェクト: AlleyCat1976/Meridian59_103
/* 
 * PauseMusic:  Store current position of background music.  Assumes that
 *   music is playing on MIDI device.
 */
void PauseMusic(void)
{
#ifdef M59_MSS
   if (!has_midi)
      return;

   if( AIL_sample_status( hseqBackground ) == SMP_PLAYING )
      AIL_stop_sample( hseqBackground );
   // indicate we are paused
   music_pos = 1;
   debug(( "Pausing music.\n" ));
#else
   MCI_STATUS_PARMS mciStatusParms;

   if (!has_midi)
      return;

   mciStatusParms.dwItem = MCI_STATUS_POSITION;
   mciSendCommand(midi_element, MCI_STATUS, 
                  MCI_STATUS_ITEM, (DWORD)(LPVOID) &mciStatusParms);
   music_pos = mciStatusParms.dwReturn;

   /* Get time format */
   mciStatusParms.dwItem = MCI_STATUS_TIME_FORMAT;
   mciSendCommand(midi_element, MCI_STATUS, 
                  MCI_STATUS_ITEM, (DWORD)(LPVOID) &mciStatusParms);
   time_format = mciStatusParms.dwReturn;

   debug(("Pausing, position = %ld\n", music_pos));
#endif
}
コード例 #2
0
 //
 // Return the current sample status
 //
 U32 Status()
 {
   return
   (
     flag3D ? AIL_3D_sample_status(handle3D) : AIL_sample_status(handle2D)
   );
 }
コード例 #3
0
ファイル: music.c プロジェクト: AlleyCat1976/Meridian59_103
/*
 * PlayMidiFile:  Play given MIDI file and notify given window when done.
 *   Returns 0 if successful, MCI error code otherwise.
 */
DWORD PlayMidiFile(HWND hWndNotify, char *fname)
{
   if (!has_midi)
      return 0;

#ifdef M59_MSS
   // If a sample was playing, end it
   if( AIL_sample_status( hseqImmediate ) != SMP_DONE )
      AIL_end_sample( hseqImmediate );

   // free memory from previous MIDI file
   if( pMIDIImmediate )
      AIL_mem_free_lock( pMIDIImmediate );

   // First try MP3 file
   char *ext = strstr( _strlwr( fname ), ".mid" );
   if( ext != NULL )
      strcpy( ext, ".mp3" );

   // load the file
   pMIDIImmediate = (BYTE *) AIL_file_read( fname, NULL );
   if( !pMIDIImmediate )
   {
      // Next try xmi file
      ext = strstr(fname, ".mp3" );
      if( ext != NULL )
         strcpy( ext, ".xmi" );
      
      pMIDIImmediate = (BYTE *) AIL_file_read( fname, NULL );
      if( !pMIDIImmediate )
      {
         debug(( "Failed to load music file %s.\n", fname ));
         return 0;
      }
   }

   // Initialize the sample
   if (!AIL_set_named_sample_file(hseqImmediate, fname, pMIDIImmediate,
                                  AIL_file_size(fname), 0))
   {
      debug(( "Failed to init music file.\n" ));
      return 0;
   }

   // Set volume
   float vol = ((float) config.music_volume) / CONFIG_MAX_VOLUME;
   AIL_set_sample_volume_levels(hseqImmediate, vol, vol );

   // start playing
   AIL_start_sample(hseqImmediate);

   // Set end-of-sample callback so we can unpause
   //	the background music when done playing.
   AIL_register_EOS_callback(hseqImmediate, MIDIDoneCallback);

   debug(( "Playing music file %s.\n", fname ));
   playing_midi = True;
   return 0;
#else
   {
      DWORD dwReturn;
      MCI_PLAY_PARMS mciPlayParms;

      if ((dwReturn = OpenMidiFile(fname)) != 0)
      {
        return dwReturn;
      }

      /*
       * Begin playback. The window procedure function
       * for the parent window is notified with an
       * MM_MCINOTIFY message when playback is complete.
       * The window procedure then closes the device.
       */
      mciPlayParms.dwCallback = (DWORD) hWndNotify;
      if (dwReturn = mciSendCommand(midi_element, MCI_PLAY,
                                    MCI_NOTIFY, (DWORD)(LPVOID) &mciPlayParms)) 
      {
         mciSendCommand(midi_element, MCI_CLOSE, 0, 0);
         return dwReturn;
      }
      
      debug(("Playing MIDI file, element = %d\n", midi_element));
      ResetMusicVolume();
      playing_midi = True;
      return 0;
   }
#endif
}