Hi everyone!

First, thanks to all developers for the wonderful piece of software that is
lmms!

I was missing the ability to show the notes from other tracks when editing
melodies and/or beats/basslines, so, having little to do this afternoon I
put together a (dirty?) little hack to do so,

I added a button to show/hide the notes from the other tracks in piano roll,
notes from other tracks appear in light transluscent white. This is useful
when making complex melodies in order to avoid dissonances that are
sometimes hard to detect otherwise.

Currently this works for instruments tracks (but doesnt display notes from
Beat/Bassline tracks) and for Beat/Bassline individual tracks (showing all
notes from the tracks in a beat), in fact, it just looks at the notes
contained in the tracks of the m_pattern's track's trackcontainer.

Here are two patchs to files include/piano_roll.h and src/gui/piano_roll.cpp
from lmms-0.4.10 archive,

let me know if you find it usefull, and any other comments are welcome

regards,

fm
109c109,110
< 					int  _width, note * _n );
---
> 					int  _width, note * _n,
> 					bool isFromOtherTrack = false);
119a121
> 	void show();
238a241,242
> 	
> 	toolButton * m_showOtherTracksButton;
257a262,263
> 	bool m_showOtherTracks;
> 	
308c314
< 
---
> 	
68a69
> #include <project_notes.h>
69a71
> #include <iostream>
146a149
> 	m_showOtherTracks( true ),
284a288,289
> 					
> 	
352a358,359
> 	
> 	
376c383,387
< 
---
> 	
> 	m_showOtherTracksButton = new toolButton( embed::getIconPixmap( "note" ),
> 		    tr( "Show/Hide notes from other tacks" ),
> 		    this, SLOT( show() ), m_toolBar );
> 		    
484a496
> 	tb_layout->addWidget( m_showOtherTracksButton );
629c641
< 					int _width, note * _n )
---
> 					int _width, note * _n, bool isFromOtherTrack)
654a667
> 	
660a674,679
> 	else if(isFromOtherTrack)
> 	{
> 		col.setRgb(255, 255, 255);
> 		col.setAlpha(64);
> 		_p.fillRect( _x, _y, _width, KEY_LINE_HEIGHT - 2, col );
> 	}
689c708,710
< 	col = defaultNoteColor;
---
> 	if(!isFromOtherTrack) col = defaultNoteColor;
> 	else col.setRgb(0,0,0);
> 	
703,704c724,725
< 	_p.setPen( defaultNoteColor.lighter( 200 ) );
< 	if( _width > 2 )
---
> 	
> 	if(!isFromOtherTrack)
706,707c727,736
< 		_p.drawLine( _x + _width - 3, _y + 2, _x + _width - 3,
< 						_y + KEY_LINE_HEIGHT - 4 );
---
> 	    _p.setPen( defaultNoteColor.lighter( 200 ) );
> 	    if( _width > 2 )
> 	    {
> 		    _p.drawLine( _x + _width - 3, _y + 2, _x + _width - 3,
> 						    _y + KEY_LINE_HEIGHT - 4 );
> 	    }
> 	    _p.drawLine( _x + _width - 1, _y + 2, _x + _width - 1,
> 						    _y + KEY_LINE_HEIGHT - 4 );
> 	    _p.drawLine( _x + _width - 2, _y + 2, _x + _width - 2,
> 						    _y + KEY_LINE_HEIGHT - 4 );
709,712d737
< 	_p.drawLine( _x + _width - 1, _y + 2, _x + _width - 1,
< 						_y + KEY_LINE_HEIGHT - 4 );
< 	_p.drawLine( _x + _width - 2, _y + 2, _x + _width - 2,
< 						_y + KEY_LINE_HEIGHT - 4 );
2681a2707,2731
> 		
> 		std::vector<NoteVector> noteVectors;
> 		
> 		
> 		//get all the notes at the same position
> 		if(m_showOtherTracks && m_pattern->getTrack()->type() == track::InstrumentTrack)
> 		{
> 		    trackContainer *tc;
> 		    //if(and m_pattern->getTrack()->getTrackContainer()->nodeName()=="bbtrackcontainer")
> 		    tc = m_pattern->getTrack()->getTrackContainer();
> 		    trackContainer::trackList trks = tc->tracks();
> 		    for(trackContainer::trackList::ConstIterator t = trks.begin(); t!= trks.end(); t++)
> 		    {
> 			if((*t)->type() == track::InstrumentTrack && (*t)->id() != m_pattern->getTrack()->id())
> 			{
> 			    track::tcoVector tcos;
> 			    (*t)->getTCOsInRange(tcos,m_pattern->startPosition(),m_pattern->endPosition());
> 			    for(track::tcoVector::ConstIterator tco = tcos.begin(); tco!=tcos.end(); tco++)
> 			    {
> 				pattern *p = dynamic_cast<pattern*>(*tco);
> 				noteVectors.push_back(p->notes());
> 			    }
> 			}
> 		    }
> 		}
2687,2689c2737,2743
< 
< 		for( NoteVector::ConstIterator it = notes.begin();
< 						it != notes.end(); ++it )
---
> 		
> 		noteVectors.push_back(notes);
> 		
> 		for(std::vector<NoteVector>::iterator niter = noteVectors.begin();
> 		    niter!= noteVectors.end(); niter++)
> 		    for( NoteVector::ConstIterator it = niter->begin();
> 						    it != niter->end(); ++it )
2690a2745,2746
> 			bool isFromOtherTrack = (niter!=noteVectors.end()-1);
> 			
2725c2781
< 								note_width, *it );
---
> 								note_width, *it, isFromOtherTrack);
2730c2786,2790
< 			if( m_noteEditMode == NoteEditVolume )
---
> 			if(isFromOtherTrack)
> 			{
> 			    //do nothing
> 			}
> 			else if( m_noteEditMode == NoteEditVolume )
3069c3129,3142
< 
---
> void pianoRoll::show()
> {
>     if(m_showOtherTracks)
>     {
> 	m_showOtherTracks = false;
> 	m_showOtherTracksButton->setIcon(embed::getIconPixmap( "note_half" ));
>     }
>     else
>     {
> 	m_showOtherTracks = true;
> 	m_showOtherTracksButton->setIcon(embed::getIconPixmap( "note" ));
>     }
>     update();
> }
------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
LMMS-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lmms-devel

Reply via email to