Subversion Repositories svn.mios32

Rev

Rev 753 | Rev 759 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
174 tk 1
// $Id: seq_ui_trkevnt.c 756 2009-10-18 20:01:48Z tk $
2
/*
319 tk 3
 * Track event page
174 tk 4
 *
5
 * ==========================================================================
6
 *
7
 *  Copyright (C) 2008 Thorsten Klose (tk@midibox.org)
8
 *  Licensed for personal non-commercial use only.
9
 *  All other rights reserved.
10
 *
11
 * ==========================================================================
12
 */
13
 
14
/////////////////////////////////////////////////////////////////////////////
15
// Include files
16
/////////////////////////////////////////////////////////////////////////////
17
 
18
#include <mios32.h>
326 tk 19
#include <string.h>
174 tk 20
#include "seq_lcd.h"
21
#include "seq_ui.h"
22
#include "seq_cc.h"
333 tk 23
#include "seq_par.h"
174 tk 24
#include "seq_layer.h"
690 tk 25
#include "seq_midi_port.h"
26
#include "seq_label.h"
718 tk 27
#include "seq_cc_labels.h"
174 tk 28
 
29
 
30
/////////////////////////////////////////////////////////////////////////////
31
// Local definitions
32
/////////////////////////////////////////////////////////////////////////////
33
 
319 tk 34
// Note/Chord/CC
472 tk 35
#define NUM_OF_ITEMS_NORMAL 8
319 tk 36
#define ITEM_GXTY           0
37
#define ITEM_EVENT_MODE     1
38
#define ITEM_MIDI_PORT      2
39
#define ITEM_MIDI_CHANNEL   3
472 tk 40
#define ITEM_EDIT_NAME      4
41
#define ITEM_LAYER_SELECT   5
42
#define ITEM_LAYER_CONTROL  6
43
#define ITEM_LAYER_PAR      7
174 tk 44
 
319 tk 45
// Drum
46
#define NUM_OF_ITEMS_DRUM   11
472 tk 47
//#define ITEM_GXTY           0
48
//#define ITEM_EVENT_MODE     1
49
//#define ITEM_MIDI_PORT      2
50
//#define ITEM_MIDI_CHANNEL   3
51
//#define ITEM_EDIT_NAME      4
319 tk 52
#define ITEM_LAYER_A_SELECT 5
53
#define ITEM_LAYER_B_SELECT 6
54
#define ITEM_DRUM_SELECT    7
55
#define ITEM_DRUM_NOTE      8
56
#define ITEM_DRUM_VEL_N     9
57
#define ITEM_DRUM_VEL_A     10
174 tk 58
 
319 tk 59
 
60
 
174 tk 61
/////////////////////////////////////////////////////////////////////////////
323 tk 62
// Local types
63
/////////////////////////////////////////////////////////////////////////////
64
 
65
typedef struct {
66
  seq_event_mode_t event_mode;  // event mode as forwarded to SEQ_CC_MIDI_EVENT_MODE
67
  u8               par_layers;  // number of parameter layers
68
  u16              par_steps;   // number of steps per parameter layer
69
  u8               trg_layers;  // number of trigger layers
70
  u16              trg_steps;   // number of steps per trigger layer
328 tk 71
  u8               instruments; // number of instruments per track
323 tk 72
} layer_config_t;
73
 
74
 
75
/////////////////////////////////////////////////////////////////////////////
176 tk 76
// Local prototypes
77
/////////////////////////////////////////////////////////////////////////////
78
 
323 tk 79
static s32 GetLayerConfig(u8 track);
80
static s32 CopyPreset(u8 track, u8 config);
756 tk 81
static void InitReq(u32 dummy);
176 tk 82
 
83
 
84
/////////////////////////////////////////////////////////////////////////////
178 tk 85
// Local variables
86
/////////////////////////////////////////////////////////////////////////////
87
 
481 tk 88
static u8 edit_label_mode;
472 tk 89
 
323 tk 90
static u8 selected_layer_config;
472 tk 91
static u8 selected_layer_config_track;
319 tk 92
 
752 tk 93
static u8 edit_cc_number;
94
 
472 tk 95
static const layer_config_t layer_config[] = {
328 tk 96
  //      mode           par_layers  par_steps  trg_layers  trg_steps  instruments
97
  { SEQ_EVENT_MODE_Note,    16,          64,        8,          64,      1 },
98
  { SEQ_EVENT_MODE_Note,     8,         128,        8,         128,      1 },
99
  { SEQ_EVENT_MODE_Note,     4,         256,        8,         256,      1 },
100
  { SEQ_EVENT_MODE_Chord,   16,          64,        8,          64,      1 },
101
  { SEQ_EVENT_MODE_Chord,    8,         128,        8,         128,      1 },
102
  { SEQ_EVENT_MODE_Chord,    4,         256,        8,         256,      1 },
103
  { SEQ_EVENT_MODE_CC,      16,          64,        8,          64,      1 },
104
  { SEQ_EVENT_MODE_CC,       8,         128,        8,         128,      1 },
105
  { SEQ_EVENT_MODE_CC,       4,         256,        8,         256,      1 },
106
  { SEQ_EVENT_MODE_Drum,     1,          64,        2,          64,     16 },
107
  { SEQ_EVENT_MODE_Drum,     2,          32,        1,         128,     16 },
108
  { SEQ_EVENT_MODE_Drum,     1,         128,        2,         128,      8 },
109
  { SEQ_EVENT_MODE_Drum,     2,          64,        1,         256,      8 }
323 tk 110
};
111
 
319 tk 112
 
178 tk 113
/////////////////////////////////////////////////////////////////////////////
174 tk 114
// Local LED handler function
115
/////////////////////////////////////////////////////////////////////////////
116
static s32 LED_Handler(u16 *gp_leds)
117
{
178 tk 118
  if( ui_cursor_flash ) { // if flashing flag active: no LED flag set
323 tk 119
    // flash INIT LED if current preset doesn't match with old preset
120
    // this notifies the user, that he should press the "INIT" button
178 tk 121
    u8 visible_track = SEQ_UI_VisibleTrackGet();
481 tk 122
    if( !edit_label_mode && selected_layer_config != GetLayerConfig(visible_track) )
319 tk 123
      *gp_leds = 0x8000;
178 tk 124
 
174 tk 125
    return 0;
178 tk 126
  }
174 tk 127
 
481 tk 128
  if( edit_label_mode ) {
752 tk 129
    *gp_leds = 0;
472 tk 130
  } else if( layer_config[selected_layer_config].event_mode == SEQ_EVENT_MODE_Drum ) {
131
    switch( ui_selected_item ) {
132
      case ITEM_GXTY: *gp_leds = 0x0001; break;
133
      case ITEM_EVENT_MODE: *gp_leds = 0x001e; break;
134
      case ITEM_MIDI_PORT: *gp_leds = 0x0020; break;
135
      case ITEM_MIDI_CHANNEL: *gp_leds = 0x0040; break;
136
      case ITEM_EDIT_NAME: *gp_leds = 0x0080; break;
319 tk 137
      case ITEM_LAYER_A_SELECT: *gp_leds = 0x0100; break;
138
      case ITEM_LAYER_B_SELECT: *gp_leds = 0x0200; break;
139
      case ITEM_DRUM_SELECT: *gp_leds = 0x0400; break;
140
      case ITEM_DRUM_NOTE: *gp_leds = 0x0800; break;
141
      case ITEM_DRUM_VEL_N: *gp_leds = 0x1000; break;
142
      case ITEM_DRUM_VEL_A: *gp_leds = 0x2000; break;
143
    }
144
  } else {
145
    switch( ui_selected_item ) {
146
      case ITEM_GXTY: *gp_leds = 0x0001; break;
147
      case ITEM_EVENT_MODE: *gp_leds = 0x001e; break;
148
      case ITEM_MIDI_PORT: *gp_leds = 0x0020; break;
149
      case ITEM_MIDI_CHANNEL: *gp_leds = 0x0040; break;
472 tk 150
      case ITEM_EDIT_NAME: *gp_leds = 0x0080; break;
319 tk 151
      case ITEM_LAYER_SELECT: *gp_leds = 0x0100; break;
323 tk 152
      case ITEM_LAYER_CONTROL: *gp_leds = 0x0200; break;
153
      case ITEM_LAYER_PAR: *gp_leds = 0x3c00; break;
319 tk 154
    }
174 tk 155
  }
156
 
157
  return 0; // no error
158
}
159
 
160
 
161
/////////////////////////////////////////////////////////////////////////////
162
// Local encoder callback function
163
// Should return:
164
//   1 if value has been changed
165
//   0 if value hasn't been changed
166
//  -1 if invalid or unsupported encoder
167
/////////////////////////////////////////////////////////////////////////////
168
static s32 Encoder_Handler(seq_ui_encoder_t encoder, s32 incrementer)
169
{
323 tk 170
  u8 event_mode = layer_config[selected_layer_config].event_mode;
335 tk 171
  u8 visible_track = SEQ_UI_VisibleTrackGet();
178 tk 172
 
752 tk 173
  if( edit_label_mode && encoder <= SEQ_UI_ENCODER_GP16 ) {
174
    switch( encoder ) {
175
      case SEQ_UI_ENCODER_GP15: { // select preset
176
    int pos;
177
 
178
    if( event_mode == SEQ_EVENT_MODE_Drum ) {
179
      if( SEQ_UI_Var8_Inc(&ui_edit_preset_num_drum, 0, SEQ_LABEL_NumPresetsDrum()-1, incrementer) ) {
180
        SEQ_LABEL_CopyPresetDrum(ui_edit_preset_num_drum, (char *)&seq_core_trk[visible_track].name[5*ui_selected_instrument]);
181
        for(pos=4, ui_edit_name_cursor=pos; pos>=0; --pos)
182
          if( seq_core_trk[visible_track].name[5*ui_selected_instrument + pos] == ' ' )
183
        ui_edit_name_cursor = pos;
184
          else
185
        break;
186
        return 1;
187
      }
188
      return 0;
189
    } else {
190
      if( ui_edit_name_cursor < 5 ) { // select category preset
191
        if( SEQ_UI_Var8_Inc(&ui_edit_preset_num_category, 0, SEQ_LABEL_NumPresetsCategory()-1, incrementer) ) {
192
          SEQ_LABEL_CopyPresetCategory(ui_edit_preset_num_category, (char *)&seq_core_trk[visible_track].name[0]);
193
          for(pos=4, ui_edit_name_cursor=pos; pos>=0; --pos)
194
        if( seq_core_trk[visible_track].name[pos] == ' ' )
195
          ui_edit_name_cursor = pos;
196
        else
197
          break;
198
          return 1;
199
        }
200
        return 0;
201
      } else { // select label preset
202
        if( SEQ_UI_Var8_Inc(&ui_edit_preset_num_label, 0, SEQ_LABEL_NumPresets()-1, incrementer) ) {
203
          SEQ_LABEL_CopyPreset(ui_edit_preset_num_label, (char *)&seq_core_trk[visible_track].name[5]);
204
          for(pos=19, ui_edit_name_cursor=pos; pos>=5; --pos)
205
        if( seq_core_trk[visible_track].name[pos] == ' ' )
206
          ui_edit_name_cursor = pos;
207
        else
208
          break;
209
          return 1;
210
        }
211
        return 0;
212
      }
213
    }
214
      } break;
215
 
216
      case SEQ_UI_ENCODER_GP16: { // exit keypad editor
217
    // exit keypad editor
218
    edit_label_mode = 0;
219
    return 1;
220
      } break;
221
    }
222
 
223
    if( event_mode == SEQ_EVENT_MODE_Drum )
224
      return SEQ_UI_KeyPad_Handler(encoder, incrementer, (char *)&seq_core_trk[visible_track].name[ui_selected_instrument*5], 5);
225
    else
226
      return SEQ_UI_KeyPad_Handler(encoder, incrementer, (char *)&seq_core_trk[visible_track].name, 20);
227
  }
228
 
472 tk 229
  if( encoder >= SEQ_UI_ENCODER_GP9 && encoder <= SEQ_UI_ENCODER_GP16 ) {
752 tk 230
    if( selected_layer_config != GetLayerConfig(visible_track) ) {
231
      // ENC function disabled so long pattern hasn't been initialized
232
      return -1;
233
    }
234
 
235
    if( event_mode == SEQ_EVENT_MODE_Drum ) {
472 tk 236
      switch( encoder ) {
237
        case SEQ_UI_ENCODER_GP9:
752 tk 238
      ui_selected_item = ITEM_LAYER_A_SELECT;
472 tk 239
      break;
174 tk 240
 
472 tk 241
        case SEQ_UI_ENCODER_GP10:
752 tk 242
      ui_selected_item = ITEM_LAYER_B_SELECT;
472 tk 243
      break;
174 tk 244
 
472 tk 245
        case SEQ_UI_ENCODER_GP11:
752 tk 246
      ui_selected_item = ITEM_DRUM_SELECT;
472 tk 247
      break;
174 tk 248
 
472 tk 249
        case SEQ_UI_ENCODER_GP12:
752 tk 250
      ui_selected_item = ITEM_DRUM_NOTE;
472 tk 251
      break;
174 tk 252
 
472 tk 253
        case SEQ_UI_ENCODER_GP13:
752 tk 254
      ui_selected_item = ITEM_DRUM_VEL_N;
255
      break;
256
 
481 tk 257
        case SEQ_UI_ENCODER_GP14:
752 tk 258
      ui_selected_item = ITEM_DRUM_VEL_A;
259
      break;
472 tk 260
 
481 tk 261
        case SEQ_UI_ENCODER_GP15:
262
        case SEQ_UI_ENCODER_GP16:
752 tk 263
      return -1; // not mapped to encoder
472 tk 264
      }
265
    } else {
266
      switch( encoder ) {
267
        case SEQ_UI_ENCODER_GP9:
752 tk 268
      ui_selected_item = ITEM_LAYER_SELECT;
472 tk 269
      break;
174 tk 270
 
472 tk 271
        case SEQ_UI_ENCODER_GP10:
752 tk 272
      ui_selected_item = ITEM_LAYER_CONTROL;
472 tk 273
      break;
174 tk 274
 
472 tk 275
        case SEQ_UI_ENCODER_GP11:
276
        case SEQ_UI_ENCODER_GP12:
277
        case SEQ_UI_ENCODER_GP13:
278
        case SEQ_UI_ENCODER_GP14:
752 tk 279
      // CC number selection now has to be confirmed with GP button
280
      if( ui_selected_item != ITEM_LAYER_PAR ) {
281
        edit_cc_number = SEQ_CC_Get(visible_track, SEQ_CC_LAY_CONST_B1 + ui_selected_par_layer);
282
        ui_selected_item = ITEM_LAYER_PAR;
283
        SEQ_UI_Msg(SEQ_UI_MSG_USER, 2000, "Please confirm CC", "with GP button!");
284
      } else if( incrementer == 0 ) {
285
        if( edit_cc_number != SEQ_CC_Get(visible_track, SEQ_CC_LAY_CONST_B1 + ui_selected_par_layer) ) {
286
          SEQ_CC_Set(visible_track, SEQ_CC_LAY_CONST_B1 + ui_selected_par_layer, edit_cc_number);
287
          SEQ_UI_Msg(SEQ_UI_MSG_USER, 2000, "CC number", "has been changed.");
288
        }
289
      }
472 tk 290
      break;
174 tk 291
 
472 tk 292
        case SEQ_UI_ENCODER_GP15:
293
      return -1; // not mapped to encoder
319 tk 294
 
472 tk 295
        case SEQ_UI_ENCODER_GP16:
296
      return -1; // not mapped to encoder
297
      }
298
    }
299
  } else {
300
    switch( encoder ) {
301
      case SEQ_UI_ENCODER_GP1:
302
    ui_selected_item = ITEM_GXTY;
303
    break;
304
 
305
      case SEQ_UI_ENCODER_GP2:
306
      case SEQ_UI_ENCODER_GP3:
307
      case SEQ_UI_ENCODER_GP4:
308
      case SEQ_UI_ENCODER_GP5:
309
    ui_selected_item = ITEM_EVENT_MODE;
310
    break;
311
 
312
      case SEQ_UI_ENCODER_GP6:
313
    ui_selected_item = ITEM_MIDI_PORT;
314
    break;
315
 
316
      case SEQ_UI_ENCODER_GP7:
317
    ui_selected_item = ITEM_MIDI_CHANNEL;
318
    break;
319
 
320
      case SEQ_UI_ENCODER_GP8:
321
    ui_selected_item = ITEM_EDIT_NAME;
322
    break;
323
    }
174 tk 324
  }
325
 
326
  // for GP encoders and Datawheel
327
  switch( ui_selected_item ) {
752 tk 328
    case ITEM_GXTY: return SEQ_UI_GxTyInc(incrementer);
323 tk 329
    case ITEM_EVENT_MODE: {
330
      u8 max_layer_config = (sizeof(layer_config)/sizeof(layer_config_t)) - 1;
331
      return SEQ_UI_Var8_Inc(&selected_layer_config, 0, max_layer_config, incrementer);
332
    } break;
472 tk 333
 
285 tk 334
    case ITEM_MIDI_PORT: {
335
      mios32_midi_port_t port = SEQ_CC_Get(visible_track, SEQ_CC_MIDI_PORT);
336
      u8 port_ix = SEQ_MIDI_PORT_OutIxGet(port);
337
      if( SEQ_UI_Var8_Inc(&port_ix, 0, SEQ_MIDI_PORT_OutNumGet()-1, incrementer) ) {
338
    mios32_midi_port_t new_port = SEQ_MIDI_PORT_OutPortGet(port_ix);
339
    SEQ_UI_CC_Set(SEQ_CC_MIDI_PORT, new_port);
340
    return 1; // value changed
341
      }
342
      return 0; // value not changed
343
    } break;
472 tk 344
 
752 tk 345
    case ITEM_MIDI_CHANNEL: return SEQ_UI_CC_Inc(SEQ_CC_MIDI_CHANNEL, 0, 15, incrementer);
472 tk 346
 
752 tk 347
    case ITEM_EDIT_NAME:
348
      // switch to keypad editor
349
      ui_selected_item = ITEM_EDIT_NAME;
350
      edit_label_mode = 1;
351
      SEQ_UI_KeyPad_Init();
352
      return 1;
174 tk 353
  }
354
 
752 tk 355
  if( event_mode == SEQ_EVENT_MODE_Drum ) {
319 tk 356
    switch( ui_selected_item ) {
325 tk 357
      case ITEM_DRUM_SELECT: {
328 tk 358
        u8 num_drums = layer_config[selected_layer_config].instruments;
336 tk 359
        return SEQ_UI_Var8_Inc(&ui_selected_instrument, 0, num_drums-1, incrementer);
325 tk 360
      } break;
335 tk 361
      case ITEM_LAYER_A_SELECT: {
362
        if( SEQ_UI_CC_Inc(SEQ_CC_PAR_ASG_DRUM_LAYER_A, 0, SEQ_PAR_NUM_TYPES-1, incrementer) ) {
336 tk 363
      SEQ_LAYER_CopyParLayerPreset(visible_track, 0);
335 tk 364
      return 1;
365
    }
366
    return 0;
367
      } break;
368
      case ITEM_LAYER_B_SELECT: {
369
        if( SEQ_UI_CC_Inc(SEQ_CC_PAR_ASG_DRUM_LAYER_B, 0, SEQ_PAR_NUM_TYPES-1, incrementer) ) {
336 tk 370
      SEQ_LAYER_CopyParLayerPreset(visible_track, 1);
335 tk 371
      return 1;
372
    }
373
    return 0;
374
      } break;
336 tk 375
      case ITEM_DRUM_NOTE:     return SEQ_UI_CC_Inc(SEQ_CC_LAY_CONST_A1 + ui_selected_instrument, 0, 127, incrementer);
376
      case ITEM_DRUM_VEL_N:    return SEQ_UI_CC_Inc(SEQ_CC_LAY_CONST_B1 + ui_selected_instrument, 0, 127, incrementer);
377
      case ITEM_DRUM_VEL_A:    return SEQ_UI_CC_Inc(SEQ_CC_LAY_CONST_C1 + ui_selected_instrument, 0, 127, incrementer);
319 tk 378
    }
379
  } else {
380
    switch( ui_selected_item ) {
336 tk 381
      case ITEM_LAYER_SELECT:  return SEQ_UI_Var8_Inc(&ui_selected_par_layer, 0, 15, incrementer);
752 tk 382
      case ITEM_LAYER_PAR:
383
    if( event_mode == SEQ_EVENT_MODE_Drum ) {
384
      return SEQ_UI_CC_Inc(SEQ_CC_LAY_CONST_B1 + ui_selected_par_layer, 0, 127, incrementer);
385
    } else {
386
      // CC number selection now has to be confirmed with GP button
387
      return SEQ_UI_Var8_Inc(&edit_cc_number, 0, 127, incrementer);
388
    }
389
 
333 tk 390
      case ITEM_LAYER_CONTROL: {
391
    // TODO: has to be done for all selected tracks
336 tk 392
    if( SEQ_UI_CC_Inc(SEQ_CC_LAY_CONST_A1 + ui_selected_par_layer, 0, SEQ_PAR_NUM_TYPES-1, incrementer) ) {
393
      SEQ_LAYER_CopyParLayerPreset(visible_track, ui_selected_par_layer);
333 tk 394
      return 1;
395
    }
396
    return 0;
397
      } break;
319 tk 398
    }
399
  }
400
 
174 tk 401
  return -1; // invalid or unsupported encoder
402
}
403
 
404
 
405
/////////////////////////////////////////////////////////////////////////////
406
// Local button callback function
407
// Should return:
408
//   1 if value has been changed
409
//   0 if value hasn't been changed
410
//  -1 if invalid or unsupported button
411
/////////////////////////////////////////////////////////////////////////////
412
static s32 Button_Handler(seq_ui_button_t button, s32 depressed)
413
{
414
  if( depressed ) return 0; // ignore when button depressed
415
 
752 tk 416
  u8 event_mode = layer_config[selected_layer_config].event_mode;
472 tk 417
  u8 visible_track = SEQ_UI_VisibleTrackGet();
323 tk 418
 
752 tk 419
  if( button == SEQ_UI_BUTTON_GP16 ) {
481 tk 420
    if( edit_label_mode ) {
752 tk 421
      // exit keypad editor
422
      edit_label_mode = 0;
472 tk 423
    } else {
756 tk 424
      SEQ_UI_InstallDelayedActionCallback(InitReq, 2000, 0);
425
      SEQ_UI_Msg(SEQ_UI_MSG_DELAYED_ACTION_R, 2001, "", "to initialize Track!");
472 tk 426
    }
752 tk 427
    return 1; // value has been changed
472 tk 428
  }
429
 
752 tk 430
  if( button <= SEQ_UI_BUTTON_GP15 )
431
    return Encoder_Handler((seq_ui_encoder_t)button, 0);
432
 
174 tk 433
  switch( button ) {
434
    case SEQ_UI_BUTTON_Select:
435
    case SEQ_UI_BUTTON_Right:
481 tk 436
      if( edit_label_mode ) {
752 tk 437
    // ignore
472 tk 438
      } else if( event_mode == SEQ_EVENT_MODE_Drum ) {
319 tk 439
    if( ++ui_selected_item >= NUM_OF_ITEMS_DRUM )
440
      ui_selected_item = 0;
441
      } else {
442
    if( ++ui_selected_item >= NUM_OF_ITEMS_NORMAL )
443
      ui_selected_item = 0;
444
      }
445
 
174 tk 446
      return 1; // value always changed
447
 
448
    case SEQ_UI_BUTTON_Left:
481 tk 449
      if( edit_label_mode ) {
752 tk 450
    // ignore
472 tk 451
      } else if( event_mode == SEQ_EVENT_MODE_Drum ) {
452
    if( ui_selected_item == 0 )
319 tk 453
      ui_selected_item = NUM_OF_ITEMS_DRUM-1;
454
      } else {
455
    if( ui_selected_item == 0 )
456
      ui_selected_item = NUM_OF_ITEMS_NORMAL-1;
457
      }
174 tk 458
      return 1; // value always changed
459
 
460
    case SEQ_UI_BUTTON_Up:
461
      return Encoder_Handler(SEQ_UI_ENCODER_Datawheel, 1);
462
 
463
    case SEQ_UI_BUTTON_Down:
464
      return Encoder_Handler(SEQ_UI_ENCODER_Datawheel, -1);
465
  }
466
 
467
  return -1; // invalid or unsupported button
468
}
469
 
470
 
471
/////////////////////////////////////////////////////////////////////////////
472
// Local Display Handler function
473
// IN: <high_prio>: if set, a high-priority LCD update is requested
474
/////////////////////////////////////////////////////////////////////////////
475
static s32 LCD_Handler(u8 high_prio)
476
{
477
  if( high_prio )
478
    return 0; // there are no high-priority updates
479
 
480
  // layout:
481
  // 00000000001111111111222222222233333333330000000000111111111122222222223333333333
482
  // 01234567890123456789012345678901234567890123456789012345678901234567890123456789
483
  // <--------------------------------------><-------------------------------------->
472 tk 484
  // Trk. Type Steps/ParL/TrgL Port Chn. EditLayer  controls                         
485
  // G1T1 Note  256   4     8  IIC2  12  Name  D    Prob                         INIT
174 tk 486
 
472 tk 487
  // Trk. Type Steps/ParL/TrgL Port Chn. EditLayer  controls                         
718 tk 488
  // G1T1 Note  256   4     8  IIC2  12  Name  D    CC #001 (ModWheel)           INIT
319 tk 489
 
490
  // Track Type "Note", Chord" and "CC":
491
  // Note: Parameter Layer A/B/C statically assigned to Note Number/Velocity/Length
492
  //       Parameter Layer D..P can be mapped to
493
  //       - additional Notes (e.g. for poly recording)
494
  //       - Base note (directly forwarded to Transposer, e.g. for Force-to-Scale or Chords)
495
  //       - CC (Number 000..127 assignable, GM controller name will be displayed)
496
  //       - Pitch Bender
497
  //       - Loopback (Number 000..127 assignable, name will be displayed)
338 tk 498
  //       - Delay (0..95 ticks @384 ppqn)
319 tk 499
  //       - Probability (100%..0%)
327 tk 500
  //       - "Roll/Flam Effect" (a selection of up to 128 different effects selectable for each step separately)
319 tk 501
  // Chord: same like Note, but predefined Chords will be played
502
  // CC: Layer A/B/C play CCs (or other parameters) as well - no note number, no velocity, no length
503
 
504
  // Available Layer Constraints (Partitioning for 1024 bytes Par. memory, 2048 bits Trg. memory)
505
  //    - 256 Steps with  4 Parameter Layers A-D and 8 Trigger Layers A-H
506
  //    - 128 Steps with  8 Parameter Layers A-H and 8 Trigger Layers A-H
507
  //    -  64 Steps with 16 Parameter Layers A-P and 8 Trigger Layers A-H
508
 
509
 
510
  // layout:
511
  // 00000000001111111111222222222233333333330000000000111111111122222222223333333333
512
  // 01234567890123456789012345678901234567890123456789012345678901234567890123456789
513
  // <--------------------------------------><-------------------------------------->
472 tk 514
  // Trk. Type StepsP/T  Drums Port Chn. EditLayA LayB  Drum Note VelN VelA          
515
  // G1T1 Drum  (64/2*64) 16   USB1  10  NamePrb. ----   BD   C-1  100  127      INIT
319 tk 516
 
472 tk 517
  // Trk. Type StepsP/T  Drums Port Chn. EditLayA LayB  Drum Note VelN VelA          
518
  // G1T1 Drum  (2*64/256) 8   USB1  12  NameVel. Len.   SD   D-1  ---  ---      INIT
319 tk 519
 
520
 
521
  // Track Type "Drums":
327 tk 522
  //    1 or 2 parameter layers for each trigger layer (drum instrument).
523
  //    If parameters layers consist of more than 1024 steps in total, steps > 1024 will be mirrored
524
  //    assignable to Velocity/Gatelength/Delay/Probability/Roll/Flam only
319 tk 525
  //    (no CC, no Pitch Bender, no Loopback, as they don't work note-wise, but 
526
  //     only channel wise
527
  //     just send them from a different track)
528
 
529
  // Each drum instrument provides 4 constant parameters for:
530
  //   - Note Number
472 tk 531
  //   - MIDI Channel (1-16) for all drum instruments (TODO: optionally allow to use a "local" channel, edit parameter right of VelA)
319 tk 532
  //   - Velocity Normal (if not taken from Parameter Layer)
533
  //   - Velocity Accented (if not taken from Parameter Layer)
534
 
535
 
536
  // Available Layer Constraints (Partitioning for 1024 bytes Par. memory, 2048 bits Trg. memory)
327 tk 537
  //    - 16 Parameter Layers with 64 steps and 2*16 Trigger Layers A-P with 64 steps taken for Gate and Accent
538
  //    - 2*16 Parameter Layer with 32 steps and 16 Trigger Layers A-P with 128 steps taken for Gate
539
  //    - 8 Parameter Layer with 128 steps and 2*8 Trigger Layers A-P with 128 steps taken for Gate and Accent
540
  //    - 2*8 Parameter Layer with 64 steps and 8 Trigger Layers A-P with 256 steps taken for Gate
319 tk 541
 
472 tk 542
 
543
 
544
  // "Edit Name" layout:
545
  // 00000000001111111111222222222233333333330000000000111111111122222222223333333333
546
  // 01234567890123456789012345678901234567890123456789012345678901234567890123456789
547
  // <--------------------------------------><-------------------------------------->
752 tk 548
  // Please enter Track Category for G1T1    <xxxxx-xxxxxxxxxxxxxxx>                 
753 tk 549
  // .,!1 ABC2 DEF3 GHI4 JKL5 MNO6 PQRS7 TUV8WXYZ9 0 -?  Char <>  Del Ins Preset DONE
472 tk 550
 
729 tk 551
  // "Edit Drum Name" layout:
552
  // 00000000001111111111222222222233333333330000000000111111111122222222223333333333
553
  // 01234567890123456789012345678901234567890123456789012345678901234567890123456789
554
  // <--------------------------------------><-------------------------------------->
752 tk 555
  // Please enter Drum Label for G1T1- 1:C-1 <xxxxx>                                 
753 tk 556
  // .,!1 ABC2 DEF3 GHI4 JKL5 MNO6 PQRS7 TUV8WXYZ9 0 -?  Char <>  Del Ins Preset DONE
729 tk 557
 
174 tk 558
  u8 visible_track = SEQ_UI_VisibleTrackGet();
472 tk 559
 
560
  // if track has changed, switch layer config:
561
  if( visible_track != selected_layer_config_track ) {
562
    selected_layer_config_track = visible_track;
563
    selected_layer_config = GetLayerConfig(selected_layer_config_track);
564
  }
565
 
323 tk 566
  u8 event_mode = layer_config[selected_layer_config].event_mode;
174 tk 567
 
472 tk 568
 
174 tk 569
  ///////////////////////////////////////////////////////////////////////////
752 tk 570
  if( edit_label_mode ) {
571
    int i;
319 tk 572
 
752 tk 573
    SEQ_LCD_CursorSet(0, 0);
574
    if( event_mode == SEQ_EVENT_MODE_Drum ) {
575
      SEQ_LCD_PrintString("Please enter Drum Label for ");
576
      SEQ_LCD_PrintGxTy(ui_selected_group, ui_selected_tracks);
577
      SEQ_LCD_PrintFormattedString("-%2d:", ui_selected_instrument + 1);
578
      SEQ_LCD_PrintNote(SEQ_CC_Get(visible_track, SEQ_CC_LAY_CONST_A1 + ui_selected_instrument));
579
      SEQ_LCD_PrintSpaces(1);
472 tk 580
 
752 tk 581
      SEQ_LCD_PrintChar('<');
582
      for(i=0; i<5; ++i)
583
    SEQ_LCD_PrintChar(seq_core_trk[visible_track].name[5*ui_selected_instrument + i]);
584
      SEQ_LCD_PrintChar('>');
585
      SEQ_LCD_PrintSpaces(33);
472 tk 586
 
729 tk 587
      // insert flashing cursor
588
      if( ui_cursor_flash ) {
589
    if( ui_edit_name_cursor >= 5 ) // correct cursor position if it is outside the 5 char label space
590
      ui_edit_name_cursor = 0;
752 tk 591
    SEQ_LCD_CursorSet(41 + ui_edit_name_cursor, 0);
729 tk 592
    SEQ_LCD_PrintChar('*');
593
      }
594
    } else {
752 tk 595
      if( ui_edit_name_cursor < 5 ) {
596
    SEQ_LCD_PrintString("Please enter Track Category for ");
597
    SEQ_LCD_PrintGxTy(ui_selected_group, ui_selected_tracks);
598
    SEQ_LCD_PrintSpaces(4);
599
      } else {
600
    SEQ_LCD_PrintString("Please enter Track Label for ");
601
    SEQ_LCD_PrintGxTy(ui_selected_group, ui_selected_tracks);
602
    SEQ_LCD_PrintSpaces(7);
729 tk 603
      }
752 tk 604
      SEQ_LCD_PrintChar('<');
605
      for(i=0; i<5; ++i)
606
    SEQ_LCD_PrintChar(seq_core_trk[visible_track].name[i]);
607
      SEQ_LCD_PrintChar('-');
608
      for(i=5; i<20; ++i)
609
    SEQ_LCD_PrintChar(seq_core_trk[visible_track].name[i]);
610
      SEQ_LCD_PrintChar('>');
611
      SEQ_LCD_PrintSpaces(17);
472 tk 612
    }
729 tk 613
 
752 tk 614
 
615
    // insert flashing cursor
616
    if( ui_cursor_flash ) {
617
      SEQ_LCD_CursorSet(40 + ((ui_edit_name_cursor < 5) ? 1 : 2) + ui_edit_name_cursor, 0);
618
      SEQ_LCD_PrintChar('*');
619
    }
620
 
621
    SEQ_UI_KeyPad_LCD_Msg();
622
    SEQ_LCD_PrintString("Preset DONE");
623
 
624
    return 0;
625
  }
626
 
627
  ///////////////////////////////////////////////////////////////////////////
628
  SEQ_LCD_CursorSet(0, 0);
629
 
630
  SEQ_LCD_PrintString("Trk. Type ");
631
  SEQ_LCD_PrintString((event_mode == SEQ_EVENT_MODE_Drum) ? "StepsP/T  Drums " : "Steps/ParL/TrgL ");
632
  SEQ_LCD_PrintString("Port Chn. ");
633
 
634
  if( ui_selected_item == ITEM_EDIT_NAME && ui_cursor_flash ) {
635
    SEQ_LCD_PrintSpaces(4);
636
  } else {
637
    SEQ_LCD_PrintFormattedString("Edit");
638
  }
639
 
640
  if( selected_layer_config != GetLayerConfig(visible_track) ) {
472 tk 641
    SEQ_LCD_PrintString("    Please initialize the track         ");
642
  } else if( event_mode == SEQ_EVENT_MODE_Drum ) {
319 tk 643
    SEQ_LCD_PrintString("LayA ");
472 tk 644
    SEQ_LCD_PrintString((layer_config[selected_layer_config].par_layers >= 2) ? "LayB " : "     ");
645
    SEQ_LCD_PrintString(" Drum Note VelN VelA          ");
174 tk 646
  } else {
472 tk 647
    SEQ_LCD_PrintString("Layer  controls                         ");
174 tk 648
  }
649
 
650
  ///////////////////////////////////////////////////////////////////////////
278 tk 651
  SEQ_LCD_CursorSet(0, 1);
174 tk 652
 
653
  if( ui_selected_item == ITEM_GXTY && ui_cursor_flash ) {
654
    SEQ_LCD_PrintSpaces(5);
655
  } else {
656
    SEQ_LCD_PrintGxTy(ui_selected_group, ui_selected_tracks);
657
    SEQ_LCD_PrintSpaces(1);
658
  }
659
 
660
  ///////////////////////////////////////////////////////////////////////////
661
 
319 tk 662
  if( ui_selected_item == ITEM_EVENT_MODE && ui_cursor_flash ) {
663
    SEQ_LCD_PrintSpaces(21);
664
  } else {
747 tk 665
    SEQ_LCD_PrintString((char *)SEQ_LAYER_GetEvntModeName(event_mode));
174 tk 666
 
328 tk 667
    layer_config_t *lc = (layer_config_t *)&layer_config[selected_layer_config];
321 tk 668
    if( event_mode == SEQ_EVENT_MODE_Drum ) {
327 tk 669
      SEQ_LCD_PrintChar(' ');
670
      SEQ_LCD_PrintChar('(');
671
      SEQ_LCD_PrintSpaces(14); // for easier handling
672
      SEQ_LCD_CursorSet(12, 1);
673
 
328 tk 674
      if( lc->par_layers > 1 )
675
    SEQ_LCD_PrintFormattedString("%d*", lc->par_layers);
676
      SEQ_LCD_PrintFormattedString("%d/", lc->par_steps);
677
      if( lc->trg_layers > 1 )
678
    SEQ_LCD_PrintFormattedString("%d*", lc->trg_layers);
679
      SEQ_LCD_PrintFormattedString("%d", lc->trg_steps);
327 tk 680
 
328 tk 681
      SEQ_LCD_PrintFormattedString(") %d", lc->instruments);
327 tk 682
      SEQ_LCD_CursorSet(26, 1);
683
 
321 tk 684
    } else {
328 tk 685
      SEQ_LCD_PrintFormattedString("  %3d %3d  %3d  ", lc->par_steps, lc->par_layers, lc->trg_layers);
321 tk 686
    }
319 tk 687
  }
174 tk 688
 
689
  ///////////////////////////////////////////////////////////////////////////
319 tk 690
  mios32_midi_port_t port = SEQ_CC_Get(visible_track, SEQ_CC_MIDI_PORT);
691
  if( ui_selected_item == ITEM_MIDI_PORT && ui_cursor_flash ) {
692
    SEQ_LCD_PrintSpaces(5);
693
  } else {
694
    SEQ_LCD_PrintMIDIOutPort(port);
695
    SEQ_LCD_PrintChar(SEQ_MIDI_PORT_OutCheckAvailable(port) ? ' ' : '*');
174 tk 696
  }
697
 
698
  ///////////////////////////////////////////////////////////////////////////
699
  if( ui_selected_item == ITEM_MIDI_CHANNEL && ui_cursor_flash ) {
700
    SEQ_LCD_PrintSpaces(5);
701
  } else {
278 tk 702
    SEQ_LCD_PrintFormattedString("%3d  ", SEQ_CC_Get(visible_track, SEQ_CC_MIDI_CHANNEL)+1);
174 tk 703
  }
704
 
705
  ///////////////////////////////////////////////////////////////////////////
472 tk 706
  if( ui_selected_item == ITEM_EDIT_NAME && ui_cursor_flash ) {
707
    SEQ_LCD_PrintSpaces(4);
708
  } else {
709
    SEQ_LCD_PrintFormattedString("Name");
710
  }
711
 
712
 
713
  ///////////////////////////////////////////////////////////////////////////
752 tk 714
  if( selected_layer_config != GetLayerConfig(visible_track) ) {
472 tk 715
    SEQ_LCD_PrintString(" ---------------------------------> ");
740 tk 716
    if( (ui_cursor_flash_overrun_ctr & 1) ) {
319 tk 717
      SEQ_LCD_PrintSpaces(4);
718
    } else {
472 tk 719
      SEQ_LCD_PrintString("INIT");
319 tk 720
    }
174 tk 721
 
472 tk 722
  ///////////////////////////////////////////////////////////////////////////
723
  } else if( event_mode == SEQ_EVENT_MODE_Drum ) {
319 tk 724
    /////////////////////////////////////////////////////////////////////////
725
    if( ui_selected_item == ITEM_LAYER_A_SELECT && ui_cursor_flash ) {
726
      SEQ_LCD_PrintSpaces(5);
727
    } else {
333 tk 728
      SEQ_LCD_PrintString(SEQ_PAR_AssignedTypeStr(visible_track, 0));
319 tk 729
    }
174 tk 730
 
319 tk 731
    /////////////////////////////////////////////////////////////////////////
732
    if( ui_selected_item == ITEM_LAYER_B_SELECT && ui_cursor_flash ) {
472 tk 733
      SEQ_LCD_PrintSpaces(5);
319 tk 734
    } else {
472 tk 735
      if( layer_config[selected_layer_config].par_layers >= 2 ) {
736
    SEQ_LCD_PrintString(SEQ_PAR_AssignedTypeStr(visible_track, 1));
737
      } else {
738
    if( ui_selected_item == ITEM_LAYER_B_SELECT )
739
      SEQ_LCD_PrintString("---- "); // not a bug, but a feature - highlight, that layer not configurable
740
    else
741
      SEQ_LCD_PrintSpaces(5);
742
      }
319 tk 743
    }
472 tk 744
    SEQ_LCD_PrintSpaces(1);
319 tk 745
 
746
    /////////////////////////////////////////////////////////////////////////
747
    if( ui_selected_item == ITEM_DRUM_SELECT && ui_cursor_flash ) {
748
      SEQ_LCD_PrintSpaces(5);
749
    } else {
336 tk 750
      SEQ_LCD_PrintTrackDrum(visible_track, ui_selected_instrument, (char *)seq_core_trk[visible_track].name);
319 tk 751
    }
752
 
753
    /////////////////////////////////////////////////////////////////////////
754
    SEQ_LCD_PrintSpaces(1);
755
    if( ui_selected_item == ITEM_DRUM_NOTE && ui_cursor_flash ) {
756
      SEQ_LCD_PrintSpaces(3);
757
    } else {
336 tk 758
      SEQ_LCD_PrintNote(SEQ_CC_Get(visible_track, SEQ_CC_LAY_CONST_A1 + ui_selected_instrument));
319 tk 759
    }
760
    SEQ_LCD_PrintSpaces(1);
761
 
762
    /////////////////////////////////////////////////////////////////////////
763
    if( ui_selected_item == ITEM_DRUM_VEL_N && ui_cursor_flash ) {
764
      SEQ_LCD_PrintSpaces(5);
765
    } else {
336 tk 766
      SEQ_LCD_PrintFormattedString(" %3d ", SEQ_CC_Get(visible_track, SEQ_CC_LAY_CONST_B1 + ui_selected_instrument));
319 tk 767
    }
768
 
769
    /////////////////////////////////////////////////////////////////////////
770
    if( ui_selected_item == ITEM_DRUM_VEL_A && ui_cursor_flash ) {
771
      SEQ_LCD_PrintSpaces(5);
772
    } else {
336 tk 773
      SEQ_LCD_PrintFormattedString(" %3d ", SEQ_CC_Get(visible_track, SEQ_CC_LAY_CONST_C1 + ui_selected_instrument));
319 tk 774
    }
178 tk 775
  } else {
319 tk 776
    /////////////////////////////////////////////////////////////////////////
777
    SEQ_LCD_PrintSpaces(2);
778
    if( ui_selected_item == ITEM_LAYER_SELECT && ui_cursor_flash ) {
779
      SEQ_LCD_PrintChar(' ');
300 tk 780
    } else {
336 tk 781
      SEQ_LCD_PrintChar('A' + ui_selected_par_layer);
300 tk 782
    }
319 tk 783
    SEQ_LCD_PrintSpaces(4);
784
 
785
    /////////////////////////////////////////////////////////////////////////
786
    if( ui_selected_item == ITEM_LAYER_CONTROL && ui_cursor_flash ) {
323 tk 787
      SEQ_LCD_PrintSpaces(5);
319 tk 788
    } else {
336 tk 789
      SEQ_LCD_PrintString(SEQ_PAR_AssignedTypeStr(visible_track, ui_selected_par_layer));
319 tk 790
    }
323 tk 791
 
792
    /////////////////////////////////////////////////////////////////////////
793
    if( ui_selected_item == ITEM_LAYER_PAR && ui_cursor_flash ) {
794
      SEQ_LCD_PrintSpaces(19);
795
    } else {
336 tk 796
      switch( SEQ_PAR_AssignmentGet(visible_track, ui_selected_par_layer) ) {
718 tk 797
        case SEQ_PAR_Type_CC: {
741 tk 798
      mios32_midi_port_t port = SEQ_CC_Get(visible_track, SEQ_CC_MIDI_PORT);
752 tk 799
      u8 current_value = SEQ_CC_Get(visible_track, SEQ_CC_LAY_CONST_B1 + ui_selected_par_layer);
800
      u8 edit_value = ui_selected_item == ITEM_LAYER_PAR ? edit_cc_number : current_value;
801
      SEQ_LCD_PrintFormattedString("%03d%c(%s)     ",
802
                       edit_value,
803
                       (current_value != edit_value) ? '!' : ' ',
804
                       SEQ_CC_LABELS_Get(port, edit_value));
718 tk 805
    } break;
333 tk 806
        default:
807
      SEQ_LCD_PrintSpaces(19);
808
      }
323 tk 809
    }
178 tk 810
  }
174 tk 811
 
472 tk 812
  SEQ_LCD_PrintString("     INIT");
178 tk 813
 
323 tk 814
 
174 tk 815
  return 0; // no error
816
}
817
 
818
 
819
/////////////////////////////////////////////////////////////////////////////
820
// Initialisation
821
/////////////////////////////////////////////////////////////////////////////
822
s32 SEQ_UI_TRKEVNT_Init(u32 mode)
823
{
824
  // install callback routines
825
  SEQ_UI_InstallButtonCallback(Button_Handler);
826
  SEQ_UI_InstallEncoderCallback(Encoder_Handler);
827
  SEQ_UI_InstallLEDCallback(LED_Handler);
828
  SEQ_UI_InstallLCDCallback(LCD_Handler);
829
 
178 tk 830
 
481 tk 831
  edit_label_mode = 0;
472 tk 832
  selected_layer_config_track = SEQ_UI_VisibleTrackGet();
833
  selected_layer_config = GetLayerConfig(selected_layer_config_track);
834
 
835
  // initialize edit label vars (name is modified directly, not via ui_edit_name!)
836
  ui_edit_name_cursor = 0;
837
  ui_edit_preset_num_category = 0;
838
  ui_edit_preset_num_label = 0;
839
 
174 tk 840
  return 0; // no error
841
}
176 tk 842
 
843
 
844
/////////////////////////////////////////////////////////////////////////////
323 tk 845
// Copies preset
176 tk 846
/////////////////////////////////////////////////////////////////////////////
323 tk 847
static s32 CopyPreset(u8 track, u8 config)
176 tk 848
{
323 tk 849
  // exit if invalid config
850
  if( config >= (sizeof(layer_config)/sizeof(layer_config_t)) )
851
    return -1; // invalid config
176 tk 852
 
328 tk 853
  layer_config_t *lc = (layer_config_t *)&layer_config[selected_layer_config];
854
 
323 tk 855
  // partitionate layers and clear all steps
328 tk 856
  SEQ_PAR_TrackInit(track, lc->par_steps, lc->par_layers, lc->instruments);
857
  SEQ_TRG_TrackInit(track, lc->trg_steps, lc->trg_layers, lc->instruments);
176 tk 858
 
472 tk 859
#if 0
860
  // confusing if assignments are not changed under such a condition
336 tk 861
  u8 init_assignments = lc->event_mode != SEQ_CC_Get(track, SEQ_CC_MIDI_EVENT_MODE);
472 tk 862
#else
863
  u8 init_assignments = 1;
864
#endif
336 tk 865
 
328 tk 866
  SEQ_CC_Set(track, SEQ_CC_MIDI_EVENT_MODE, lc->event_mode);
176 tk 867
 
326 tk 868
  // BEGIN TMP
328 tk 869
  if( lc->event_mode == SEQ_EVENT_MODE_Drum ) {
729 tk 870
    int i;
871
 
872
    for(i=0; i<16; ++i)
873
      SEQ_LABEL_CopyPresetDrum(i, (char *)&seq_core_trk[track].name[5*i]);
326 tk 874
  } else {
875
    memset((char *)seq_core_trk[track].name, ' ', 80);
876
  }
877
  // END TMP
878
 
324 tk 879
  u8 only_layers = 0;
880
  u8 all_triggers_cleared = 0;
335 tk 881
  return SEQ_LAYER_CopyPreset(track, only_layers, all_triggers_cleared, init_assignments);
323 tk 882
}
176 tk 883
 
884
 
323 tk 885
/////////////////////////////////////////////////////////////////////////////
886
// Determines current layer config
887
/////////////////////////////////////////////////////////////////////////////
888
static s32 GetLayerConfig(u8 track)
889
{
890
  int i;
891
 
892
  u8 event_mode = SEQ_CC_Get(track, SEQ_CC_MIDI_EVENT_MODE);
893
  u8 par_layers = SEQ_PAR_NumLayersGet(track);
894
  u16 par_steps = SEQ_PAR_NumStepsGet(track);
895
  u8 trg_layers = SEQ_TRG_NumLayersGet(track);
896
  u16 trg_steps = SEQ_TRG_NumStepsGet(track);
328 tk 897
  u8 num_instruments = SEQ_PAR_NumInstrumentsGet(track);
323 tk 898
 
899
  for(i=0; i<(sizeof(layer_config)/sizeof(layer_config_t)); ++i) {
900
    layer_config_t *lc = (layer_config_t *)&layer_config[i];
901
    if( lc->event_mode == event_mode &&
902
    lc->par_layers == par_layers && lc->par_steps == par_steps &&
325 tk 903
    lc->trg_layers == trg_layers && lc->trg_steps == trg_steps &&
328 tk 904
    lc->instruments == num_instruments ) {
323 tk 905
      return i;
176 tk 906
    }
907
  }
908
 
323 tk 909
  return 0; // not found, return index to first config
176 tk 910
}
178 tk 911
 
756 tk 912
/////////////////////////////////////////////////////////////////////////////
913
// help function for Init button function
914
/////////////////////////////////////////////////////////////////////////////
915
static void InitReq(u32 dummy)
916
{
917
  u8 visible_track = SEQ_UI_VisibleTrackGet();
918
 
919
  // TODO: copy preset for all selected tracks!
920
  CopyPreset(visible_track, selected_layer_config);
921
 
922
  SEQ_UI_Msg(SEQ_UI_MSG_USER_R, 1000, "Track has been", "initialized!");
923
}