add sample rate parameter in raw sample import

This commit is contained in:
tildearrow 2024-01-16 21:12:34 -05:00
parent ab3624789b
commit 928bfd2afd
4 changed files with 16 additions and 6 deletions

View file

@ -954,7 +954,7 @@ class DivEngine {
DivSample* sampleFromFile(const char* path); DivSample* sampleFromFile(const char* path);
// get raw sample // get raw sample
DivSample* sampleFromFileRaw(const char* path, DivSampleDepth depth, int channels, bool bigEndian, bool unsign, bool swapNibbles); DivSample* sampleFromFileRaw(const char* path, DivSampleDepth depth, int channels, bool bigEndian, bool unsign, bool swapNibbles, int rate);
// delete sample // delete sample
void delSample(int index); void delSample(int index);

View file

@ -302,7 +302,7 @@ DivSample* DivEngine::sampleFromFile(const char* path) {
#endif #endif
} }
DivSample* DivEngine::sampleFromFileRaw(const char* path, DivSampleDepth depth, int channels, bool bigEndian, bool unsign, bool swapNibbles) { DivSample* DivEngine::sampleFromFileRaw(const char* path, DivSampleDepth depth, int channels, bool bigEndian, bool unsign, bool swapNibbles, int rate) {
if (song.sample.size()>=256) { if (song.sample.size()>=256) {
lastError="too many samples!"; lastError="too many samples!";
return NULL; return NULL;
@ -420,8 +420,8 @@ DivSample* DivEngine::sampleFromFileRaw(const char* path, DivSampleDepth depth,
return NULL; return NULL;
} }
sample->rate=32000; sample->rate=rate;
sample->centerRate=32000; sample->centerRate=rate;
sample->depth=depth; sample->depth=depth;
sample->init(samples); sample->init(samples);

View file

@ -5988,6 +5988,15 @@ bool FurnaceGUI::loop() {
pendingRawSampleBigEndian=false; pendingRawSampleBigEndian=false;
} }
ImGui::AlignTextToFramePadding();
ImGui::Text("Sample rate");
ImGui::SameLine();
ImGui::SetNextItemWidth(120.0f*dpiScale);
if (ImGui::InputInt("##RSRate",&pendingRawSampleRate,100,1000)) {
if (pendingRawSampleRate<100) pendingRawSampleRate=100;
if (pendingRawSampleRate>384000) pendingRawSampleRate=384000;
}
if (pendingRawSampleDepth==DIV_SAMPLE_DEPTH_8BIT || pendingRawSampleDepth==DIV_SAMPLE_DEPTH_16BIT) { if (pendingRawSampleDepth==DIV_SAMPLE_DEPTH_8BIT || pendingRawSampleDepth==DIV_SAMPLE_DEPTH_16BIT) {
ImGui::AlignTextToFramePadding(); ImGui::AlignTextToFramePadding();
ImGui::Text("Channels"); ImGui::Text("Channels");
@ -6033,7 +6042,7 @@ bool FurnaceGUI::loop() {
} }
if (ImGui::Button("OK")) { if (ImGui::Button("OK")) {
DivSample* s=e->sampleFromFileRaw(pendingRawSample.c_str(),(DivSampleDepth)pendingRawSampleDepth,pendingRawSampleChannels,pendingRawSampleBigEndian,pendingRawSampleUnsigned,pendingRawSampleSwapNibbles); DivSample* s=e->sampleFromFileRaw(pendingRawSample.c_str(),(DivSampleDepth)pendingRawSampleDepth,pendingRawSampleChannels,pendingRawSampleBigEndian,pendingRawSampleUnsigned,pendingRawSampleSwapNibbles,pendingRawSampleRate);
if (s==NULL) { if (s==NULL) {
showError(e->getLastError()); showError(e->getLastError());
} else { } else {
@ -7225,6 +7234,7 @@ FurnaceGUI::FurnaceGUI():
editString(NULL), editString(NULL),
pendingRawSampleDepth(8), pendingRawSampleDepth(8),
pendingRawSampleChannels(1), pendingRawSampleChannels(1),
pendingRawSampleRate(32000),
pendingRawSampleUnsigned(false), pendingRawSampleUnsigned(false),
pendingRawSampleBigEndian(false), pendingRawSampleBigEndian(false),
pendingRawSampleSwapNibbles(false), pendingRawSampleSwapNibbles(false),

View file

@ -1497,7 +1497,7 @@ class FurnaceGUI {
SDL_Event userEvent; SDL_Event userEvent;
String pendingRawSample; String pendingRawSample;
int pendingRawSampleDepth, pendingRawSampleChannels; int pendingRawSampleDepth, pendingRawSampleChannels, pendingRawSampleRate;
bool pendingRawSampleUnsigned, pendingRawSampleBigEndian, pendingRawSampleSwapNibbles, pendingRawSampleReplace; bool pendingRawSampleUnsigned, pendingRawSampleBigEndian, pendingRawSampleSwapNibbles, pendingRawSampleReplace;
ImGuiWindowFlags globalWinFlags; ImGuiWindowFlags globalWinFlags;