add more raw sample import options
This commit is contained in:
parent
c8222fd491
commit
dba96812aa
|
@ -3676,13 +3676,11 @@ DivSample* DivEngine::sampleFromFileRaw(const char* path, DivSampleDepth depth,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (channels<1) {
|
if (channels<1) {
|
||||||
lastError="invalid channel count";
|
channels=1;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
if (depth!=DIV_SAMPLE_DEPTH_8BIT && depth!=DIV_SAMPLE_DEPTH_16BIT) {
|
if (depth!=DIV_SAMPLE_DEPTH_8BIT && depth!=DIV_SAMPLE_DEPTH_16BIT) {
|
||||||
if (channels!=1) {
|
if (channels!=1) {
|
||||||
lastError="channel count has to be 1 for non-8/16-bit format";
|
channels=1;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BUSY_BEGIN;
|
BUSY_BEGIN;
|
||||||
|
@ -3767,6 +3765,7 @@ DivSample* DivEngine::sampleFromFileRaw(const char* path, DivSampleDepth depth,
|
||||||
samples=lenDivided*2;
|
samples=lenDivided*2;
|
||||||
break;
|
break;
|
||||||
case DIV_SAMPLE_DEPTH_8BIT:
|
case DIV_SAMPLE_DEPTH_8BIT:
|
||||||
|
case DIV_SAMPLE_DEPTH_MULAW:
|
||||||
samples=lenDivided;
|
samples=lenDivided;
|
||||||
break;
|
break;
|
||||||
case DIV_SAMPLE_DEPTH_BRR:
|
case DIV_SAMPLE_DEPTH_BRR:
|
||||||
|
@ -3836,12 +3835,46 @@ DivSample* DivEngine::sampleFromFileRaw(const char* path, DivSampleDepth depth,
|
||||||
}
|
}
|
||||||
delete[] buf;
|
delete[] buf;
|
||||||
|
|
||||||
// swap nibbles if needed
|
|
||||||
if (swapNibbles) {
|
if (swapNibbles) {
|
||||||
unsigned char* b=(unsigned char*)sample->getCurBuf();
|
unsigned char* b=(unsigned char*)sample->getCurBuf();
|
||||||
|
switch (depth) {
|
||||||
|
case DIV_SAMPLE_DEPTH_1BIT:
|
||||||
|
case DIV_SAMPLE_DEPTH_1BIT_DPCM:
|
||||||
|
// reverse bit order
|
||||||
|
for (unsigned int i=0; i<sample->getCurBufLen(); i++) {
|
||||||
|
b[i]=(
|
||||||
|
((b[i]&128)?1:0)|
|
||||||
|
((b[i]&64)?2:0)|
|
||||||
|
((b[i]&32)?4:0)|
|
||||||
|
((b[i]&16)?8:0)|
|
||||||
|
((b[i]&8)?16:0)|
|
||||||
|
((b[i]&4)?32:0)|
|
||||||
|
((b[i]&2)?64:0)|
|
||||||
|
((b[i]&1)?128:0)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case DIV_SAMPLE_DEPTH_YMZ_ADPCM:
|
||||||
|
case DIV_SAMPLE_DEPTH_QSOUND_ADPCM:
|
||||||
|
case DIV_SAMPLE_DEPTH_ADPCM_A:
|
||||||
|
case DIV_SAMPLE_DEPTH_ADPCM_B:
|
||||||
|
case DIV_SAMPLE_DEPTH_VOX:
|
||||||
|
// swap nibbles
|
||||||
for (unsigned int i=0; i<sample->getCurBufLen(); i++) {
|
for (unsigned int i=0; i<sample->getCurBufLen(); i++) {
|
||||||
b[i]=(b[i]<<4)|(b[i]>>4);
|
b[i]=(b[i]<<4)|(b[i]>>4);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case DIV_SAMPLE_DEPTH_MULAW:
|
||||||
|
// Namco to G.711
|
||||||
|
// Namco: smmmmxxx
|
||||||
|
// G.711: sxxxmmmm (^0xff)
|
||||||
|
for (unsigned int i=0; i<sample->getCurBufLen(); i++) {
|
||||||
|
b[i]=(((b[i]&7)<<4)|(((b[i]>>3)&15)^((b[i]&0x80)?15:0))|(b[i]&0x80))^0xff;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BUSY_END;
|
BUSY_END;
|
||||||
|
|
|
@ -5766,23 +5766,45 @@ bool FurnaceGUI::loop() {
|
||||||
pendingRawSampleBigEndian=false;
|
pendingRawSampleBigEndian=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::BeginDisabled(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");
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
ImGui::SetNextItemWidth(120.0f*dpiScale);
|
||||||
if (ImGui::InputInt("##RSChans",&pendingRawSampleChannels)) {
|
if (ImGui::InputInt("##RSChans",&pendingRawSampleChannels)) {
|
||||||
}
|
}
|
||||||
ImGui::Text("(will be mixed down to mono)");
|
ImGui::Text("(will be mixed down to mono)");
|
||||||
ImGui::Checkbox("Unsigned",&pendingRawSampleUnsigned);
|
ImGui::Checkbox("Unsigned",&pendingRawSampleUnsigned);
|
||||||
ImGui::EndDisabled();
|
}
|
||||||
|
|
||||||
ImGui::BeginDisabled(pendingRawSampleDepth!=DIV_SAMPLE_DEPTH_16BIT);
|
if (pendingRawSampleDepth==DIV_SAMPLE_DEPTH_16BIT) {
|
||||||
ImGui::Checkbox("Big endian",&pendingRawSampleBigEndian);
|
ImGui::Checkbox("Big endian",&pendingRawSampleBigEndian);
|
||||||
ImGui::EndDisabled();
|
}
|
||||||
|
|
||||||
ImGui::BeginDisabled(pendingRawSampleDepth==DIV_SAMPLE_DEPTH_16BIT);
|
if (pendingRawSampleDepth==DIV_SAMPLE_DEPTH_YMZ_ADPCM ||
|
||||||
|
pendingRawSampleDepth==DIV_SAMPLE_DEPTH_QSOUND_ADPCM ||
|
||||||
|
pendingRawSampleDepth==DIV_SAMPLE_DEPTH_ADPCM_A ||
|
||||||
|
pendingRawSampleDepth==DIV_SAMPLE_DEPTH_ADPCM_B ||
|
||||||
|
pendingRawSampleDepth==DIV_SAMPLE_DEPTH_VOX) {
|
||||||
ImGui::Checkbox("Swap nibbles",&pendingRawSampleSwapNibbles);
|
ImGui::Checkbox("Swap nibbles",&pendingRawSampleSwapNibbles);
|
||||||
ImGui::EndDisabled();
|
}
|
||||||
|
|
||||||
|
if (pendingRawSampleDepth==DIV_SAMPLE_DEPTH_MULAW) {
|
||||||
|
ImGui::Text("Encoding:");
|
||||||
|
ImGui::Indent();
|
||||||
|
if (ImGui::RadioButton("G.711",pendingRawSampleSwapNibbles==0)) {
|
||||||
|
pendingRawSampleSwapNibbles=0;
|
||||||
|
}
|
||||||
|
if (ImGui::RadioButton("Namco",pendingRawSampleSwapNibbles==1)) {
|
||||||
|
pendingRawSampleSwapNibbles=1;
|
||||||
|
}
|
||||||
|
ImGui::Unindent();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pendingRawSampleDepth==DIV_SAMPLE_DEPTH_1BIT ||
|
||||||
|
pendingRawSampleDepth==DIV_SAMPLE_DEPTH_1BIT_DPCM) {
|
||||||
|
ImGui::Checkbox("Reverse bit order",&pendingRawSampleSwapNibbles);
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
|
Loading…
Reference in New Issue