diff --git a/mscore/exportmp3.cpp b/mscore/exportmp3.cpp index b549be9b0b61..6e344baf420f 100644 --- a/mscore/exportmp3.cpp +++ b/mscore/exportmp3.cpp @@ -655,6 +655,7 @@ bool MuseScore::saveMp3(Score* score, const QString& name) int oldSampleRate = MScore::sampleRate; int sampleRate = preferences.exportAudioSampleRate; + exporter.setBitrate(preferences.exportMp3BitRate); int inSamples = exporter.initializeStream(channels, sampleRate); if (inSamples < 0) { diff --git a/mscore/musescore.cpp b/mscore/musescore.cpp index f01f27a798a8..6513743637ed 100644 --- a/mscore/musescore.cpp +++ b/mscore/musescore.cpp @@ -5393,6 +5393,7 @@ int main(int argc, char* av[]) parser.addOption(QCommandLineOption({"P", "export-score-parts"}, "Used with -o .pdf, export score + parts")); parser.addOption(QCommandLineOption( "no-fallback-font", "will not use Bravura as fallback musical font")); parser.addOption(QCommandLineOption({"f", "force"}, "Used with -o, ignore warnings reg. score being corrupted or from wrong version")); + parser.addOption(QCommandLineOption({"b", "bitrate"}, "Used with -o .mp3, sets bitrate", "bitrate")); parser.addPositionalArgument("scorefiles", "The files to open", "[scorefile...]"); @@ -5504,6 +5505,15 @@ int main(int argc, char* av[]) if (exportScoreParts && !converterMode) parser.showHelp(EXIT_FAILURE); ignoreWarnings = parser.isSet("f"); + if (parser.isSet("b")) { + QString temp = parser.value("b"); + if (temp.isEmpty()) + parser.showHelp(EXIT_FAILURE); + bool ok = false; + preferences.exportMp3BitRate = temp.toInt(&ok); + if (!ok) + preferences.exportMp3BitRate = 128; + } QStringList argv = parser.positionalArguments(); diff --git a/mscore/preferences.cpp b/mscore/preferences.cpp index 8f624c09b938..2122ef121ade 100644 --- a/mscore/preferences.cpp +++ b/mscore/preferences.cpp @@ -53,8 +53,6 @@ bool useALSA = false, useJACK = false, usePortaudio = false, usePulseAudio = fal extern bool externalStyle; -static int exportAudioSampleRates[2] = { 44100, 48000 }; - //--------------------------------------------------------- // Preferences //--------------------------------------------------------- @@ -201,7 +199,8 @@ void Preferences::init() #else nativeDialogs = false; // don't use system native file dialogs #endif - exportAudioSampleRate = exportAudioSampleRates[0]; + exportAudioSampleRate = 44100; + exportMp3BitRate = 128; workspace = "Basic"; exportPdfDpi = 300; @@ -337,6 +336,7 @@ void Preferences::write() s.setValue("vraster", MScore::vRaster()); s.setValue("nativeDialogs", nativeDialogs); s.setValue("exportAudioSampleRate", exportAudioSampleRate); + s.setValue("exportMp3BitRate", exportMp3BitRate); s.setValue("workspace", workspace); s.setValue("exportPdfDpi", exportPdfDpi); @@ -509,6 +509,7 @@ void Preferences::read() nativeDialogs = s.value("nativeDialogs", nativeDialogs).toBool(); exportAudioSampleRate = s.value("exportAudioSampleRate", exportAudioSampleRate).toInt(); + exportMp3BitRate = s.value("exportMp3Bitrate", exportMp3BitRate).toInt(); workspace = s.value("workspace", workspace).toString(); exportPdfDpi = s.value("exportPdfDpi", exportPdfDpi).toInt(); @@ -589,7 +590,54 @@ PreferenceDialog::PreferenceDialog(QWidget* parent) #endif #ifndef USE_ALSA alsaDriver->setVisible(false); +#else + exportAudioSampleRate->clear(); + alsaSampleRate->addItem(tr("192000"), 192000); + alsaSampleRate->addItem( tr("96000"), 96000); + alsaSampleRate->addItem( tr("88200"), 88200); + alsaSampleRate->addItem( tr("48000"), 48000); // default + alsaSampleRate->addItem( tr("44100"), 44100); + alsaSampleRate->addItem( tr("32000"), 32000); + alsaSampleRate->addItem( tr("22050"), 22050); + + alsaPeriodSize->clear(); + alsaPeriodSize->addItem(tr("4096"), 4096); + alsaPeriodSize->addItem(tr("2048"), 2048); + alsaPeriodSize->addItem(tr("1024"), 1024); // default + alsaPeriodSize->addItem( tr("512"), 512); + alsaPeriodSize->addItem( tr("256"), 256); + alsaPeriodSize->addItem( tr("128"), 128); + alsaPeriodSize->addItem( tr("64"), 64); +#endif + + exportAudioSampleRate->clear(); + exportAudioSampleRate->addItem(tr("44100"), 44100); // default + exportAudioSampleRate->addItem(tr("48000"), 48000); + +#ifndef USE_LAME + exportMp3BitRateLabel->setVisible(false); + exportMp3BitRate->setVisible(false); + exporMp3BitRateUnit->setVisible(false) +#else + exportMp3BitRate->clear(); + exportMp3BitRate->addItem( tr("8"), 8); + exportMp3BitRate->addItem( tr("16"), 16); + exportMp3BitRate->addItem( tr("32"), 32); + exportMp3BitRate->addItem( tr("40"), 40); + exportMp3BitRate->addItem( tr("48"), 48); + //exportMp3BitRate->addItem( tr("56"), 56); + exportMp3BitRate->addItem( tr("64"), 64); + exportMp3BitRate->addItem( tr("80"), 80); + exportMp3BitRate->addItem( tr("96"), 96); + exportMp3BitRate->addItem(tr("112"), 112); + exportMp3BitRate->addItem(tr("128"), 128); // default + exportMp3BitRate->addItem(tr("160"), 160); + exportMp3BitRate->addItem(tr("192"), 192); + exportMp3BitRate->addItem(tr("224"), 224); + exportMp3BitRate->addItem(tr("256"), 256); + exportMp3BitRate->addItem(tr("320"), 320); #endif + #ifndef USE_PORTAUDIO portaudioDriver->setVisible(false); #endif @@ -664,11 +712,6 @@ PreferenceDialog::PreferenceDialog(QWidget* parent) recordButtons->addButton(recordEditMode, RMIDI_NOTE_EDIT_MODE); recordButtons->addButton(recordRealtimeAdvance, RMIDI_REALTIME_ADVANCE); - int n = sizeof(exportAudioSampleRates)/sizeof(*exportAudioSampleRates); - exportAudioSampleRate->clear(); - for (int idx = 0; idx < n; ++idx) - exportAudioSampleRate->addItem(QString("%1").arg(exportAudioSampleRates[idx])); - connect(recordButtons, SIGNAL(buttonClicked(int)), SLOT(recordButtonClicked(int))); connect(midiRemoteControlClear, SIGNAL(clicked()), SLOT(midiRemoteControlClearClicked())); connect(portaudioDriver, SIGNAL(toggled(bool)), SLOT(exclusiveAudioDriver(bool))); @@ -832,9 +875,10 @@ void PreferenceDialog::updateValues() alsaDevice->setText(prefs.alsaDevice); - int index = alsaSampleRate->findText(QString("%1").arg(prefs.alsaSampleRate)); + int index = alsaSampleRate->findData(prefs.alsaSampleRate); alsaSampleRate->setCurrentIndex(index); - index = alsaPeriodSize->findText(QString("%1").arg(prefs.alsaPeriodSize)); + + index = alsaPeriodSize->findData(prefs.alsaPeriodSize); alsaPeriodSize->setCurrentIndex(index); alsaFragments->setValue(prefs.alsaFragments); @@ -995,15 +1039,12 @@ void PreferenceDialog::updateValues() myPlugins->setText(prefs.myPluginsPath); mySoundfonts->setText(prefs.mySoundfontsPath); - idx = 0; - int n = sizeof(exportAudioSampleRates)/sizeof(*exportAudioSampleRates); - for (;idx < n; ++idx) { - if (exportAudioSampleRates[idx] == prefs.exportAudioSampleRate) - break; - } - if (idx == n) // if not found in table - idx = 0; - exportAudioSampleRate->setCurrentIndex(idx); + index = exportAudioSampleRate->findData(prefs.exportAudioSampleRate); + exportAudioSampleRate->setCurrentIndex(index); + + index = exportMp3BitRate->findData(prefs.exportMp3BitRate); + exportMp3BitRate->setCurrentIndex(index); + exportPdfDpi->setValue(prefs.exportPdfDpi); pageVertical->setChecked(MScore::verticalOrientation()); } @@ -1343,8 +1384,8 @@ void PreferenceDialog::apply() || (prefs.usePortaudioAudio != portaudioDriver->isChecked()) || (prefs.usePulseAudio != pulseaudioDriver->isChecked()) || (prefs.alsaDevice != alsaDevice->text()) - || (prefs.alsaSampleRate != alsaSampleRate->currentText().toInt()) - || (prefs.alsaPeriodSize != alsaPeriodSize->currentText().toInt()) + || (prefs.alsaSampleRate != alsaSampleRate->currentData().toInt()) + || (prefs.alsaPeriodSize != alsaPeriodSize->currentData().toInt()) || (prefs.alsaFragments != alsaFragments->value()) ) { if (seq) @@ -1353,8 +1394,8 @@ void PreferenceDialog::apply() prefs.usePortaudioAudio = portaudioDriver->isChecked(); prefs.usePulseAudio = pulseaudioDriver->isChecked(); prefs.alsaDevice = alsaDevice->text(); - prefs.alsaSampleRate = alsaSampleRate->currentText().toInt(); - prefs.alsaPeriodSize = alsaPeriodSize->currentText().toInt(); + prefs.alsaSampleRate = alsaSampleRate->currentData().toInt(); + prefs.alsaPeriodSize = alsaPeriodSize->currentData().toInt(); prefs.alsaFragments = alsaFragments->value(); preferences = prefs; if (seq) { @@ -1400,8 +1441,8 @@ void PreferenceDialog::apply() prefs.myPluginsPath = myPlugins->text(); prefs.mySoundfontsPath = mySoundfonts->text(); - int idx = exportAudioSampleRate->currentIndex(); - prefs.exportAudioSampleRate = exportAudioSampleRates[idx]; + prefs.exportAudioSampleRate = exportAudioSampleRate->currentData().toInt(); + prefs.exportMp3BitRate = exportMp3BitRate->currentData().toInt(); prefs.midiExpandRepeats = expandRepeats->isChecked(); prefs.midiExportRPNs = exportRPNs->isChecked(); diff --git a/mscore/preferences.h b/mscore/preferences.h index 197030206b1c..9f35d39d7198 100644 --- a/mscore/preferences.h +++ b/mscore/preferences.h @@ -177,6 +177,7 @@ struct Preferences { bool nativeDialogs; int exportAudioSampleRate; + int exportMp3BitRate; QString workspace; int exportPdfDpi; diff --git a/mscore/prefsdialog.ui b/mscore/prefsdialog.ui index c370439046f0..7c1687cfbe35 100644 --- a/mscore/prefsdialog.ui +++ b/mscore/prefsdialog.ui @@ -328,6 +328,9 @@ Select delay (in minutes) between auto saves + + min + 1 @@ -336,13 +339,6 @@ - - - - minutes - - - @@ -703,6 +699,9 @@ Icon Width + + px + 5 @@ -730,6 +729,9 @@ Icon Height + + px + 5 @@ -1094,6 +1096,9 @@ Proximity for selecting elements: + + px + 1 @@ -1187,7 +1192,7 @@ Delay between notes in automatic Real-time mode - ms + ms 300 @@ -1250,7 +1255,7 @@ Default duration - ms + ms 20 @@ -2720,17 +2725,7 @@ true - - - - Period Size: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - + Fragments @@ -2745,7 +2740,37 @@ 8 - 2 + 3 + + + + + + + Device + + + default + + + + + + + Fragments: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Period Size: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -2766,7 +2791,20 @@ - + + + + Qt::Horizontal + + + + 40 + 20 + + + + + Period Size @@ -2774,66 +2812,46 @@ Choose period size + + 2 + - 4096 + 4096 - 2048 + 2048 - 1024 + 1024 - 512 + 512 - 256 + 256 - 128 + 128 - 64 + 64 - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Fragments: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - @@ -2842,53 +2860,66 @@ Choose sample rate + + 3 + - 192000 + 192000 - 96000 + 96000 - 88200 + 88200 - 48000 + 48000 - 44100 + 44100 - 32000 + 32000 - 22050 + 22050 - - - - Device - + + - default + Hz + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -3345,7 +3376,7 @@ - Resolution DPI: + Resolution: @@ -3380,6 +3411,9 @@ Choose resolution DPI + + DPI + 32 @@ -3429,60 +3463,8 @@ - - - - Audio - - - Audio - - - - - - Sample rate: - - - - - - - Sample rate - - - Choose sample rate - - - - 44100 - - - - - 48000 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - + 0 @@ -3552,15 +3534,15 @@ PDF - - + + - Resolution DPI: + Resolution: - + Resolution DPI @@ -3568,6 +3550,9 @@ Choose resolution DPI + + DPI + 75 @@ -3579,7 +3564,7 @@ - + Qt::Horizontal @@ -3595,6 +3580,162 @@ + + + + Audio + + + Audio + + + + + + 128 + + + 8 + + + + 32 + + + + + 40 + + + + + 48 + + + + + 56 + + + + + 64 + + + + + 80 + + + + + 96 + + + + + 112 + + + + + 128 + + + + + 160 + + + + + 192 + + + + + 224 + + + + + 256 + + + + + 320 + + + + + + + + Sample rate: + + + + + + + Sample rate + + + Choose sample rate + + + 0 + + + + 44100 + + + + + 48000 + + + + + + + + Hz + + + + + + + kBit/s + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + MP3 Bitrate: + + + + + +