music editor keybaord
This commit is contained in:
parent
16e8a5a9aa
commit
d3c1276271
512
src/music.c
512
src/music.c
|
@ -738,257 +738,253 @@ static void updateSelection(Music* music)
|
||||||
resetSelection(music);
|
resetSelection(music);
|
||||||
}
|
}
|
||||||
|
|
||||||
// static void processTrackerKeydown(Music* music, SDL_Keysym* keysum)
|
static void processTrackerKeyboard(Music* music)
|
||||||
// {
|
{
|
||||||
// tic_keycode keycode = keysum->sym;
|
tic_mem* tic = music->tic;
|
||||||
// SDL_Scancode scancode = keysum->scancode;
|
|
||||||
|
|
||||||
// bool shift = SDL_GetModState() & KMOD_SHIFT;
|
if(tic->ram.input.keyboard.data == 0)
|
||||||
|
{
|
||||||
|
music->tracker.note = -1;
|
||||||
|
s32 channel = music->tracker.col / CHANNEL_COLS;
|
||||||
|
music->tic->api.sfx_stop(music->tic, channel);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// if(shift)
|
bool shift = tic->api.key(tic, tic_key_shift);
|
||||||
// {
|
|
||||||
// switch (keycode)
|
|
||||||
// {
|
|
||||||
// case SDLK_UP:
|
|
||||||
// case SDLK_DOWN:
|
|
||||||
// case SDLK_LEFT:
|
|
||||||
// case SDLK_RIGHT:
|
|
||||||
// case SDLK_HOME:
|
|
||||||
// case SDLK_END:
|
|
||||||
// case SDLK_PAGEUP:
|
|
||||||
// case SDLK_PAGEDOWN:
|
|
||||||
// case SDLK_TAB:
|
|
||||||
// checkSelection(music);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// switch (keycode)
|
if(shift)
|
||||||
// {
|
{
|
||||||
// case SDLK_UP: upRow(music); break;
|
if(isKeyBeenPressed(tic_key_up)
|
||||||
// case SDLK_DOWN: downRow(music); break;
|
|| isKeyBeenPressed(tic_key_down)
|
||||||
// case SDLK_LEFT: leftCol(music); break;
|
|| isKeyBeenPressed(tic_key_left)
|
||||||
// case SDLK_RIGHT: rightCol(music); break;
|
|| isKeyBeenPressed(tic_key_right)
|
||||||
// case SDLK_HOME: goHome(music); break;
|
|| isKeyBeenPressed(tic_key_home)
|
||||||
// case SDLK_END: goEnd(music); break;
|
|| isKeyBeenPressed(tic_key_end)
|
||||||
// case SDLK_PAGEUP: pageUp(music); break;
|
|| isKeyBeenPressed(tic_key_pageup)
|
||||||
// case SDLK_PAGEDOWN: pageDown(music); break;
|
|| isKeyBeenPressed(tic_key_pagedown)
|
||||||
// case SDLK_TAB: doTab(music); break;
|
|| isKeyBeenPressed(tic_key_tab))
|
||||||
// case SDLK_DELETE:
|
{
|
||||||
// deleteSelection(music);
|
checkSelection(music);
|
||||||
// history_add(music->history);
|
}
|
||||||
// downRow(music);
|
}
|
||||||
// break;
|
|
||||||
// case SDLK_SPACE: playNote(music); break;
|
|
||||||
// case SDLK_RETURN:
|
|
||||||
// case SDLK_KP_ENTER:
|
|
||||||
// {
|
|
||||||
// const tic_music_pos* pos = getMusicPos(music);
|
|
||||||
// pos->track < 0
|
|
||||||
// ? (shift ? playFrameRow(music) : playFrame(music))
|
|
||||||
// : stopTrack(music);
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if(shift)
|
if(isKeyBeenPressed(tic_key_up)) upRow(music);
|
||||||
// {
|
else if(isKeyBeenPressed(tic_key_down)) downRow(music);
|
||||||
// switch (keycode)
|
else if(isKeyBeenPressed(tic_key_left)) leftCol(music);
|
||||||
// {
|
else if(isKeyBeenPressed(tic_key_right)) rightCol(music);
|
||||||
// case SDLK_UP:
|
else if(isKeyBeenPressed(tic_key_home)) goHome(music);
|
||||||
// case SDLK_DOWN:
|
else if(isKeyBeenPressed(tic_key_end)) goEnd(music);
|
||||||
// case SDLK_LEFT:
|
else if(isKeyBeenPressed(tic_key_pageup)) pageUp(music);
|
||||||
// case SDLK_RIGHT:
|
else if(isKeyBeenPressed(tic_key_pagedown)) pageDown(music);
|
||||||
// case SDLK_HOME:
|
else if(isKeyBeenPressed(tic_key_tab)) doTab(music);
|
||||||
// case SDLK_END:
|
else if(isKeyBeenPressed(tic_key_delete))
|
||||||
// case SDLK_PAGEUP:
|
{
|
||||||
// case SDLK_PAGEDOWN:
|
deleteSelection(music);
|
||||||
// case SDLK_TAB:
|
history_add(music->history);
|
||||||
// updateSelection(music);
|
downRow(music);
|
||||||
// }
|
}
|
||||||
// }
|
else if(isKeyBeenPressed(tic_key_space)) playNote(music);
|
||||||
// else resetSelection(music);
|
else if(isKeyBeenPressed(tic_key_return))
|
||||||
|
{
|
||||||
|
const tic_music_pos* pos = getMusicPos(music);
|
||||||
|
pos->track < 0
|
||||||
|
? (shift ? playFrameRow(music) : playFrame(music))
|
||||||
|
: stopTrack(music);
|
||||||
|
}
|
||||||
|
|
||||||
// static const SDL_Scancode Piano[] =
|
if(shift)
|
||||||
// {
|
{
|
||||||
// SDL_SCANCODE_Z,
|
if(isKeyBeenPressed(tic_key_up)
|
||||||
// SDL_SCANCODE_S,
|
|| isKeyBeenPressed(tic_key_down)
|
||||||
// SDL_SCANCODE_X,
|
|| isKeyBeenPressed(tic_key_left)
|
||||||
// SDL_SCANCODE_D,
|
|| isKeyBeenPressed(tic_key_right)
|
||||||
// SDL_SCANCODE_C,
|
|| isKeyBeenPressed(tic_key_home)
|
||||||
// SDL_SCANCODE_V,
|
|| isKeyBeenPressed(tic_key_end)
|
||||||
// SDL_SCANCODE_G,
|
|| isKeyBeenPressed(tic_key_pageup)
|
||||||
// SDL_SCANCODE_B,
|
|| isKeyBeenPressed(tic_key_pagedown)
|
||||||
// SDL_SCANCODE_H,
|
|| isKeyBeenPressed(tic_key_tab))
|
||||||
// SDL_SCANCODE_N,
|
{
|
||||||
// SDL_SCANCODE_J,
|
updateSelection(music);
|
||||||
// SDL_SCANCODE_M,
|
}
|
||||||
|
}
|
||||||
|
else resetSelection(music);
|
||||||
|
|
||||||
// // octave +1
|
static const tic_keycode Piano[] =
|
||||||
// SDL_SCANCODE_Q,
|
{
|
||||||
// SDL_SCANCODE_2,
|
tic_key_z,
|
||||||
// SDL_SCANCODE_W,
|
tic_key_s,
|
||||||
// SDL_SCANCODE_3,
|
tic_key_x,
|
||||||
// SDL_SCANCODE_E,
|
tic_key_d,
|
||||||
// SDL_SCANCODE_R,
|
tic_key_c,
|
||||||
// SDL_SCANCODE_5,
|
tic_key_v,
|
||||||
// SDL_SCANCODE_T,
|
tic_key_g,
|
||||||
// SDL_SCANCODE_6,
|
tic_key_b,
|
||||||
// SDL_SCANCODE_Y,
|
tic_key_h,
|
||||||
// SDL_SCANCODE_7,
|
tic_key_n,
|
||||||
// SDL_SCANCODE_U,
|
tic_key_j,
|
||||||
// };
|
tic_key_m,
|
||||||
|
|
||||||
// if (getChannelPattern(music))
|
// octave +1
|
||||||
// {
|
tic_key_q,
|
||||||
// s32 col = music->tracker.col % CHANNEL_COLS;
|
tic_key_2,
|
||||||
|
tic_key_w,
|
||||||
|
tic_key_3,
|
||||||
|
tic_key_e,
|
||||||
|
tic_key_r,
|
||||||
|
tic_key_5,
|
||||||
|
tic_key_t,
|
||||||
|
tic_key_6,
|
||||||
|
tic_key_y,
|
||||||
|
tic_key_7,
|
||||||
|
tic_key_u,
|
||||||
|
};
|
||||||
|
|
||||||
// switch (col)
|
if (getChannelPattern(music))
|
||||||
// {
|
{
|
||||||
// case ColumnNote:
|
s32 col = music->tracker.col % CHANNEL_COLS;
|
||||||
// case ColumnSemitone:
|
|
||||||
// if (scancode == SDL_SCANCODE_1 || scancode == SDL_SCANCODE_A)
|
|
||||||
// {
|
|
||||||
// setStopNote(music);
|
|
||||||
// downRow(music);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// tic_track_pattern* pattern = getChannelPattern(music);
|
|
||||||
|
|
||||||
// for (s32 i = 0; i < COUNT_OF(Piano); i++)
|
switch (col)
|
||||||
// {
|
{
|
||||||
// if (scancode == Piano[i])
|
case ColumnNote:
|
||||||
// {
|
case ColumnSemitone:
|
||||||
// s32 note = i % NOTES;
|
if (isKeyBeenPressed(tic_key_1) || isKeyBeenPressed(tic_key_a))
|
||||||
|
{
|
||||||
|
setStopNote(music);
|
||||||
|
downRow(music);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tic_track_pattern* pattern = getChannelPattern(music);
|
||||||
|
|
||||||
// if(pattern->rows[music->tracker.row].note > NoteNone)
|
for (s32 i = 0; i < COUNT_OF(Piano); i++)
|
||||||
// {
|
{
|
||||||
// pattern->rows[music->tracker.row].note = note + NoteStart;
|
if (isKeyBeenPressed(Piano[i]))
|
||||||
// playNote(music);
|
{
|
||||||
// }
|
s32 note = i % NOTES;
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// s32 octave = i / NOTES + music->tracker.last.octave;
|
|
||||||
// s32 volume = music->tracker.last.volume;
|
|
||||||
// s32 sfx = music->tracker.last.sfx;
|
|
||||||
// setNote(music, note, octave, volume, sfx);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// downRow(music);
|
if(pattern->rows[music->tracker.row].note > NoteNone)
|
||||||
|
{
|
||||||
|
pattern->rows[music->tracker.row].note = note + NoteStart;
|
||||||
|
playNote(music);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
s32 octave = i / NOTES + music->tracker.last.octave;
|
||||||
|
s32 volume = music->tracker.last.volume;
|
||||||
|
s32 sfx = music->tracker.last.sfx;
|
||||||
|
setNote(music, note, octave, volume, sfx);
|
||||||
|
}
|
||||||
|
|
||||||
// break;
|
downRow(music);
|
||||||
// }
|
|
||||||
|
|
||||||
// }
|
break;
|
||||||
// }
|
}
|
||||||
// break;
|
}
|
||||||
// case ColumnOctave:
|
}
|
||||||
// if(getNote(music) >= 0)
|
break;
|
||||||
// {
|
case ColumnOctave:
|
||||||
// s32 octave = -1;
|
if(getNote(music) >= 0)
|
||||||
// if (keycode >= SDLK_1 && keycode <= SDLK_8) octave = keycode - SDLK_1;
|
{
|
||||||
// if (keycode >= SDLK_KP_1 && keycode <= SDLK_KP_8) octave = keycode - SDLK_KP_1;
|
s32 octave = -1;
|
||||||
|
|
||||||
// if(octave >= 0)
|
char sym = getKeyboardText();
|
||||||
// {
|
|
||||||
// setOctave(music, octave);
|
|
||||||
// downRow(music);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
// case ColumnSfxHi:
|
|
||||||
// case ColumnSfxLow:
|
|
||||||
// if(getNote(music) >= 0)
|
|
||||||
// {
|
|
||||||
// s32 val = -1;
|
|
||||||
|
|
||||||
// if (keycode >= SDLK_0 && keycode <= SDLK_9) val = keycode - SDLK_0;
|
if(sym >= '1' && sym <= '8') octave = sym - '1';
|
||||||
// if (keycode >= SDLK_KP_1 && keycode <= SDLK_KP_9) val = keycode - SDLK_KP_1 + 1;
|
|
||||||
// if (keycode == SDLK_KP_0) val = 0;
|
|
||||||
|
|
||||||
// if(val >= 0)
|
if(octave >= 0)
|
||||||
// {
|
{
|
||||||
// enum {Base = 10};
|
setOctave(music, octave);
|
||||||
// s32 sfx = getSfx(music);
|
downRow(music);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ColumnSfxHi:
|
||||||
|
case ColumnSfxLow:
|
||||||
|
if(getNote(music) >= 0)
|
||||||
|
{
|
||||||
|
s32 val = -1;
|
||||||
|
|
||||||
// sfx = col == 3
|
char sym = getKeyboardText();
|
||||||
// ? val * Base + sfx % Base
|
|
||||||
// : sfx / Base * Base + val % Base;
|
|
||||||
|
|
||||||
// setSfx(music, sfx);
|
if (sym >= '0' && sym <= '9') val = sym - '0';
|
||||||
|
|
||||||
// if(col == 3) rightCol(music);
|
if(val >= 0)
|
||||||
// else downRow(music), leftCol(music);
|
{
|
||||||
// }
|
enum {Base = 10};
|
||||||
// }
|
s32 sfx = getSfx(music);
|
||||||
// break;
|
|
||||||
// case ColumnVolume:
|
|
||||||
// if (getNote(music) >= 0)
|
|
||||||
// {
|
|
||||||
// s32 val = -1;
|
|
||||||
|
|
||||||
// if(keycode >= SDLK_0 && keycode <= SDLK_9) val = keycode - SDLK_0;
|
sfx = col == 3
|
||||||
// if(keycode >= SDLK_a && keycode <= SDLK_f) val = keycode - SDLK_a + 10;
|
? val * Base + sfx % Base
|
||||||
// if(keycode >= SDLK_KP_1 && keycode <= SDLK_KP_9) val = keycode - SDLK_KP_1 + 1;
|
: sfx / Base * Base + val % Base;
|
||||||
// if(keycode == SDLK_KP_0) val = 0;
|
|
||||||
|
|
||||||
// if(val >= 0)
|
setSfx(music, sfx);
|
||||||
// {
|
|
||||||
// setVolume(music, MAX_VOLUME - val);
|
|
||||||
// downRow(music);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// history_add(music->history);
|
if(col == 3) rightCol(music);
|
||||||
// }
|
else downRow(music), leftCol(music);
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ColumnVolume:
|
||||||
|
if (getNote(music) >= 0)
|
||||||
|
{
|
||||||
|
s32 val = -1;
|
||||||
|
|
||||||
// static void processPatternKeydown(Music* music, SDL_Keysym* keysum)
|
char sym = getKeyboardText();
|
||||||
// {
|
|
||||||
// tic_keycode keycode = keysum->sym;
|
|
||||||
|
|
||||||
// s32 channel = music->tracker.col / CHANNEL_COLS;
|
if(sym >= '0' && sym <= '9') val = sym - '0';
|
||||||
|
if(sym >= 'a' && sym <= 'f') val = sym - 'a' + 10;
|
||||||
|
|
||||||
// switch (keycode)
|
if(val >= 0)
|
||||||
// {
|
{
|
||||||
// case SDLK_DELETE: setChannelPatternValue(music, 0, channel); break;
|
setVolume(music, MAX_VOLUME - val);
|
||||||
// case SDLK_TAB: nextPattern(music); break;
|
downRow(music);
|
||||||
// case SDLK_DOWN:
|
}
|
||||||
// case SDLK_KP_ENTER:
|
}
|
||||||
// case SDLK_RETURN: music->tracker.row = music->tracker.scroll; break;
|
break;
|
||||||
// case SDLK_LEFT: patternColLeft(music); break;
|
}
|
||||||
// case SDLK_RIGHT: patternColRight(music); break;
|
|
||||||
// default:
|
|
||||||
// {
|
|
||||||
// s32 val = -1;
|
|
||||||
|
|
||||||
// if(keycode >= SDLK_0 && keycode <= SDLK_9) val = keycode - SDLK_0;
|
history_add(music->history);
|
||||||
// if(keycode >= SDLK_KP_1 && keycode <= SDLK_KP_9) val = keycode - SDLK_KP_1 + 1;
|
}
|
||||||
// if(keycode == SDLK_KP_0) val = 0;
|
}
|
||||||
|
|
||||||
|
static void processPatternKeyboard(Music* music)
|
||||||
|
{
|
||||||
|
s32 channel = music->tracker.col / CHANNEL_COLS;
|
||||||
|
|
||||||
// if(val >= 0)
|
if(isKeyBeenPressed(tic_key_delete)) setChannelPatternValue(music, 0, channel);
|
||||||
// {
|
else if(isKeyBeenPressed(tic_key_tab)) nextPattern(music);
|
||||||
// enum {Base = 10};
|
else if(isKeyBeenPressed(tic_key_left)) patternColLeft(music);
|
||||||
// s32 patternId = tic_tool_get_pattern_id(getTrack(music), music->tracker.frame, channel);
|
else if(isKeyBeenPressed(tic_key_right)) patternColRight(music);
|
||||||
|
else if(isKeyBeenPressed(tic_key_down)
|
||||||
|
|| isKeyBeenPressed(tic_key_return))
|
||||||
|
music->tracker.row = music->tracker.scroll;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
s32 val = -1;
|
||||||
|
|
||||||
// patternId = music->tracker.patternCol == 0
|
char sym = getKeyboardText();
|
||||||
// ? val * Base + patternId % Base
|
|
||||||
// : patternId / Base * Base + val % Base;
|
|
||||||
|
|
||||||
// if(patternId <= MUSIC_PATTERNS)
|
if(sym >= '0' && sym <= '9') val = sym - '0';
|
||||||
// {
|
|
||||||
// setChannelPatternValue(music, patternId, channel);
|
|
||||||
|
|
||||||
// if(music->tracker.patternCol == 0)
|
if(val >= 0)
|
||||||
// patternColRight(music);
|
{
|
||||||
// }
|
enum {Base = 10};
|
||||||
// }
|
s32 patternId = tic_tool_get_pattern_id(getTrack(music), music->tracker.frame, channel);
|
||||||
// }
|
|
||||||
// }
|
patternId = music->tracker.patternCol == 0
|
||||||
// }
|
? val * Base + patternId % Base
|
||||||
|
: patternId / Base * Base + val % Base;
|
||||||
|
|
||||||
|
if(patternId <= MUSIC_PATTERNS)
|
||||||
|
{
|
||||||
|
setChannelPatternValue(music, patternId, channel);
|
||||||
|
|
||||||
|
if(music->tracker.patternCol == 0)
|
||||||
|
patternColRight(music);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void selectAll(Music* music)
|
static void selectAll(Music* music)
|
||||||
{
|
{
|
||||||
|
@ -1003,45 +999,35 @@ static void selectAll(Music* music)
|
||||||
updateSelection(music);
|
updateSelection(music);
|
||||||
}
|
}
|
||||||
|
|
||||||
// static void processKeydown(Music* music, SDL_Keysym* keysum)
|
static void processKeyboard(Music* music)
|
||||||
// {
|
{
|
||||||
// tic_keycode keycode = keysum->sym;
|
tic_mem* tic = music->tic;
|
||||||
|
|
||||||
// switch(getClipboardEvent())
|
switch(getClipboardEvent())
|
||||||
// {
|
{
|
||||||
// case TIC_CLIPBOARD_CUT: copyToClipboard(music, true); break;
|
case TIC_CLIPBOARD_CUT: copyToClipboard(music, true); break;
|
||||||
// case TIC_CLIPBOARD_COPY: copyToClipboard(music, false); break;
|
case TIC_CLIPBOARD_COPY: copyToClipboard(music, false); break;
|
||||||
// case TIC_CLIPBOARD_PASTE: copyFromClipboard(music); break;
|
case TIC_CLIPBOARD_PASTE: copyFromClipboard(music); break;
|
||||||
// default: break;
|
default: break;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// SDL_Keymod keymod = SDL_GetModState();
|
bool ctrl = tic->api.key(tic, tic_key_ctrl);
|
||||||
|
|
||||||
// if (keymod & TIC_MOD_CTRL)
|
if (ctrl)
|
||||||
// {
|
{
|
||||||
// switch (keycode)
|
if(isKeyBeenPressed(tic_key_a)) selectAll(music);
|
||||||
// {
|
else if(isKeyBeenPressed(tic_key_z)) undo(music);
|
||||||
// case SDLK_a: selectAll(music); break;
|
else if(isKeyBeenPressed(tic_key_y)) redo(music);
|
||||||
// case SDLK_z: undo(music); break;
|
else if(isKeyBeenPressed(tic_key_up)) upFrame(music);
|
||||||
// case SDLK_y: redo(music); break;
|
else if(isKeyBeenPressed(tic_key_down)) downFrame(music);
|
||||||
// case SDLK_UP: upFrame(music); break;
|
}
|
||||||
// case SDLK_DOWN: downFrame(music); break;
|
else
|
||||||
// }
|
{
|
||||||
// }
|
music->tracker.row >= 0
|
||||||
// else
|
? processTrackerKeyboard(music)
|
||||||
// {
|
: processPatternKeyboard(music);
|
||||||
// music->tracker.row >= 0
|
}
|
||||||
// ? processTrackerKeydown(music, keysum)
|
}
|
||||||
// : processPatternKeydown(music, keysum);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// static void processKeyup(Music* music, SDL_Keysym* keysum)
|
|
||||||
// {
|
|
||||||
// music->tracker.note = -1;
|
|
||||||
// s32 channel = music->tracker.col / CHANNEL_COLS;
|
|
||||||
// music->tic->api.sfx_stop(music->tic, channel);
|
|
||||||
// }
|
|
||||||
|
|
||||||
static void setIndex(Music* music, s32 delta, void* data)
|
static void setIndex(Music* music, s32 delta, void* data)
|
||||||
{
|
{
|
||||||
|
@ -1595,19 +1581,7 @@ static void drawTrackerLayout(Music* music)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SDL_Event* event = NULL;
|
processKeyboard(music);
|
||||||
// while ((event = pollEvent()))
|
|
||||||
// {
|
|
||||||
// switch (event->type)
|
|
||||||
// {
|
|
||||||
// case SDL_KEYDOWN:
|
|
||||||
// processKeydown(music, &event->key.keysym);
|
|
||||||
// break;
|
|
||||||
// case SDL_KEYUP:
|
|
||||||
// processKeyup(music, &event->key.keysym);
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
if(music->tracker.follow)
|
if(music->tracker.follow)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue