xboxscene.org forums

OG Xbox Forums => Software Forums => Development => Topic started by: celinedrules on April 25, 2005, 09:10:00 PM

Title: Looping Wav Files
Post by: celinedrules on April 25, 2005, 09:10:00 PM
CODE
CSound g_backgrnd;
{

InitialiseD3D();
g_backgrnd.Create( "D:\\media\\background.wav" );
g_backgrnd.playsound();

 while(true)
      {

            g_pD3DDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 255), 1.0f, 0);
            g_pD3DDevice->BeginScene();

     XFactorTextureAdvert();

            g_pD3DDevice->EndScene();

            g_pD3DDevice->Present(NULL, NULL, NULL, NULL);
      }    

   g_backgrnd.Release();

      CleanUp();
}

And in sound.cpp:
CODE
#include "sound.h"

IDirectMusicLoader8*  CSound::m_pLoader  = NULL;
IDirectMusicPerformance8*   CSound::m_pPerformance   = NULL;

void CSound::Create(char* filename) //e.g. "D:\\chomp.wav"
{
   
   if( (m_pLoader == NULL) && (m_pPerformance == NULL))
   {
  SetupSound();
   }

   LoadSound(filename);
}

void CSound::LoadSound(char* filename) //e.g. "D:\\chomp.wav"
{   
   m_pLoader->LoadObjectFromFile( CLSID_DirectMusicSegment, IID_IDirectMusicSegment8,
                                  filename, (VOID**)&m_pSoundSegment);
}

void CSound::playsound()
{
   m_pPerformance->PlaySegmentEx( m_pSoundSegment, NULL, NULL, DMUS_SEGF_SECONDARY,
                                     0, NULL, NULL, NULL );
}

void CSound::SetupSound()
{

    IDirectMusicHeap* pNormalHeap;
    DirectMusicCreateDefaultHeap( &pNormalHeap );

    IDirectMusicHeap* pPhysicalHeap;
    DirectMusicCreateDefaultPhysicalHeap( &pPhysicalHeap );

    DirectMusicInitializeEx( pNormalHeap, pPhysicalHeap, &DirectMusicDefaultFactory );

    pNormalHeap->Release();
    pPhysicalHeap->Release();
   

    DirectMusicCreateInstance( CLSID_DirectMusicLoader, NULL,
                               IID_IDirectMusicLoader8, (VOID**)&m_pLoader );

    DirectMusicCreateInstance( CLSID_DirectMusicPerformance, NULL,
                               IID_IDirectMusicPerformance8, (VOID**)&m_pPerformance );

    
  m_pPerformance->InitAudioX( DMUS_INITAUDIO_NOTHREADS, 64, 128, 0 );



}

void CSound::Release()
{
   m_pSoundSegment->Release();
   
}
Title: Looping Wav Files
Post by: fghjj on April 26, 2005, 05:11:00 AM
beerchug.gif
Title: Looping Wav Files
Post by: celinedrules on April 26, 2005, 10:22:00 AM
That works thanks. There is just one thing, when it loops there is a brief pause about 1/2 a second. Is there a way to get rid of that?