bool CAudio::IsPlaying() { if(m_dwChannel != 0) return (BASS_ChannelIsActive(m_dwChannel) == BASS_ACTIVE_PLAYING); return false; }
int XAudPlayer::Tick() { if (m_stream) return (BASS_ChannelIsActive(m_stream) == BASS_ACTIVE_PLAYING); else return 0; }
void BASS_AudioInterface::insertData(float* data,int nSamples) { for (int i=0;i<nSamples;i++) { if (mBuffSize < mMaxBuffSize) { mTempBuffer[mBuffSize++] = data[i]; } if (mBuffSize == mFreq * mNumChannels / 10) { DWORD err = BASS_StreamPutData(mStream, mTempBuffer, mBuffSize * 4); mBuffSize = 0; DWORD state = BASS_ChannelIsActive(mStream); if (state != BASS_ACTIVE_PLAYING) { BASS_ChannelPlay(mStream, 0); } } } }
BOOL CBassMusicEngine::IsPlaying( HSTREAM hStream ) { if( BASS_ChannelIsActive(hStream) == BASS_ACTIVE_PLAYING ) return TRUE; return FALSE; }
void CALLBACK CBassMusicEngine::MySyncProc( HSYNC handle, DWORD channel, DWORD data, void *user ) { CBassMusicEngine *pBassMusicEngine = CBassMusicEngine::GetInstance(); if ( (pBassMusicEngine == NULL) || (pBassMusicEngine->m_pMusicState == NULL) ) return; DWORD dwActive = BASS_ChannelIsActive(channel); if( dwActive == BASS_ACTIVE_STOPPED ) { pBassMusicEngine->m_pMusicState->OnStop(); } if( dwActive == BASS_ACTIVE_PAUSED ) { pBassMusicEngine->m_pMusicState->OnPause(); } if( dwActive == BASS_ACTIVE_PLAYING ) { pBassMusicEngine->m_pMusicState->OnPlaying(); } if( dwActive == BASS_ACTIVE_STALLED ) { pBassMusicEngine->m_pMusicState->OnStalled(); } }
bool CAudio::IsStalled() { if(m_dwChannel != 0) return (BASS_ChannelIsActive(m_dwChannel) == BASS_ACTIVE_STALLED); return false; }
bool CAudio::IsPaused() { if(m_dwChannel != 0) return (BASS_ChannelIsActive(m_dwChannel) == BASS_ACTIVE_PAUSED); return false; }
bool StreamRender::isFinal(){ if(BASS_ChannelIsActive(stream)!=BASS_ACTIVE_PLAYING) return(true); else return(false); }
bool CClientSound::IsFinished ( void ) { if ( m_pSound ) { return BASS_ChannelIsActive( m_pSound ) == BASS_ACTIVE_STOPPED; } return false; }
bool CAudio::IsPlaying() { // Do we have a valid channel? if(m_dwChannel != 0) return (BASS_ChannelIsActive(m_dwChannel) == BASS_ACTIVE_PLAYING); return false; }
bool stillPlayingSound (int ch) { if (soundOK) if (ch != -1) if (soundCache[ch].fileLoaded != -1) if (BASS_ChannelIsActive (soundCache[ch].mostRecentChannel) != BASS_ACTIVE_STOPPED) return true; return false; }
bool CClientSound::IsPaused ( void ) { if ( m_pSound ) { return BASS_ChannelIsActive( m_pSound ) == BASS_ACTIVE_PAUSED; } return false; }
bool CAudio::IsPaused() { // Do we have a valid channel? if(m_dwChannel != 0) return (BASS_ChannelIsActive(m_dwChannel) == BASS_ACTIVE_PAUSED); return false; }
bool CAudio::IsStalled() { // Do we have a valid channel? if(m_dwChannel != 0) return (BASS_ChannelIsActive(m_dwChannel) == BASS_ACTIVE_STALLED); return false; }
// --[ Method ]--------------------------------------------------------------- // // - Class : CSoundStream // - prototype : bool HasFinished() const // // - Purpose : Returns true if the sound stream playing has finished. // // ----------------------------------------------------------------------------- bool CSoundStream::HasFinished() const { if(!IsValid()) { return false; } return BASS_ChannelIsActive(m_handle) == BASS_ACTIVE_STOPPED; }
// --[ Method ]--------------------------------------------------------------- // // - Class : CSoundStream // - prototype : bool IsBeingPlayed() const // // - Purpose : Returns true if the sound stream is being played. // // ----------------------------------------------------------------------------- bool CSoundStream::IsBeingPlayed() const { if(!IsValid()) { return false; } return BASS_ChannelIsActive(m_handle) == BASS_ACTIVE_PLAYING; }
bool IsActive(HSTREAM stream) { DWORD state = BASS_ChannelIsActive(stream); if (state == BASS_ACTIVE_PLAYING || state == BASS_ACTIVE_PAUSED) { return true; } return false; }
bool StreamRender::isFinal(){ StreamMath *streammath = new StreamMath(stream); int tmp; int Nivel; //----------------------------------------- if((int) streammath->Duracion()<=Descartar)// si es descartable tmp=0; // lo ponemos 0 para descartarlo else tmp=Solapar;//no es asignamos el final //--------------------------------------------- if(Solapar==0) tmp=0; //si solapar=0 corte real //--------------------------------------------- if(Detector)// si el detector esta activado/ o no Nivel=DetectorNivel; else Nivel=120;//al maximo como si no hubiese detector //------------------------------------------------- //if(isTanda) // tmp=0;// si es tanda corte real /// detector************************************************************ if(tmp!=0) //si solapar es cero no hace falta el detector corte por final real { if(streammath->Contador()<=tmp) //esta dentro del rango y el detecto activado { tmp=0; // ponemos a cero por si falla el detector o no lo detecta if((int) streammath->VumetroDe()<=Nivel) // es detectatdo por el detector { delete streammath; return(true); } } } delete streammath; /// corte por final real*********************************************************** if(BASS_ChannelIsActive(stream)!=BASS_ACTIVE_PLAYING) return(true); else return(false); }
void setSoundVolume (int a, int v) { if (soundOK) { int ch = findInSoundCache (a); if (ch != -1) { if (BASS_ChannelIsActive (soundCache[ch].mostRecentChannel)) { BASS_ChannelSetAttribute (soundCache[ch].mostRecentChannel, BASS_ATTRIB_VOL, (float) v / 255); } } } }
//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]); } }
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; } }
gboolean Update(gpointer data) { int c,x,y,cx,cy; GtkWidget *dc=GetWidget("drawingarea1"); GdkGC *gc=dc->style->fg_gc[GTK_WIDGET_STATE(dc)]; GdkGCValues gcsave; gdk_gc_get_values(gc,&gcsave); cx=dc->allocation.width/2; cy=dc->allocation.height/2; { // clear the display GdkColor c={0,0xffff,0xffff,0xffff}; gdk_gc_set_rgb_fg_color(gc,&c); gdk_draw_rectangle(dc->window,gc,TRUE,0,0,dc->allocation.width,dc->allocation.height); } { // Draw the listener GdkColor c={0,0x8000,0x8000,0x8000}; gdk_gc_set_rgb_fg_color(gc,&c); gdk_draw_arc(dc->window,gc,TRUE,cx-4,cy-4,8,8,0,360*64); } for (c=0;c<chanc;c++) { // If the channel's playing then update it's position if (BASS_ChannelIsActive(chans[c].channel)==BASS_ACTIVE_PLAYING) { // Check if channel has reached the max distance if (chans[c].pos.z>=MAXDIST || chans[c].pos.z<=-MAXDIST) chans[c].vel.z=-chans[c].vel.z; if (chans[c].pos.x>=MAXDIST || chans[c].pos.x<=-MAXDIST) chans[c].vel.x=-chans[c].vel.x; // Update channel position chans[c].pos.z+=chans[c].vel.z*TIMERPERIOD/1000; chans[c].pos.x+=chans[c].vel.x*TIMERPERIOD/1000; BASS_ChannelSet3DPosition(chans[c].channel,&chans[c].pos,NULL,&chans[c].vel); } { // Draw the channel position indicator static GdkColor cols[2]={{0,0xffff,0xc000,0xc000},{0,0xffff,0,0}}; gdk_gc_set_rgb_fg_color(gc,&cols[chan==c]); x=cx+(int)((cx-10)*chans[c].pos.x/MAXDIST); y=cy-(int)((cy-10)*chans[c].pos.z/MAXDIST); gdk_draw_arc(dc->window,gc,TRUE,x-4,y-4,8,8,0,360*64); } } // Apply the 3D changes BASS_Apply3D(); gdk_gc_set_values(gc,&gcsave,GDK_GC_FOREGROUND); return TRUE; }
/** * @brief Colled every 0.3 secinds and update text field where represented recording size. */ void Widget::timerProc() { // update the recording/playback counter QString text = "no data"; if (rchan) // recording text = QString::number(BASS_ChannelGetPosition(rchan,BASS_POS_BYTE)); else if (chan) { if (BASS_ChannelIsActive(chan)) // playing text = QString::number(BASS_ChannelGetPosition(chan,BASS_POS_BYTE))+"/"+QString::number(BASS_ChannelGetLength(chan,BASS_POS_BYTE)); else text = QString::number(BASS_ChannelGetLength(chan,BASS_POS_BYTE)); } ui->lineEdit->setText(text); }
void BassSoundEngine::Update(float dwTimeMilliSecond) { if(ScreenState==SCREEN_GAMEMAIN) { if(BASS_ChannelIsActive(channel[0])!=BASS_ACTIVE_PLAYING || !channel[0]){ if(m_pAudio) // audio stopped, resume audio in video m_pAudio->put_Volume(Lin2dB(defaultVolume)); }else{ // channel 0 is active if(m_pAudio) m_pAudio->put_Volume(-10000); if(pitch_factor!=0) SetPitch(pitch_factor,0,true), pitch_factor = 0; if(sampleRate_factor!=0) SetSampleRate(sampleRate_factor,0,true), sampleRate_factor = 0; if(tempo_factor!=0) SetTempo(tempo_factor,0,true), tempo_factor = 0; } } for(int i = 0; i < nowChannel; i++) { if(channel[i]!=NULL) { float volume; BASS_ChannelGetAttribute(channel[i], BASS_ATTRIB_VOL, &volume); if(volume==0){ BASS_ChannelStop(channel[i]); channel[i] = NULL; } if(volume>volumeDes[i]) { volume -= soundSpd*dwTimeMilliSecond; if(volume<volumeDes[i]) volume = volumeDes[i]; } if(volume<volumeDes[i]) { volume += soundSpd*dwTimeMilliSecond; if(volume>volumeDes[i]) volume = volumeDes[i]; } BASS_ChannelSetAttribute(channel[i], BASS_ATTRIB_VOL, volume); if(volume==0) FreeChannel(i, true); } } }
// GetState av::SourceStates BassSound3D::GetState() const { const DWORD result = BASS_ChannelIsActive(m_channel); if (result == BASS_ACTIVE_PLAYING) { return av::SSS_PLAYING; } else if (result == BASS_ACTIVE_PAUSED) { return av::SSS_PAUSED; } return av::SSS_STOPPED; }
void BassSoundEngine::FreeChannel(int chan_id, bool bImmediate) { if(channel[chan_id] == NULL) return; if(BASS_ChannelIsActive(channel[chan_id])==BASS_ACTIVE_PLAYING) { if(bImmediate){ BASS_ChannelStop(channel[chan_id]); }else{ int new_id = GetNewChannel(); channel[new_id] = channel[chan_id]; SetChannelVolume(0, new_id, true); } } channel[chan_id] = NULL; }
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); }
// 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; }
CHANNEL BassSoundEngine::GetNewChannel() { // Attempt to find an unused channel for( int x=1; x<maxChannel; x++) if(channel[x]==NULL){ nowChannel = max(nowChannel, x+1); return x; } // Free all inactive channels for( int x=1; x<maxChannel; x++) if(BASS_ChannelIsActive(channel[x])!=BASS_ACTIVE_PLAYING){ channel[x] = NULL; } // Attempt to find a free channel again for( int x=1; x<maxChannel; x++) if(channel[x]==NULL){ nowChannel = max(nowChannel, x+1); return x; } return -1; }
// scan the peaks void __cdecl ScanPeaks(DWORD decoder) { DWORD cpos=0,peak[2]={0}; while (!killscan) { DWORD level=BASS_ChannelGetLevel(decoder); // scan peaks DWORD pos; if (peak[0]<LOWORD(level)) peak[0]=LOWORD(level); // set left peak if (peak[1]<HIWORD(level)) peak[1]=HIWORD(level); // set right peak if (!BASS_ChannelIsActive(decoder)) pos=-1; // reached the end else pos=BASS_ChannelGetPosition(decoder,BASS_POS_BYTE)/bpp; if (pos>cpos) { DWORD a; for (a=0;a<peak[0]*(HEIGHT/2)/32768;a++) wavebuf[(HEIGHT/2-1-a)*WIDTH+cpos]=1+a; // draw left peak for (a=0;a<peak[1]*(HEIGHT/2)/32768;a++) wavebuf[(HEIGHT/2+1+a)*WIDTH+cpos]=1+a; // draw right peak if (pos>=WIDTH) break; // gone off end of display cpos=pos; peak[0]=peak[1]=0; } } BASS_StreamFree(decoder); // free the decoder scanthread=0; }