Example #1
0
int MUSIC_InitGUS
   (
   midifuncs *Funcs
   )

   {
   int status;

   status = MUSIC_Ok;

   if ( GUSMIDI_Init() != GUS_Ok )
      {
      MUSIC_SetErrorCode( MUSIC_SoundCardError );
      return( MUSIC_Error );
      }

   Funcs->NoteOff           = GUSMIDI_NoteOff;
   Funcs->NoteOn            = GUSMIDI_NoteOn;
   Funcs->PolyAftertouch    = NULL;
   Funcs->ControlChange     = GUSMIDI_ControlChange;
   Funcs->ProgramChange     = GUSMIDI_ProgramChange;
   Funcs->ChannelAftertouch = NULL;
   Funcs->PitchBend         = GUSMIDI_PitchBend;
   Funcs->ReleasePatches    = NULL;//GUSMIDI_ReleasePatches;
   Funcs->LoadPatch         = NULL;//GUSMIDI_LoadPatch;
   Funcs->SetVolume         = GUSMIDI_SetVolume;
   Funcs->GetVolume         = GUSMIDI_GetVolume;

   MIDI_SetMidiFuncs( Funcs );

   return( status );
   }
Example #2
0
int MUSIC_StopSong
   (
   void
   )

   {
   MUSIC_StopFade();
   MIDI_StopSong();
   MUSIC_SetErrorCode( MUSIC_Ok );
   return( MUSIC_Ok );
   }
Example #3
0
int MUSIC_PlaySong
   (
   unsigned char *song,
   int loopflag
   )

   {
   int status;

   switch( MUSIC_SoundDevice )
      {
      case SoundBlaster :
      case Adlib :
      case ProAudioSpectrum :
      case SoundMan16 :
      case GenMidi :
      case SoundCanvas :
      case WaveBlaster :
      case SoundScape :
      case Awe32 :
      case UltraSound :
         MIDI_StopSong();
         status = MIDI_PlaySong( song, loopflag );
         if ( status != MIDI_Ok )
            {
            MUSIC_SetErrorCode( MUSIC_MidiError );
            return( MUSIC_Warning );
            }
         break;

      case SoundSource :
      case PC :
      default :
         MUSIC_SetErrorCode( MUSIC_InvalidCard );
         return( MUSIC_Warning );
         break;
      }

   return( MUSIC_Ok );
   }
Example #4
0
int MUSIC_FadeVolume
   (
   int tovolume,
   int milliseconds
   )

   {
   int fromvolume;

   if ( ( MUSIC_SoundDevice == ProAudioSpectrum ) ||
      ( MUSIC_SoundDevice == SoundMan16 ) ||
      ( MUSIC_SoundDevice == GenMidi ) ||
      ( MUSIC_SoundDevice == SoundScape ) ||
      ( MUSIC_SoundDevice == SoundCanvas ) )
      {
      MIDI_SetVolume( tovolume );
      return( MUSIC_Ok );
      }

   if ( MUSIC_FadeTask != NULL )
      {
      MUSIC_StopFade();
      }

   tovolume = max( 0, tovolume );
   tovolume = min( 255, tovolume );
   fromvolume = MUSIC_GetVolume();

   MUSIC_FadeLength = milliseconds / 25;
   MUSIC_FadeRate   = ( ( tovolume - fromvolume ) << 7 ) / MUSIC_FadeLength;
   MUSIC_LastFadeVolume = fromvolume;
   MUSIC_CurrentFadeVolume = fromvolume << 7;
   MUSIC_EndingFadeVolume = tovolume;

   MUSIC_FadeTask = TS_ScheduleTask( MUSIC_FadeRoutine, 40, 1, NULL );
   if ( MUSIC_FadeTask == NULL )
      {
      MUSIC_SetErrorCode( MUSIC_TaskManError );
      return( MUSIC_Warning );
      }

   TS_Dispatch();
   return( MUSIC_Ok );
   }
Example #5
0
File: music.c Project: Blzut3/Engoo
int MUSIC_PlaySong
   (
   unsigned char *song,
   int loopflag
   )

   {
   int status;

   MUSIC_StopSong();

   status = MIDI_PlaySong( song, loopflag );
   if ( status != MIDI_Ok )
      {
      MUSIC_SetErrorCode( MUSIC_MidiError );
      return( MUSIC_Warning );
      }

   return( MUSIC_Ok );
   }
Example #6
0
int MUSIC_InitAWE32
   (
   midifuncs *Funcs
   )

   {
   int status;

   status = AWE32_Init();
   if ( status != AWE32_Ok )
      {
      MUSIC_SetErrorCode( MUSIC_SoundCardError );
      return( MUSIC_Error );
      }

   Funcs->NoteOff           = AWE32_NoteOff;
   Funcs->NoteOn            = AWE32_NoteOn;
   Funcs->PolyAftertouch    = AWE32_PolyAftertouch;
   Funcs->ControlChange     = AWE32_ControlChange;
   Funcs->ProgramChange     = AWE32_ProgramChange;
   Funcs->ChannelAftertouch = AWE32_ChannelAftertouch;
   Funcs->PitchBend         = AWE32_PitchBend;
   Funcs->ReleasePatches    = NULL;
   Funcs->LoadPatch         = NULL;
   Funcs->SetVolume         = NULL;
   Funcs->GetVolume         = NULL;

   if ( BLASTER_CardHasMixer() )
      {
      BLASTER_SaveMidiVolume();
      Funcs->SetVolume = BLASTER_SetMidiVolume;
      Funcs->GetVolume = BLASTER_GetMidiVolume;
      }

   status = MUSIC_Ok;
   MIDI_SetMidiFuncs( Funcs );

   return( status );
   }
Example #7
0
int MUSIC_InitMidi
   (
   int        card,
   midifuncs *Funcs,
   int        Address
   )

   {
   int status;

   status = MUSIC_Ok;

   if ( ( card == WaveBlaster ) || ( card == SoundCanvas ) ||
      ( card == GenMidi ) )
      {
      // Setup WaveBlaster Daughterboard clone
      // (ie. SoundCanvas DB, TurtleBeach Rio)
      BLASTER_SetupWaveBlaster();
      }

   if ( card == SoundScape )
      {
      Address = SOUNDSCAPE_GetMIDIPort();
      if ( Address < SOUNDSCAPE_Ok )
         {
         MUSIC_SetErrorCode( MUSIC_SoundCardError );
         return( MUSIC_Error );
         }
      }

   if ( MPU_Init( Address ) != MPU_Ok )
      {
      MUSIC_SetErrorCode( MUSIC_MPU401Error );
      return( MUSIC_Error );
      }

   Funcs->NoteOff           = MPU_NoteOff;
   Funcs->NoteOn            = MPU_NoteOn;
   Funcs->PolyAftertouch    = MPU_PolyAftertouch;
   Funcs->ControlChange     = MPU_ControlChange;
   Funcs->ProgramChange     = MPU_ProgramChange;
   Funcs->ChannelAftertouch = MPU_ChannelAftertouch;
   Funcs->PitchBend         = MPU_PitchBend;
   Funcs->ReleasePatches    = NULL;
   Funcs->LoadPatch         = NULL;
   Funcs->SetVolume         = NULL;
   Funcs->GetVolume         = NULL;

   if ( card == WaveBlaster )
      {
      if ( BLASTER_CardHasMixer() )
         {
         BLASTER_SaveMidiVolume();
         Funcs->SetVolume = BLASTER_SetMidiVolume;
         Funcs->GetVolume = BLASTER_GetMidiVolume;
         }
      }

   MIDI_SetMidiFuncs( Funcs );

   return( status );
   }
Example #8
0
int MUSIC_InitFM
   (
   int card,
   midifuncs *Funcs
   )

   {
   int status;
   int passtatus;

   status = MIDI_Ok;

   if ( !AL_DetectFM() )
      {
      MUSIC_SetErrorCode( MUSIC_FMNotDetected );
      return( MUSIC_Error );
      }

   // Init the fm routines
   AL_Init( card );

   Funcs->NoteOff           = AL_NoteOff;
   Funcs->NoteOn            = AL_NoteOn;
   Funcs->PolyAftertouch    = NULL;
   Funcs->ControlChange     = AL_ControlChange;
   Funcs->ProgramChange     = AL_ProgramChange;
   Funcs->ChannelAftertouch = NULL;
   Funcs->PitchBend         = AL_SetPitchBend;
   Funcs->ReleasePatches    = NULL;
   Funcs->LoadPatch         = NULL;
   Funcs->SetVolume         = NULL;
   Funcs->GetVolume         = NULL;

   switch( card )
      {
      case SoundBlaster :
         if ( BLASTER_CardHasMixer() )
            {
            BLASTER_SaveMidiVolume();
            Funcs->SetVolume = BLASTER_SetMidiVolume;
            Funcs->GetVolume = BLASTER_GetMidiVolume;
            }
         else
            {
            Funcs->SetVolume = NULL;
            Funcs->GetVolume = NULL;
            }
         break;

      case Adlib :
         Funcs->SetVolume = NULL;
         Funcs->GetVolume = NULL;
         break;

      case ProAudioSpectrum :
      case SoundMan16 :
         Funcs->SetVolume = NULL;
         Funcs->GetVolume = NULL;

         passtatus = PAS_SaveMusicVolume();
         if ( passtatus == PAS_Ok )
            {
            Funcs->SetVolume = PAS_SetFMVolume;
            Funcs->GetVolume = PAS_GetFMVolume;
            }
         break;
      }

   MIDI_SetMidiFuncs( Funcs );

   return( status );
   }
Example #9
0
int MUSIC_Init
   (
   int SoundCard,
   int Address
   )

   {
   int i;
   int status;

   if ( USER_CheckParameter( "ASSVER" ) )
      {
      MUSIC_SetErrorCode( MUSIC_ASSVersion );
      return( MUSIC_Error );
      }

   status = LL_LockMemory();
   if ( status != LL_Ok )
      {
      MUSIC_SetErrorCode( MUSIC_DPMI_Error );
      return( MUSIC_Error );
      }

   for( i = 0; i < 128; i++ )
      {
      MIDI_PatchMap[ i ] = i;
      }

   status = MUSIC_Ok;
   MUSIC_SoundDevice = SoundCard;

   switch( SoundCard )
      {
      case SoundBlaster :
      case Adlib :
      case ProAudioSpectrum :
      case SoundMan16 :
         status = MUSIC_InitFM( SoundCard, &MUSIC_MidiFunctions );
         break;

      case GenMidi :
      case SoundCanvas :
      case WaveBlaster :
      case SoundScape :
         status = MUSIC_InitMidi( SoundCard, &MUSIC_MidiFunctions, Address );
         break;

      case Awe32 :
         status = MUSIC_InitAWE32( &MUSIC_MidiFunctions );
         break;

      case UltraSound :
         status = MUSIC_InitGUS( &MUSIC_MidiFunctions );
         break;

      case SoundSource :
      case PC :
      default :
         MUSIC_SetErrorCode( MUSIC_InvalidCard );
         status = MUSIC_Error;
      }

   if ( status != MUSIC_Ok )
      {
      LL_UnlockMemory();
      }

   return( status );
   }