Beispiel #1
0
/*------------------------
	イニシャライズ
  -------------------------*/
STDMETHODIMP CFACE::Sound( LONG DSMODE ){ if ( DSMODE == dwSndMode ) return S_OK;
	// ログに記述
		LogBegin( "Sounds Initializer" );
		LogPut( CONTINUE , IDS_LOG_MODEOUT , DSMODE ); 

	// ハンドルチェック
		CHECK_HWND;
	// グラフィック定数範囲チェック
		CHECK_RANGE( DSMODE , 0 , 1 );

	// 使用しないモード
	if ( DSMODE == SOUNDDISABLE ) SoundRelease( ); 
	else{
		SoundRelease( );	// 全解放
		// DirectSound を作成する。
		if ( FAILED( DirectSoundCreate( NULL , &ObjDS , NULL ) ) )
			DSoundInitFailed;
		// 協調レベルを設定する
		if ( FAILED( ObjDS->SetCooperativeLevel( hWnd , DSSCL_NORMAL ) ) )
			DSoundInitFailed;
		// イベントの作成
		// at Half, at EndPos , FinallyHandler at Half
		for ( int i = 0 ; i < 3 ; i++ ) 
			hEvent[ i ] = CreateEvent( NULL , FALSE , FALSE , NULL );
	}
	dwSndMode = (BYTE)DSMODE;
	LogQuit( );
	return S_OK;
}
Beispiel #2
0
void LoadResourceSOUND(const char *path_name, int surface)
{
    int i;
    //if(MuteLog) return;

    EffectsOff();

    XBuffer buf;
    XStream ff(0);
    for(i = 0; i < EFF_MAX; i++) {

        if ((SndData[i].status & LOCAL_SOUND) && SndData[i].lpDSB && surface) {
            SoundRelease(SndData[i].lpDSB);
            SndData[i].lpDSB = NULL;
        }

        buf.init();
        if((i == EFF_DRIVING) || (i == EFF_START) || (i == EFF_STOP)) {
            if(EngineNoise) {
                buf < "resource/sound/effects" < "/" < SndData[i].fname < ".wav";
            } else {
                continue;
            }
        } else {
            buf < path_name < "/" < SndData[i].fname < ".wav";
        }

        if(ff.open(buf.GetBuf(),XS_IN)) {
            ff.close();
            if (SndData[i].lpDSB) {
                SoundRelease(SndData[i].lpDSB);
                SndData[i].lpDSB = NULL;
            }
            SoundLoad(buf.GetBuf(),&SndData[i].lpDSB);

        }
        //std::cout<<"file:"<<buf.GetBuf()<<" addr:"<<SndData[i].lpDSB<<std::endl;
    }
    EffectsOn(surface);

    sndBackgroundMax = sndStepMax = sndScratchMax = 0;
    for(i = EFF_BACKGROUND_0; i <= EFF_BACKGROUND_5; i++)
        if(SndData[i].lpDSB) sndBackgroundMax++;
    for(i = EFF_STEP0; i <= EFF_STEP2; i++)
        if(SndData[i].lpDSB) sndStepMax++;
    for(i = EFF_SCRATCH0; i <= EFF_SCRATCH1; i++)
        if(SndData[i].lpDSB) sndScratchMax++;
}
Beispiel #3
0
void LocalEffectFree(void) {
    EffectsOff();
    for(int i = 0; i < EFF_MAX; i++) {
        if ((SndData[i].status & LOCAL_SOUND) && SndData[i].lpDSB) {
            SoundRelease(SndData[i].lpDSB);
            SndData[i].lpDSB = NULL;
        }
    }
    EffectsOn(1);
}
Beispiel #4
0
void SoundEscaveOff(void) {

    EffectsOff();
    for(int i = 0; i < EFF_MAX; i++) {

        if ((SndData[i].status & ESCAVE_SOUND) && SndData[i].lpDSB) {
            SoundRelease(SndData[i].lpDSB);
            SndData[i].lpDSB = NULL;
        }
    }
    EffectsOn(0);
}
Beispiel #5
0
void LoadMotorSound(void) {
    XBuffer buf;
    XStream ff(0);
    for(int i = 0; i < 3; i++) {
        buf.init();

        if(EngineNoise)
            buf < "resource/sound/effects/" < "/" < SndData[i].fname < ".wav";

        if(ff.open(buf.GetBuf(),XS_IN)) {
            ff.close();
            if (SndData[i].lpDSB) {
                SoundStop(SndData[i].channel);
                SoundRelease(SndData[i].lpDSB);
                SndData[i].lpDSB = NULL;
            }
            SoundLoad(buf.GetBuf(),&SndData[i].lpDSB);
        }
    }	//  end for i
}