allow sample preview via keyboard
This commit is contained in:
parent
05bbfaced2
commit
46fd774f30
4 changed files with 53 additions and 3 deletions
|
|
@ -2868,7 +2868,7 @@ int DivEngine::getEffectiveSampleRate(int rate) {
|
|||
return rate;
|
||||
}
|
||||
|
||||
void DivEngine::previewSample(int sample) {
|
||||
void DivEngine::previewSample(int sample, int note) {
|
||||
isBusy.lock();
|
||||
if (sample<0 || sample>=(int)song.sample.size()) {
|
||||
sPreview.sample=-1;
|
||||
|
|
@ -2877,7 +2877,12 @@ void DivEngine::previewSample(int sample) {
|
|||
return;
|
||||
}
|
||||
blip_clear(samp_bb);
|
||||
blip_set_rates(samp_bb,song.sample[sample]->rate,got.rate);
|
||||
double rate=song.sample[sample]->rate;
|
||||
if (note>=0) {
|
||||
rate=(440.0*pow(2.0,(double)(note+3)/12.0));
|
||||
if (rate<=0) rate=song.sample[sample]->rate;
|
||||
}
|
||||
blip_set_rates(samp_bb,rate,got.rate);
|
||||
samp_prevSample=0;
|
||||
sPreview.pos=0;
|
||||
sPreview.sample=sample;
|
||||
|
|
@ -2885,6 +2890,13 @@ void DivEngine::previewSample(int sample) {
|
|||
isBusy.unlock();
|
||||
}
|
||||
|
||||
void DivEngine::stopSamplePreview() {
|
||||
isBusy.lock();
|
||||
sPreview.sample=-1;
|
||||
sPreview.pos=0;
|
||||
isBusy.unlock();
|
||||
}
|
||||
|
||||
void DivEngine::previewWave(int wave, int note) {
|
||||
isBusy.lock();
|
||||
if (wave<0 || wave>=(int)song.wave.size()) {
|
||||
|
|
@ -2907,8 +2919,10 @@ void DivEngine::previewWave(int wave, int note) {
|
|||
}
|
||||
|
||||
void DivEngine::stopWavePreview() {
|
||||
isBusy.lock();
|
||||
sPreview.wave=-1;
|
||||
sPreview.pos=0;
|
||||
isBusy.unlock();
|
||||
}
|
||||
|
||||
String DivEngine::getConfigPath() {
|
||||
|
|
|
|||
|
|
@ -263,7 +263,8 @@ class DivEngine {
|
|||
void syncReset();
|
||||
|
||||
// trigger sample preview
|
||||
void previewSample(int sample);
|
||||
void previewSample(int sample, int note=-1);
|
||||
void stopSamplePreview();
|
||||
|
||||
// trigger wave preview
|
||||
void previewWave(int wave, int note);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue