コード例 #1
0
      //
      // StopByRecord
      //
      // Stop all voices playing the given record
      //
      void StopByRecord(Record *r)
      {
        if (Initialized())
        {
          for (U32 i = 0; i < totalVoices; i++)
          {
            // Get the voice at this index
            Voice *voice = voices[i];

            if ((voice->Status() != SMP_DONE) && (voice->record == r))
            {
              voice->Stop();
            }
          }
        }
      }
コード例 #2
0
      //
      // FindVoicePlayingEffect
      //
      // Returns the first voice playing 'e', or NULL
      //
      static Voice * FindVoicePlayingEffect(Effect *e)
      {
        // Ensure index is valid
        if (e->GetVoiceIndex() < totalVoices)
        {
          // Get the voice at this index
          Voice *v = voices[e->GetVoiceIndex()];

          // Still playing and pointing to the given effect
          if ((v->Status() != SMP_DONE) && v->effect.Alive() && (v->effect == e))
          {
            return (v);
          }
        }

        return (NULL);
      }
コード例 #3
0
      //
      // RecordInUse
      //
      // TRUE if 'record' is currently being used by a voice
      //
      Bool RecordInUse(Record *record)
      {
        if (Initialized())
        {
          // Try and find a voice that is using the record
          for (U32 i = 0; i < totalVoices; i++)
          {
            // Get the voice at this index
            Voice *voice = voices[i];

            if (voice->Status() != SMP_DONE && voice->record == record)
            {
              return (TRUE);
            }
          }
        }

        return (FALSE);
      }
コード例 #4
0
      //
      // Request
      //
      // Request the use of a voice
      //
      static Voice * Request(F32 priority, Bool flag3D, U8 &index)
      {
        ASSERT(Initialized());

        // Try and find a voice that is currently free
		U32 i = 0;
        for (; i < totalVoices; i++)
        {
          // Get the voice at this index
          Voice *voice = voices[i];

          // Correct type and available for use
          if ((voice->flag3D == flag3D) && (voice->Status() == SMP_DONE))
          {
            index = (U8)i;
            return (voice);
          }
        }
 
        // Try and free a voice using the priority system
        for (i = 0; i < totalVoices; i++)
        {
          // Get the voice at this index
          Voice *voice = voices[i];

          // Correct type and lower priority
          if ((voice->flag3D == flag3D) && (voice->priority < priority))
          {
            index = (U8)i;
            voice->Stop();
            return (voice);
          }
        }

        return (NULL);     
      }