Opus audio export

• May 10, 2019 - 18:28

Now that libsndfile is adding Opus input and output (already checked in to master), it'd be nice to see Musescore take advantage of that.

Listening tests in early 2011, a year and a half before Opus was ready for release, showed it was already better than AAC and Vorbis (ergo vastly better than MP3), and encoders have made a lot of further progress in the years since then. Playback support has spread to most media players, web browsers, etc.


Comments

In reply to by Belteshazzar_

Meanwhile libsndfile 1.0.30.

See also https://github.com/musescore/MuseScore/pull/6489

BTW: I tried to add Opus export, using the following rather simple code changes/additions:

$ git diff
diff --git a/mscore/exportaudio.cpp b/mscore/exportaudio.cpp
index 7115df49b..686dd81cd 100644
--- a/mscore/exportaudio.cpp
+++ b/mscore/exportaudio.cpp
@@ -313,10 +313,12 @@ bool MuseScore::saveAudio(Score* score, const QString& name)
 
     if (name.endsWith(".wav")) {
         format = SF_FORMAT_WAV | PCMRate;
-    } else if (name.endsWith(".ogg")) {
-        format = SF_FORMAT_OGG | SF_FORMAT_VORBIS;
     } else if (name.endsWith(".flac")) {
         format = SF_FORMAT_FLAC | PCMRate;
+    } else if (name.endsWith(".ogg")) {
+        format = SF_FORMAT_OGG | SF_FORMAT_VORBIS;
+    } else if (name.endsWith(".opus")) {
+        format = SF_FORMAT_OGG | SF_FORMAT_OPUS;
     } else {
         qDebug("unknown audio file type <%s>", qPrintable(name));
         return false;
diff --git a/mscore/file.cpp b/mscore/file.cpp
index 2b4074329..412f80f97 100644
--- a/mscore/file.cpp
+++ b/mscore/file.cpp
@@ -1740,6 +1740,7 @@ void MuseScore::exportFile()
     fl.append(tr("Wave Audio") + " (*.wav)");
     fl.append(tr("FLAC Audio") + " (*.flac)");
     fl.append(tr("Ogg Vorbis Audio") + " (*.ogg)");
+    fl.append(tr("Ogg Opus Audio") + " (*.opus)");
 #endif
 #ifdef USE_LAME
     fl.append(tr("MP3 Audio") + " (*.mp3)");
@@ -1838,6 +1839,7 @@ bool MuseScore::exportParts()
     fl.append(tr("Wave Audio") + " (*.wav)");
     fl.append(tr("FLAC Audio") + " (*.flac)");
     fl.append(tr("Ogg Vorbis Audio") + " (*.ogg)");
+    fl.append(tr("Ogg Opus Audio") + " (*.opus)");
 #endif
 #ifdef USE_LAME
     fl.append(tr("MP3 Audio") + " (*.mp3)");
@@ -2076,7 +2078,7 @@ bool MuseScore::saveAs(Score* cs_, bool saveCopy, const QString& path, const QSt
         rv = saveSvg(cs_, fn);
     }
 #ifdef HAS_AUDIOFILE
-    else if (ext == "wav" || ext == "flac" || ext == "ogg") {
+    else if (ext == "wav" || ext == "flac" || ext == "ogg" || ext == "opus") {
         rv = saveAudio(cs_, fn);
     }
 #endif
diff --git a/mscore/musescore.cpp b/mscore/musescore.cpp
index ef610d682..46d45a48c 100644
--- a/mscore/musescore.cpp
+++ b/mscore/musescore.cpp
@@ -4005,7 +4005,7 @@ static bool doConvert(Score* cs, const QString& fn)
         return mscore->saveSvg(cs, fn);
     }
 #ifdef HAS_AUDIOFILE
-    else if (fn.endsWith(".wav") || fn.endsWith(".ogg") || fn.endsWith(".flac")) {
+    else if (fn.endsWith(".wav") || fn.endsWith(".flac") || fn.endsWith(".ogg") || fn.endsWith(".opus")) {
         return mscore->saveAudio(cs, fn);
     }
 #endif

but it just crashes and without any stack trace, so I must be missing something important

Do you still have an unanswered question? Please log in first to post your question.