flac export

master
zetaPRIME 2022-03-15 00:59:05 -04:00
parent 34b4721f69
commit 9ed8d6039d
3 changed files with 15 additions and 6 deletions

6
notes
View File

@ -32,8 +32,10 @@ parameters {
TODO {
immediate frontburner {
- user-defined default template
clear song info on loading template?
- support rendering to FLAC
- figure out why it defaults to mp3 regardless of type selection?? (it's because qt does a default suffix)
add rendering modal
revert action

View File

@ -18,6 +18,7 @@ using namespace Xybrid::Data;
#include <QMutex>
#include <QTimer>
#include <QProcess>
#include <QFileInfo>
#ifdef Q_OS_MAC
#define FFMPEG "/usr/local/bin/ffmpeg"
@ -209,7 +210,7 @@ uint16_t AudioEngine::preview(std::shared_ptr<Project> p, int16_t port, int16_t
return nId;
}
void AudioEngine::render(std::shared_ptr<Project> p, QString filename) {
void AudioEngine::render(std::shared_ptr<Project> p, QString fileName) {
if (!p) return; // yeah, no
if (mode != Stopped) {
@ -236,13 +237,19 @@ void AudioEngine::render(std::shared_ptr<Project> p, QString filename) {
initAudio(); // we actually need the period size. whoops.
QFileInfo fi(fileName);
auto ext = fi.suffix().toLower();
QProcess enc;
QStringList param;
param << "-y" << "-f" << "s16le" << "-ac" << "2" << "-ar" << QString::number(sampleRate) << "-i" << "pipe:";
if (!project->title.isEmpty()) param << "-metadata" << qs("title=%1").arg(project->title);
if (!project->artist.isEmpty()) param << "-metadata" << qs("artist=%1").arg(project->artist);
param << "-f" << "mp3" << "-codec:a" << "libmp3lame"<< "-q:a" << "0"; // specify mp3, vbr v0
param << filename;
// flac out is pretty simple, as it turns out
if (ext == "flac") param << "-c:a" << "flac" << "-compression_level" << "8";
// else specify mp3, vbr v0
else param << "-f" << "mp3" << "-codec:a" << "libmp3lame"<< "-q:a" << "0";
param << fileName;
enc.start(FFMPEG, param);
enc.waitForStarted();

View File

@ -44,7 +44,7 @@ const QString FileOps::Filter::project = qs("Xybrid project (*.xyp);;All files (
const QString FileOps::Filter::node = qs("Xybrid node (*.xyn);;All files (*)");
const QString FileOps::Filter::audioIn = qs("Audio files (*.mp3, *.ogg, *.flac, *.wav);;MPEG Layer 3 (*.mp3);;All files (*)");
const QString FileOps::Filter::audioOut = qs("MPEG Layer 3 (*.mp3)"); // only supported formats
const QString FileOps::Filter::audioOut = qs("Audio files (*.mp3, *.flac);;MPEG Layer 3 (*.mp3);;FLAC (*.flac)"); // only supported formats
QString FileOps::showOpenDialog(QWidget* parent, const QString& caption, const QString& directory, const QString& filter) {
QFileDialog dlg(parent, caption, directory, filter);