formats combo, more format for wav export
This commit is contained in:
parent
27cf8be1c4
commit
ad4572be43
3 changed files with 89 additions and 42 deletions
|
|
@ -102,8 +102,7 @@ enum DivMIDIModes {
|
|||
};
|
||||
|
||||
enum DivAudioExportFormats {
|
||||
DIV_EXPORT_FORMAT_S16=0,
|
||||
DIV_EXPORT_FORMAT_F32,
|
||||
DIV_EXPORT_FORMAT_WAV=0,
|
||||
DIV_EXPORT_FORMAT_OPUS,
|
||||
DIV_EXPORT_FORMAT_FLAC,
|
||||
DIV_EXPORT_FORMAT_VORBIS,
|
||||
|
|
@ -116,10 +115,18 @@ enum DivAudioExportBitrateModes {
|
|||
DIV_EXPORT_BITRATE_AVERAGE,
|
||||
};
|
||||
|
||||
enum DivAudioExportWavFormats {
|
||||
DIV_EXPORT_WAV_U8=0,
|
||||
DIV_EXPORT_WAV_S16,
|
||||
DIV_EXPORT_WAV_S32,
|
||||
DIV_EXPORT_WAV_F32
|
||||
};
|
||||
|
||||
struct DivAudioExportOptions {
|
||||
DivAudioExportModes mode;
|
||||
DivAudioExportFormats format;
|
||||
DivAudioExportBitrateModes bitRateMode;
|
||||
DivAudioExportWavFormats wavFormat;
|
||||
int sampleRate;
|
||||
int chans;
|
||||
int loops;
|
||||
|
|
@ -130,7 +137,7 @@ struct DivAudioExportOptions {
|
|||
float vbrQuality;
|
||||
DivAudioExportOptions():
|
||||
mode(DIV_EXPORT_MODE_ONE),
|
||||
format(DIV_EXPORT_FORMAT_S16),
|
||||
format(DIV_EXPORT_FORMAT_WAV),
|
||||
bitRateMode(DIV_EXPORT_BITRATE_CONSTANT),
|
||||
sampleRate(44100),
|
||||
chans(2),
|
||||
|
|
@ -514,6 +521,7 @@ class DivEngine {
|
|||
DivAudioEngines audioEngine;
|
||||
DivAudioExportModes exportMode;
|
||||
DivAudioExportFormats exportFormat;
|
||||
DivAudioExportWavFormats wavFormat;
|
||||
DivAudioExportBitrateModes exportBitRateMode;
|
||||
double exportFadeOut;
|
||||
bool isFadingOut;
|
||||
|
|
@ -1506,7 +1514,8 @@ class DivEngine {
|
|||
haltOn(DIV_HALT_NONE),
|
||||
audioEngine(DIV_AUDIO_NULL),
|
||||
exportMode(DIV_EXPORT_MODE_ONE),
|
||||
exportFormat(DIV_EXPORT_FORMAT_S16),
|
||||
exportFormat(DIV_EXPORT_FORMAT_WAV),
|
||||
wavFormat(DIV_EXPORT_WAV_S16),
|
||||
exportBitRateMode(DIV_EXPORT_BITRATE_CONSTANT),
|
||||
exportFadeOut(0.0),
|
||||
isFadingOut(false),
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ bool DivEngine::getIsFadingOut() {
|
|||
#ifdef HAVE_SNDFILE
|
||||
|
||||
#define MAP_BITRATE \
|
||||
if (exportFormat!=DIV_EXPORT_FORMAT_S16 && exportFormat!=DIV_EXPORT_FORMAT_F32) { \
|
||||
if (exportFormat!=DIV_EXPORT_FORMAT_WAV) { \
|
||||
double mappedLevel=0.0; \
|
||||
\
|
||||
switch (exportFormat) { \
|
||||
|
|
@ -179,11 +179,26 @@ void DivEngine::runExportThread() {
|
|||
si.samplerate=got.rate;
|
||||
si.channels=exportOutputs;
|
||||
switch (exportFormat) {
|
||||
case DIV_EXPORT_FORMAT_S16:
|
||||
si.format=SF_FORMAT_WAV|SF_FORMAT_PCM_16;
|
||||
break;
|
||||
case DIV_EXPORT_FORMAT_F32:
|
||||
si.format=SF_FORMAT_WAV|SF_FORMAT_FLOAT;
|
||||
case DIV_EXPORT_FORMAT_WAV:
|
||||
si.format=SF_FORMAT_WAV;
|
||||
switch (wavFormat) {
|
||||
case DIV_EXPORT_WAV_U8:
|
||||
si.format|=SF_FORMAT_PCM_U8;
|
||||
break;
|
||||
case DIV_EXPORT_WAV_S16:
|
||||
si.format|=SF_FORMAT_PCM_16;
|
||||
break;
|
||||
case DIV_EXPORT_WAV_S32:
|
||||
si.format|=SF_FORMAT_PCM_32;
|
||||
break;
|
||||
case DIV_EXPORT_WAV_F32:
|
||||
si.format|=SF_FORMAT_FLOAT;
|
||||
break;
|
||||
default:
|
||||
si.format|=SF_FORMAT_PCM_U8;
|
||||
logW("wtf");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case DIV_EXPORT_FORMAT_OPUS:
|
||||
si.format=SF_FORMAT_OGG|SF_FORMAT_OPUS;
|
||||
|
|
@ -426,11 +441,26 @@ void DivEngine::runExportThread() {
|
|||
si.samplerate=got.rate;
|
||||
si.channels=exportOutputs;
|
||||
switch (exportFormat) {
|
||||
case DIV_EXPORT_FORMAT_S16:
|
||||
si.format=SF_FORMAT_WAV|SF_FORMAT_PCM_16;
|
||||
break;
|
||||
case DIV_EXPORT_FORMAT_F32:
|
||||
si.format=SF_FORMAT_WAV|SF_FORMAT_FLOAT;
|
||||
case DIV_EXPORT_FORMAT_WAV:
|
||||
si.format=SF_FORMAT_WAV;
|
||||
switch (wavFormat) {
|
||||
case DIV_EXPORT_WAV_U8:
|
||||
si.format|=SF_FORMAT_PCM_U8;
|
||||
break;
|
||||
case DIV_EXPORT_WAV_S16:
|
||||
si.format|=SF_FORMAT_PCM_16;
|
||||
break;
|
||||
case DIV_EXPORT_WAV_S32:
|
||||
si.format|=SF_FORMAT_PCM_32;
|
||||
break;
|
||||
case DIV_EXPORT_WAV_F32:
|
||||
si.format|=SF_FORMAT_FLOAT;
|
||||
break;
|
||||
default:
|
||||
si.format|=SF_FORMAT_PCM_U8;
|
||||
logW("wtf");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case DIV_EXPORT_FORMAT_OPUS:
|
||||
si.format=SF_FORMAT_OGG|SF_FORMAT_OPUS;
|
||||
|
|
@ -584,6 +614,7 @@ bool DivEngine::saveAudio(const char* path, DivAudioExportOptions options) {
|
|||
exportPath=path;
|
||||
exportMode=options.mode;
|
||||
exportFormat=options.format;
|
||||
wavFormat=options.wavFormat;
|
||||
exportBitRate=options.bitRate;
|
||||
exportBitRateMode=options.bitRateMode;
|
||||
exportVBRQuality=options.vbrQuality;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue