コード例 #1
0
void NodeSubclassingApp::draw()
{
	gl::clear();

	if( mMonitorNode && mMonitorNode->isEnabled() ) {
		Rectf scopeRect( 10, 10, (float)getWindowWidth() - 10, (float)getWindowHeight() - 10 );
		drawAudioBuffer( mMonitorNode->getBuffer(), scopeRect, true, Color( 0.9f, 0.4f, 0 ) );
	}
}
コード例 #2
0
ファイル: DeviceTestApp.cpp プロジェクト: ffimusic/Cinder
void DeviceTestApp::draw()
{
    gl::clear();
    gl::color( 0, 0.9f, 0 );

    gl::pushMatrices();
    gl::translate( 0, mViewYOffset );

    if( mMonitor && mMonitor->isEnabled() ) {
        const audio::Buffer &buffer = mMonitor->getBuffer();

        float padding = 20;
        float waveHeight = ((float)getWindowHeight() - padding * 3.0f ) / (float)buffer.getNumChannels();

        float yOffset = padding;
        float xScale = (float)getWindowWidth() / (float)buffer.getNumFrames();
        for( size_t ch = 0; ch < buffer.getNumChannels(); ch++ ) {
            PolyLine2f waveform;
            const float *channel = buffer.getChannel( ch );
            for( size_t i = 0; i < buffer.getNumFrames(); i++ ) {
                float x = i * xScale;
                float y = ( channel[i] * 0.5f + 0.5f ) * waveHeight + yOffset;
                waveform.push_back( vec2( x, y ) );
            }
            gl::draw( waveform );
            yOffset += waveHeight + padding;
        }

        float volume = mMonitor->getVolume();
        Rectf volumeRect( mGainSlider.mBounds.x1, mGainSlider.mBounds.y2 + padding, mGainSlider.mBounds.x1 + mGainSlider.mBounds.getWidth() * volume, mGainSlider.mBounds.y2 + padding + 20 );
        gl::drawSolidRect( volumeRect );
    }

    drawWidgets( mWidgets );

    if( mInputDeviceNodeUnderrunFade > 0.0001f ) {
        gl::color( ColorA( 0.8f, 0.2f, 0, mInputDeviceNodeUnderrunFade ) );
        gl::drawSolidRect( mUnderrunRect );
        gl::drawStringCentered( "in underrun", mUnderrunRect.getCenter(), Color::black() );
    }
    if( mInputDeviceNodeOverrunFade > 0.0001f ) {
        gl::color( ColorA( 0.8f, 0.2f, 0, mInputDeviceNodeOverrunFade ) );
        gl::drawSolidRect( mOverrunRect );
        gl::drawStringCentered( "in overrun", mOverrunRect.getCenter(), Color::black() );
    }
    if( mOutputDeviceNodeClipFade > 0.0001f ) {
        gl::color( ColorA( 0.8f, 0.2f, 0, mOutputDeviceNodeClipFade ) );
        gl::drawSolidRect( mClipRect );
        gl::drawStringCentered( "out clip", mClipRect.getCenter(), Color::black() );
    }

    gl::popMatrices();
}