Exemplo n.º 1
0
void SoundModuleBASS::Play()
{
    if(mHandle != 0)
    {
        BASS_MusicPlay(mHandle);
    }
}
Exemplo n.º 2
0
// --[  Method  ]---------------------------------------------------------------
//
//  - Class     : CSoundModule
//  - prototype : bool Play()
//
//  - Purpose   : Plays the module.
//
// -----------------------------------------------------------------------------
bool CSoundModule::Play()
{
    if(!IsValid())
    {
        return false;
    }

    return BASS_MusicPlay(m_handle) == TRUE;
}
Exemplo n.º 3
0
//used to play a certain music index
//will not play anything if ind exceeds num music
PUBLIC void GUTPlayMusic(unsigned int ind)
{
	if(ind < g_gameMusic.numMusic)
	{
		BASS_ChannelStop(g_gameMusic.music[g_gameMusic.curMusic]);

		g_gameMusic.curMusic=ind;
		BASS_MusicPlay(g_gameMusic.music[ind]);
	}
}
Exemplo n.º 4
0
//used to play a random song within the music list
//this will only change the music if the last music stopped playing
//this is ideally used in update loops
PUBLIC void GUTPlayRandMusic(unsigned int minInd, unsigned int maxInd)
{
	if(maxInd < minInd)
		maxInd = g_gameMusic.numMusic-1;

	if(minInd < g_gameMusic.numMusic && maxInd < g_gameMusic.numMusic
		&& BASS_ChannelIsActive(g_gameMusic.music[g_gameMusic.curMusic])==0)
	{
		g_gameMusic.curMusic = Random(minInd, maxInd);
		BASS_MusicPlay(g_gameMusic.music[g_gameMusic.curMusic]);
	}
}
Exemplo n.º 5
0
BOOL CALLBACK dialogproc(HWND h,UINT m,WPARAM w,LPARAM l)
{
	switch (m) {
		case WM_COMMAND:
			switch (LOWORD(w)) {
				case IDCANCEL:
					DestroyWindow(h);
					return 1;
				case 10:
					{
						char file[MAX_PATH]="";
						ofn.lpstrFilter="playable files\0*.mo3;*.xm;*.mod;*.s3m;*.it;*.mtm;*.mp3;*.mp2;*.mp1;*.ogg;*.wav\0All files\0*.*\0\0";
						ofn.lpstrFile=file;
						if (GetOpenFileName(&ofn)) {
							memcpy(path,file,ofn.nFileOffset);
							path[ofn.nFileOffset-1]=0;
							// free both MOD and stream, it must be one of them! :)
							BASS_MusicFree(chan);
							BASS_StreamFree(chan);
							if (!(chan=BASS_StreamCreateFile(FALSE,file,0,0,floatable?BASS_SAMPLE_FLOAT:0))
								&& !(chan=BASS_MusicLoad(FALSE,file,0,0,BASS_MUSIC_LOOP|BASS_MUSIC_RAMP|(floatable?BASS_MUSIC_FLOAT:0)))) {
								// whatever it is, it ain't playable
								MESS(10,WM_SETTEXT,0,"click here to open a file...");
								Error("Can't play the file");
								break;
							}
							if (BASS_ChannelGetFlags(chan)&BASS_SAMPLE_MONO) {
								// mono = not allowed
								MESS(10,WM_SETTEXT,0,"click here to open a file...");
								BASS_MusicFree(chan);
								BASS_StreamFree(chan);
								Error("mono sources are not supported");
								break;
							}
							MESS(10,WM_SETTEXT,0,file);
							// setup DSPs on new channel
							SendMessage(win,WM_COMMAND,11,0);
							SendMessage(win,WM_COMMAND,12,0);
							SendMessage(win,WM_COMMAND,13,0);
							// play both MOD and stream, it must be one of them!
							BASS_MusicPlay(chan);
							BASS_StreamPlay(chan,0,BASS_SAMPLE_LOOP);
						}
					}
					return 1;
				case 11: // toggle "rotate"
					if (MESS(11,BM_GETCHECK,0,0)) {
						rotpos=0.7853981f;
						rotdsp=BASS_ChannelSetDSP(chan,&Rotate,0);
					} else
						BASS_ChannelRemoveDSP(chan,rotdsp);
					break;
				case 12: // toggle "echo"
					if (MESS(12,BM_GETCHECK,0,0)) {
						memset(echbuf,0,sizeof(echbuf));
						echpos=0;
						echdsp=BASS_ChannelSetDSP(chan,&Echo,0);
					} else
						BASS_ChannelRemoveDSP(chan,echdsp);
					break;
				case 13: // toggle "flanger"
					if (MESS(13,BM_GETCHECK,0,0)) {
						memset(flabuf,0,sizeof(flabuf));
						flapos=0;
					    flas=FLABUFLEN/2;
					    flasinc=0.002f;
						fladsp=BASS_ChannelSetDSP(chan,&Flange,0);
					} else
						BASS_ChannelRemoveDSP(chan,fladsp);
					break;
			}
			break;

		case WM_INITDIALOG:
			win=h;
			GetCurrentDirectory(MAX_PATH,path);
			memset(&ofn,0,sizeof(ofn));
			ofn.lStructSize=sizeof(ofn);
			ofn.hwndOwner=h;
			ofn.hInstance=inst;
			ofn.nMaxFile=MAX_PATH;
			ofn.lpstrInitialDir=path;
			ofn.Flags=OFN_HIDEREADONLY|OFN_EXPLORER;
			// initialize - default device, 44100hz, stereo, 16 bits, floating-point DSP
			if (!BASS_Init(-1,44100,BASS_DEVICE_FLOATDSP,win)) {
				Error("Can't initialize device");
				DestroyWindow(win);
				return 1;
			}
			BASS_Start();
			// check for floating-point capability
			floatable=BASS_StreamCreate(44100,BASS_SAMPLE_FLOAT,NULL,0);
			if (floatable) BASS_StreamFree(floatable); // woohoo!
			return 1;
	}
	return 0;
}