Skip to content

Commit

Permalink
Revert "Rebase #2 (#3)"
Browse files Browse the repository at this point in the history
This reverts commit cc52e81.
  • Loading branch information
ryuukumar committed Jul 10, 2020
1 parent 98b601a commit a58da95
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 45 deletions.
3 changes: 0 additions & 3 deletions include/PianoRoll.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,6 @@ protected slots:
volume_t m_lastNoteVolume;
panning_t m_lastNotePanning;

//When resizing several notes, we want to calculate a common minimum length
MidiTime m_minResizeLen;

int m_startKey; // first key when drawing
int m_lastKey;

Expand Down
55 changes: 32 additions & 23 deletions src/gui/FxMixerView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,12 @@ void FxMixerView::deleteChannel(int index)
m_channelAreaWidget->adjustSize();

// make sure every channel knows what index it is
for(int i=index + 1; i<m_fxChannelViews.size(); ++i)
for(int i=0; i<m_fxChannelViews.size(); ++i)
{
m_fxChannelViews[i]->m_fxLine->setChannelIndex(i-1);
if( i > index )
{
m_fxChannelViews[i]->m_fxLine->setChannelIndex(i-1);
}
}
m_fxChannelViews.remove(index);

Expand All @@ -436,32 +439,38 @@ void FxMixerView::deleteUnusedChannels()
tracks += Engine::getSong()->tracks();
tracks += Engine::getBBTrackContainer()->tracks();

std::vector<bool> inUse(m_fxChannelViews.size(), false);

//Populate inUse by checking the destination channel for every track
for (Track* t: tracks)
// go through all FX Channels
for(int i = m_fxChannelViews.size()-1; i > 0; --i)
{
//The channel that this track sends to. Since master channel is always in use,
//setting this to 0 is a safe default (for tracks that don't sent to the mixer).
int channel = 0;
if (t->type() == Track::InstrumentTrack)
// check if an instrument references to the current channel
bool empty=true;
for( Track* t : tracks )
{
InstrumentTrack* inst = dynamic_cast<InstrumentTrack *>(t);
channel = inst->effectChannelModel()->value();
if( t->type() == Track::InstrumentTrack )
{
InstrumentTrack* inst = dynamic_cast<InstrumentTrack *>( t );
if( i == inst->effectChannelModel()->value(0) )
{
empty=false;
break;
}
}
else if( t->type() == Track::SampleTrack )
{
SampleTrack *strack = dynamic_cast<SampleTrack *>( t );
if( i == strack->effectChannelModel()->value(0) )
{
empty=false;
break;
}
}
}
else if (t->type() == Track::SampleTrack)
FxChannel * ch = Engine::fxMixer()->effectChannel( i );
// delete channel if no references found
if( empty && ch->m_receives.isEmpty() )
{
SampleTrack *strack = dynamic_cast<SampleTrack *>(t);
channel = strack->effectChannelModel()->value();
deleteChannel( i );
}
inUse[channel] = true;
}

//Check all channels except master, delete those with no incoming sends
for(int i = m_fxChannelViews.size()-1; i > 0; --i)
{
if (!inUse[i] && Engine::fxMixer()->effectChannel(i)->m_receives.isEmpty())
{ deleteChannel(i); }
}
}

Expand Down
24 changes: 5 additions & 19 deletions src/gui/editors/PianoRoll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ PianoRoll::PianoRoll() :
m_lenOfNewNotes( MidiTime( 0, DefaultTicksPerBar/4 ) ),
m_lastNoteVolume( DefaultVolume ),
m_lastNotePanning( DefaultPanning ),
m_minResizeLen( 0 ),
m_startKey( INITIAL_START_KEY ),
m_lastKey( 0 ),
m_editMode( ModeDraw ),
Expand Down Expand Up @@ -1728,21 +1727,9 @@ void PianoRoll::mousePressEvent(QMouseEvent * me )
// then resize the note
m_action = ActionResizeNote;

//Calculate the minimum length we should allow when resizing
//each note, and let all notes use the smallest one found
m_minResizeLen = quantization();
for (Note *note : selectedNotes)
{
//Notes from the BB editor can have a negative length, so
//change their length to the displayed one before resizing
if (note->oldLength() <= 0) { note->setOldLength(4); }
//Let the note be sized down by quantized increments, stopping
//when the next step down would result in a negative length
int thisMin = note->oldLength() % quantization();
//The initial value for m_minResizeLen is the minimum length of
//a note divisible by the current Q. Therefore we ignore notes
//where thisMin == 0 when checking for a new minimum
if (thisMin > 0 && thisMin < m_minResizeLen) { m_minResizeLen = thisMin; }
if (note->oldLength() <= 0) { note->setOldLength(4); }
}

// set resize-cursor
Expand Down Expand Up @@ -2677,7 +2664,7 @@ void PianoRoll::dragNotes( int x, int y, bool alt, bool shift, bool ctrl )
// If shift is pressed we resize and rearrange only the selected notes
// If shift + ctrl then we also rearrange all posterior notes (sticky)
// If shift is pressed but only one note is selected, apply sticky

auto selectedNotes = getSelectedNotes();

if (shift)
Expand Down Expand Up @@ -2763,12 +2750,11 @@ void PianoRoll::dragNotes( int x, int y, bool alt, bool shift, bool ctrl )
else
{
// shift is not pressed; stretch length of selected notes but not their position
int minLength = alt ? 1 : m_minResizeLen.getTicks();

for (Note *note : selectedNotes)
{
int newLength = qMax(minLength, note->oldLength() + off_ticks);
note->setLength(MidiTime(newLength));
int newLength = note->oldLength() + off_ticks;
newLength = qMax(1, newLength);
note->setLength( MidiTime(newLength) );

m_lenOfNewNotes = note->length();
}
Expand Down

0 comments on commit a58da95

Please sign in to comment.