Rubén Ibarra Pastor




From: pastor...@msn.com
To: ra...@iki.fi
Subject: RE: [LMMS-devel] Timer Patch(tested on Git version)
Date: Thu, 18 Jul 2013 19:01:41 -0600




Try again with this patches, changes "centiseconds" to milliseconds and about 
the command you asked, yes it does changes the milliseconds shown in the timer, 
it changes them when you make left click on the timeline to seek a song. Also 
song_cpp.patch adds lots of milliseconds working for when it is needed, there 
is still more funcionality that can be added by the way.
Still has some things to add by the way but I think is ok to have most things 
added on it. It's git after all.

 



Rubén Ibarra Pastor




> Date: Thu, 18 Jul 2013 10:44:47 +0300
> From: ra...@iki.fi
> To: pastor...@msn.com
> CC: lmms-devel@lists.sourceforge.net
> Subject: Re: [LMMS-devel] Timer Patch(tested on Git version)
> 
> Quoting Rubén Ibarra Pastor <pastor...@msn.com>:
> 
> > The Same timer widget, this time with Git patches.
> 
> Please, tell me if I'm wrong (didn't actually run this yet), but it  
> looks to me like this doesn't in any way acknowledge any tempo  
> automation in the past?
> 
> engine::getSong()->setMilliseconds(((((t.getTicks()))*60*100/48)/engine::getSong()->getTempo()));
> 
> 
> And besides, your milliseconds look more like centiseconds (100 vs.  
> 1000 in all calculations). Someone might scratch their head in the  
> future over naming like that...
> 
> -- 
> ra...@iki.fi
> http://www.mikseri.net/radioproject
> 
> 
> 
> ------------------------------------------------------------------------------
> See everything from the browser to the database with AppDynamics
> Get end-to-end visibility with application monitoring from AppDynamics
> Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
> _______________________________________________
> LMMS-devel mailing list
> LMMS-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lmms-devel
                                                                                
  

Attachment: MainWindow.patch
Description: Binary data

Attachment: Song_cpp.patch
Description: Binary data

Attachment: song_header.patch
Description: Binary data

Attachment: timeline.patch
Description: Binary data

/*
 * timer_widget.cpp - widget for visualization of elapsed time
 * Based on visualization widget
 * Uploaded by Ruben Ibarra
* TODO: Add glow effect and make it look more digital
 * Licensed by GPLv2
 */


#include <QtGui/QMouseEvent>
#include <QtGui/QPainter>

#include "timer_widget.h"
#include "gui_templates.h"
#include "MainWindow.h"
#include "embed.h"
#include "engine.h"
#include "tooltip.h"
#include "song.h"



timerWidget::timerWidget( const QPixmap & _bg, QWidget * _p ) :
	QWidget( _p ),
	s_background( _bg ),
	mode( 0 )
{
	setFixedSize( s_background.width(), s_background.height() );
	setAttribute( Qt::WA_OpaquePaintEvent, true );

	const fpp_t frames = engine::getMixer()->framesPerPeriod();
	m_buffer = new sampleFrame[frames];

	engine::getMixer()->clearAudioBuffer( m_buffer, frames );

	toolTip::add( this, tr( "click to enable/disable visualization of "
							"time" ) );
}




timerWidget::~timerWidget()
{
	delete[] m_buffer;
}




void timerWidget::updateAudioBuffer()
{
	if( !engine::getSong()->isExporting() )
	{
		engine::getMixer()->lock();
		const surroundSampleFrame * c = engine::getMixer()->
							currentReadBuffer();
		const fpp_t fpp = engine::getMixer()->framesPerPeriod();
		memcpy( m_buffer, c, sizeof( surroundSampleFrame ) * fpp );
		engine::getMixer()->unlock();
	}
}




void timerWidget::setActive( bool _active )
{

	if( mode != 2 )
	{
		connect( engine::mainWindow(),
					SIGNAL( periodicUpdate() ),
					this, SLOT( update() ) );
		connect( engine::getMixer(),
					SIGNAL( nextAudioBuffer() ),
				this, SLOT( updateAudioBuffer() ) );
	}
	else
	{
		disconnect( engine::mainWindow(),
					SIGNAL( periodicUpdate() ),
					this, SLOT( update() ) );
		disconnect( engine::getMixer(),
					SIGNAL( nextAudioBuffer() ),
				this, SLOT( updateAudioBuffer() ) );
		// we have to update (remove last waves),
		// because timer doesn't do that anymore
		update();
	}
}




void timerWidget::paintEvent( QPaintEvent * )
{
	QPainter p( this );

	p.drawPixmap( 0, 0, s_background );

	//if( m_active && !engine::getSong()->isExporting() )
	if( (mode == 1) && !engine::getSong()->isExporting() )
	{
		p.setPen( QColor( 64, 224, 255 ) );
		p.setRenderHint( QPainter::Antialiasing );

		// now draw all that stuff
		milliseconds = milliseconds.setNum((engine::getSong()->getMilliseconds()/10)%100);
		seconds = seconds.setNum((engine::getSong()->getMilliseconds()/1000)%60);
		minutes = minutes.setNum((engine::getSong()->getMilliseconds()/60000));
		p.setFont( pointSize<16>( p.font() ) );
		if((engine::getSong()->getMilliseconds()/60000) < 10)//Minutes
		  time1 = "0";
		else
		  time1 = "";
                if((engine::getSong()->getMilliseconds()/1000)%60 < 10)//Seconds
		  time2 = ":0";
		else
		  time2 = ":";
                if((engine::getSong()->getMilliseconds()/10)%100 < 10)//Milliseconds
		  time3 = ":0";
		else
		  time3 = ":";
		total = minutes + ":" + seconds  + ":" + milliseconds;
		total = time1 + minutes + time2 + seconds + time3 + milliseconds;
		p.drawText( 10, 30,total);
	}
	else if(mode == 2)
	{
		p.setPen( QColor( 64, 224, 255 ) );
		p.setRenderHint( QPainter::Antialiasing );
		tacts = seconds.setNum(engine::getSong()->getTacts());
		ticks = minutes.setNum(engine::getSong()->getTicks());
		milliseconds = milliseconds.setNum((engine::getSong()->getMilliseconds()/10)%100);
		p.setFont( pointSize<16>( p.font() ) );
		if(engine::getSong()->getTacts() < 10)//Tacts
		  time1 = "0";
		else
		  time1 = "";
                if(engine::getSong()->getTicks() < 10)//Ticks
		  time2 = ":0";
		else
		  time2 = ":";
                if((engine::getSong()->getMilliseconds()/10)%100 < 10)//Milliseconds
		  time3 = ":0";
		else
		  time3 = ":";
		total = time1 + tacts + time2 + ticks + time3 + milliseconds;
		p.drawText( 10, 30,total);
	}
	else
	{
		p.setPen( QColor( 192, 192, 192 ) );
		p.setFont( pointSize<7>( p.font() ) );
		p.drawText( 6, height()-5, tr( "Click to enable" ) );
	}
}




void timerWidget::mousePressEvent( QMouseEvent * _me )
{
	if( _me->button() == Qt::LeftButton )
	{
		if(mode == 0)
			setActive( true );
		else if(mode == 2)
			setActive( false);
		mode++;
		mode = mode%3;
	}
}



#include "moc_timer_widget.cxx"


/*
 * timer_widget.cpp - widget for visualization of ellapsed time
 * Based on visualization widget
 * Uploaded by Ruben Ibarra
 * TODO: Add glow effect
 * Licensed by GPLv2
 */



#ifndef _TIMER_WIDGET
#define _TIMER_WIDGET

#include <QtGui/QWidget>
#include <QtGui/QPixmap>
#include <QtGui/QGraphicsDropShadowEffect>

#include "Mixer.h"


class timerWidget : public QWidget
{
        Q_OBJECT
public:
        timerWidget( const QPixmap & _bg, QWidget * _parent);
        virtual ~timerWidget();
        void setActive( bool _active );

protected:
        virtual void paintEvent( QPaintEvent * _pe );
        virtual void mousePressEvent( QMouseEvent * _me );


protected slots:
        void updateAudioBuffer();


private:
        QPixmap s_background;
        QPointF * m_points;
        QString seconds;
        QString minutes;
        QString milliseconds;
        QString tacts;
        QString ticks;
        QString time1,time2,time3;
        QString total;
        QGraphicsDropShadowEffect * dse;
        sampleFrame * m_buffer;
        int mode;

} ;

#endif
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
LMMS-devel mailing list
LMMS-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lmms-devel

Reply via email to