@@ -94,6 +94,8 @@ namespace Audio::Internal {
9494 }
9595
9696 ExportAudioAddOn::ExportAudioAddOn (QObject *parent) : WindowInterfaceAddOn(parent) {
97+ m_simpleConfig.setFormatQuality (100 );
98+ m_simpleConfig.setFormatSampleRate (48000 );
9799 }
98100
99101 ExportAudioAddOn::~ExportAudioAddOn () = default ;
@@ -141,6 +143,17 @@ namespace Audio::Internal {
141143 emit currentParameterChanged ();
142144 }
143145
146+ AudioExporterConfig ExportAudioAddOn::simpleConfig () const {
147+ return m_simpleConfig;
148+ }
149+
150+ void ExportAudioAddOn::setSimpleConfig (const AudioExporterConfig &config) {
151+ if (m_simpleConfig == config)
152+ return ;
153+ m_simpleConfig = config;
154+ emit simpleConfigChanged ();
155+ }
156+
144157 void ExportAudioAddOn::exportAudio () {
145158 auto windowInterface = windowHandle ()->cast <Core::ProjectWindowInterface>();
146159 if (!windowInterface || !windowInterface->window ())
@@ -163,15 +176,16 @@ namespace Audio::Internal {
163176 m_currentParameter.setRangeStart (0 );
164177 m_currentParameter.setRangeLength (timeRangeAllEnd);
165178
166- connect (AudioExporterPresets::instance (), &AudioExporterPresets::currentConfigChanged, &exporter, [&exporter] {
167- exporter.setConfig (AudioExporterPresets::instance ()->currentConfig ());
168- });
169179 connect (this , &ExportAudioAddOn::currentParameterChanged, &exporter, [this , &exporter] {
170180 exporter.setParameter (currentParameter ());
171181 });
172- exporter.setConfig (AudioExporterPresets::instance ()->currentConfig ());
173182 exporter.setParameter (currentParameter ());
174183
184+ if (m_simpleConfig.fileName ().isEmpty () || m_simpleConfig.fileDirectory ().isEmpty ()) {
185+ m_simpleConfig.setFileDirectory (AudioExporterPrivate::of (&exporter)->projectDirectory ());
186+ m_simpleConfig.setFileName (AudioExporterPrivate::of (&exporter)->projectName () + " .wav" );
187+ }
188+
175189 QQmlComponent component (Core::RuntimeInterface::qmlEngine (), " DiffScope.Audio" , " AudioExportDialog" );
176190 if (component.isError ()) {
177191 qFatal () << component.errorString ();
@@ -230,6 +244,34 @@ namespace Audio::Internal {
230244 presets->setCurrentConfig (config);
231245 }
232246
247+ void ExportAudioAddOn::browseFileSimple () {
248+ auto windowInterface = windowHandle ()->cast <Core::ProjectWindowInterface>();
249+ auto config = m_simpleConfig;
250+ const QStringList filters = {
251+ tr (" WAV (*.wav)" ),
252+ tr (" Ogg Vorbis (*.ogg)" ),
253+ };
254+ QString selectedFilter = filters.at (config.fileType () == AudioExporterConfig::FT_Wav ? 0 : 1 );
255+ const auto path = QFileDialog::getSaveFileName (
256+ nullptr ,
257+ {},
258+ calculateSimplePath (config),
259+ filters.join (QStringLiteral (" ;;" )),
260+ &selectedFilter
261+ );
262+ if (path.isEmpty ()) {
263+ return ;
264+ }
265+ const QFileInfo fileInfo (path);
266+ const auto templateSuffix = config.mixingOption () == AudioExporterConfig::MO_Mixed
267+ ? QStringLiteral (" ." )
268+ : QStringLiteral (" _${trackIndex}_${trackName}." );
269+ config.setFileName (fileInfo.completeBaseName () + templateSuffix + fileInfo.suffix ());
270+ config.setFileDirectory (fileInfo.dir ().canonicalPath ());
271+ applyFileType (config, filters.indexOf (selectedFilter) == 0 ? AudioExporterConfig::FT_Wav : AudioExporterConfig::FT_OggVorbis);
272+ setSimpleConfig (config);
273+ }
274+
233275 void ExportAudioAddOn::setMixingOption (int index) {
234276 auto presets = AudioExporterPresets::instance ();
235277 auto config = presets->currentConfig ();
@@ -260,6 +302,34 @@ namespace Audio::Internal {
260302 presets->setCurrentConfig (config);
261303 }
262304
305+ void ExportAudioAddOn::setMixingOptionSimple (int index) {
306+ auto config = m_simpleConfig;
307+ config.setMixingOption (static_cast <AudioExporterConfig::MixingOption>(index));
308+
309+ const QFileInfo fileInfo (config.fileName ());
310+ auto basename = fileInfo.completeBaseName ();
311+ auto suffix = fileInfo.suffix ();
312+ if (index == AudioExporterConfig::MO_Mixed) {
313+ if (basename.endsWith (QStringLiteral (" _${trackIndex}_${trackName}" ))) {
314+ basename = basename.chopped (27 );
315+ }
316+ } else if (!basename.contains (QStringLiteral (" ${trackIndex}" )) &&
317+ !basename.contains (QStringLiteral (" ${trackName}" ))) {
318+ basename += QStringLiteral (" _${trackIndex}_${trackName}" );
319+ }
320+ if (suffix.isEmpty ()) {
321+ suffix = AudioExporterConfig::extensionOfType (config.fileType ());
322+ }
323+ config.setFileName (basename + QStringLiteral (" ." ) + suffix);
324+ setSimpleConfig (config);
325+ }
326+
327+ void ExportAudioAddOn::setFileTypeSimple (int index) {
328+ auto config = m_simpleConfig;
329+ applyFileType (config, index);
330+ setSimpleConfig (config);
331+ }
332+
263333 double ExportAudioAddOn::calculateDurationInMsec (AudioExporter *exporter) const {
264334 auto windowInterface = windowHandle ()->cast <Core::ProjectWindowInterface>();
265335
@@ -269,6 +339,19 @@ namespace Audio::Internal {
269339 return musicTimeline->create (0 , 0 , range.second ).millisecond () - musicTimeline->create (0 , 0 , range.first ).millisecond ();
270340 }
271341
342+ QString ExportAudioAddOn::calculateSimplePath (const AudioExporterConfig &config) {
343+ auto fileName = config.fileName ();
344+ if (config.mixingOption () == AudioExporterConfig::MO_Mixed) {
345+ return QDir::toNativeSeparators (QDir (config.fileDirectory ()).absoluteFilePath (fileName));
346+ } else {
347+ QFileInfo info (fileName);
348+ auto baseName = info.completeBaseName ();
349+ Q_ASSERT (baseName.endsWith (QStringLiteral (" _${trackIndex}_${trackName}" )));
350+ baseName = baseName.chopped (27 );
351+ return QDir::toNativeSeparators (QDir (config.fileDirectory ()).absoluteFilePath (baseName + QStringLiteral (" ." ) + info.suffix ()));
352+ }
353+ }
354+
272355 void ExportAudioAddOn::appendFileNameTemplate (const QString &templateString) {
273356 auto config = AudioExporterPresets::instance ()->currentConfig ();
274357 QFileInfo info (config.fileName ());
0 commit comments