add "copy to new sample" action
This commit is contained in:
parent
21373b42bb
commit
0b673f8419
4 changed files with 54 additions and 0 deletions
|
|
@ -1796,6 +1796,55 @@ void FurnaceGUI::doAction(int what) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case GUI_ACTION_SAMPLE_MOVE_NEW: {
|
||||
if (curSample<0 || curSample>=(int)e->song.sample.size()) break;
|
||||
DivSample* sample=e->song.sample[curSample];
|
||||
SAMPLE_OP_BEGIN;
|
||||
if (end-start<1) {
|
||||
showError(_("select at least one sample!"));
|
||||
break;
|
||||
}
|
||||
|
||||
curSample=e->addSample();
|
||||
if (curSample==-1) {
|
||||
showError(_("too many samples!"));
|
||||
break;
|
||||
}
|
||||
|
||||
DivSample* prevSample=sample;
|
||||
e->lockEngine([this,prevSample,start,end]() {
|
||||
DivSample* sample=e->getSample(curSample);
|
||||
if (sample!=NULL) {
|
||||
int length=end-start;
|
||||
sample->centerRate=prevSample->centerRate;
|
||||
sample->name=prevSample->name;
|
||||
sample->loopStart=prevSample->loopStart;
|
||||
sample->loopEnd=prevSample->loopEnd;
|
||||
sample->loop=prevSample->loop;
|
||||
sample->loopMode=prevSample->loopMode;
|
||||
sample->brrEmphasis=prevSample->brrEmphasis;
|
||||
sample->brrNoFilter=prevSample->brrNoFilter;
|
||||
sample->dither=prevSample->dither;
|
||||
sample->depth=prevSample->depth;
|
||||
if (sample->init(length)) {
|
||||
if (prevSample->getCurBuf()!=NULL) {
|
||||
int offS=prevSample->getSampleOffset(start,0,sample->depth);
|
||||
int offE=prevSample->getSampleOffset(end,0,sample->depth);
|
||||
uint8_t *srcMem=(uint8_t*)prevSample->getCurBuf();
|
||||
memcpy(sample->getCurBuf(),&srcMem[offS],offE-offS);
|
||||
}
|
||||
}
|
||||
}
|
||||
e->renderSamples();
|
||||
});
|
||||
|
||||
// TODO: confirm these
|
||||
wantScrollListSample=true;
|
||||
MARK_MODIFIED;
|
||||
updateSampleTex=true;
|
||||
notifySampleChange=true;
|
||||
break;
|
||||
}
|
||||
|
||||
case GUI_ACTION_ORDERS_UP:
|
||||
if (curOrder>0) {
|
||||
|
|
|
|||
|
|
@ -962,6 +962,7 @@ enum FurnaceGUIActions {
|
|||
GUI_ACTION_SAMPLE_MAKE_INS,
|
||||
GUI_ACTION_SAMPLE_SET_LOOP,
|
||||
GUI_ACTION_SAMPLE_CREATE_WAVE,
|
||||
GUI_ACTION_SAMPLE_COPY_NEW,
|
||||
GUI_ACTION_SAMPLE_MAX,
|
||||
|
||||
GUI_ACTION_ORDERS_MIN,
|
||||
|
|
|
|||
|
|
@ -845,6 +845,7 @@ const FurnaceGUIActionDef guiActions[GUI_ACTION_MAX]={
|
|||
D("SAMPLE_MAKE_INS", _N("Sample editor: Create instrument from sample"), 0),
|
||||
D("SAMPLE_SET_LOOP", _N("Sample editor: Set loop to selection"), FURKMOD_CMD|SDLK_l),
|
||||
D("SAMPLE_CREATE_WAVE", _N("Sample editor: Create wavetable from selection"), FURKMOD_CMD|SDLK_w),
|
||||
D("SAMPLE_COPY_NEW", _N("Sample editor: Copy selection to new sample"), 0),
|
||||
D("SAMPLE_MAX", "", NOT_AN_ACTION),
|
||||
|
||||
D("ORDERS_MIN", _N("---Orders"), NOT_AN_ACTION),
|
||||
|
|
|
|||
|
|
@ -2013,6 +2013,9 @@ void FurnaceGUI::drawSampleEdit() {
|
|||
if (ImGui::MenuItem(_("create wavetable from selection"),BIND_FOR(GUI_ACTION_SAMPLE_CREATE_WAVE))) {
|
||||
doAction(GUI_ACTION_SAMPLE_CREATE_WAVE);
|
||||
}
|
||||
if (ImGui::MenuItem(_("copy selection to new sample"),BIND_FOR(GUI_ACTION_SAMPLE_MOVE_NEW))) {
|
||||
doAction(GUI_ACTION_SAMPLE_MOVE_NEW);
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue