예제 #1
0
void FileWvOut :: tick( const StkFrames& frames )
{
#if defined(_STK_DEBUG_)
  if ( !file_.isOpen() ) {
    oStream_ << "FileWvOut::tick(): no file open!";
    handleError( StkError::WARNING );
    return;
  }

  if ( data_.channels() != frames.channels() ) {
    oStream_ << "FileWvOut::tick(): incompatible channel value in StkFrames argument!";
    handleError( StkError::FUNCTION_ARGUMENT );
  }
#endif

  unsigned int iFrames = 0;
  unsigned int j, nChannels = data_.channels();
  for ( unsigned int i=0; i<frames.frames(); i++ ) {

    for ( j=0; j<nChannels; j++ ) {
      data_[iData_] = frames[iFrames++];
      clipTest( data_[iData_++] );
    }

    this->incrementFrame();
  }
}
예제 #2
0
void FileWvOut :: computeFrames( const StkFrames& frames )
{
  if ( !file_.isOpen() ) {
    errorString_ << "FileWvOut::computeFrames(): no file open!";
    handleError( StkError::WARNING );
    return;
  }

  if ( data_.channels() != frames.channels() ) {
    errorString_ << "FileWvOut::computeFrames(): incompatible channel value in StkFrames argument!";
    handleError( StkError::FUNCTION_ARGUMENT );
  }

  unsigned int j, nChannels = data_.channels();
  if ( nChannels == 1 || frames.interleaved() ) {

    unsigned int iFrames = 0;
    for ( unsigned int i=0; i<frames.frames(); i++ ) {

      for ( j=0; j<nChannels; j++ ) {
        data_[iData_] = frames[iFrames++];
        clipTest( data_[iData_++] );
      }

      this->incrementFrame();
    }
  }
  else { // non-interleaved frames

    unsigned long hop = frames.frames();
    unsigned int index;
    for ( unsigned int i=0; i<frames.frames(); i++ ) {

      index = i;
      for ( j=0; j<nChannels; j++ ) {
        data_[iData_] = frames[index];
        clipTest( data_[iData_++] );
        index += hop;
      }

      this->incrementFrame();
    }
  }
}
예제 #3
0
void FileWvOut :: computeSample( const StkFloat sample )
{
  if ( !file_.isOpen() ) {
    errorString_ << "FileWvOut::computeSample(): no file open!";
    handleError( StkError::WARNING );
    return;
  }

  unsigned int nChannels = data_.channels();
  StkFloat input = sample;
  clipTest( input );
  for ( unsigned int j=0; j<nChannels; j++ )
    data_[iData_++] = input;

  this->incrementFrame();
}
static
bool calcScreenCoordinates(SPVertex * _vsrc, vertexclip * _vclip, int _numVertex)
{
	for (u32 i = 0; i < _numVertex; ++i) {
		SPVertex & v = _vsrc[i];

		if ((v.modify & MODIFY_XY) == 0) {
			_vclip[i].x = gSP.viewport.vtrans[0] + (v.x / v.w) * gSP.viewport.vscale[0];
			_vclip[i].y = gSP.viewport.vtrans[1] + (v.y / v.w) * -gSP.viewport.vscale[1];
		} else {
			_vclip[i].x = v.x;
			_vclip[i].y = v.y;
		}

		if ((v.modify & MODIFY_Z) == 0) {
			_vclip[i].z = (gSP.viewport.vtrans[2] + (v.z / v.w) * gSP.viewport.vscale[2]) * 32768.0f;
		} else {
			_vclip[i].z = v.z * 32768.0f;
		}

		clipTest(_vclip[i]);
	}

	if (_numVertex > 3) // Don't cull w-clipped vertices
		return true;

	const u32 cullMode = (gSP.geometryMode & G_CULL_BOTH);
	if (cullMode == 0 || cullMode == G_CULL_BOTH)
		return true;

	// Check culling
	const float x1 = _vclip[0].x - _vclip[1].x;
	const float y1 = _vclip[0].y - _vclip[1].y;
	const float x2 = _vclip[2].x - _vclip[1].x;
	const float y2 = _vclip[2].y - _vclip[1].y;

	if ((gSP.geometryMode & G_CULL_BACK) != 0) {
		if ((x1*y2 - y1*x2) < 0.0f) //counter-clockwise, positive
			return false;
	} else {
		if ((x1*y2 - y1*x2) >= 0.0f) //clockwise, negative
			return false;
	}

	return true;
}
예제 #5
0
void FileWvOut :: tick( const StkFloat sample )
{
#if defined(_STK_DEBUG_)
  if ( !file_.isOpen() ) {
    oStream_ << "FileWvOut::tick(): no file open!";
    handleError( StkError::WARNING );
    return;
  }
#endif

  unsigned int nChannels = data_.channels();
  StkFloat input = sample;
  clipTest( input );
  for ( unsigned int j=0; j<nChannels; j++ )
    data_[iData_++] = input;

  this->incrementFrame();
}
예제 #6
0
파일: RtWvOut.cpp 프로젝트: Air-Craft/stk
void RtWvOut :: tick( const StkFrames& frames )
{
#if defined(_STK_DEBUG_)
  if ( data_.channels() != frames.channels() ) {
    oStream_ << "RtWvOut::tick(): incompatible channel value in StkFrames argument!";
    handleError( StkError::FUNCTION_ARGUMENT );
  }
#endif

  if ( stopped_ ) this->start();

  // See how much space we have and fill as much as we can ... if we
  // still have samples left in the frames object, then wait and
  // repeat.
  unsigned int framesEmpty, nFrames, bytes, framesWritten = 0;
  unsigned int nChannels = data_.channels();
  while ( framesWritten < frames.frames() ) {

    // Block until we have some room for output data.
    while ( framesFilled_ == (long) data_.frames() ) Stk::sleep( 1 );
    framesEmpty = data_.frames() - framesFilled_;

    // Copy data in one chunk up to the end of the data buffer.
    nFrames = framesEmpty;
    if ( writeIndex_ + nFrames > data_.frames() )
      nFrames = data_.frames() - writeIndex_;
    if ( nFrames > frames.frames() - framesWritten )
      nFrames = frames.frames() - framesWritten;
    bytes = nFrames * nChannels * sizeof( StkFloat );
    StkFloat *samples = &data_[writeIndex_ * nChannels];
    StkFrames *ins = (StkFrames *) &frames;
    memcpy( samples, &(*ins)[framesWritten * nChannels], bytes );
    for ( unsigned int i=0; i<nFrames * nChannels; i++ ) clipTest( *samples++ );

    writeIndex_ += nFrames;
    if ( writeIndex_ == data_.frames() ) writeIndex_ = 0;

    framesWritten += nFrames;
    mutex_.lock();
    framesFilled_ += nFrames;
    mutex_.unlock();
    frameCounter_ += nFrames;
  }
}
예제 #7
0
파일: RtWvOut.cpp 프로젝트: Air-Craft/stk
void RtWvOut :: tick( const StkFloat sample )
{
  if ( stopped_ ) this->start();

  // Block until we have room for at least one frame of output data.
  while ( framesFilled_ == (long) data_.frames() ) Stk::sleep( 1 );

  unsigned int nChannels = data_.channels();
  StkFloat input = sample;
  clipTest( input );
  unsigned long index = writeIndex_ * nChannels;
  for ( unsigned int j=0; j<nChannels; j++ )
    data_[index++] = input;

  mutex_.lock();
  framesFilled_++;
  mutex_.unlock();
  frameCounter_++;
  writeIndex_++;
  if ( writeIndex_ == data_.frames() )
    writeIndex_ = 0;
}