Skip to content

Commit

Permalink
- Plugin latency/delay compensation is now introduced
Browse files Browse the repository at this point in the history
  as an option to tracks only (cf. Track/Properties...
  /Latency compensation). (HIGHLY EXPERIMENTAL)
  • Loading branch information
rncbc committed Mar 16, 2019
1 parent 9df6f14 commit 391cfef
Show file tree
Hide file tree
Showing 18 changed files with 244 additions and 190 deletions.
5 changes: 3 additions & 2 deletions ChangeLog
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ ChangeLog


GIT HEAD GIT HEAD


- Plugin latency/delay compensation is now intrduced - Plugin latency/delay compensation is now introduced
as an option to tracks only. (HIGHLY EXPERIMENTAL) as an option to tracks only (cf. Track/Properties...
/Latency compensation). (HIGHLY EXPERIMENTAL)


- Refactored all singleton/unique application instance - Refactored all singleton/unique application instance
setup logic away from X11/Xcb hackery. (EXPERIMENTAL) setup logic away from X11/Xcb hackery. (EXPERIMENTAL)
Expand Down
47 changes: 43 additions & 4 deletions src/qtractorAudioEngine.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ qtractorAudioEngine::qtractorAudioEngine ( qtractorSession *pSession )
m_pExportFile = NULL; m_pExportFile = NULL;
m_pExportBuses = NULL; m_pExportBuses = NULL;
m_pExportBuffer = NULL; m_pExportBuffer = NULL;
m_iExportOffset = 0;
m_iExportStart = 0; m_iExportStart = 0;
m_iExportEnd = 0; m_iExportEnd = 0;
m_bExportDone = true; m_bExportDone = true;
Expand Down Expand Up @@ -1173,7 +1174,7 @@ void qtractorAudioEngine::process_export ( unsigned int nframes )
const unsigned long iFrameEnd = iFrameStart + nframes; const unsigned long iFrameEnd = iFrameStart + nframes;


// Write output bus buffers to export audio file... // Write output bus buffers to export audio file...
if (iFrameStart < m_iExportEnd && iFrameEnd > m_iExportStart) { if (iFrameStart < m_iExportEnd) {
// Prepare mix-down buffer... // Prepare mix-down buffer...
m_pExportBuffer->process_prepare(nframes); m_pExportBuffer->process_prepare(nframes);
// Force/sync every audio clip approaching... // Force/sync every audio clip approaching...
Expand Down Expand Up @@ -1442,6 +1443,24 @@ bool qtractorAudioEngine::isExporting (void) const
} }




// Last known export accessors.
unsigned long qtractorAudioEngine::exportStart (void) const
{
return m_iExportStart;
}

unsigned long qtractorAudioEngine::exportOffset (void) const
{
return m_iExportOffset;
}

unsigned long qtractorAudioEngine::exportLength (void) const
{
return (m_iExportEnd > m_iExportStart ? m_iExportEnd - m_iExportStart : 0);
}



// Audio-export method. // Audio-export method.
bool qtractorAudioEngine::fileExport ( bool qtractorAudioEngine::fileExport (
const QString& sExportPath, const QList<qtractorAudioBus *>& exportBuses, const QString& sExportPath, const QList<qtractorAudioBus *>& exportBuses,
Expand Down Expand Up @@ -1525,9 +1544,29 @@ bool qtractorAudioEngine::fileExport (
pAudioBus->setMonitor(false); pAudioBus->setMonitor(false);
} }


// Make sure all track latencies are reset and
// maximum track latency is acquainted as offset...
m_iExportOffset = 0;

for (qtractorTrack *pTrack = pSession->tracks().first();
pTrack; pTrack = pTrack->next()) {
if (!pTrack->isMute() && (!pSession->soloTracks() || pTrack->isSolo())) {
qtractorPluginList *pPluginList = pTrack->pluginList();
if (pPluginList) {
pPluginList->resetLatency();
const unsigned long iLatency = pPluginList->latency();
if (m_iExportOffset < iLatency)
m_iExportOffset = iLatency;
}
}
}

if (m_iExportOffset > m_iExportStart)
m_iExportOffset = m_iExportStart;

// Because we'll have to set the export conditions... // Because we'll have to set the export conditions...
pSession->setLoop(0, 0); pSession->setLoop(0, 0);
pSession->setPlayHead(m_iExportStart); pSession->setPlayHead(m_iExportStart - m_iExportOffset);


// Special initialization. // Special initialization.
m_iBufferOffset = 0; m_iBufferOffset = 0;
Expand Down Expand Up @@ -1582,8 +1621,8 @@ bool qtractorAudioEngine::fileExport (
m_pExportBuses = NULL; m_pExportBuses = NULL;
m_pExportFile = NULL; m_pExportFile = NULL;
m_pExportBuffer = NULL; m_pExportBuffer = NULL;
m_iExportStart = 0; // m_iExportStart = 0;
m_iExportEnd = 0; // m_iExportEnd = 0;
m_bExportDone = true; m_bExportDone = true;


// Back to business.. // Back to business..
Expand Down
6 changes: 6 additions & 0 deletions src/qtractorAudioEngine.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ class qtractorAudioEngine : public qtractorEngine
void setExporting(bool bExporting); void setExporting(bool bExporting);
bool isExporting() const; bool isExporting() const;


// Last known export extents accessors.
unsigned long exportStart() const;
unsigned long exportOffset() const;
unsigned long exportLength() const;

// Audio-export method. // Audio-export method.
bool fileExport(const QString& sExportPath, bool fileExport(const QString& sExportPath,
const QList<qtractorAudioBus *>& exportBuses, const QList<qtractorAudioBus *>& exportBuses,
Expand Down Expand Up @@ -289,6 +294,7 @@ class qtractorAudioEngine : public qtractorEngine
// Audio-export (in)active state. // Audio-export (in)active state.
volatile bool m_bExporting; volatile bool m_bExporting;
qtractorAudioFile *m_pExportFile; qtractorAudioFile *m_pExportFile;
unsigned long m_iExportOffset;
unsigned long m_iExportStart; unsigned long m_iExportStart;
unsigned long m_iExportEnd; unsigned long m_iExportEnd;
volatile bool m_bExportDone; volatile bool m_bExportDone;
Expand Down
6 changes: 4 additions & 2 deletions src/qtractorExportForm.cpp
Original file line number Original file line Diff line number Diff line change
@@ -1,7 +1,7 @@
// qtractorExportForm.cpp // qtractorExportForm.cpp
// //
/**************************************************************************** /****************************************************************************
Copyright (C) 2005-2018, rncbc aka Rui Nuno Capela. All rights reserved. Copyright (C) 2005-2019, rncbc aka Rui Nuno Capela. All rights reserved.
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
Expand Down Expand Up @@ -282,7 +282,9 @@ void qtractorExportForm::accept (void)
if (pTracks && m_ui.AddTrackCheckBox->isChecked()) { if (pTracks && m_ui.AddTrackCheckBox->isChecked()) {
pTracks->addAudioTracks( pTracks->addAudioTracks(
QStringList(sExportPath), QStringList(sExportPath),
m_ui.ExportStartSpinBox->value(), pAudioEngine->exportStart(),
pAudioEngine->exportOffset(),
pAudioEngine->exportLength(),
pTracks->currentTrack()); pTracks->currentTrack());
} }
else pMainForm->addAudioFile(sExportPath); else pMainForm->addAudioFile(sExportPath);
Expand Down
2 changes: 1 addition & 1 deletion src/qtractorExportForm.h
Original file line number Original file line Diff line number Diff line change
@@ -1,7 +1,7 @@
// qtractorExportForm.h // qtractorExportForm.h
// //
/**************************************************************************** /****************************************************************************
Copyright (C) 2005-2018, rncbc aka Rui Nuno Capela. All rights reserved. Copyright (C) 2005-2019, rncbc aka Rui Nuno Capela. All rights reserved.
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
Expand Down
2 changes: 1 addition & 1 deletion src/qtractorExportForm.ui
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<author>rncbc aka Rui Nuno Capela</author> <author>rncbc aka Rui Nuno Capela</author>
<comment>qtractor - An Audio/MIDI multi-track sequencer. <comment>qtractor - An Audio/MIDI multi-track sequencer.


Copyright (C) 2005-2018, rncbc aka Rui Nuno Capela. All rights reserved. Copyright (C) 2005-2019, rncbc aka Rui Nuno Capela. All rights reserved.


This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
Expand Down
2 changes: 1 addition & 1 deletion src/qtractorMainForm.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3833,7 +3833,7 @@ void qtractorMainForm::trackImportAudio (void)
const unsigned long iClipStart = m_pSession->editHead(); const unsigned long iClipStart = m_pSession->editHead();
qtractorTrack *pTrack = m_pTracks->currentTrack(); qtractorTrack *pTrack = m_pTracks->currentTrack();
m_pTracks->addAudioTracks( m_pTracks->addAudioTracks(
m_pFiles->audioListView()->openFileNames(), iClipStart, pTrack); m_pFiles->audioListView()->openFileNames(), iClipStart, 0, 0, pTrack);
m_pTracks->trackView()->ensureVisibleFrame(iClipStart); m_pTracks->trackView()->ensureVisibleFrame(iClipStart);
} }
} }
Expand Down
2 changes: 1 addition & 1 deletion src/qtractorTrackList.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1715,7 +1715,7 @@ void qtractorTrackList::dropEvent ( QDropEvent *pDropEvent )
if (!midi_files.isEmpty()) if (!midi_files.isEmpty())
m_pTracks->addMidiTracks(midi_files, iClipStart, pAfterTrack); m_pTracks->addMidiTracks(midi_files, iClipStart, pAfterTrack);
if (!audio_files.isEmpty()) if (!audio_files.isEmpty())
m_pTracks->addAudioTracks(audio_files, iClipStart, pAfterTrack); m_pTracks->addAudioTracks(audio_files, iClipStart, 0, 0, pAfterTrack);


if (midi_files.isEmpty() && audio_files.isEmpty()) { if (midi_files.isEmpty() && audio_files.isEmpty()) {
qtractorMainForm *pMainForm = qtractorMainForm::getInstance(); qtractorMainForm *pMainForm = qtractorMainForm::getInstance();
Expand Down
7 changes: 6 additions & 1 deletion src/qtractorTracks.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2711,7 +2711,8 @@ bool qtractorTracks::copyTrack ( qtractorTrack *pTrack )


// Import Audio files into new tracks... // Import Audio files into new tracks...
bool qtractorTracks::addAudioTracks ( const QStringList& files, bool qtractorTracks::addAudioTracks ( const QStringList& files,
unsigned long iClipStart, qtractorTrack *pAfterTrack ) unsigned long iClipStart, unsigned long iClipOffset,
unsigned long iClipLength, qtractorTrack *pAfterTrack )
{ {
// Have we some? // Have we some?
if (files.isEmpty()) if (files.isEmpty())
Expand Down Expand Up @@ -2763,6 +2764,10 @@ bool qtractorTracks::addAudioTracks ( const QStringList& files,
qtractorAudioClip *pAudioClip = new qtractorAudioClip(pTrack); qtractorAudioClip *pAudioClip = new qtractorAudioClip(pTrack);
pAudioClip->setFilename(sPath); pAudioClip->setFilename(sPath);
pAudioClip->setClipStart(iClipStart); pAudioClip->setClipStart(iClipStart);
if (iClipOffset > 0)
pAudioClip->setClipOffset(iClipOffset);
if (iClipLength > 0)
pAudioClip->setClipLength(iClipLength);
// Time to add the new track/clip into session; // Time to add the new track/clip into session;
// actuallly, this is when the given audio file gets open... // actuallly, this is when the given audio file gets open...
pTrack->addClip(pAudioClip); pTrack->addClip(pAudioClip);
Expand Down
3 changes: 2 additions & 1 deletion src/qtractorTracks.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ class qtractorTracks : public QSplitter


// Import Audio/MIDI files into new tracks... // Import Audio/MIDI files into new tracks...
bool addAudioTracks(const QStringList& files, bool addAudioTracks(const QStringList& files,
unsigned long iClipStart, qtractorTrack *pAfterTrack = NULL); unsigned long iClipStart, unsigned long iClipOffset = 0,
unsigned long iClipLength = 0, qtractorTrack *pAfterTrack = NULL);
bool addMidiTracks(const QStringList& files, bool addMidiTracks(const QStringList& files,
unsigned long iClipStart, qtractorTrack *pAfterTrack = NULL); unsigned long iClipStart, qtractorTrack *pAfterTrack = NULL);
bool addMidiTrackChannel(const QString& sPath, int iTrackChannel, bool addMidiTrackChannel(const QString& sPath, int iTrackChannel,
Expand Down
44 changes: 22 additions & 22 deletions src/translations/qtractor_cs.ts
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ Audio: %1 channels, %2 Hz</source>
(posunutí výšky tónu v půltónech %1)</translation> (posunutí výšky tónu v půltónech %1)</translation>
</message> </message>
<message> <message>
<location filename="../qtractorAudioEngine.cpp" line="2593"/> <location filename="../qtractorAudioEngine.cpp" line="2632"/>
<location filename="../qtractorAudioEngine.cpp" line="2877"/> <location filename="../qtractorAudioEngine.cpp" line="2916"/>
<location filename="../qtractorMidiEngine.cpp" line="3994"/> <location filename="../qtractorMidiEngine.cpp" line="3994"/>
<location filename="../qtractorMidiEngine.cpp" line="4559"/> <location filename="../qtractorMidiEngine.cpp" line="4559"/>
<source>%1 In</source> <source>%1 In</source>
<translation>%1 Vstup</translation> <translation>%1 Vstup</translation>
</message> </message>
<message> <message>
<location filename="../qtractorAudioEngine.cpp" line="2602"/> <location filename="../qtractorAudioEngine.cpp" line="2641"/>
<location filename="../qtractorAudioEngine.cpp" line="2877"/> <location filename="../qtractorAudioEngine.cpp" line="2916"/>
<location filename="../qtractorMidiEngine.cpp" line="4003"/> <location filename="../qtractorMidiEngine.cpp" line="4003"/>
<location filename="../qtractorMidiEngine.cpp" line="4559"/> <location filename="../qtractorMidiEngine.cpp" line="4559"/>
<source>%1 Out</source> <source>%1 Out</source>
Expand Down Expand Up @@ -638,15 +638,15 @@ Stopa: &quot;%1&quot; Vstup: &quot;%2&quot; Výstup: &quot;%3&quot;</translation
<translation>%1 Hlasitost</translation> <translation>%1 Hlasitost</translation>
</message> </message>
<message> <message>
<location filename="../qtractorAudioEngine.cpp" line="2595"/> <location filename="../qtractorAudioEngine.cpp" line="2634"/>
<location filename="../qtractorAudioEngine.cpp" line="2604"/> <location filename="../qtractorAudioEngine.cpp" line="2643"/>
<location filename="../qtractorTrack.cpp" line="695"/> <location filename="../qtractorTrack.cpp" line="695"/>
<source>%1 Gain</source> <source>%1 Gain</source>
<translation>%1 Zesílení</translation> <translation>%1 Zesílení</translation>
</message> </message>
<message> <message>
<location filename="../qtractorAudioEngine.cpp" line="2597"/> <location filename="../qtractorAudioEngine.cpp" line="2636"/>
<location filename="../qtractorAudioEngine.cpp" line="2606"/> <location filename="../qtractorAudioEngine.cpp" line="2645"/>
<location filename="../qtractorMidiEngine.cpp" line="3998"/> <location filename="../qtractorMidiEngine.cpp" line="3998"/>
<location filename="../qtractorMidiEngine.cpp" line="4007"/> <location filename="../qtractorMidiEngine.cpp" line="4007"/>
<location filename="../qtractorTrack.cpp" line="698"/> <location filename="../qtractorTrack.cpp" line="698"/>
Expand Down Expand Up @@ -1826,12 +1826,12 @@ Chcete jej nahradit?</translation>
<translation>Vyvedení zvukového souboru: &quot;%1&quot; právě začalo...</translation> <translation>Vyvedení zvukového souboru: &quot;%1&quot; právě začalo...</translation>
</message> </message>
<message> <message>
<location filename="../qtractorExportForm.cpp" line="291"/> <location filename="../qtractorExportForm.cpp" line="293"/>
<source>Audio file export: &quot;%1&quot; complete.</source> <source>Audio file export: &quot;%1&quot; complete.</source>
<translation>Vyvedení zvukového souboru: &quot;%1&quot; je hotovo.</translation> <translation>Vyvedení zvukového souboru: &quot;%1&quot; je hotovo.</translation>
</message> </message>
<message> <message>
<location filename="../qtractorExportForm.cpp" line="296"/> <location filename="../qtractorExportForm.cpp" line="298"/>
<source>Audio file export: <source>Audio file export:


&quot;%1&quot; &quot;%1&quot;
Expand All @@ -1844,17 +1844,17 @@ failed.</source>
selhalo.</translation> selhalo.</translation>
</message> </message>
<message> <message>
<location filename="../qtractorExportForm.cpp" line="322"/> <location filename="../qtractorExportForm.cpp" line="324"/>
<source>MIDI file export: &quot;%1&quot; started...</source> <source>MIDI file export: &quot;%1&quot; started...</source>
<translation>Vyvedení souboru MIDI: &quot;%1&quot; právě začalo...</translation> <translation>Vyvedení souboru MIDI: &quot;%1&quot; právě začalo...</translation>
</message> </message>
<message> <message>
<location filename="../qtractorExportForm.cpp" line="343"/> <location filename="../qtractorExportForm.cpp" line="345"/>
<source>MIDI file export: &quot;%1&quot; complete.</source> <source>MIDI file export: &quot;%1&quot; complete.</source>
<translation>Vyvedení souboru MIDI: &quot;%1&quot; je hotovo.</translation> <translation>Vyvedení souboru MIDI: &quot;%1&quot; je hotovo.</translation>
</message> </message>
<message> <message>
<location filename="../qtractorExportForm.cpp" line="348"/> <location filename="../qtractorExportForm.cpp" line="350"/>
<source>MIDI file export: <source>MIDI file export:


&quot;%1&quot; &quot;%1&quot;
Expand All @@ -1867,17 +1867,17 @@ failed.</source>
selhalo.</translation> selhalo.</translation>
</message> </message>
<message> <message>
<location filename="../qtractorExportForm.cpp" line="405"/> <location filename="../qtractorExportForm.cpp" line="407"/>
<source>Export %1 File</source> <source>Export %1 File</source>
<translation>Vyvést %1 soubor</translation> <translation>Vyvést %1 soubor</translation>
</message> </message>
<message> <message>
<location filename="../qtractorExportForm.cpp" line="408"/> <location filename="../qtractorExportForm.cpp" line="410"/>
<source>%1 files (*.%1)</source> <source>%1 files (*.%1)</source>
<translation>%1 soborů (*.%1)</translation> <translation>%1 soborů (*.%1)</translation>
</message> </message>
<message> <message>
<location filename="../qtractorExportForm.cpp" line="409"/> <location filename="../qtractorExportForm.cpp" line="411"/>
<source>All files (*.*)</source> <source>All files (*.*)</source>
<translation>Všechny soubory (*.*)</translation> <translation>Všechny soubory (*.*)</translation>
</message> </message>
Expand Down Expand Up @@ -13170,21 +13170,21 @@ Jste si jistý?</translation>
</message> </message>
<message> <message>
<location filename="../qtractorTracks.cpp" line="1009"/> <location filename="../qtractorTracks.cpp" line="1009"/>
<location filename="../qtractorTracks.cpp" line="2782"/> <location filename="../qtractorTracks.cpp" line="2787"/>
<source>Audio file import &quot;%1&quot; on %2 %3. <source>Audio file import &quot;%1&quot; on %2 %3.
</source> </source>
<translation>Zavedení zvukového souboru &quot;%1&quot; do %2 %3. <translation>Zavedení zvukového souboru &quot;%1&quot; do %2 %3.
</translation> </translation>
</message> </message>
<message> <message>
<location filename="../qtractorTracks.cpp" line="1014"/> <location filename="../qtractorTracks.cpp" line="1014"/>
<location filename="../qtractorTracks.cpp" line="2787"/> <location filename="../qtractorTracks.cpp" line="2792"/>
<source>Audio file import: &quot;%1&quot;.</source> <source>Audio file import: &quot;%1&quot;.</source>
<translation>Zavedení zvukového souboru: &quot;%1&quot;.</translation> <translation>Zavedení zvukového souboru: &quot;%1&quot;.</translation>
</message> </message>
<message> <message>
<location filename="../qtractorTracks.cpp" line="1044"/> <location filename="../qtractorTracks.cpp" line="1044"/>
<location filename="../qtractorTracks.cpp" line="2973"/> <location filename="../qtractorTracks.cpp" line="2978"/>
<source>MIDI file import &quot;%1&quot; track-channel %2 on %3 %4. <source>MIDI file import &quot;%1&quot; track-channel %2 on %3 %4.
</source> </source>
<translation>Zavedení MIDI souboru: &quot;%1&quot;, stopa-kanál %2 %3 %4. <translation>Zavedení MIDI souboru: &quot;%1&quot;, stopa-kanál %2 %3 %4.
Expand Down Expand Up @@ -13271,20 +13271,20 @@ Jste si jistý?</translation>
<translation>Odstranit rozsah stopy</translation> <translation>Odstranit rozsah stopy</translation>
</message> </message>
<message> <message>
<location filename="../qtractorTracks.cpp" line="2902"/> <location filename="../qtractorTracks.cpp" line="2907"/>
<source>MIDI file import &quot;%1&quot; on %2 %3. <source>MIDI file import &quot;%1&quot; on %2 %3.
</source> </source>
<translation>Zavedení MIDI souboru &quot;%1&quot; do %2 %3. <translation>Zavedení MIDI souboru &quot;%1&quot; do %2 %3.
</translation> </translation>
</message> </message>
<message> <message>
<location filename="../qtractorTracks.cpp" line="2907"/> <location filename="../qtractorTracks.cpp" line="2912"/>
<source>MIDI file import: &quot;%1&quot;.</source> <source>MIDI file import: &quot;%1&quot;.</source>
<translation>Zavedení MIDI souboru: &quot;%1&quot;.</translation> <translation>Zavedení MIDI souboru: &quot;%1&quot;.</translation>
</message> </message>
<message> <message>
<location filename="../qtractorTracks.cpp" line="1050"/> <location filename="../qtractorTracks.cpp" line="1050"/>
<location filename="../qtractorTracks.cpp" line="2979"/> <location filename="../qtractorTracks.cpp" line="2984"/>
<source>MIDI file import: &quot;%1&quot;, track-channel: %2.</source> <source>MIDI file import: &quot;%1&quot;, track-channel: %2.</source>
<translation>Zavedení MIDI souboru: &quot;%1&quot;, stopa-kanál: %2.</translation> <translation>Zavedení MIDI souboru: &quot;%1&quot;, stopa-kanál: %2.</translation>
</message> </message>
Expand Down
Loading

0 comments on commit 391cfef

Please sign in to comment.