예제 #1
0
void drawAudioBuffer( const audio::Buffer &buffer, const Rectf &bounds, bool drawFrame, const ci::ColorA &color )
{
	gl::ScopedGlslProg glslScope( getStockShader( gl::ShaderDef().color() ) );

	gl::color( color );

	const float waveHeight = bounds.getHeight() / (float)buffer.getNumChannels();
	const float xScale = bounds.getWidth() / (float)buffer.getNumFrames();

	float yOffset = bounds.y1;
	for( size_t ch = 0; ch < buffer.getNumChannels(); ch++ ) {
		PolyLine2f waveform;
		const float *channel = buffer.getChannel( ch );
		float x = bounds.x1;
		for( size_t i = 0; i < buffer.getNumFrames(); i++ ) {
			x += xScale;
			float y = ( 1 - ( channel[i] * 0.5f + 0.5f ) ) * waveHeight + yOffset;
			waveform.push_back( vec2( x, y ) );
		}

		if( ! waveform.getPoints().empty() )
			gl::draw( waveform );

		yOffset += waveHeight;
	}

	if( drawFrame ) {
		gl::color( color.r, color.g, color.b, color.a * 0.6f );
		gl::drawStrokedRect( bounds );
	}
}
예제 #2
0
void drawBuffer(const std::deque<int8_t>& buffer, const Rectf &bounds, bool drawFrame, const ci::ColorA &color, float scaleFactor )
{
  gl::ScopedGlslProg glslScope( getStockShader( gl::ShaderDef().color() ) );
  
  gl::color( color );
  
  const float waveHeight = bounds.getHeight();
  const float xScale = bounds.getWidth() / (float)buffer.size();
  
  float yOffset = bounds.y1;
  PolyLine2f waveform;
  float x = bounds.x1;
  for( size_t i = 0; i < buffer.size(); i++ ) {
    x += xScale;
    float y = ( 1.0f - ( buffer[i] * scaleFactor + 0.5f) ) * waveHeight + yOffset;
    waveform.push_back( vec2( x, y ) );
  }
  
  if( ! waveform.getPoints().empty() )
    gl::draw( waveform );
  
  if( drawFrame ) {
    gl::color( color.r, color.g, color.b, color.a * 0.6f );
    gl::drawStrokedRect( bounds );
  }
}
예제 #3
0
void Triangulator::addPolyLine( const PolyLine2f &polyLine )
{
	if( polyLine.size() > 0 )
		tessAddContour( mTess.get(), 2, &polyLine.getPoints()[0], sizeof(float) * 2, (int)polyLine.size() );
}