Exemple #1
0
// show the approximate position in MM:SS format
void UpdatePositionLabel(void)
{
	if(!BASS_FX_TempoGetRateRatio(chan)) return;
	{
		char c[30];
		float totalsec=(float)MESS(IDC_POS,TBM_GETRANGEMAX,0,0)/BASS_FX_TempoGetRateRatio(chan);
		float posec=(float)MESS(IDC_POS,TBM_GETPOS,0,0)/BASS_FX_TempoGetRateRatio(chan);
		sprintf(c,"Playing position: %02d:%02d / %02d:%02d", (int)posec/60,(int)posec%60,(int)totalsec/60,(int)totalsec%60);
		MESS(IDC_SPOS,WM_SETTEXT,0,c);
	}
}
Exemple #2
0
float GetNewBPM(DWORD hBPM)
{
	return BASS_FX_BPM_Translate(hBPM, BASS_FX_TempoGetRateRatio(chan)*100.0f, BASS_FX_BPM_TRAN_PERCENT2);

	// or you could do it this way too :)
	// return (orgBPM * BASS_FX_TempoGetRateRatio(chan));
}
Exemple #3
0
// get the beat position in seconds
void CALLBACK beatTimerProc(UINT uTimerID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2)
{
    if (BASS_FX_TempoGetRateRatio(chan)){
		double beatpos;
		char c[30];

		beatpos = BASS_ChannelBytes2Seconds(chan, BASS_ChannelGetPosition(chan, BASS_POS_BYTE)) / BASS_FX_TempoGetRateRatio(chan);
		sprintf(c,"Beat pos: %0.2f", beatpos);
		MESS(IDC_SBEAT,WM_SETTEXT,0,c);
	}
	timeKillEvent(uTimerID);
}
Exemple #4
0
pascal void TimerProc(EventLoopTimerRef inTimer, void *inUserData)
{
	float ratio=BASS_FX_TempoGetRateRatio(chan);
	if (!ratio) return;
	SetControl32BitValue(GetControl(15),(DWORD)BASS_ChannelBytes2Seconds(chan,BASS_ChannelGetPosition(chan,BASS_POS_BYTE))); // update position
	{ // show the approximate position in MM:SS format
		char c[50];
		DWORD totalsec=GetControl32BitMaximum(GetControl(15))/ratio;
		DWORD posec=GetControl32BitValue(GetControl(15))/ratio;
		sprintf(c,"Playing position: %02u:%02u / %02u:%02u",posec/60,posec%60,totalsec/60,totalsec%60);
		SetStaticText(14,c);
	}
}
HCHANNEL BassSoundEngine::PlayMusic(int sound_id, CHANNEL Ichannel, bool loop, float volume)
{
	if(Ichannel<0||Ichannel>=maxChannel){
		Ichannel = GetNewChannel();
		if(Ichannel<0)
			return NULL;
	}else
		FreeChannel(Ichannel);
	HSTREAM sound = playMusic[sound_id];
	channel[Ichannel] = sound;

	DWORD hr;
	bool useDSP = false;

	// set position
	float freq;
	if(Ichannel==0)
	{
		hr = BASS_ChannelGetAttribute(sound, BASS_ATTRIB_FREQ, &freq);
		hr = SetPosition(0, sound_id, 0);
		hr = BASS_FX_TempoGetRateRatio(sound);
		if(hr>0)
			useDSP = true;
		music_sampleRate = freq;
	}

	// set volume
	volumeDes[Ichannel] = volume*defaultVolume;
	hr = BASS_ChannelSetAttribute(sound, BASS_ATTRIB_VOL, volumeDes[Ichannel]);

	// start play
	hr = BASS_ChannelPlay(sound, useDSP?FALSE:TRUE);

	// set loop
	if(loop)
		hr = BASS_ChannelFlags(sound, BASS_SAMPLE_LOOP, BASS_SAMPLE_LOOP);

	if(Ichannel==0)
		Update(0);

	return sound;
}