Implement sample loop end position, enum-ise sample depth (#557)
TODO: new sample format
This commit is contained in:
parent
a137eefd20
commit
5127d5ef18
29 changed files with 461 additions and 306 deletions
|
|
@ -709,6 +709,7 @@ void FurnaceGUI::doAction(int what) {
|
|||
sample->centerRate=prevSample->centerRate;
|
||||
sample->name=prevSample->name;
|
||||
sample->loopStart=prevSample->loopStart;
|
||||
sample->loopEnd=prevSample->loopEnd;
|
||||
sample->depth=prevSample->depth;
|
||||
if (sample->init(prevSample->samples)) {
|
||||
if (prevSample->getCurBuf()!=NULL) {
|
||||
|
|
@ -838,7 +839,7 @@ void FurnaceGUI::doAction(int what) {
|
|||
if (!sample->insert(pos,sampleClipboardLen)) {
|
||||
showError("couldn't paste! make sure your sample is 8 or 16-bit.");
|
||||
} else {
|
||||
if (sample->depth==8) {
|
||||
if (sample->depth==DIV_SAMPLE_DEPTH_8BIT) {
|
||||
for (size_t i=0; i<sampleClipboardLen; i++) {
|
||||
sample->data8[pos+i]=sampleClipboard[i]>>8;
|
||||
}
|
||||
|
|
@ -864,7 +865,7 @@ void FurnaceGUI::doAction(int what) {
|
|||
if (pos<0) pos=0;
|
||||
|
||||
e->lockEngine([this,sample,pos]() {
|
||||
if (sample->depth==8) {
|
||||
if (sample->depth==DIV_SAMPLE_DEPTH_8BIT) {
|
||||
for (size_t i=0; i<sampleClipboardLen; i++) {
|
||||
if (pos+i>=sample->samples) break;
|
||||
sample->data8[pos+i]=sampleClipboard[i]>>8;
|
||||
|
|
@ -894,7 +895,7 @@ void FurnaceGUI::doAction(int what) {
|
|||
if (pos<0) pos=0;
|
||||
|
||||
e->lockEngine([this,sample,pos]() {
|
||||
if (sample->depth==8) {
|
||||
if (sample->depth==DIV_SAMPLE_DEPTH_8BIT) {
|
||||
for (size_t i=0; i<sampleClipboardLen; i++) {
|
||||
if (pos+i>=sample->samples) break;
|
||||
int val=sample->data8[pos+i]+(sampleClipboard[i]>>8);
|
||||
|
|
@ -948,7 +949,7 @@ void FurnaceGUI::doAction(int what) {
|
|||
SAMPLE_OP_BEGIN;
|
||||
float maxVal=0.0f;
|
||||
|
||||
if (sample->depth==16) {
|
||||
if (sample->depth==DIV_SAMPLE_DEPTH_16BIT) {
|
||||
for (unsigned int i=start; i<end; i++) {
|
||||
float val=fabs((float)sample->data16[i]/32767.0f);
|
||||
if (val>maxVal) maxVal=val;
|
||||
|
|
@ -963,7 +964,7 @@ void FurnaceGUI::doAction(int what) {
|
|||
sample->data16[i]=val;
|
||||
}
|
||||
}
|
||||
} else if (sample->depth==8) {
|
||||
} else if (sample->depth==DIV_SAMPLE_DEPTH_8BIT) {
|
||||
for (unsigned int i=start; i<end; i++) {
|
||||
float val=fabs((float)sample->data8[i]/127.0f);
|
||||
if (val>maxVal) maxVal=val;
|
||||
|
|
@ -994,14 +995,14 @@ void FurnaceGUI::doAction(int what) {
|
|||
e->lockEngine([this,sample]() {
|
||||
SAMPLE_OP_BEGIN;
|
||||
|
||||
if (sample->depth==16) {
|
||||
if (sample->depth==DIV_SAMPLE_DEPTH_16BIT) {
|
||||
for (unsigned int i=start; i<end; i++) {
|
||||
float val=sample->data16[i]*float(i-start)/float(end-start);
|
||||
if (val<-32768) val=-32768;
|
||||
if (val>32767) val=32767;
|
||||
sample->data16[i]=val;
|
||||
}
|
||||
} else if (sample->depth==8) {
|
||||
} else if (sample->depth==DIV_SAMPLE_DEPTH_8BIT) {
|
||||
for (unsigned int i=start; i<end; i++) {
|
||||
float val=sample->data8[i]*float(i-start)/float(end-start);
|
||||
if (val<-128) val=-128;
|
||||
|
|
@ -1024,14 +1025,14 @@ void FurnaceGUI::doAction(int what) {
|
|||
e->lockEngine([this,sample]() {
|
||||
SAMPLE_OP_BEGIN;
|
||||
|
||||
if (sample->depth==16) {
|
||||
if (sample->depth==DIV_SAMPLE_DEPTH_16BIT) {
|
||||
for (unsigned int i=start; i<end; i++) {
|
||||
float val=sample->data16[i]*float(end-i)/float(end-start);
|
||||
if (val<-32768) val=-32768;
|
||||
if (val>32767) val=32767;
|
||||
sample->data16[i]=val;
|
||||
}
|
||||
} else if (sample->depth==8) {
|
||||
} else if (sample->depth==DIV_SAMPLE_DEPTH_8BIT) {
|
||||
for (unsigned int i=start; i<end; i++) {
|
||||
float val=sample->data8[i]*float(end-i)/float(end-start);
|
||||
if (val<-128) val=-128;
|
||||
|
|
@ -1058,11 +1059,11 @@ void FurnaceGUI::doAction(int what) {
|
|||
e->lockEngine([this,sample]() {
|
||||
SAMPLE_OP_BEGIN;
|
||||
|
||||
if (sample->depth==16) {
|
||||
if (sample->depth==DIV_SAMPLE_DEPTH_16BIT) {
|
||||
for (unsigned int i=start; i<end; i++) {
|
||||
sample->data16[i]=0;
|
||||
}
|
||||
} else if (sample->depth==8) {
|
||||
} else if (sample->depth==DIV_SAMPLE_DEPTH_8BIT) {
|
||||
for (unsigned int i=start; i<end; i++) {
|
||||
sample->data8[i]=0;
|
||||
}
|
||||
|
|
@ -1116,7 +1117,7 @@ void FurnaceGUI::doAction(int what) {
|
|||
e->lockEngine([this,sample]() {
|
||||
SAMPLE_OP_BEGIN;
|
||||
|
||||
if (sample->depth==16) {
|
||||
if (sample->depth==DIV_SAMPLE_DEPTH_16BIT) {
|
||||
for (unsigned int i=start; i<end; i++) {
|
||||
unsigned int ri=end-i-1+start;
|
||||
if (ri<=i) break;
|
||||
|
|
@ -1124,7 +1125,7 @@ void FurnaceGUI::doAction(int what) {
|
|||
sample->data16[ri]^=sample->data16[i];
|
||||
sample->data16[i]^=sample->data16[ri];
|
||||
}
|
||||
} else if (sample->depth==8) {
|
||||
} else if (sample->depth==DIV_SAMPLE_DEPTH_8BIT) {
|
||||
for (unsigned int i=start; i<end; i++) {
|
||||
unsigned int ri=end-i-1+start;
|
||||
if (ri<=i) break;
|
||||
|
|
@ -1148,12 +1149,12 @@ void FurnaceGUI::doAction(int what) {
|
|||
e->lockEngine([this,sample]() {
|
||||
SAMPLE_OP_BEGIN;
|
||||
|
||||
if (sample->depth==16) {
|
||||
if (sample->depth==DIV_SAMPLE_DEPTH_16BIT) {
|
||||
for (unsigned int i=start; i<end; i++) {
|
||||
sample->data16[i]=-sample->data16[i];
|
||||
if (sample->data16[i]==-32768) sample->data16[i]=32767;
|
||||
}
|
||||
} else if (sample->depth==8) {
|
||||
} else if (sample->depth==DIV_SAMPLE_DEPTH_8BIT) {
|
||||
for (unsigned int i=start; i<end; i++) {
|
||||
sample->data8[i]=-sample->data8[i];
|
||||
if (sample->data16[i]==-128) sample->data16[i]=127;
|
||||
|
|
@ -1174,11 +1175,11 @@ void FurnaceGUI::doAction(int what) {
|
|||
e->lockEngine([this,sample]() {
|
||||
SAMPLE_OP_BEGIN;
|
||||
|
||||
if (sample->depth==16) {
|
||||
if (sample->depth==DIV_SAMPLE_DEPTH_16BIT) {
|
||||
for (unsigned int i=start; i<end; i++) {
|
||||
sample->data16[i]^=0x8000;
|
||||
}
|
||||
} else if (sample->depth==8) {
|
||||
} else if (sample->depth==DIV_SAMPLE_DEPTH_8BIT) {
|
||||
for (unsigned int i=start; i<end; i++) {
|
||||
sample->data8[i]^=0x80;
|
||||
}
|
||||
|
|
@ -1261,8 +1262,8 @@ void FurnaceGUI::doAction(int what) {
|
|||
e->lockEngine([this,sample]() {
|
||||
SAMPLE_OP_BEGIN;
|
||||
|
||||
sample->trim(0,end);
|
||||
sample->loopStart=start;
|
||||
sample->loopEnd=end;
|
||||
updateSampleTex=true;
|
||||
|
||||
e->renderSamples();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue