Esempio n. 1
0
BOOL InitSound()
{
	DSBUFFERDESC	dsbdesc;


	if (!hWnd)
	{
		return true;
	}

	if (!lpds)
	{
		//Create DirectSound interface
		if (DirectSoundCreate8(NULL, &lpds, NULL))
		{
			Error("DirectSoundCreate8(NULL, &lpds, NULL)");
			return true;
		}

		//Set cooperative level
		if (lpds->SetCooperativeLevel(hWnd, DSSCL_NORMAL))
		{
			Error("lpds->SetCooperativeLevel(hWnd, DSSCL_NORMAL)");
			CloseSound();
			return true;
		}
	}


	//Get primary buffer and set it to run silently
	if (!lpdsbPrimary)
	{
		ZeroMemory(&dsbdesc, sizeof(dsbdesc));
		dsbdesc.dwSize = sizeof(dsbdesc);
		dsbdesc.dwFlags = DSBCAPS_PRIMARYBUFFER;
		if (lpds->CreateSoundBuffer(&dsbdesc, &lpdsbPrimary, NULL))
		{
			Error("lpds->CreateSoundBuffer(&dsbdesc, &lpdsbPrimary, NULL)");
			CloseSound();
			return true;
		}

		if (lpdsbPrimary->Play(0, 0, DSBPLAY_LOOPING))
		{
			Error("lpdsbPrimary->Play(0, 0, DSBPLAY_LOOPING)");
			CloseSound();
			return true;
		}
	}

	Settings.SoundEnabled = true;

	return false;
}
Esempio n. 2
0
/*
 * make a sound like thunder
 * this function is called after each time BoltSound is called
 */
static void BoomSound()
/*********************/
{
    short i;
    short low;
    short high;

    StopSound();
    SetVoiceQueueSize( 1, 600 );

    SetVoiceAccent( 1, 120, 50, S_STACCATO, 0 );

    for( i=0; i < 1000; i++ ) {
        /*
         * create a random low-pitched sound
         */
        high = rand() % 200 + 1;
        low = rand() % high + 1;
        SetVoiceSound( 1, MAKELONG( low, high ), 1 );
    }
    StartSound();
    WaitSoundState( S_QUEUEEMPTY ); /* wait for the sound to finish */
    StopSound();
    CloseSound();
} /* BoomSound */
Esempio n. 3
0
 SoundHubObject::~SoundHubObject()
 {
     CloseSound();
 }
Esempio n. 4
0
void WindowsTerm()
{
	CloseSound( sd );
}