mirror of
https://github.com/tildearrow/furnace.git
synced 2024-12-29 02:51:24 +00:00
GUI: add "create wave from selection" option
in sample editor
This commit is contained in:
parent
16eba9ec96
commit
a33e6e3989
4 changed files with 31 additions and 0 deletions
|
@ -1295,6 +1295,32 @@ void FurnaceGUI::doAction(int what) {
|
|||
MARK_MODIFIED;
|
||||
break;
|
||||
}
|
||||
case GUI_ACTION_SAMPLE_CREATE_WAVE: {
|
||||
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!");
|
||||
} else if (end-start>256) {
|
||||
showError("maximum size is 256 samples!");
|
||||
} else {
|
||||
curWave=e->addWave();
|
||||
if (curWave==-1) {
|
||||
showError("too many wavetables!");
|
||||
} else {
|
||||
DivWavetable* wave=e->song.wave[curWave];
|
||||
wave->min=0;
|
||||
wave->max=255;
|
||||
wave->len=end-start;
|
||||
for (unsigned int i=start; i<end; i++) {
|
||||
wave->data[i-start]=(sample->data8[i]&0xff)^0x80;
|
||||
}
|
||||
nextWindow=GUI_WINDOW_WAVE_EDIT;
|
||||
MARK_MODIFIED;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case GUI_ACTION_ORDERS_UP:
|
||||
if (curOrder>0) {
|
||||
|
|
|
@ -525,6 +525,7 @@ enum FurnaceGUIActions {
|
|||
GUI_ACTION_SAMPLE_ZOOM_AUTO,
|
||||
GUI_ACTION_SAMPLE_MAKE_INS,
|
||||
GUI_ACTION_SAMPLE_SET_LOOP,
|
||||
GUI_ACTION_SAMPLE_CREATE_WAVE,
|
||||
GUI_ACTION_SAMPLE_MAX,
|
||||
|
||||
GUI_ACTION_ORDERS_MIN,
|
||||
|
|
|
@ -641,6 +641,7 @@ const FurnaceGUIActionDef guiActions[GUI_ACTION_MAX]={
|
|||
D("SAMPLE_ZOOM_AUTO", "Toggle auto-zoom", FURKMOD_CMD|SDLK_0),
|
||||
D("SAMPLE_MAKE_INS", "Create instrument from sample", 0),
|
||||
D("SAMPLE_SET_LOOP", "Set loop to selection", FURKMOD_CMD|SDLK_l),
|
||||
D("SAMPLE_CREATE_WAVE", "Create wavetable from selection", FURKMOD_CMD|SDLK_w),
|
||||
D("SAMPLE_MAX", "", NOT_AN_ACTION),
|
||||
|
||||
D("ORDERS_MIN", "---Orders", NOT_AN_ACTION),
|
||||
|
|
|
@ -1293,6 +1293,9 @@ void FurnaceGUI::drawSampleEdit() {
|
|||
if (ImGui::MenuItem("set loop to selection",BIND_FOR(GUI_ACTION_SAMPLE_SET_LOOP))) {
|
||||
doAction(GUI_ACTION_SAMPLE_SET_LOOP);
|
||||
}
|
||||
if (ImGui::MenuItem("create wavetable from selection",BIND_FOR(GUI_ACTION_SAMPLE_CREATE_WAVE))) {
|
||||
doAction(GUI_ACTION_SAMPLE_CREATE_WAVE);
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue