mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-24 05:25:12 +00:00
raw sample import fixes
This commit is contained in:
parent
91f9352eaf
commit
041a76ad81
4 changed files with 15 additions and 6 deletions
|
@ -2639,7 +2639,7 @@ DivSample* DivEngine::sampleFromFile(const char* path) {
|
|||
#endif
|
||||
}
|
||||
|
||||
DivSample* DivEngine::sampleFromFileRaw(const char* path, DivSampleDepth depth, int channels, bool bigEndian) {
|
||||
DivSample* DivEngine::sampleFromFileRaw(const char* path, DivSampleDepth depth, int channels, bool bigEndian, bool unsign) {
|
||||
if (song.sample.size()>=256) {
|
||||
lastError="too many samples!";
|
||||
return NULL;
|
||||
|
@ -2780,7 +2780,11 @@ DivSample* DivEngine::sampleFromFileRaw(const char* path, DivSampleDepth depth,
|
|||
int accum=0;
|
||||
for (int j=0; j<channels; j++) {
|
||||
if (pos+1>=len) break;
|
||||
accum+=((short*)buf)[pos>>1];
|
||||
if (bigEndian) {
|
||||
accum+=(short)(((short)((buf[pos]<<8)|buf[pos+1]))^(unsign?0x8000:0));
|
||||
} else {
|
||||
accum+=(short)(((short)(buf[pos]|(buf[pos+1]<<8)))^(unsign?0x8000:0));
|
||||
}
|
||||
pos+=2;
|
||||
}
|
||||
accum/=channels;
|
||||
|
@ -2791,7 +2795,7 @@ DivSample* DivEngine::sampleFromFileRaw(const char* path, DivSampleDepth depth,
|
|||
int accum=0;
|
||||
for (int j=0; j<channels; j++) {
|
||||
if (pos>=len) break;
|
||||
accum+=(signed char)buf[pos++];
|
||||
accum+=(signed char)(buf[pos++]^(unsign?0x80:0));
|
||||
}
|
||||
accum/=channels;
|
||||
sample->data8[i]=accum;
|
||||
|
|
|
@ -725,7 +725,7 @@ class DivEngine {
|
|||
DivSample* sampleFromFile(const char* path);
|
||||
|
||||
// get raw sample
|
||||
DivSample* sampleFromFileRaw(const char* path, DivSampleDepth depth, int channels, bool bigEndian);
|
||||
DivSample* sampleFromFileRaw(const char* path, DivSampleDepth depth, int channels, bool bigEndian, bool unsign);
|
||||
|
||||
// delete sample
|
||||
void delSample(int index);
|
||||
|
|
|
@ -4172,6 +4172,7 @@ bool FurnaceGUI::loop() {
|
|||
if (ImGui::InputInt("##RSChans",&pendingRawSampleChannels)) {
|
||||
}
|
||||
ImGui::Text("(will be mixed down to mono)");
|
||||
ImGui::Checkbox("Unsigned",&pendingRawSampleUnsigned);
|
||||
ImGui::EndDisabled();
|
||||
|
||||
ImGui::BeginDisabled(pendingRawSampleDepth!=DIV_SAMPLE_DEPTH_16BIT);
|
||||
|
@ -4179,7 +4180,7 @@ bool FurnaceGUI::loop() {
|
|||
ImGui::EndDisabled();
|
||||
|
||||
if (ImGui::Button("OK")) {
|
||||
DivSample* s=e->sampleFromFileRaw(pendingRawSample.c_str(),(DivSampleDepth)pendingRawSampleDepth,pendingRawSampleChannels,pendingRawSampleBigEndian);
|
||||
DivSample* s=e->sampleFromFileRaw(pendingRawSample.c_str(),(DivSampleDepth)pendingRawSampleDepth,pendingRawSampleChannels,pendingRawSampleBigEndian,pendingRawSampleUnsigned);
|
||||
if (s==NULL) {
|
||||
showError(e->getLastError());
|
||||
} else {
|
||||
|
@ -4653,6 +4654,10 @@ FurnaceGUI::FurnaceGUI():
|
|||
drawHalt(10),
|
||||
macroPointSize(16),
|
||||
waveEditStyle(0),
|
||||
pendingRawSampleDepth(8),
|
||||
pendingRawSampleChannels(1),
|
||||
pendingRawSampleUnsigned(false),
|
||||
pendingRawSampleBigEndian(false),
|
||||
globalWinFlags(0),
|
||||
curFileDialog(GUI_FILE_OPEN),
|
||||
warnAction(GUI_WARN_OPEN),
|
||||
|
|
|
@ -975,7 +975,7 @@ class FurnaceGUI {
|
|||
|
||||
String pendingRawSample;
|
||||
int pendingRawSampleDepth, pendingRawSampleChannels;
|
||||
bool pendingRawSampleBigEndian;
|
||||
bool pendingRawSampleUnsigned, pendingRawSampleBigEndian;
|
||||
|
||||
ImGuiWindowFlags globalWinFlags;
|
||||
|
||||
|
|
Loading…
Reference in a new issue