GUI: sample editor preview in selection
This commit is contained in:
parent
957e35af0b
commit
84d4ca63c2
5 changed files with 28 additions and 11 deletions
|
|
@ -1471,8 +1471,10 @@ int DivEngine::getEffectiveSampleRate(int rate) {
|
|||
return rate;
|
||||
}
|
||||
|
||||
void DivEngine::previewSample(int sample, int note) {
|
||||
void DivEngine::previewSample(int sample, int note, int pStart, int pEnd) {
|
||||
BUSY_BEGIN;
|
||||
sPreview.pBegin=pStart;
|
||||
sPreview.pEnd=pEnd;
|
||||
if (sample<0 || sample>=(int)song.sample.size()) {
|
||||
sPreview.sample=-1;
|
||||
sPreview.pos=0;
|
||||
|
|
@ -1488,7 +1490,7 @@ void DivEngine::previewSample(int sample, int note) {
|
|||
if (rate<100) rate=100;
|
||||
blip_set_rates(samp_bb,rate,got.rate);
|
||||
samp_prevSample=0;
|
||||
sPreview.pos=0;
|
||||
sPreview.pos=(sPreview.pBegin>=0)?sPreview.pBegin:0;
|
||||
sPreview.sample=sample;
|
||||
sPreview.wave=-1;
|
||||
BUSY_END;
|
||||
|
|
|
|||
|
|
@ -339,10 +339,13 @@ class DivEngine {
|
|||
int sample;
|
||||
int wave;
|
||||
unsigned int pos;
|
||||
int pBegin, pEnd;
|
||||
SamplePreview():
|
||||
sample(-1),
|
||||
wave(-1),
|
||||
pos(0) {}
|
||||
pos(0),
|
||||
pBegin(-1),
|
||||
pEnd(-1) {}
|
||||
} sPreview;
|
||||
|
||||
short vibTable[64];
|
||||
|
|
@ -525,7 +528,7 @@ class DivEngine {
|
|||
void syncReset();
|
||||
|
||||
// trigger sample preview
|
||||
void previewSample(int sample, int note=-1);
|
||||
void previewSample(int sample, int note=-1, int pStart=-1, int pEnd=-1);
|
||||
void stopSamplePreview();
|
||||
|
||||
// trigger wave preview
|
||||
|
|
|
|||
|
|
@ -1159,7 +1159,7 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
|
|||
DivSample* s=song.sample[sPreview.sample];
|
||||
|
||||
for (size_t i=0; i<prevtotal; i++) {
|
||||
if (sPreview.pos>=s->samples) {
|
||||
if (sPreview.pos>=s->samples || (sPreview.pEnd>=0 && (int)sPreview.pos>=sPreview.pEnd)) {
|
||||
samp_temp=0;
|
||||
} else {
|
||||
samp_temp=s->data16[sPreview.pos++];
|
||||
|
|
@ -1167,15 +1167,15 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
|
|||
blip_add_delta(samp_bb,i,samp_temp-samp_prevSample);
|
||||
samp_prevSample=samp_temp;
|
||||
|
||||
if (sPreview.pos>=s->samples) {
|
||||
if (s->loopStart>=0 && s->loopStart<(int)s->samples) {
|
||||
if (sPreview.pos>=s->samples || (sPreview.pEnd>=0 && (int)sPreview.pos>=sPreview.pEnd)) {
|
||||
if (s->loopStart>=0 && s->loopStart<(int)s->samples && (int)sPreview.pos>=s->loopStart) {
|
||||
sPreview.pos=s->loopStart;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sPreview.pos>=s->samples) {
|
||||
if (s->loopStart>=0 && s->loopStart<(int)s->samples) {
|
||||
if (sPreview.pos>=s->samples || (sPreview.pEnd>=0 && (int)sPreview.pos>=sPreview.pEnd)) {
|
||||
if (s->loopStart>=0 && s->loopStart<(int)s->samples && (int)sPreview.pos>=s->loopStart) {
|
||||
sPreview.pos=s->loopStart;
|
||||
} else {
|
||||
sPreview.sample=-1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue