audio export: more stuff

This commit is contained in:
tildearrow 2024-05-11 14:25:53 -05:00
parent 68383869d3
commit 56a3cfe13d
3 changed files with 87 additions and 15 deletions

View file

@ -34,12 +34,24 @@ void FurnaceGUI::drawExportAudio(bool onWindow) {
}
if (ImGui::RadioButton("multiple files (one per chip)",audioExportOptions.mode==DIV_EXPORT_MODE_MANY_SYS)) {
audioExportOptions.mode=DIV_EXPORT_MODE_MANY_SYS;
}
}
if (ImGui::RadioButton("multiple files (one per channel)",audioExportOptions.mode==DIV_EXPORT_MODE_MANY_CHAN)) {
audioExportOptions.mode=DIV_EXPORT_MODE_MANY_CHAN;
}
ImGui::Unindent();
if (audioExportOptions.mode!=DIV_EXPORT_MODE_MANY_SYS) {
ImGui::Text("Bit depth:");
ImGui::Indent();
if (ImGui::RadioButton("16-bit integer",audioExportOptions.format==DIV_EXPORT_FORMAT_S16)) {
audioExportOptions.format=DIV_EXPORT_FORMAT_S16;
}
if (ImGui::RadioButton("32-bit float",audioExportOptions.format==DIV_EXPORT_FORMAT_F32)) {
audioExportOptions.format=DIV_EXPORT_FORMAT_F32;
}
ImGui::Unindent();
}
if (ImGui::InputInt("Sample rate",&audioExportOptions.sampleRate,100,10000)) {
if (audioExportOptions.sampleRate<8000) audioExportOptions.sampleRate=8000;
if (audioExportOptions.sampleRate>384000) 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; i<DIV_MAX_CHANS; i++) {
audioExportOptions.channelMask[i]=true;
}
}
ImGui::SameLine();
if (ImGui::SmallButton("None")) {
for (int i=0; i<DIV_MAX_CHANS; i++) {
audioExportOptions.channelMask[i]=false;
}
}
ImGui::SameLine();
if (ImGui::SmallButton("Invert")) {
for (int i=0; i<DIV_MAX_CHANS; i++) {
audioExportOptions.channelMask[i]=!audioExportOptions.channelMask[i];
}
}
if (ImGui::BeginChild("Channel Selection",ImVec2(0,200.0f*dpiScale))) {
for (int i=0; i<e->getTotalChannelCount(); 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");
}
}