GUI: prepare to improve note input timing
the idea is to snap to the closest Y position...
This commit is contained in:
parent
44605a42a5
commit
6deee95d87
|
@ -1254,54 +1254,62 @@ void FurnaceGUI::stopPreviewNote(SDL_Scancode scancode, bool autoNote) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FurnaceGUI::noteInput(int num, int key, int vol) {
|
void FurnaceGUI::noteInput(int num, int key, int vol) {
|
||||||
DivPattern* pat=e->curPat[cursor.xCoarse].getPattern(e->curOrders->ord[cursor.xCoarse][curOrder],true);
|
int ch=cursor.xCoarse;
|
||||||
|
int ord=curOrder;
|
||||||
|
int y=cursor.y;
|
||||||
|
|
||||||
|
if (e->isPlaying()) {
|
||||||
|
e->getPlayPos(ord,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
DivPattern* pat=e->curPat[ch].getPattern(e->curOrders->ord[ch][ord],true);
|
||||||
bool removeIns=false;
|
bool removeIns=false;
|
||||||
|
|
||||||
prepareUndo(GUI_UNDO_PATTERN_EDIT);
|
prepareUndo(GUI_UNDO_PATTERN_EDIT);
|
||||||
|
|
||||||
if (key==GUI_NOTE_OFF) { // note off
|
if (key==GUI_NOTE_OFF) { // note off
|
||||||
pat->data[cursor.y][0]=100;
|
pat->data[y][0]=100;
|
||||||
pat->data[cursor.y][1]=0;
|
pat->data[y][1]=0;
|
||||||
removeIns=true;
|
removeIns=true;
|
||||||
} else if (key==GUI_NOTE_OFF_RELEASE) { // note off + env release
|
} else if (key==GUI_NOTE_OFF_RELEASE) { // note off + env release
|
||||||
pat->data[cursor.y][0]=101;
|
pat->data[y][0]=101;
|
||||||
pat->data[cursor.y][1]=0;
|
pat->data[y][1]=0;
|
||||||
removeIns=true;
|
removeIns=true;
|
||||||
} else if (key==GUI_NOTE_RELEASE) { // env release only
|
} else if (key==GUI_NOTE_RELEASE) { // env release only
|
||||||
pat->data[cursor.y][0]=102;
|
pat->data[y][0]=102;
|
||||||
pat->data[cursor.y][1]=0;
|
pat->data[y][1]=0;
|
||||||
removeIns=true;
|
removeIns=true;
|
||||||
} else {
|
} else {
|
||||||
pat->data[cursor.y][0]=num%12;
|
pat->data[y][0]=num%12;
|
||||||
pat->data[cursor.y][1]=num/12;
|
pat->data[y][1]=num/12;
|
||||||
if (pat->data[cursor.y][0]==0) {
|
if (pat->data[y][0]==0) {
|
||||||
pat->data[cursor.y][0]=12;
|
pat->data[y][0]=12;
|
||||||
pat->data[cursor.y][1]--;
|
pat->data[y][1]--;
|
||||||
}
|
}
|
||||||
pat->data[cursor.y][1]=(unsigned char)pat->data[cursor.y][1];
|
pat->data[y][1]=(unsigned char)pat->data[y][1];
|
||||||
if (latchIns==-2) {
|
if (latchIns==-2) {
|
||||||
if (curIns>=(int)e->song.ins.size()) curIns=-1;
|
if (curIns>=(int)e->song.ins.size()) curIns=-1;
|
||||||
if (curIns>=0) {
|
if (curIns>=0) {
|
||||||
pat->data[cursor.y][2]=curIns;
|
pat->data[y][2]=curIns;
|
||||||
}
|
}
|
||||||
} else if (latchIns!=-1 && !e->song.ins.empty()) {
|
} else if (latchIns!=-1 && !e->song.ins.empty()) {
|
||||||
pat->data[cursor.y][2]=MIN(((int)e->song.ins.size())-1,latchIns);
|
pat->data[y][2]=MIN(((int)e->song.ins.size())-1,latchIns);
|
||||||
}
|
}
|
||||||
int maxVol=e->getMaxVolumeChan(cursor.xCoarse);
|
int maxVol=e->getMaxVolumeChan(ch);
|
||||||
if (latchVol!=-1) {
|
if (latchVol!=-1) {
|
||||||
pat->data[cursor.y][3]=MIN(maxVol,latchVol);
|
pat->data[y][3]=MIN(maxVol,latchVol);
|
||||||
} else if (vol!=-1) {
|
} else if (vol!=-1) {
|
||||||
pat->data[cursor.y][3]=e->mapVelocity(cursor.xCoarse,pow((float)vol/127.0f,midiMap.volExp));
|
pat->data[y][3]=e->mapVelocity(ch,pow((float)vol/127.0f,midiMap.volExp));
|
||||||
}
|
}
|
||||||
if (latchEffect!=-1) pat->data[cursor.y][4]=latchEffect;
|
if (latchEffect!=-1) pat->data[y][4]=latchEffect;
|
||||||
if (latchEffectVal!=-1) pat->data[cursor.y][5]=latchEffectVal;
|
if (latchEffectVal!=-1) pat->data[y][5]=latchEffectVal;
|
||||||
}
|
}
|
||||||
if (removeIns) {
|
if (removeIns) {
|
||||||
if (settings.removeInsOff) {
|
if (settings.removeInsOff) {
|
||||||
pat->data[cursor.y][2]=-1;
|
pat->data[y][2]=-1;
|
||||||
}
|
}
|
||||||
if (settings.removeVolOff) {
|
if (settings.removeVolOff) {
|
||||||
pat->data[cursor.y][3]=-1;
|
pat->data[y][3]=-1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
makeUndo(GUI_UNDO_PATTERN_EDIT);
|
makeUndo(GUI_UNDO_PATTERN_EDIT);
|
||||||
|
@ -1310,28 +1318,36 @@ void FurnaceGUI::noteInput(int num, int key, int vol) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FurnaceGUI::valueInput(int num, bool direct, int target) {
|
void FurnaceGUI::valueInput(int num, bool direct, int target) {
|
||||||
DivPattern* pat=e->curPat[cursor.xCoarse].getPattern(e->curOrders->ord[cursor.xCoarse][curOrder],true);
|
int ch=cursor.xCoarse;
|
||||||
|
int ord=curOrder;
|
||||||
|
int y=cursor.y;
|
||||||
|
|
||||||
|
if (e->isPlaying()) {
|
||||||
|
e->getPlayPos(ord,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
DivPattern* pat=e->curPat[ch].getPattern(e->curOrders->ord[ch][ord],true);
|
||||||
prepareUndo(GUI_UNDO_PATTERN_EDIT);
|
prepareUndo(GUI_UNDO_PATTERN_EDIT);
|
||||||
if (target==-1) target=cursor.xFine+1;
|
if (target==-1) target=cursor.xFine+1;
|
||||||
if (direct) {
|
if (direct) {
|
||||||
pat->data[cursor.y][target]=num&0xff;
|
pat->data[y][target]=num&0xff;
|
||||||
} else {
|
} else {
|
||||||
if (pat->data[cursor.y][target]==-1) pat->data[cursor.y][target]=0;
|
if (pat->data[y][target]==-1) pat->data[y][target]=0;
|
||||||
if (!settings.pushNibble && !curNibble) {
|
if (!settings.pushNibble && !curNibble) {
|
||||||
pat->data[cursor.y][target]=num;
|
pat->data[y][target]=num;
|
||||||
} else {
|
} else {
|
||||||
pat->data[cursor.y][target]=((pat->data[cursor.y][target]<<4)|num)&0xff;
|
pat->data[y][target]=((pat->data[y][target]<<4)|num)&0xff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cursor.xFine==1) { // instrument
|
if (cursor.xFine==1) { // instrument
|
||||||
if (pat->data[cursor.y][target]>=(int)e->song.ins.size()) {
|
if (pat->data[y][target]>=(int)e->song.ins.size()) {
|
||||||
pat->data[cursor.y][target]&=0x0f;
|
pat->data[y][target]&=0x0f;
|
||||||
if (pat->data[cursor.y][target]>=(int)e->song.ins.size()) {
|
if (pat->data[y][target]>=(int)e->song.ins.size()) {
|
||||||
pat->data[cursor.y][target]=(int)e->song.ins.size()-1;
|
pat->data[y][target]=(int)e->song.ins.size()-1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (settings.absorbInsInput) {
|
if (settings.absorbInsInput) {
|
||||||
curIns=pat->data[cursor.y][target];
|
curIns=pat->data[y][target];
|
||||||
wavePreviewInit=true;
|
wavePreviewInit=true;
|
||||||
updateFMPreview=true;
|
updateFMPreview=true;
|
||||||
}
|
}
|
||||||
|
@ -1349,17 +1365,17 @@ void FurnaceGUI::valueInput(int num, bool direct, int target) {
|
||||||
}
|
}
|
||||||
} else if (cursor.xFine==2) {
|
} else if (cursor.xFine==2) {
|
||||||
if (curNibble) {
|
if (curNibble) {
|
||||||
if (pat->data[cursor.y][target]>e->getMaxVolumeChan(cursor.xCoarse)) pat->data[cursor.y][target]=e->getMaxVolumeChan(cursor.xCoarse);
|
if (pat->data[y][target]>e->getMaxVolumeChan(ch)) pat->data[y][target]=e->getMaxVolumeChan(ch);
|
||||||
} else {
|
} else {
|
||||||
pat->data[cursor.y][target]&=15;
|
pat->data[y][target]&=15;
|
||||||
}
|
}
|
||||||
makeUndo(GUI_UNDO_PATTERN_EDIT);
|
makeUndo(GUI_UNDO_PATTERN_EDIT);
|
||||||
if (direct) {
|
if (direct) {
|
||||||
curNibble=false;
|
curNibble=false;
|
||||||
} else {
|
} else {
|
||||||
if (e->getMaxVolumeChan(cursor.xCoarse)<16) {
|
if (e->getMaxVolumeChan(ch)<16) {
|
||||||
curNibble=false;
|
curNibble=false;
|
||||||
if (pat->data[cursor.y][target]>e->getMaxVolumeChan(cursor.xCoarse)) pat->data[cursor.y][target]=e->getMaxVolumeChan(cursor.xCoarse);
|
if (pat->data[y][target]>e->getMaxVolumeChan(ch)) pat->data[y][target]=e->getMaxVolumeChan(ch);
|
||||||
editAdvance();
|
editAdvance();
|
||||||
} else {
|
} else {
|
||||||
curNibble=!curNibble;
|
curNibble=!curNibble;
|
||||||
|
@ -1377,7 +1393,7 @@ void FurnaceGUI::valueInput(int num, bool direct, int target) {
|
||||||
editAdvance();
|
editAdvance();
|
||||||
} else {
|
} else {
|
||||||
if (settings.effectCursorDir==2) {
|
if (settings.effectCursorDir==2) {
|
||||||
if (++cursor.xFine>=(3+(e->curPat[cursor.xCoarse].effectCols*2))) {
|
if (++cursor.xFine>=(3+(e->curPat[ch].effectCols*2))) {
|
||||||
cursor.xFine=3;
|
cursor.xFine=3;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue