fix 4 bit pcm
This commit is contained in:
parent
bcf4f5f508
commit
000c85b4cb
|
@ -505,6 +505,7 @@ DivSample* DivEngine::sampleFromFileRaw(const char* path, DivSampleDepth depth,
|
|||
case DIV_SAMPLE_DEPTH_ADPCM_B:
|
||||
case DIV_SAMPLE_DEPTH_ADPCM_K:
|
||||
case DIV_SAMPLE_DEPTH_VOX:
|
||||
case DIV_SAMPLE_DEPTH_4BIT:
|
||||
samples=lenDivided*2;
|
||||
break;
|
||||
case DIV_SAMPLE_DEPTH_IMA_ADPCM:
|
||||
|
@ -617,6 +618,7 @@ DivSample* DivEngine::sampleFromFileRaw(const char* path, DivSampleDepth depth,
|
|||
case DIV_SAMPLE_DEPTH_ADPCM_B:
|
||||
case DIV_SAMPLE_DEPTH_ADPCM_K:
|
||||
case DIV_SAMPLE_DEPTH_VOX:
|
||||
case DIV_SAMPLE_DEPTH_4BIT:
|
||||
// swap nibbles
|
||||
for (unsigned int i=0; i<sample->getCurBufLen(); i++) {
|
||||
b[i]=(b[i]<<4)|(b[i]>>4);
|
||||
|
@ -629,7 +631,7 @@ DivSample* DivEngine::sampleFromFileRaw(const char* path, DivSampleDepth depth,
|
|||
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;
|
||||
break;\
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -633,7 +633,7 @@ bool DivSample::initInternal(DivSampleDepth d, int count) {
|
|||
break;
|
||||
case DIV_SAMPLE_DEPTH_4BIT:
|
||||
if (data4!=NULL) delete[] data4;
|
||||
length4=count;
|
||||
length4=(count+1)/2;
|
||||
data4=new unsigned char[length4];
|
||||
memset(data4,0,length4);
|
||||
break;
|
||||
|
@ -1334,11 +1334,18 @@ void DivSample::render(unsigned int formatMask) {
|
|||
}
|
||||
}
|
||||
break;
|
||||
case DIV_SAMPLE_DEPTH_4BIT:
|
||||
case DIV_SAMPLE_DEPTH_4BIT: {
|
||||
unsigned short nibble=0;
|
||||
for (unsigned int i=0; i<samples; i++) {
|
||||
data16[i]=data4[i]<<12;
|
||||
if (i&1) {
|
||||
nibble=data4[i/2]&0xf;
|
||||
} else {
|
||||
nibble=data4[i/2]>>4;
|
||||
}
|
||||
data16[i]=(nibble<<12)^0x8000;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
@ -1542,11 +1549,16 @@ void DivSample::render(unsigned int formatMask) {
|
|||
}
|
||||
if (NOT_IN_FORMAT(DIV_SAMPLE_DEPTH_4BIT)) {
|
||||
if (!initInternal(DIV_SAMPLE_DEPTH_4BIT,samples)) return;
|
||||
for (unsigned int i=0; i<samples; i++) {
|
||||
data4[i]=(data16[i]>>12)&0xf;
|
||||
// if (i+1<samples) {
|
||||
// data4[i/2]|=(data16[i+1]>>12);
|
||||
// }
|
||||
unsigned char _sample=0, sample4=0;
|
||||
unsigned short* samplePtr = (unsigned short*)data16;
|
||||
for (unsigned int i=0; i<samples; i+=2) {
|
||||
_sample=(*samplePtr++^0x8000)>>12;
|
||||
sample4=_sample<<4;
|
||||
if (i+1<samples) {
|
||||
_sample=(*samplePtr++^0x8000)>>12;
|
||||
sample4|=_sample;
|
||||
}
|
||||
data4[i/2]=sample4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7010,6 +7010,7 @@ bool FurnaceGUI::loop() {
|
|||
ImGui::SameLine();
|
||||
ImGui::SetNextItemWidth(120.0f*dpiScale);
|
||||
if (ImGui::InputInt("##RSChans",&pendingRawSampleChannels,1,2)) {
|
||||
CLAMP_VAR(pendingRawSampleChannels, 1, 16)
|
||||
}
|
||||
ImGui::Text(_("(will be mixed down to mono)"));
|
||||
ImGui::Checkbox(_("Unsigned"),&pendingRawSampleUnsigned);
|
||||
|
@ -7023,7 +7024,8 @@ bool FurnaceGUI::loop() {
|
|||
pendingRawSampleDepth==DIV_SAMPLE_DEPTH_QSOUND_ADPCM ||
|
||||
pendingRawSampleDepth==DIV_SAMPLE_DEPTH_ADPCM_A ||
|
||||
pendingRawSampleDepth==DIV_SAMPLE_DEPTH_ADPCM_B ||
|
||||
pendingRawSampleDepth==DIV_SAMPLE_DEPTH_VOX) {
|
||||
pendingRawSampleDepth==DIV_SAMPLE_DEPTH_VOX ||
|
||||
pendingRawSampleDepth==DIV_SAMPLE_DEPTH_4BIT) {
|
||||
ImGui::Checkbox(_("Swap nibbles"),&pendingRawSampleSwapNibbles);
|
||||
}
|
||||
|
||||
|
|
|
@ -1917,7 +1917,18 @@ void FurnaceGUI::drawSampleEdit() {
|
|||
posX=samplePos+pos.x*sampleZoom;
|
||||
if (posX>(int)sample->samples) posX=-1;
|
||||
}
|
||||
posY=(0.5-pos.y/rectSize.y)*((sample->depth==DIV_SAMPLE_DEPTH_8BIT)?255:65535);
|
||||
switch (sample->depth) {
|
||||
case DIV_SAMPLE_DEPTH_8BIT:
|
||||
posY=(0.5-pos.y/rectSize.y)*255;
|
||||
break;
|
||||
case DIV_SAMPLE_DEPTH_4BIT:
|
||||
posY=(1-pos.y/rectSize.y)*15;
|
||||
break;
|
||||
default:
|
||||
posY=(0.5-pos.y/rectSize.y)*65535;
|
||||
break;
|
||||
}
|
||||
|
||||
if (posX>=0) {
|
||||
statusBar2=fmt::sprintf("(%d, %d)",posX,posY);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue