audio export: more stuff
This commit is contained in:
parent
68383869d3
commit
56a3cfe13d
3 changed files with 87 additions and 15 deletions
|
|
@ -98,8 +98,14 @@ enum DivMIDIModes {
|
|||
DIV_MIDI_MODE_LIGHT_SHOW
|
||||
};
|
||||
|
||||
enum DivAudioExportFormats {
|
||||
DIV_EXPORT_FORMAT_S16=0,
|
||||
DIV_EXPORT_FORMAT_F32
|
||||
};
|
||||
|
||||
struct DivAudioExportOptions {
|
||||
DivAudioExportModes mode;
|
||||
DivAudioExportFormats format;
|
||||
int sampleRate;
|
||||
int chans;
|
||||
int loops;
|
||||
|
|
@ -108,6 +114,7 @@ struct DivAudioExportOptions {
|
|||
bool channelMask[DIV_MAX_CHANS];
|
||||
DivAudioExportOptions():
|
||||
mode(DIV_EXPORT_MODE_ONE),
|
||||
format(DIV_EXPORT_FORMAT_S16),
|
||||
sampleRate(44100),
|
||||
chans(2),
|
||||
loops(0),
|
||||
|
|
@ -478,8 +485,10 @@ class DivEngine {
|
|||
DivChannelState chan[DIV_MAX_CHANS];
|
||||
DivAudioEngines audioEngine;
|
||||
DivAudioExportModes exportMode;
|
||||
DivAudioExportFormats exportFormat;
|
||||
double exportFadeOut;
|
||||
int exportOutputs;
|
||||
bool exportChannelMask[DIV_MAX_CHANS];
|
||||
DivConfig conf;
|
||||
FixedQueue<DivNoteEvent,8192> pendingNotes;
|
||||
// bitfield
|
||||
|
|
@ -1382,6 +1391,7 @@ class DivEngine {
|
|||
haltOn(DIV_HALT_NONE),
|
||||
audioEngine(DIV_AUDIO_NULL),
|
||||
exportMode(DIV_EXPORT_MODE_ONE),
|
||||
exportFormat(DIV_EXPORT_FORMAT_S16),
|
||||
exportFadeOut(0.0),
|
||||
exportOutputs(2),
|
||||
cmdStreamInt(NULL),
|
||||
|
|
@ -1435,6 +1445,7 @@ class DivEngine {
|
|||
memset(sysDefs,0,DIV_MAX_CHIP_DEFS*sizeof(void*));
|
||||
memset(walked,0,8192);
|
||||
memset(oscBuf,0,DIV_MAX_OUTPUTS*(sizeof(float*)));
|
||||
memset(exportChannelMask,1,DIV_MAX_CHANS*sizeof(bool));
|
||||
|
||||
for (int i=0; i<DIV_MAX_CHIP_DEFS; i++) {
|
||||
sysFileMapFur[i]=DIV_SYSTEM_NULL;
|
||||
|
|
|
|||
|
|
@ -46,7 +46,11 @@ void DivEngine::runExportThread() {
|
|||
SFWrapper sfWrap;
|
||||
si.samplerate=got.rate;
|
||||
si.channels=exportOutputs;
|
||||
si.format=SF_FORMAT_WAV|SF_FORMAT_PCM_16;
|
||||
if (exportFormat==DIV_EXPORT_FORMAT_S16) {
|
||||
si.format=SF_FORMAT_WAV|SF_FORMAT_PCM_16;
|
||||
} else {
|
||||
si.format=SF_FORMAT_WAV|SF_FORMAT_FLOAT;
|
||||
}
|
||||
|
||||
sf=sfWrap.doOpen(exportPath.c_str(),SFM_WRITE,&si);
|
||||
if (sf==NULL) {
|
||||
|
|
@ -253,6 +257,7 @@ void DivEngine::runExportThread() {
|
|||
logI("rendering to files...");
|
||||
|
||||
for (int i=0; i<chans; i++) {
|
||||
if (!exportChannelMask[i]) continue;
|
||||
SNDFILE* sf;
|
||||
SF_INFO si;
|
||||
SFWrapper sfWrap;
|
||||
|
|
@ -260,7 +265,11 @@ void DivEngine::runExportThread() {
|
|||
logI("- %s",fname.c_str());
|
||||
si.samplerate=got.rate;
|
||||
si.channels=exportOutputs;
|
||||
si.format=SF_FORMAT_WAV|SF_FORMAT_PCM_16;
|
||||
if (exportFormat==DIV_EXPORT_FORMAT_S16) {
|
||||
si.format=SF_FORMAT_WAV|SF_FORMAT_PCM_16;
|
||||
} else {
|
||||
si.format=SF_FORMAT_WAV|SF_FORMAT_FLOAT;
|
||||
}
|
||||
|
||||
sf=sfWrap.doOpen(fname.c_str(),SFM_WRITE,&si);
|
||||
if (sf==NULL) {
|
||||
|
|
@ -391,7 +400,9 @@ bool DivEngine::saveAudio(const char* path, DivAudioExportOptions options) {
|
|||
#else
|
||||
exportPath=path;
|
||||
exportMode=options.mode;
|
||||
exportFormat=options.format;
|
||||
exportFadeOut=options.fadeOut;
|
||||
memcpy(exportChannelMask,options.channelMask,DIV_MAX_CHANS*sizeof(bool));
|
||||
if (exportMode!=DIV_EXPORT_MODE_ONE) {
|
||||
// remove extension
|
||||
String lowerCase=exportPath;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue