Exemplo n.º 1
0
int GetTime(HSTREAM stream)
{
    QWORD pos = BASS_ChannelGetPosition(stream);
    float secs = BASS_ChannelBytes2Seconds(stream, pos);
    secs *= 1000.0f;
    return (int)secs;
}
Exemplo n.º 2
0
bool BassPlayer::fileInfo(const QUrl & uri, IMediaInfo * info) {
    bool currently_played = media_url.isValid() && uri == media_url;

    int chUID;

    if (currently_played)
        chUID = chan;
    else {
        if (uri.isLocalFile())
            chUID = open(uri.toLocalFile(), LOCAL_PLAY_ATTRS);
        else
            chUID = openRemote(uri.toString(), REMOTE_PLAY_ATTRS);

        if (!chUID) return false;
    }

    float time = BASS_ChannelBytes2Seconds(chUID, BASS_ChannelGetLength(chUID, BASS_POS_BYTE)); // playback duration
    qint64 len = BASS_StreamGetFilePosition(chUID, BASS_FILEPOS_END); // file length

    info -> setDuration(time);
    info -> setBitrate((len / (125 * time) + 0.5));

    BASS_CHANNELINFO media_info;
    if (BASS_ChannelGetInfo(chUID, &media_info)) {
        info -> setSize(len + BASS_StreamGetFilePosition(chUID, BASS_FILEPOS_START));
        info -> setSampleRate(media_info.freq);
        info -> setChannels(media_info.chans);
    }

    if (!currently_played)
        BASS_StreamFree(chUID);
    return true;
}
Exemplo n.º 3
0
int GetDuration(HSTREAM stream)
{
    QWORD bytelength = BASS_ChannelGetLength(stream);
    float secs = BASS_ChannelBytes2Seconds(stream, bytelength); 
    secs *= 1000; // to ms
    return (int)secs;
}
Exemplo n.º 4
0
void MusicSelection::checkThatMusicIsPlayingWithinRange()
{
	double currentPosition = BASS_ChannelBytes2Seconds(bgm, (BASS_ChannelGetPosition(bgm, BASS_POS_BYTE)));
	if (currentPosition > beatMaps[currentSelectedMusicIndex].musicEndPosition || currentPosition < beatMaps[currentSelectedMusicIndex].musicStartPosition)
	{
		BASS_ChannelSetPosition(bgm, BASS_ChannelSeconds2Bytes(bgm, beatMaps[currentSelectedMusicIndex].musicStartPosition), BASS_POS_BYTE);
		BASS_ChannelPlay(bgm, false);
	}
}
DWORD CBSoundBuffer::GetPosition()
{
	if (m_Stream)
	{
		QWORD len = BASS_ChannelGetPosition(m_Stream, BASS_POS_BYTE);
		return 1000 * BASS_ChannelBytes2Seconds(m_Stream, len);
	}
	else return 0;
}
Exemplo n.º 6
0
void PlaybackWidget::changeSong(QString songPath)
{
    stopSong();
	curchan = BASS_StreamCreateFile(false,songPath.utf16(),0,0,
                                    BASS_SAMPLE_FLOAT | BASS_STREAM_AUTOFREE | BASS_UNICODE);
    BASS_ChannelPlay(curchan,false);
    cursongblength = BASS_ChannelGetLength(curchan, BASS_POS_BYTE);
    cursonglength = BASS_ChannelBytes2Seconds(curchan,cursongblength);
    changeState(PLAYING);
}
Exemplo n.º 7
0
unsigned int CClientSound::GetLength ( void )
{
    if ( m_pSound )
    {
        QWORD length = BASS_ChannelGetLength( m_pSound, BASS_POS_BYTE );
        if ( length != -1 )
            return static_cast <unsigned int> ( BASS_ChannelBytes2Seconds( m_pSound, length ) * 1000 );
    }
    return 0;
}
Exemplo n.º 8
0
unsigned int CClientSound::GetPlayPosition ( void )
{
    if ( m_pSound )
    {
        QWORD pos = BASS_ChannelGetPosition( m_pSound, BASS_POS_BYTE );
        if ( pos != -1 )
            return static_cast <unsigned int> ( BASS_ChannelBytes2Seconds( m_pSound, pos ) * 1000 );
    }
    return 0;
}
Exemplo n.º 9
0
HSTREAM CBassMusicEngine::LoadFile( LPCTSTR lpszFileName )
{
	tagMusicInfo _Info;
	ZeroMemory(&_Info,sizeof _Info);

	if (!(_Info.hStream = BASS_StreamCreateFile(FALSE, lpszFileName,0,0,BASS_SAMPLE_MONO)))
	{
		ShowError(TEXT("不能打开该文件"));
		return -1;
	}

	_Info.dwTime = BASS_ChannelBytes2Seconds(_Info.hStream,BASS_ChannelGetLength(_Info.hStream,BASS_POS_BYTE) );

	TAG_ID3 *pTag = (TAG_ID3 *)BASS_ChannelGetTags(_Info.hStream,BASS_TAG_ID3);
	if ( pTag != NULL )
	{
#ifdef UNICODE
		MultiByteToWideChar(CP_ACP, 0, pTag->artist, -1, _Info.szArtist, 30);
		MultiByteToWideChar(CP_ACP, 0, pTag->title, -1, _Info.szTitle, 30);

		if ( lstrlen(_Info.szArtist) == 0 )
		{
			lstrcpyn(_Info.szArtist,TEXT("未知"),CountArray(_Info.szArtist));
		}

		if ( lstrlen(_Info.szTitle) == 0 )
		{
			CString StrTitle(lpszFileName);

			StrTitle = StrTitle.Right(StrTitle.GetLength()-StrTitle.ReverseFind('\\')-1);
			StrTitle = StrTitle.Left(StrTitle.Find('.'));
			lstrcpyn(_Info.szTitle,StrTitle,CountArray(_Info.szTitle));
		}
#else
		lstrcpyn(_Info.szArtist,CString(pTag->artist),CountArray(_Info.szArtist));
		lstrcpyn(_Info.szTitle,CString(pTag->title),CountArray(_Info.szTitle));
#endif
	}
	else
	{
		CString StrTitle(lpszFileName);

		StrTitle = StrTitle.Right(StrTitle.GetLength()-StrTitle.ReverseFind('\\')-1);
		StrTitle = StrTitle.Left(StrTitle.Find('.'));

		lstrcpyn(_Info.szArtist,TEXT("未知"),CountArray(_Info.szArtist));
		lstrcpyn(_Info.szTitle,StrTitle,CountArray(_Info.szTitle));
	}

	m_MusicEngineMap.insert(pair<HSTREAM,tagMusicInfo>(_Info.hStream,_Info));

	//Play(_Info.hStream);

	return _Info.hStream;
}
Exemplo n.º 10
0
// Non-streams only
double CBassAudio::GetPlayPosition ( void )
{
    // Only relevant for non-streams, which are always ready if valid
    if ( m_pSound )
    {
        QWORD pos = BASS_ChannelGetPosition( m_pSound, BASS_POS_BYTE );
        if ( pos != -1 )
            return BASS_ChannelBytes2Seconds( m_pSound, pos );
    }
    return 0;
}
Exemplo n.º 11
0
// Non-streams only
double CBassAudio::GetLength ( void )
{
    // Only relevant for non-streams, which are always ready if valid
    if ( m_pSound )
    {
        QWORD length = BASS_ChannelGetLength( m_pSound, BASS_POS_BYTE );
        if ( length != -1 )
            return BASS_ChannelBytes2Seconds( m_pSound, length );
    }
    return 0;
}
Exemplo n.º 12
0
pascal OSStatus OpenEventHandler(EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData)
{
	NavDialogRef fileDialog;
	NavDialogCreationOptions fo;
	NavGetDefaultDialogCreationOptions(&fo);
	fo.optionFlags=0;
	fo.parentWindow=win;
	NavCreateChooseFileDialog(&fo,NULL,NULL,NULL,NULL,NULL,&fileDialog);
// if someone wants to somehow get the file selector to filter like in the Windows example, that'd be nice ;)
	if (!NavDialogRun(fileDialog)) {
		NavReplyRecord r;
		if (!NavDialogGetReply(fileDialog,&r)) {
			AEKeyword k;
			FSRef fr;
			if (!AEGetNthPtr(&r.selection,1,typeFSRef,&k,NULL,&fr,sizeof(fr),NULL)) {
				char file[256];
				FSRefMakePath(&fr,(BYTE*)file,sizeof(file));
				BASS_StreamFree(chan); // free old stream before opening new
				if (!(chan=BASS_StreamCreateFile(FALSE,file,0,0,BASS_SAMPLE_LOOP|BASS_SAMPLE_FLOAT))) {
					SetControlTitleWithCFString(inUserData,CFSTR("click here to open a file..."));
					{
						ControlRef cref=GetControl(11);
						SetControlData(cref,kControlNoPart,kControlStaticTextTextTag,0,"");
						DrawOneControl(cref);
					}
					SetControl32BitMaximum(GetControl(12),0);
					Error("Can't play the file");
				} else {
					CFStringRef cs=CFStringCreateWithCString(0,file,kCFStringEncodingUTF8);
					SetControlTitleWithCFString(inUserData,cs);
					CFRelease(cs);
					{ // display the file type and length
						QWORD bytes=BASS_ChannelGetLength(chan,BASS_POS_BYTE);
						DWORD time=BASS_ChannelBytes2Seconds(chan,bytes);
						BASS_CHANNELINFO info;
						BASS_ChannelGetInfo(chan,&info);
						sprintf(file,"channel type = %x (%s)\nlength = %llu (%u:%02u)",
							info.ctype,GetCTypeString(info.ctype,info.plugin),bytes,time/60,time%60);
						{
							ControlRef cref=GetControl(11);
							SetControlData(cref,kControlNoPart,kControlStaticTextTextTag,strlen(file),file);
							DrawOneControl(cref);
						}
						SetControl32BitMaximum(GetControl(12),time); // update scroller range
					}
					BASS_ChannelPlay(chan,FALSE);
				}
			}
			NavDisposeReply(&r);
		}
	}
	NavDialogDispose(fileDialog);
    return noErr;
}
Exemplo n.º 13
0
/*
	Добавление песни в плейлист
*/
VOID DlgPlayList::addSongToPlayList(HSTREAM stream, TCHAR* path)
{
	TAG_ID3* id3 = (TAG_ID3*)BASS_ChannelGetTags(stream, BASS_TAG_ID3);		//получение данных о песне
	std::wstringstream infoAboutTheSong;									//Буфер строки (Название песни + Исполнитель + время)
	infoSong info;					
	QWORD lengthSong = BASS_ChannelGetLength(stream, BASS_POS_BYTE);		//длина песни в байтах
	INT seconds = BASS_ChannelBytes2Seconds(stream, lengthSong);			//длина песни в секундах
	INT min = seconds / 60;													//Определение минут
	seconds = seconds % 60;							//Определение секунд
	/*
		Заполнение данных о песне
	*/
	if (id3 == NULL || strlen(id3->artist) == 0)
	{
		INT idx = lstrlen(path);
		INT length = idx;
		TCHAR name[MAX_PATH];
		INT k = 0;
		while (path[idx] != '\\')
		{
			idx--;
		}
		for (INT i = idx + 1; i < length;i++)
		{
			name[k] = path[i];
			k++;
		}
		name[k - 4] = '\0';					//Удаление формата песни
		infoAboutTheSong << name << "               ";
	}
	else
	{
		strcpy(info.title, id3->title);							//Name
		strcpy(info.artist, id3->artist);						//Author
		strcpy(info.album, id3->album);							//Album
		strcpy(info.year, id3->year);							//Year
		infoAboutTheSong << info.artist << " "
			<< info.title << "               ";
	}
	info.minutes = min;														//Minutes
	info.seconds = seconds;													//Seconds
	info.hStream = stream;													//Stream
	lstrcpy(info.path, path);												//Path of the song
	/*
		Запись времени песни в строку
	*/
	infoAboutTheSong << info.minutes << ":";
	if (seconds < 10)
		infoAboutTheSong << "0" << info.seconds;
	else
		infoAboutTheSong << info.seconds;
	ListBox_AddString(hPlayList, infoAboutTheSong.str().c_str());			//Add in PlayList
	songs.push_back(info);													//Add in vector
}
Exemplo n.º 14
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);
}
Exemplo n.º 15
0
void BASS_AudioInterface::update(float time_increase)
{
	// control playback and return time position
	int state  = BASS_ChannelIsActive(mStream);

	mTime = BASS_ChannelBytes2Seconds(mStream, BASS_ChannelGetPosition(mStream, BASS_POS_BYTE));

	float duration = mClip->getDuration();
	if (mTime > duration) {
		mTime=duration;
	}
}
Exemplo n.º 16
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);
	}
}
Exemplo n.º 17
0
int CAudio::GetAt() 
{
	if (m_bIsOnlineStream)
		return -1;

	// Do we have a valid channel?
	if (m_dwChannel) 
	{
		long length = BASS_ChannelGetPosition(m_dwChannel, BASS_POS_BYTE);
		return BASS_ChannelBytes2Seconds (m_dwChannel, length);
	}
	return -1;
}
Exemplo n.º 18
0
void logic()
{ 	
	if (music_started == -1) { BASS_ChannelPlay(music_channel,FALSE); music_started = 1; }

	QWORD bytepos = BASS_ChannelGetPosition(music_channel, BASS_POS_BYTE);
	double pos = BASS_ChannelBytes2Seconds(music_channel, bytepos);
	millis = (float)pos*1000;

	//printf("millis:%f\n", millis);

	UpdateShaderParams();

	glutPostRedisplay();
}
Exemplo n.º 19
0
int CAudio::GetLength()
{
	if (m_bIsOnlineStream)
		return -1;
	
	if (m_dwChannel)
	{
		// get length
		long length = BASS_ChannelGetLength (m_dwChannel, BASS_POS_BYTE);
		
		// convert into seconds and return
		return BASS_ChannelBytes2Seconds(m_dwChannel, length);
	}
	return -1;
}
Exemplo n.º 20
0
void PlaybackWidget::update()
{
    //Check if the song is finished, and request the next one from playlist
    if(state == PLAYING && !BASS_ChannelIsActive(curchan))
    {
        state = STOPPED;
        emit songOver();
    }
    //Now update the gui elements
    QWORD pos = BASS_ChannelGetPosition(curchan, BASS_POS_BYTE);
    int ms = BASS_ChannelBytes2Seconds(curchan, pos);
    float ratio = (float)ms/cursonglength;
    ui.playedLbl->setText(msToString(ms));
    ui.totalLbl->setText("-" + msToString(cursonglength - ms));
    int val = ratio*ui.playSlider->maximum();
    ui.playSlider->setValue(val);
}
Exemplo n.º 21
0
// --[  Method  ]---------------------------------------------------------------
//
//  - Class     : CSoundStream
//  - prototype : bool GetPlayPos(float* pfSeconds) const
//
//  - Purpose   : Gets the current playing position (seconds) of the stream.
//
// -----------------------------------------------------------------------------
bool CSoundStream::GetPlayPos(float* pfSeconds) const
{
    if(!IsValid())
    {
        return false;
    }

    QWORD pos = BASS_ChannelGetPosition(m_handle);

    if(pos == -1)
    {
        return false;
    }

    *pfSeconds = BASS_ChannelBytes2Seconds(m_handle, pos);
    return true;
}
Exemplo n.º 22
0
void DrawTimeLine(HDC dc, QWORD pos, DWORD col, DWORD y)
{
	HPEN pen=CreatePen(PS_SOLID,0,col),oldpen;
	DWORD wpos=pos/bpp;
	DWORD time=BASS_ChannelBytes2Seconds(chan,pos)*1000; // position in milliseconds
	char text[16];
	sprintf(text,"%u:%02u.%03u",time/60000,(time/1000)%60,time%1000);
	oldpen=(HPEN)SelectObject(dc,pen);
	MoveToEx(dc,wpos,0,NULL);
	LineTo(dc,wpos,HEIGHT);
	SetTextColor(dc,col);
	SetBkMode(dc,TRANSPARENT);
	SetTextAlign(dc,wpos>=WIDTH/2?TA_RIGHT:TA_LEFT);
	TextOut(dc,wpos,y,text,strlen(text));
	SelectObject(dc,oldpen);
	DeleteObject(pen);
}
Exemplo n.º 23
0
// --[  Method  ]---------------------------------------------------------------
//
//  - Class     : CSoundStream
//  - prototype : bool GetPlayLength(float* pfSeconds) const
//
//  - Purpose   : Gets the stream length (seconds).
//
// -----------------------------------------------------------------------------
bool CSoundStream::GetPlayLength(float* pfSeconds) const
{
    if(!IsValid())
    {
        return false;
    }

    QWORD len  = BASS_StreamGetLength(m_handle); // length in bytes

    if(len == -1)
    {
        return false;
    }

    *pfSeconds = BASS_ChannelBytes2Seconds(m_handle, len); // the time length
    return true;
}
Exemplo n.º 24
0
void PlayIntro()
{
	//WriteDebug("Play Start.\n");
	if (setupcfg.music)
	{
#ifdef RELEASETYPE_DEMO
		BASS_StreamPlay(str,FALSE,0);
#else
		mvxSystem_Play();
#endif
		//WriteDebug("Music Start.\n");
	}
	int StartTime=timeGetTime();
	int Time=0;
	while (!Done)
	{
		if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg); 
		}
		else if (Keys[VK_ESCAPE]) Done=true;
		else
		{
			glDisable(GL_SCISSOR_TEST);

			glClear(0x4100);

#ifdef RELEASETYPE_DEMO
			if (setupcfg.music) Time=(int)(BASS_ChannelBytes2Seconds(str,BASS_ChannelGetPosition(str))*100.0f);
#else
			if (setupcfg.music) Time=(int)(mvxSystem_GetSync()/10.0f);
#endif
			else                Time=(int)((timeGetTime()-StartTime)/10);
			//Time+=10;
			
			DisplayFrame(Time, MaterialList, SceneList, WorldList, EventList, EventNum);

			SwapBuffers(hDC);
			//Sleep(10);
			//if (Time>10140) Done=true;
		}
	}
}
Exemplo n.º 25
0
// scan the peaks
void __cdecl ScanPeaks(void *p)
{
	DWORD decoder=(DWORD)p;
	DWORD pos=0;
	float spp=BASS_ChannelBytes2Seconds(decoder,bpp); // seconds per pixel
	while (!killscan) {
		float peak[2];
		if (spp>1) { // more than 1 second per pixel, break it down...
			float todo=spp;
			peak[1]=peak[0]=0;
			do {
				float level[2],step=(todo<1?todo:1);
				BASS_ChannelGetLevelEx(decoder,level,step,BASS_LEVEL_STEREO); // scan peaks
				if (peak[0]<level[0]) peak[0]=level[0];
				if (peak[1]<level[1]) peak[1]=level[1];
				todo-=step;
			} while (todo>0);
		} else
			BASS_ChannelGetLevelEx(decoder,peak,spp,BASS_LEVEL_STEREO); // scan peaks
		{
			DWORD a;
			for (a=0;a<peak[0]*(HEIGHT/2);a++)
				wavebuf[(HEIGHT/2-1-a)*WIDTH+pos]=1+a; // draw left peak
			for (a=0;a<peak[1]*(HEIGHT/2);a++)
				wavebuf[(HEIGHT/2+1+a)*WIDTH+pos]=1+a; // draw right peak
		}
		pos++;
		if (pos>=WIDTH) break; // reached end of display
		if (!BASS_ChannelIsActive(decoder)) break; // reached end of channel
	}
	if (!killscan) {
		DWORD size;
		BASS_ChannelSetPosition(decoder,(QWORD)-1,BASS_POS_BYTE|BASS_POS_SCAN); // build seek table (scan to end)
		size=BASS_ChannelGetAttributeEx(decoder,BASS_ATTRIB_SCANINFO,0,0); // get seek table size
		if (size) { // got it
			void *info=malloc(size); // allocate a buffer
			BASS_ChannelGetAttributeEx(decoder,BASS_ATTRIB_SCANINFO,info,size); // get the seek table
			BASS_ChannelSetAttributeEx(chan,BASS_ATTRIB_SCANINFO,info,size); // apply it to the playback channel
			free(info);
		}
	}
	BASS_StreamFree(decoder); // free the decoder
	scanthread=0;
}
Exemplo n.º 26
0
double BassDecoder::length() const {
  #if defined(LIBTOOLS_WINDOWS) && !defined(BASS_H)
  if (!BASS_ChannelGetLength || 
      !BASS_ChannelBytes2Seconds || 
      !BASS_ErrorGetCode)
  {
    std::cerr << "Missing BASS_ChannelGetLength, BASS_ChannelBytes2Seconds or BASS_ErrorGetCode function" << std::endl;
    return -1;
  }
  #endif 

  if (_music)
  {
    QWORD ret = BASS_ChannelGetLength((DWORD)_music,BASS_POS_BYTE);
    if (ret==-1) return -1;
    return BASS_ChannelBytes2Seconds((DWORD)_music,ret);
  }
  return -1;
}
Exemplo n.º 27
0
float BassPlayer::bpmCalc(const QUrl & uri) {
    int cochan;

    if (uri.isLocalFile())
        cochan = open(uri.toLocalFile(), LOCAL_BPM_ATTRS);// BASS_StreamCreateFile(false, uri.toLocalFile().toStdWString().c_str(), 0, 0, LOCAL_BPM_ATTRS);
    else
        cochan = openRemote(uri.toString(), REMOTE_BPM_ATTRS); //BASS_StreamCreateURL(uri.toString().toStdString().c_str(), 0, REMOTE_BPM_ATTRS, NULL, 0);

    if (cochan) {
        int playBackDuration = BASS_ChannelBytes2Seconds(cochan, BASS_ChannelGetLength(cochan, BASS_POS_BYTE));

        return BASS_FX_BPM_DecodeGet(cochan,
            0,
            playBackDuration,
            MAKEWORD(20, 180),
            BASS_FX_FREESOURCE, //BASS_FX_BPM_BKGRND // BASS_FX_BPM_MULT2
            NULL, NULL
        );
    } else return 0;
}
Exemplo n.º 28
0
/*
	WM_TIMER
*/
VOID Application::Cls_OnTimer(HWND hwnd, UINT id)
{
	if (id == id_timer)
	{
		QWORD len = BASS_ChannelGetLength(hStream, BASS_POS_BYTE);
		INT seconds = BASS_ChannelBytes2Seconds(hStream, len);
		SendMessage(hTBPlayingSong, TBM_SETPOS, TRUE, (LPARAM)secPlaying);
		INT pos = SendMessage(hTBPlayingSong, TBM_GETPOS, 0, 0);
		if (secPlaying == seconds && IsRepeatSong == FALSE && playlist.songs.size() > 1)
		{
			next();
		}
		else if (IsRepeatSong == TRUE && secPlaying == seconds)
		{
			SendMessage(hTBPlayingSong, TBM_SETPOS, TRUE, (LPARAM)0);
			secPlaying = 0;
			play(hStream);
		}
		else if (playlist.songs.size() == 1 && secPlaying == seconds)
		{
			secPlaying = 0;
			KillTimer(hwnd, id_timer);
		}else if (pos == seconds)
		{
			secPlaying = 0;
			stop(hStream);
			KillTimer(hwnd, id_timer);
		}
		/*
			Показ времени проигрывания
		*/
		showTimePlaying(hwnd, secPlaying);
		if (secPlaying == 0)
			showNameSong(hStream, hwnd);
		secPlaying++;
	}
	else if (id == idTimerBySpectr) {
		InvalidateRect(hwnd, &spectrRECT, TRUE);
	}
}
Exemplo n.º 29
0
unsigned int BassDecoder::frames()
{
  #if defined(LIBTOOLS_WINDOWS) && !defined(BASS_H)
  if (!BASS_ChannelGetLength || 
      !BASS_ChannelBytes2Seconds || 
      !BASS_ErrorGetCode)
  {
    std::cerr << "Missing BASS_ChannelGetLength, BASS_ChannelBytes2Seconds or BASS_ErrorGetCode function" << std::endl;
    return -1;
  }
  #endif 

  if (_music)
  {
    QWORD ret = BASS_ChannelGetLength((DWORD)_music,BASS_POS_BYTE);
    if (ret==-1) return -1;
    double seconds=BASS_ChannelBytes2Seconds((DWORD)_music,ret);
    unsigned int frames = (unsigned int)(seconds*(double)Signal::refreshRate+0.5);
    return frames;
  }
  return 0;
}
Exemplo n.º 30
0
bool KNMusicBackendBassThread::loadFile(const QString &filePath)
{
    //Stop the current thread first.
    stop();
    //Remove all the previous sync handlers.
    removeChannelSyncs();
    //Check is the file the current file.
    if(filePath==m_filePath)
    {
        //Reset the current state.
        resetChannelInformation();
        //Update the duration.
        emit durationChanged(m_duration);
        //Emit the load success signal.
        emit loadSuccess();
        //Mission complete.
        return true;
    }
    //Load the file path.
    if(!loadBassThread(filePath))
    {
        //Load the file failed.
        return false;
    }
    //When loading the file complete, load the channel info to the thread.
    //Get the duration of the whole file.
    m_totalDuration=
            BASS_ChannelBytes2Seconds(m_channel,
                                      BASS_ChannelGetLength(m_channel,
                                                            BASS_POS_BYTE))
            *1000.0;
    //Emit the duration changed signal.
    emit durationChanged(m_totalDuration);
    //Reset the thread information.
    resetChannelInformation();
    //Load complete.
    return true;
}