Skip to content

Commit

Permalink
Song: Fix loops and recording.
Browse files Browse the repository at this point in the history
  • Loading branch information
Reflexe committed May 26, 2019
1 parent 11673ab commit 7e3d605
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
1 change: 1 addition & 0 deletions include/SampleTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ class SampleTrack : public Track
public slots:
void updateTcos();
void setPlayingTcos( bool isPlaying );
void beforeRecordOn (MidiTime time);
void updateEffectChannel();
void beforeRecord ();
void toggleRecord();
Expand Down
2 changes: 1 addition & 1 deletion include/Song.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ public slots:
void addBBTrack();

signals:
void beforeRecord ();
void beforeRecordOn (MidiTime time);

private slots:
void insertBar();
Expand Down
13 changes: 7 additions & 6 deletions src/core/Song.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ Song::Song() :
this, SLOT( masterPitchChanged() ) );*/

qRegisterMetaType<Note>( "Note" );
qRegisterMetaType<MidiTime>("MidiTime");
setType( SongContainer );
}

Expand Down Expand Up @@ -263,9 +264,6 @@ void Song::processNextBuffer()
m_vstSyncController.setPlaybackJumped( true );

emit updateSampleTracks();

if (isRecording ())
emit beforeRecord ();
}
}

Expand All @@ -274,6 +272,11 @@ void Song::processNextBuffer()
m_vstSyncController.setPlaybackJumped( true );
m_playPos[m_playMode].setJumped( false );
}

if (isRecording())
{
emit beforeRecordOn(getPlayPos());
}

f_cnt_t framesPlayed = 0;
const float framesPerTick = Engine::framesPerTick();
Expand Down Expand Up @@ -350,7 +353,7 @@ void Song::processNextBuffer()

if (isRecording())
{
emit beforeRecord ();
emit beforeRecordOn(getPlayPos());
}
emit updateSampleTracks();
}
Expand Down Expand Up @@ -560,8 +563,6 @@ void Song::record()

void Song::playAndRecord()
{
emit beforeRecord ();

playSong();
m_recording = true;
}
Expand Down
8 changes: 5 additions & 3 deletions src/tracks/SampleTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ void SampleTCOView::paintEvent( QPaintEvent * pe )
float nom = Engine::getSong()->getTimeSigModel().getNumerator();
float den = Engine::getSong()->getTimeSigModel().getDenominator();
float ticksPerTact = DefaultTicksPerTact * nom / den;

float offset = m_tco->startTimeOffset() / ticksPerTact * pixelsPerTact();
QRect r = QRect( TCO_BORDER_WIDTH + offset, spacing,
qMax( static_cast<int>( m_tco->sampleLength() * ppt / ticksPerTact ), 1 ), rect().bottom() - 2 * spacing );
Expand Down Expand Up @@ -560,6 +560,7 @@ SampleTrack::SampleTrack( TrackContainer* tc ) :
{
setName( tr( "Sample track" ) );
m_panningModel.setCenterValue( DefaultPanning );
connect (Engine::getSong (), SIGNAL(beforeRecordOn(MidiTime)), this, SLOT(beforeRecordOn(MidiTime)));
m_effectChannelModel.setRange( 0, Engine::fxMixer()->numChannels()-1, 1);

connect( &m_effectChannelModel, SIGNAL( dataChanged() ), this, SLOT( updateEffectChannel() ) );
Expand Down Expand Up @@ -775,7 +776,8 @@ void SampleTrack::setPlayingTcos( bool isPlaying )
}
}

void SampleTrack::beforeRecord() {
void SampleTrack::beforeRecordOn(MidiTime time)
{
if (isRecord ()) {
bool isRecordTCOExist = false;

Expand All @@ -790,7 +792,7 @@ void SampleTrack::beforeRecord() {
auto fallbackRecordTCO = static_cast<SampleTCO*>(createTCO (0));

fallbackRecordTCO->setRecord (true);
fallbackRecordTCO->movePosition (Engine::getSong ()->getPlayPos (Song::Mode_PlaySong));
fallbackRecordTCO->movePosition (time);
// fallbackRecordTCO->setSamplePlayLength (Engine::framesPerTick());
fallbackRecordTCO->changeLength (1);
fallbackRecordTCO->setSampleStartFrame (0);
Expand Down

0 comments on commit 7e3d605

Please sign in to comment.