Skip to content

Commit

Permalink
Merge branch 'fr462-ted'
Browse files Browse the repository at this point in the history
  • Loading branch information
tedfelix committed Oct 15, 2024
2 parents 8efd5f9 + eca1ae7 commit eb46f37
Show file tree
Hide file tree
Showing 17 changed files with 440 additions and 76 deletions.
3 changes: 3 additions & 0 deletions data/rc/rosegardenmainwindow.rc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
<Action name="file_export_csound" text="Export &amp;Csound Score File..." />
<Action name="file_export_mup" text="Export M&amp;up File..." />
<Action name="file_export_musicxml" text="Export Music&amp;XML File..." />
<Separator/>
<Action name="file_export_wav" text="Export &amp;WAV File..." />
</Menu>
<Action name="file_open" text="&amp;Open..." icon="fileopen" shortcut="Ctrl+O" />
<Action name="file_open_example" text="Open Examp&amp;le..." />
Expand Down Expand Up @@ -535,6 +537,7 @@
<Action name="file_open_template" />
<!-- ??? This doesn't work. Would be nice. -->
<menu name="file_open_recent" />
<Action name="file_export_wav" />
<Action name="file_revert" />
<Action name="file_close" />
<Action name="file_quit" />
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@ set(rg_CPPS
sound/Resampler.cpp
sound/ExternalController.cpp
sound/KorgNanoKontrol2.cpp
sound/WAVExporter.cpp
commands/notation/ResetDisplacementsCommand.cpp
commands/notation/RemoveNotationQuantizeCommand.cpp
commands/notation/AddMarkCommand.cpp
Expand Down
111 changes: 44 additions & 67 deletions src/gui/application/RosegardenMainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,6 @@ RosegardenMainWindow::RosegardenMainWindow(bool enableSound,
m_recentFiles(),
m_sequencerThread(nullptr),
m_sequencerCheckedIn(false),
#ifdef HAVE_LIBJACK
m_jackProcess(nullptr),
#endif
m_cpuBar(nullptr),
m_zoomSlider(nullptr),
m_zoomLabel(nullptr),
Expand Down Expand Up @@ -747,6 +744,7 @@ RosegardenMainWindow::setupActions()
createAction("file_export_midi", SLOT(slotExportMIDI()));
createAction("file_export_lilypond", SLOT(slotExportLilyPond()));
createAction("file_export_musicxml", SLOT(slotExportMusicXml()));
createAction("file_export_wav", SLOT(slotExportWAV()));
createAction("file_export_csound", SLOT(slotExportCsound()));
createAction("file_export_mup", SLOT(slotExportMup()));
createAction("file_print_lilypond", SLOT(slotPrintLilyPond()));
Expand Down Expand Up @@ -5080,70 +5078,6 @@ RosegardenMainWindow::slotTestStartupTester()
return ;
}

/* QStringList missingFeatures;
QStringList allMissing;
QStringList missing;
#ifdef HAVE_LIBJACK
if (m_seqManager && (m_seqManager->getSoundDriverStatus() & AUDIO_OK)) {
m_haveAudioImporter = m_startupTester->haveAudioFileImporter(&missing);
if (!m_haveAudioImporter) {
missingFeatures.push_back(tr("General audio file import and conversion"));
if (missing.count() == 0) {
allMissing.push_back(tr("The Rosegarden Audio File Importer helper script"));
} else {
for (int i = 0; i < missing.count(); ++i) {
if (missingFeatures.count() > 1) {
allMissing.push_back(tr("%1 - for audio file import").arg(missing[i]));
} else {
allMissing.push_back(missing[i]);
}
}
}
}
}
#endif
if (missingFeatures.count() > 0) {
QString message = tr("<h3>Helper programs not found</h3><p>Rosegarden could not find one or more helper programs which it needs to provide some features. The following features will not be available:</p>");
message += tr("<ul>");
for (int i = 0; i < missingFeatures.count(); ++i) {
message += tr("<li>%1</li>").arg(missingFeatures[i]);
}
message += tr("</ul>");
message += tr("<p>To fix this, you should install the following additional programs:</p>");
message += tr("<ul>");
for (int i = 0; i < allMissing.count(); ++i) {
message += tr("<li>%1</li>").arg(allMissing[i]);
}
message += tr("</ul>");
awaitDialogClearance();
QString shortMessage = tr("Helper programs not found");
// QMessageBox info(m_view);
// info.setText(shortMessage);
// info.setInformativeText(message);
// info.setStandardButtons(QMessageBox::Ok);
// info.setDefaultButton(QMessageBox::Ok);
// info.setIcon(QMessageBox::Warning);
//
// if (!DialogSuppressor::shouldSuppress
// (&info, "startuphelpersmissing")) {
// info.exec();
// }
// Looks like Thorn will have to keep the startup test for
// audiofile-importer around indefinitely, and so we need to move that
// irritating @#@^@#^ dialog into the warning widget, and get it out of
// my face before I punch it right in the nose.
m_warningWidget->queueMessage(shortMessage, message);
}*/

m_startupTester->wait();
delete m_startupTester;
m_startupTester = nullptr;
Expand Down Expand Up @@ -5535,6 +5469,49 @@ RosegardenMainWindow::slotExportMusicXml()
exportMusicXmlFile(fileName);
}

void
RosegardenMainWindow::slotExportWAV()
{
RG_DEBUG << "slotExportWAV()";

if (!m_seqManager)
return;

if (!(m_seqManager->getSoundDriverStatus() & AUDIO_OK)) {
QMessageBox::information(
this, // parent
tr("Rosegarden"), // title
tr("Unable to export WAV without JACK running.")); // text
return;
}

QString fileName = FileDialog::getSaveFileName(
this, // parent
tr("Rosegarden"), // caption
"", // dir
"", // defaultName
tr("WAV files") + " (*.wav)"); // filter

if (fileName.isEmpty())
return;

if (fileName.right(4).toLower() != ".wav")
fileName += ".wav";

QString msg = tr(
"Press play to start exporting to\n"
"%1\n"
"Press stop to stop export.\n"
"Only audio and synth plugin tracks will be exported").arg(fileName);

QMessageBox::information(
this, // parent
tr("Rosegarden"), // title
msg); // text

m_seqManager->setExportWavFile(fileName);
}

void
RosegardenMainWindow::exportMusicXmlFile(QString file)
{
Expand Down
9 changes: 5 additions & 4 deletions src/gui/application/RosegardenMainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,11 @@ public slots:
*/
void slotExportMusicXml();

/**
* Export (render) file to audio (only audio and synth plugins)
*/
void slotExportWAV();

/**
* closes all open windows by calling close() on each memberList
* item until the list is empty, then quits the application. If
Expand Down Expand Up @@ -1567,10 +1572,6 @@ protected slots:
SequencerThread *m_sequencerThread;
bool m_sequencerCheckedIn;

#ifdef HAVE_LIBJACK
QProcess *m_jackProcess;
#endif // HAVE_LIBJACK

/// CPU meter in the main window status bar.
/**
* This is NOT a general-purpose progress indicator. You want to use
Expand Down
2 changes: 1 addition & 1 deletion src/gui/dialogs/SelectBankDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

#define RG_MODULE_STRING "[SelectBankDialog]"
//#define RG_NO_DEBUG_PRINT
#define RG_NO_DEBUG_PRINT

#include "SelectBankDialog.h"

Expand Down
44 changes: 43 additions & 1 deletion src/gui/seqmanager/SequenceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#include "sound/MappedEventList.h"
#include "sound/MappedEvent.h"
#include "sound/MappedInstrument.h"
#include "sound/WAVExporter.h"
#include "misc/Preferences.h"

#include "rosegarden-version.h" // for VERSION
Expand Down Expand Up @@ -95,8 +96,13 @@ SequenceManager::SequenceManager() :
m_recordTime(new QElapsedTimer()),
m_lastTransportStartPosition(0),
m_sampleRate(0),
m_tempo(0)
m_tempo(0),
m_wavExporter(nullptr),
m_exportTimer(new QTimer(this))
{
// The timer is started when required
connect(m_exportTimer, &QTimer::timeout,
this, &SequenceManager::slotExportUpdate);
}

SequenceManager::~SequenceManager()
Expand All @@ -105,6 +111,10 @@ SequenceManager::~SequenceManager()

if (m_doc)
m_doc->getComposition().removeObserver(this);

if (m_wavExporter) {
delete m_wavExporter;
}
}

void
Expand Down Expand Up @@ -1080,6 +1090,19 @@ void SequenceManager::slotLoopChanged()
}
}

void SequenceManager::slotExportUpdate()
{
// The timer is only run when the m_compositionExportManager is set
m_wavExporter->update();
if (m_wavExporter->isComplete()) {
RG_DEBUG << "deleting completed export manager";
delete m_wavExporter;
m_wavExporter = nullptr;
// timer no longer needed
m_exportTimer->stop();
}
}

bool SequenceManager::inCountIn(const RealTime &time) const
{
if (m_transportStatus == RECORDING ||
Expand Down Expand Up @@ -1866,6 +1889,25 @@ SequenceManager::getSampleRate() const
return m_sampleRate;
}

void
SequenceManager::setExportWavFile(const QString& fileName)
{
RG_DEBUG << "setExportWavFile" << fileName;
if (m_wavExporter) {
RG_DEBUG << "replacing previous export manager";
delete m_wavExporter;
}
m_wavExporter = new WAVExporter(fileName);
// If creation of the WAVExporter has failed, bail.
if (!m_wavExporter->isOK())
return;

// and install in the driver
RosegardenSequencer::getInstance()->installExporter(m_wavExporter);
// and start the timer
m_exportTimer->start(50);
}

bool
SequenceManager::shouldWarnForImpreciseTimer()
{
Expand Down
8 changes: 8 additions & 0 deletions src/gui/seqmanager/SequenceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class CountdownDialog;
class CompositionMapper;
class AudioManagerDialog;
class MappedBufMetaIterator;
class WAVExporter;


/**
Expand Down Expand Up @@ -261,6 +262,9 @@ class ROSEGARDENPRIVATE_EXPORT SequenceManager :
/// Get sample rate from RosegardenSequencer.
int getSampleRate() const;

/// set file for export of composition at next play
void setExportWavFile(const QString& fileName);

public slots:

/**
Expand All @@ -281,6 +285,8 @@ public slots:

void slotLoopChanged();

void slotExportUpdate();

signals:
/// A program change was received.
/**
Expand Down Expand Up @@ -482,6 +488,8 @@ private slots:
/// Used by setTempo() to detect tempo changes.
tempoT m_tempo;

WAVExporter* m_wavExporter;
QTimer *m_exportTimer;
};


Expand Down
6 changes: 6 additions & 0 deletions src/sequencer/RosegardenSequencer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1523,6 +1523,12 @@ RosegardenSequencer::initialiseStudio()
m_studio->clear();
}

void
RosegardenSequencer::installExporter(WAVExporter* wavExporter)
{
m_driver->installExporter(wavExporter);
}

void
RosegardenSequencer::checkForNewClients()
{
Expand Down
3 changes: 3 additions & 0 deletions src/sequencer/RosegardenSequencer.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ namespace Rosegarden {

class MappedInstrument;
class SoundDriver;
class WAVExporter;


/// MIDI and Audio recording and playback
Expand Down Expand Up @@ -435,6 +436,8 @@ class RosegardenSequencer : public QObject
/// Initialise the virtual studio at this end of the link.
void initialiseStudio();

void installExporter(WAVExporter* wavExporter);


// --------- Transport Interface --------
//
Expand Down
10 changes: 10 additions & 0 deletions src/sound/AlsaDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5489,6 +5489,16 @@ AlsaDriver::scavengePlugins()
m_pluginScavenger.scavenge();
}

void
AlsaDriver::installExporter(WAVExporter* wavExporter)
{
#ifdef HAVE_LIBJACK
if (m_jackDriver) {
m_jackDriver->installExporter(wavExporter);
}
#endif
}

QString
AlsaDriver::getStatusLog()
{
Expand Down
2 changes: 2 additions & 0 deletions src/sound/AlsaDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@ class AlsaDriver : public SoundDriver
void claimUnwantedPlugin(void *plugin) override;
void scavengePlugins() override;

void installExporter(WAVExporter* WAVExporter) override;

/// Update Ports and Connections
/**
* Updates m_alsaPorts and m_devicePortMap to match the ports and
Expand Down
Loading

0 comments on commit eb46f37

Please sign in to comment.