SampleBuffer::SampleBuffer (int frames, int channels, int samplerate) : m_data(0), m_frames(frames), m_channels(channels), m_samplerate(samplerate) { Q_ASSERT(channels > 0); if (frames > 0) { m_data = new sample_t[totalFrames()]; std::memset(m_data, 0x00, totalFrames()*sizeof(sample_t)); } }
void Player::onAnimationChanged(WeightedAnimation *animation) { setButtonsEnabled(animation!=0); int oldPlayFrame = playFrame(); //When first overall animation emerges, stretch looping to max if(/*DEBUG. Uncomment when LoopIn/Out set by some form. this->animation==0 &&*/ animation!=NULL) loopOut = animation->getNumberOfFrames()-1; //edu: this is insidous! Disconnects ALL slots tied to that object. // DO NOT USE THAT! disconnect(animation, SIGNAL(currentFrame(int)), 0, 0); this->animation = animation; if(animation) { connect(animation, SIGNAL(currentFrame(int)), this, SLOT(animationFrameChanged())); int framesCount = animation->getNumberOfFrames(); if(framesCount<loopIn) loopIn=0; if(framesCount<loopOut) loopOut=framesCount-1; //last animation's frame if(oldPlayFrame<=totalFrames()) setPlaybackFrame(oldPlayFrame); } else
void SamplePlayHandle::play( sampleFrame * buffer ) { const fpp_t fpp = Engine::mixer()->framesPerPeriod(); //play( 0, _try_parallelizing ); if( framesDone() >= totalFrames() ) { memset( buffer, 0, sizeof( sampleFrame ) * fpp ); return; } sampleFrame * workingBuffer = buffer; f_cnt_t frames = fpp; // apply offset for the first period if( framesDone() == 0 ) { memset( buffer, 0, sizeof( sampleFrame ) * offset() ); workingBuffer += offset(); frames -= offset(); } if( !( m_track && m_track->isMuted() ) && !( m_bbTrack && m_bbTrack->isMuted() ) ) { /* stereoVolumeVector v = { { m_volumeModel->value() / DefaultVolume, m_volumeModel->value() / DefaultVolume } };*/ if( ! m_sampleBuffer->play( workingBuffer, &m_state, frames, BaseFreq ) ) { memset( workingBuffer, 0, frames * sizeof( sampleFrame ) ); } } m_frame += frames; }
bool SamplePlayHandle::isFinished() const { return framesDone() >= totalFrames() && m_doneMayReturnTrue == true; }
void Animation::setCurrentFrame(int currentFrame) { m_currentFrame = qMax(qMin(currentFrame, totalFrames()-1), 0); }
int K3b::Msf::lba() const { return totalFrames(); }