diff --git a/src/engine/engine.h b/src/engine/engine.h index 00789b916..ace57ec76 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -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 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; i384000) audioExportOptions.sampleRate=384000; @@ -59,25 +71,63 @@ void FurnaceGUI::drawExportAudio(bool onWindow) { if (audioExportOptions.fadeOut<0.0) audioExportOptions.fadeOut=0.0; } + bool isOneOn=false; + if (audioExportOptions.mode==DIV_EXPORT_MODE_MANY_CHAN) { + ImGui::Text("Channels to export:"); + ImGui::SameLine(); + if (ImGui::SmallButton("All")) { + for (int i=0; igetTotalChannelCount(); i++) { + String name=fmt::sprintf("%d. %s##_CE%d",i+1,e->getChannelName(i),i); + ImGui::Checkbox(name.c_str(),&audioExportOptions.channelMask[i]); + if (audioExportOptions.channelMask[i]) isOneOn=true; + } + } + ImGui::EndChild(); + } else { + isOneOn=true; + } + if (onWindow) { ImGui::Separator(); if (ImGui::Button("Cancel",ImVec2(200.0f*dpiScale,0))) ImGui::CloseCurrentPopup(); ImGui::SameLine(); } - if (ImGui::Button("Export",ImVec2(200.0f*dpiScale,0))) { - switch (audioExportOptions.mode) { - case DIV_EXPORT_MODE_ONE: - openFileDialog(GUI_FILE_EXPORT_AUDIO_ONE); - break; - case DIV_EXPORT_MODE_MANY_SYS: - openFileDialog(GUI_FILE_EXPORT_AUDIO_PER_SYS); - break; - case DIV_EXPORT_MODE_MANY_CHAN: - openFileDialog(GUI_FILE_EXPORT_AUDIO_PER_CHANNEL); - break; + if (isOneOn) { + if (ImGui::Button("Export",ImVec2(200.0f*dpiScale,0))) { + switch (audioExportOptions.mode) { + case DIV_EXPORT_MODE_ONE: + openFileDialog(GUI_FILE_EXPORT_AUDIO_ONE); + break; + case DIV_EXPORT_MODE_MANY_SYS: + openFileDialog(GUI_FILE_EXPORT_AUDIO_PER_SYS); + break; + case DIV_EXPORT_MODE_MANY_CHAN: + openFileDialog(GUI_FILE_EXPORT_AUDIO_PER_CHANNEL); + break; + } + ImGui::CloseCurrentPopup(); } - ImGui::CloseCurrentPopup(); + } else { + ImGui::Text("select at least one channel"); } }