MIDI input: wave and sample preview
This commit is contained in:
parent
0f14b905fe
commit
63bb5aac6b
|
@ -2436,6 +2436,29 @@ int DivEngine::getEffectiveSampleRate(int rate) {
|
||||||
|
|
||||||
void DivEngine::previewSample(int sample, int note, int pStart, int pEnd) {
|
void DivEngine::previewSample(int sample, int note, int pStart, int pEnd) {
|
||||||
BUSY_BEGIN;
|
BUSY_BEGIN;
|
||||||
|
previewSampleNoLock(sample,note,pStart,pEnd);
|
||||||
|
BUSY_END;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivEngine::stopSamplePreview() {
|
||||||
|
BUSY_BEGIN;
|
||||||
|
stopSamplePreviewNoLock();
|
||||||
|
BUSY_END;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivEngine::previewWave(int wave, int note) {
|
||||||
|
BUSY_BEGIN;
|
||||||
|
previewWaveNoLock(wave,note);
|
||||||
|
BUSY_END;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivEngine::stopWavePreview() {
|
||||||
|
BUSY_BEGIN;
|
||||||
|
stopWavePreviewNoLock();
|
||||||
|
BUSY_END;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivEngine::previewSampleNoLock(int sample, int note, int pStart, int pEnd) {
|
||||||
sPreview.pBegin=pStart;
|
sPreview.pBegin=pStart;
|
||||||
sPreview.pEnd=pEnd;
|
sPreview.pEnd=pEnd;
|
||||||
sPreview.dir=false;
|
sPreview.dir=false;
|
||||||
|
@ -2443,7 +2466,6 @@ void DivEngine::previewSample(int sample, int note, int pStart, int pEnd) {
|
||||||
sPreview.sample=-1;
|
sPreview.sample=-1;
|
||||||
sPreview.pos=0;
|
sPreview.pos=0;
|
||||||
sPreview.dir=false;
|
sPreview.dir=false;
|
||||||
BUSY_END;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
blip_clear(samp_bb);
|
blip_clear(samp_bb);
|
||||||
|
@ -2460,28 +2482,22 @@ void DivEngine::previewSample(int sample, int note, int pStart, int pEnd) {
|
||||||
sPreview.sample=sample;
|
sPreview.sample=sample;
|
||||||
sPreview.wave=-1;
|
sPreview.wave=-1;
|
||||||
sPreview.dir=false;
|
sPreview.dir=false;
|
||||||
BUSY_END;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivEngine::stopSamplePreview() {
|
void DivEngine::stopSamplePreviewNoLock() {
|
||||||
BUSY_BEGIN;
|
|
||||||
sPreview.sample=-1;
|
sPreview.sample=-1;
|
||||||
sPreview.pos=0;
|
sPreview.pos=0;
|
||||||
sPreview.dir=false;
|
sPreview.dir=false;
|
||||||
BUSY_END;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivEngine::previewWave(int wave, int note) {
|
void DivEngine::previewWaveNoLock(int wave, int note) {
|
||||||
BUSY_BEGIN;
|
|
||||||
if (wave<0 || wave>=(int)song.wave.size()) {
|
if (wave<0 || wave>=(int)song.wave.size()) {
|
||||||
sPreview.wave=-1;
|
sPreview.wave=-1;
|
||||||
sPreview.pos=0;
|
sPreview.pos=0;
|
||||||
sPreview.dir=false;
|
sPreview.dir=false;
|
||||||
BUSY_END;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (song.wave[wave]->len<=0) {
|
if (song.wave[wave]->len<=0) {
|
||||||
BUSY_END;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
blip_clear(samp_bb);
|
blip_clear(samp_bb);
|
||||||
|
@ -2494,15 +2510,12 @@ void DivEngine::previewWave(int wave, int note) {
|
||||||
sPreview.sample=-1;
|
sPreview.sample=-1;
|
||||||
sPreview.wave=wave;
|
sPreview.wave=wave;
|
||||||
sPreview.dir=false;
|
sPreview.dir=false;
|
||||||
BUSY_END;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivEngine::stopWavePreview() {
|
void DivEngine::stopWavePreviewNoLock() {
|
||||||
BUSY_BEGIN;
|
|
||||||
sPreview.wave=-1;
|
sPreview.wave=-1;
|
||||||
sPreview.pos=0;
|
sPreview.pos=0;
|
||||||
sPreview.dir=false;
|
sPreview.dir=false;
|
||||||
BUSY_END;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DivEngine::isPreviewingSample() {
|
bool DivEngine::isPreviewingSample() {
|
||||||
|
|
|
@ -616,6 +616,14 @@ class DivEngine {
|
||||||
void previewWave(int wave, int note);
|
void previewWave(int wave, int note);
|
||||||
void stopWavePreview();
|
void stopWavePreview();
|
||||||
|
|
||||||
|
// trigger sample preview
|
||||||
|
void previewSampleNoLock(int sample, int note=-1, int pStart=-1, int pEnd=-1);
|
||||||
|
void stopSamplePreviewNoLock();
|
||||||
|
|
||||||
|
// trigger wave preview
|
||||||
|
void previewWaveNoLock(int wave, int note);
|
||||||
|
void stopWavePreviewNoLock();
|
||||||
|
|
||||||
// get config path
|
// get config path
|
||||||
String getConfigPath();
|
String getConfigPath();
|
||||||
|
|
||||||
|
|
|
@ -4936,6 +4936,8 @@ bool FurnaceGUI::loop() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
curWindowThreadSafe=curWindow;
|
||||||
|
|
||||||
SDL_SetRenderDrawColor(sdlRend,uiColors[GUI_COLOR_BACKGROUND].x*255,
|
SDL_SetRenderDrawColor(sdlRend,uiColors[GUI_COLOR_BACKGROUND].x*255,
|
||||||
uiColors[GUI_COLOR_BACKGROUND].y*255,
|
uiColors[GUI_COLOR_BACKGROUND].y*255,
|
||||||
uiColors[GUI_COLOR_BACKGROUND].z*255,
|
uiColors[GUI_COLOR_BACKGROUND].z*255,
|
||||||
|
@ -5300,6 +5302,31 @@ bool FurnaceGUI::init() {
|
||||||
if (!midiMap.noteInput) return -2;
|
if (!midiMap.noteInput) return -2;
|
||||||
if (learning!=-1) return -2;
|
if (learning!=-1) return -2;
|
||||||
if (midiMap.at(msg)) return -2;
|
if (midiMap.at(msg)) return -2;
|
||||||
|
|
||||||
|
if (curWindowThreadSafe==GUI_WINDOW_WAVE_EDIT || curWindowThreadSafe==GUI_WINDOW_WAVE_LIST) {
|
||||||
|
if ((msg.type&0xf0)==TA_MIDI_NOTE_ON) {
|
||||||
|
e->previewWaveNoLock(curWave,msg.data[0]-12);
|
||||||
|
wavePreviewNote=msg.data[0]-12;
|
||||||
|
} else if ((msg.type&0xf0)==TA_MIDI_NOTE_OFF) {
|
||||||
|
if (wavePreviewNote==msg.data[0]-12) {
|
||||||
|
e->stopWavePreviewNoLock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (curWindowThreadSafe==GUI_WINDOW_SAMPLE_EDIT || curWindowThreadSafe==GUI_WINDOW_SAMPLE_LIST) {
|
||||||
|
if ((msg.type&0xf0)==TA_MIDI_NOTE_ON) {
|
||||||
|
e->previewSampleNoLock(curSample,msg.data[0]-12);
|
||||||
|
samplePreviewNote=msg.data[0]-12;
|
||||||
|
} else if ((msg.type&0xf0)==TA_MIDI_NOTE_OFF) {
|
||||||
|
if (samplePreviewNote==msg.data[0]-12) {
|
||||||
|
e->stopSamplePreviewNoLock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
return curIns;
|
return curIns;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -5602,6 +5629,7 @@ FurnaceGUI::FurnaceGUI():
|
||||||
curWindow(GUI_WINDOW_NOTHING),
|
curWindow(GUI_WINDOW_NOTHING),
|
||||||
nextWindow(GUI_WINDOW_NOTHING),
|
nextWindow(GUI_WINDOW_NOTHING),
|
||||||
curWindowLast(GUI_WINDOW_NOTHING),
|
curWindowLast(GUI_WINDOW_NOTHING),
|
||||||
|
curWindowThreadSafe(GUI_WINDOW_NOTHING),
|
||||||
lastPatternWidth(0.0f),
|
lastPatternWidth(0.0f),
|
||||||
nextDesc(NULL),
|
nextDesc(NULL),
|
||||||
latchNote(-1),
|
latchNote(-1),
|
||||||
|
|
|
@ -1382,6 +1382,7 @@ class FurnaceGUI {
|
||||||
bool collapseWindow, demandScrollX, fancyPattern, wantPatName, firstFrame, tempoView, waveHex, waveSigned, waveGenVisible, lockLayout, editOptsVisible, latchNibble, nonLatchNibble;
|
bool collapseWindow, demandScrollX, fancyPattern, wantPatName, firstFrame, tempoView, waveHex, waveSigned, waveGenVisible, lockLayout, editOptsVisible, latchNibble, nonLatchNibble;
|
||||||
bool keepLoopAlive;
|
bool keepLoopAlive;
|
||||||
FurnaceGUIWindows curWindow, nextWindow, curWindowLast;
|
FurnaceGUIWindows curWindow, nextWindow, curWindowLast;
|
||||||
|
std::atomic<FurnaceGUIWindows> curWindowThreadSafe;
|
||||||
float peak[2];
|
float peak[2];
|
||||||
float patChanX[DIV_MAX_CHANS+1];
|
float patChanX[DIV_MAX_CHANS+1];
|
||||||
float patChanSlideY[DIV_MAX_CHANS+1];
|
float patChanSlideY[DIV_MAX_CHANS+1];
|
||||||
|
|
Loading…
Reference in a new issue