Subversion Repositories svn.mios32

Rev

Rev 318 | Rev 320 | 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 319 2009-01-26 22:31:13Z 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>
19
#include "seq_lcd.h"
20
#include "seq_ui.h"
21
#include "seq_cc.h"
22
#include "seq_layer.h"
23
 
24
 
25
/////////////////////////////////////////////////////////////////////////////
26
// Local definitions
27
/////////////////////////////////////////////////////////////////////////////
28
 
319 tk 29
// Note/Chord/CC
30
#define NUM_OF_ITEMS_NORMAL 6
31
#define ITEM_GXTY           0
32
#define ITEM_EVENT_MODE     1
33
#define ITEM_MIDI_PORT      2
34
#define ITEM_MIDI_CHANNEL   3
35
#define ITEM_LAYER_SELECT   4
36
#define ITEM_LAYER_CONTROL  5
174 tk 37
 
319 tk 38
// Drum
39
#define NUM_OF_ITEMS_DRUM   11
40
#define ITEM_GXTY           0
41
#define ITEM_EVENT_MODE     1
42
#define ITEM_MIDI_PORT      2
43
#define ITEM_MIDI_CHANNEL   3
44
#define ITEM_MIDI_CHANNEL_LOCAL 4
45
#define ITEM_LAYER_A_SELECT 5
46
#define ITEM_LAYER_B_SELECT 6
47
#define ITEM_DRUM_SELECT    7
48
#define ITEM_DRUM_NOTE      8
49
#define ITEM_DRUM_VEL_N     9
50
#define ITEM_DRUM_VEL_A     10
174 tk 51
 
319 tk 52
 
53
 
174 tk 54
/////////////////////////////////////////////////////////////////////////////
176 tk 55
// Local prototypes
56
/////////////////////////////////////////////////////////////////////////////
57
 
58
static s32 PrintCValue(u8 track, u8 const_ix);
178 tk 59
static s32 CopyPreset(u8 track);
176 tk 60
 
61
 
62
/////////////////////////////////////////////////////////////////////////////
178 tk 63
// Local variables
64
/////////////////////////////////////////////////////////////////////////////
65
 
319 tk 66
static u8 event_mode; // seq_event_mode_t
67
 
68
static u8 selected_layer;
69
static u8 selected_drum;
70
 
178 tk 71
static u8 preset_copied;
319 tk 72
static u8 old_event_mode[SEQ_CORE_NUM_TRACKS];
178 tk 73
 
74
 
75
/////////////////////////////////////////////////////////////////////////////
174 tk 76
// Local LED handler function
77
/////////////////////////////////////////////////////////////////////////////
78
static s32 LED_Handler(u16 *gp_leds)
79
{
178 tk 80
  if( ui_cursor_flash ) { // if flashing flag active: no LED flag set
319 tk 81
    // flash DONE LED if current preset doesn't match with old preset
178 tk 82
    // this notifies the user, that he should press the "copy preset" button
83
    u8 visible_track = SEQ_UI_VisibleTrackGet();
319 tk 84
    if( old_event_mode[visible_track] != event_mode )
85
      *gp_leds = 0x8000;
178 tk 86
 
174 tk 87
    return 0;
178 tk 88
  }
174 tk 89
 
319 tk 90
  if( event_mode == SEQ_EVENT_MODE_Drum ) {
91
    switch( ui_selected_item ) {
92
      case ITEM_GXTY: *gp_leds = 0x0001; break;
93
      case ITEM_EVENT_MODE: *gp_leds = 0x001e; break;
94
      case ITEM_MIDI_PORT: *gp_leds = 0x0020; break;
95
      case ITEM_MIDI_CHANNEL: *gp_leds = 0x0040; break;
96
      case ITEM_MIDI_CHANNEL_LOCAL: *gp_leds = 0x0080; break;
97
      case ITEM_LAYER_A_SELECT: *gp_leds = 0x0100; break;
98
      case ITEM_LAYER_B_SELECT: *gp_leds = 0x0200; break;
99
      case ITEM_DRUM_SELECT: *gp_leds = 0x0400; break;
100
      case ITEM_DRUM_NOTE: *gp_leds = 0x0800; break;
101
      case ITEM_DRUM_VEL_N: *gp_leds = 0x1000; break;
102
      case ITEM_DRUM_VEL_A: *gp_leds = 0x2000; break;
103
    }
104
  } else {
105
    switch( ui_selected_item ) {
106
      case ITEM_GXTY: *gp_leds = 0x0001; break;
107
      case ITEM_EVENT_MODE: *gp_leds = 0x001e; break;
108
      case ITEM_MIDI_PORT: *gp_leds = 0x0020; break;
109
      case ITEM_MIDI_CHANNEL: *gp_leds = 0x0040; break;
110
      case ITEM_LAYER_SELECT: *gp_leds = 0x0100; break;
111
      case ITEM_LAYER_CONTROL: *gp_leds = 0x3e00; break;
112
    }
174 tk 113
  }
114
 
115
  return 0; // no error
116
}
117
 
118
 
119
/////////////////////////////////////////////////////////////////////////////
120
// Local encoder callback function
121
// Should return:
122
//   1 if value has been changed
123
//   0 if value hasn't been changed
124
//  -1 if invalid or unsupported encoder
125
/////////////////////////////////////////////////////////////////////////////
126
static s32 Encoder_Handler(seq_ui_encoder_t encoder, s32 incrementer)
127
{
178 tk 128
  preset_copied = 0; // for display notification
129
 
174 tk 130
  switch( encoder ) {
131
    case SEQ_UI_ENCODER_GP1:
132
      ui_selected_item = ITEM_GXTY;
133
      break;
134
 
135
    case SEQ_UI_ENCODER_GP2:
136
    case SEQ_UI_ENCODER_GP3:
137
    case SEQ_UI_ENCODER_GP4:
138
    case SEQ_UI_ENCODER_GP5:
319 tk 139
      ui_selected_item = ITEM_EVENT_MODE;
174 tk 140
      break;
141
 
142
    case SEQ_UI_ENCODER_GP6:
319 tk 143
      ui_selected_item = ITEM_MIDI_PORT;
174 tk 144
      break;
145
 
146
    case SEQ_UI_ENCODER_GP7:
319 tk 147
      ui_selected_item = ITEM_MIDI_CHANNEL;
174 tk 148
      break;
149
 
150
    case SEQ_UI_ENCODER_GP8:
319 tk 151
      if( event_mode == SEQ_EVENT_MODE_Drum )
152
    ui_selected_item = ITEM_MIDI_CHANNEL_LOCAL;
153
      else
154
    return -1;
174 tk 155
      break;
156
 
157
    case SEQ_UI_ENCODER_GP9:
319 tk 158
      ui_selected_item = (event_mode == SEQ_EVENT_MODE_Drum) ? ITEM_LAYER_A_SELECT : ITEM_LAYER_SELECT;
174 tk 159
      break;
160
 
161
    case SEQ_UI_ENCODER_GP10:
319 tk 162
      ui_selected_item = (event_mode == SEQ_EVENT_MODE_Drum) ? ITEM_LAYER_B_SELECT : ITEM_LAYER_CONTROL;
174 tk 163
      break;
164
 
165
    case SEQ_UI_ENCODER_GP11:
319 tk 166
      ui_selected_item = (event_mode == SEQ_EVENT_MODE_Drum) ? ITEM_DRUM_SELECT : ITEM_LAYER_CONTROL;
167
      break;
168
 
174 tk 169
    case SEQ_UI_ENCODER_GP12:
319 tk 170
      ui_selected_item = (event_mode == SEQ_EVENT_MODE_Drum) ? ITEM_DRUM_NOTE : ITEM_LAYER_CONTROL;
171
      break;
172
 
174 tk 173
    case SEQ_UI_ENCODER_GP13:
319 tk 174
      ui_selected_item = (event_mode == SEQ_EVENT_MODE_Drum) ? ITEM_DRUM_VEL_N : ITEM_LAYER_CONTROL;
175
      break;
176
 
174 tk 177
    case SEQ_UI_ENCODER_GP14:
319 tk 178
      ui_selected_item = (event_mode == SEQ_EVENT_MODE_Drum) ? ITEM_DRUM_VEL_A : ITEM_LAYER_CONTROL;
179
      break;
174 tk 180
 
181
    case SEQ_UI_ENCODER_GP15:
319 tk 182
      return -1; // not mapped to encoder
183
 
174 tk 184
    case SEQ_UI_ENCODER_GP16:
319 tk 185
      return -1; // not mapped to encoder
174 tk 186
  }
187
 
188
  // for GP encoders and Datawheel
189
  switch( ui_selected_item ) {
190
    case ITEM_GXTY:          return SEQ_UI_GxTyInc(incrementer);
319 tk 191
    case ITEM_EVENT_MODE:    return SEQ_UI_Var8_Inc(&event_mode, 0, 3, incrementer);
285 tk 192
    case ITEM_MIDI_PORT: {
193
      u8 visible_track = SEQ_UI_VisibleTrackGet();
194
      mios32_midi_port_t port = SEQ_CC_Get(visible_track, SEQ_CC_MIDI_PORT);
195
      u8 port_ix = SEQ_MIDI_PORT_OutIxGet(port);
196
      if( SEQ_UI_Var8_Inc(&port_ix, 0, SEQ_MIDI_PORT_OutNumGet()-1, incrementer) ) {
197
    mios32_midi_port_t new_port = SEQ_MIDI_PORT_OutPortGet(port_ix);
198
    SEQ_UI_CC_Set(SEQ_CC_MIDI_PORT, new_port);
199
    return 1; // value changed
200
      }
201
      return 0; // value not changed
202
    } break;
319 tk 203
    case ITEM_MIDI_CHANNEL:  return SEQ_UI_CC_Inc(SEQ_CC_MIDI_CHANNEL, 0, 15, incrementer);
174 tk 204
  }
205
 
319 tk 206
  if( event_mode == SEQ_EVENT_MODE_Drum ) {
207
    switch( ui_selected_item ) {
208
      case ITEM_DRUM_SELECT:   return SEQ_UI_Var8_Inc(&selected_drum, 0, 15, incrementer);
209
    }
210
  } else {
211
    switch( ui_selected_item ) {
212
      case ITEM_LAYER_SELECT:  return SEQ_UI_Var8_Inc(&selected_layer, 0, 15, incrementer);
213
    }
214
  }
215
 
174 tk 216
  return -1; // invalid or unsupported encoder
217
}
218
 
219
 
220
/////////////////////////////////////////////////////////////////////////////
221
// Local button callback function
222
// Should return:
223
//   1 if value has been changed
224
//   0 if value hasn't been changed
225
//  -1 if invalid or unsupported button
226
/////////////////////////////////////////////////////////////////////////////
227
static s32 Button_Handler(seq_ui_button_t button, s32 depressed)
228
{
178 tk 229
  preset_copied = 0; // for display notification - always clear this flag when any button has been pressed/depressed
230
 
174 tk 231
  if( depressed ) return 0; // ignore when button depressed
232
 
233
  switch( button ) {
319 tk 234
    case SEQ_UI_ENCODER_GP1:
174 tk 235
      ui_selected_item = ITEM_GXTY;
319 tk 236
      return 1;
174 tk 237
 
319 tk 238
    case SEQ_UI_ENCODER_GP2:
239
    case SEQ_UI_ENCODER_GP3:
240
    case SEQ_UI_ENCODER_GP4:
241
    case SEQ_UI_ENCODER_GP5:
242
      ui_selected_item = ITEM_EVENT_MODE;
243
      return 1;
174 tk 244
 
319 tk 245
    case SEQ_UI_ENCODER_GP6:
246
      ui_selected_item = ITEM_MIDI_PORT;
247
      return 1;
174 tk 248
 
319 tk 249
    case SEQ_UI_ENCODER_GP7:
250
      ui_selected_item = ITEM_MIDI_CHANNEL;
251
      return 1;
174 tk 252
 
319 tk 253
    case SEQ_UI_ENCODER_GP8:
254
      if( event_mode == SEQ_EVENT_MODE_Drum )
255
    ui_selected_item = ITEM_MIDI_CHANNEL_LOCAL;
256
      else
257
    return -1;
258
      return 1;
174 tk 259
 
319 tk 260
    case SEQ_UI_ENCODER_GP9:
261
      ui_selected_item = (event_mode == SEQ_EVENT_MODE_Drum) ? ITEM_LAYER_A_SELECT : ITEM_LAYER_SELECT;
262
      return 1;
174 tk 263
 
319 tk 264
    case SEQ_UI_ENCODER_GP10:
265
      ui_selected_item = (event_mode == SEQ_EVENT_MODE_Drum) ? ITEM_LAYER_B_SELECT : ITEM_LAYER_CONTROL;
266
      return 1;
174 tk 267
 
319 tk 268
    case SEQ_UI_ENCODER_GP11:
269
      ui_selected_item = (event_mode == SEQ_EVENT_MODE_Drum) ? ITEM_DRUM_SELECT : ITEM_LAYER_CONTROL;
270
      return 1;
174 tk 271
 
319 tk 272
    case SEQ_UI_ENCODER_GP12:
273
      ui_selected_item = (event_mode == SEQ_EVENT_MODE_Drum) ? ITEM_DRUM_NOTE : ITEM_LAYER_CONTROL;
274
      return 1;
275
 
276
    case SEQ_UI_ENCODER_GP13:
277
      ui_selected_item = (event_mode == SEQ_EVENT_MODE_Drum) ? ITEM_DRUM_VEL_N : ITEM_LAYER_CONTROL;
278
      return 1;
279
 
280
    case SEQ_UI_ENCODER_GP14:
281
      ui_selected_item = (event_mode == SEQ_EVENT_MODE_Drum) ? ITEM_DRUM_VEL_A : ITEM_LAYER_CONTROL;
282
      return 1;
283
 
284
    case SEQ_UI_ENCODER_GP15:
285
      // TODO
286
      return 1;
287
 
288
    case SEQ_UI_ENCODER_GP16:
178 tk 289
      // ui_selected_item = ITEM_PRESET;
290
      CopyPreset(SEQ_UI_VisibleTrackGet());
291
      return 1; // value has been changed
174 tk 292
 
319 tk 293
 
174 tk 294
    case SEQ_UI_BUTTON_Select:
295
    case SEQ_UI_BUTTON_Right:
319 tk 296
      if( event_mode == SEQ_EVENT_MODE_Drum ) {
297
    if( ++ui_selected_item >= NUM_OF_ITEMS_DRUM )
298
      ui_selected_item = 0;
299
      } else {
300
    if( ++ui_selected_item >= NUM_OF_ITEMS_NORMAL )
301
      ui_selected_item = 0;
302
      }
303
 
174 tk 304
      return 1; // value always changed
305
 
306
    case SEQ_UI_BUTTON_Left:
319 tk 307
      if( event_mode == SEQ_EVENT_MODE_Drum ) {
308
    if( ui_selected_item == 0 )
309
      ui_selected_item = NUM_OF_ITEMS_DRUM-1;
310
      } else {
311
    if( ui_selected_item == 0 )
312
      ui_selected_item = NUM_OF_ITEMS_NORMAL-1;
313
      }
174 tk 314
      return 1; // value always changed
315
 
316
    case SEQ_UI_BUTTON_Up:
317
      return Encoder_Handler(SEQ_UI_ENCODER_Datawheel, 1);
318
 
319
    case SEQ_UI_BUTTON_Down:
320
      return Encoder_Handler(SEQ_UI_ENCODER_Datawheel, -1);
321
  }
322
 
323
  return -1; // invalid or unsupported button
324
}
325
 
326
 
327
/////////////////////////////////////////////////////////////////////////////
328
// Local Display Handler function
329
// IN: <high_prio>: if set, a high-priority LCD update is requested
330
/////////////////////////////////////////////////////////////////////////////
331
static s32 LCD_Handler(u8 high_prio)
332
{
333
  if( high_prio )
334
    return 0; // there are no high-priority updates
335
 
336
  // layout:
337
  // 00000000001111111111222222222233333333330000000000111111111122222222223333333333
338
  // 01234567890123456789012345678901234567890123456789012345678901234567890123456789
339
  // <--------------------------------------><-------------------------------------->
319 tk 340
  // Trk. Type Steps/ParL/TrgL Port Chn.     Layer  controls                Edit      
341
  // G1T1 Note  256   4     8  IIC2  12        D    Prob                    Name DONE
174 tk 342
 
319 tk 343
  // Trk. Type Steps/ParL/TrgL Port Chn.     Layer  controls                Edit      
344
  // G1T1 Note  256   4     8  IIC2  12        D    CC #001 ModWheel        Name DONE
345
 
346
  // Track Type "Note", Chord" and "CC":
347
  // Note: Parameter Layer A/B/C statically assigned to Note Number/Velocity/Length
348
  //       Parameter Layer D..P can be mapped to
349
  //       - additional Notes (e.g. for poly recording)
350
  //       - Base note (directly forwarded to Transposer, e.g. for Force-to-Scale or Chords)
351
  //       - CC (Number 000..127 assignable, GM controller name will be displayed)
352
  //       - Pitch Bender
353
  //       - Loopback (Number 000..127 assignable, name will be displayed)
354
  //       - Delay (+/- 96 ticks @384 ppqn)
355
  //       - Probability (100%..0%)
356
  // Chord: same like Note, but predefined Chords will be played
357
  // CC: Layer A/B/C play CCs (or other parameters) as well - no note number, no velocity, no length
358
 
359
  // Available Layer Constraints (Partitioning for 1024 bytes Par. memory, 2048 bits Trg. memory)
360
  //    - 256 Steps with  4 Parameter Layers A-D and 8 Trigger Layers A-H
361
  //    - 128 Steps with  8 Parameter Layers A-H and 8 Trigger Layers A-H
362
  //    -  64 Steps with 16 Parameter Layers A-P and 8 Trigger Layers A-H
363
 
364
 
365
  // layout:
366
  // 00000000001111111111222222222233333333330000000000111111111122222222223333333333
367
  // 01234567890123456789012345678901234567890123456789012345678901234567890123456789
368
  // <--------------------------------------><-------------------------------------->
369
  // Trk. Type Steps/ParL/TrgL Port Chn. Glb LayA       Drum Note VelN VelA Edit     
370
  // G1T1 Drum   64   1    16  USB1  10  yes Prb.        BD   C-1  100  127 Name DONE
371
 
372
  // Trk. Type Steps/ParL/TrgL Port Chn. Glb            Drum Note VelN VelA Edit     
373
  // G1T1 Drum  256   0    16  USB1  10  yes             BD   C-1  100  127 Name DONE
374
 
375
  // Trk. Type Steps/ParL/TrgL Port Chn. Glb LayA LayB  Drum Note VelN VelA Edit     
376
  // G1T1 Drum   64   2     8  USB1  12   no Dly. Prb.   SD   D-1  100  127 Name DONE
377
 
378
 
379
  // Track Type "Drums":
380
  //    usually 1 or 2 parameter layers for each trigger layer (drum instrument)
381
  //    assignable to Velocity/Delay/Probability only
382
  //    (no CC, no Pitch Bender, no Loopback, as they don't work note-wise, but 
383
  //     only channel wise
384
  //     just send them from a different track)
385
 
386
  // Each drum instrument provides 4 constant parameters for:
387
  //   - Note Number
388
  //   - MIDI Channel (1-16) - optionally, we can select a "local" channel definition for the instrument
389
  //   - Velocity Normal (if not taken from Parameter Layer)
390
  //   - Velocity Accented (if not taken from Parameter Layer)
391
 
392
 
393
  // Available Layer Constraints (Partitioning for 1024 bytes Par. memory, 2048 bits Trg. memory)
394
  //    - 256 Steps with no Parameter Layer and 16  Trigger Layers A-P taken for Gate
395
  //    - 256 Steps with no Parameter Layer and 2*8 Trigger Layers A-H taken for Gate and Accent 
396
  //    -  64 Steps with  1 Parameter Layer and 16 Trigger Layers A-P
397
  //    -  64 Steps with  1 Parameter Layer and 16 Trigger Layers A-H taken for Gate and Accent
398
  //    -  64 Steps with  2 Parameter Layer and  8 Trigger Layers A-H
399
 
400
 
174 tk 401
  u8 visible_track = SEQ_UI_VisibleTrackGet();
402
 
403
  ///////////////////////////////////////////////////////////////////////////
278 tk 404
  SEQ_LCD_CursorSet(0, 0);
319 tk 405
  SEQ_LCD_PrintString("Trk. Type Steps/ParL/TrgL Port Chn. ");
406
 
407
  if( event_mode == SEQ_EVENT_MODE_Drum ) {
408
    SEQ_LCD_PrintString("Glb ");
409
    SEQ_LCD_PrintString("LayA ");
410
    SEQ_LCD_PrintString("LayB ");
411
    SEQ_LCD_PrintString(" Drum Note VelN VelA Edit     ");
174 tk 412
  } else {
319 tk 413
    SEQ_LCD_PrintString("    Layer  controls                Edit     ");
174 tk 414
  }
415
 
416
  ///////////////////////////////////////////////////////////////////////////
278 tk 417
  SEQ_LCD_CursorSet(0, 1);
174 tk 418
 
419
  if( ui_selected_item == ITEM_GXTY && ui_cursor_flash ) {
420
    SEQ_LCD_PrintSpaces(5);
421
  } else {
422
    SEQ_LCD_PrintGxTy(ui_selected_group, ui_selected_tracks);
423
    SEQ_LCD_PrintSpaces(1);
424
  }
425
 
426
  ///////////////////////////////////////////////////////////////////////////
427
 
319 tk 428
  if( ui_selected_item == ITEM_EVENT_MODE && ui_cursor_flash ) {
429
    SEQ_LCD_PrintSpaces(21);
430
  } else {
431
    const char event_mode_str[4][6] = { "Note ", "Chord", " CC  ", "Drum " };
432
    SEQ_LCD_PrintString(event_mode_str[event_mode]);
174 tk 433
 
319 tk 434
    u16 steps = 256;
435
    u8 par_l = 4;
436
    u8 trg_l = 8;
437
    SEQ_LCD_PrintFormattedString("  %3d %3d  %3d  ", steps, par_l, trg_l);
438
  }
174 tk 439
 
440
  ///////////////////////////////////////////////////////////////////////////
319 tk 441
  mios32_midi_port_t port = SEQ_CC_Get(visible_track, SEQ_CC_MIDI_PORT);
442
  if( ui_selected_item == ITEM_MIDI_PORT && ui_cursor_flash ) {
443
    SEQ_LCD_PrintSpaces(5);
444
  } else {
445
    SEQ_LCD_PrintMIDIOutPort(port);
446
    SEQ_LCD_PrintChar(SEQ_MIDI_PORT_OutCheckAvailable(port) ? ' ' : '*');
174 tk 447
  }
448
 
449
  ///////////////////////////////////////////////////////////////////////////
450
  if( ui_selected_item == ITEM_MIDI_CHANNEL && ui_cursor_flash ) {
451
    SEQ_LCD_PrintSpaces(5);
452
  } else {
278 tk 453
    SEQ_LCD_PrintFormattedString("%3d  ", SEQ_CC_Get(visible_track, SEQ_CC_MIDI_CHANNEL)+1);
174 tk 454
  }
455
 
456
  ///////////////////////////////////////////////////////////////////////////
319 tk 457
  if( event_mode == SEQ_EVENT_MODE_Drum ) {
458
    /////////////////////////////////////////////////////////////////////////
459
    if( ui_selected_item == ITEM_MIDI_CHANNEL_LOCAL && ui_cursor_flash ) {
460
      SEQ_LCD_PrintSpaces(4);
461
    } else {
462
      SEQ_LCD_PrintFormattedString(" no ");
463
    }
174 tk 464
 
319 tk 465
    /////////////////////////////////////////////////////////////////////////
466
    if( ui_selected_item == ITEM_LAYER_A_SELECT && ui_cursor_flash ) {
467
      SEQ_LCD_PrintSpaces(5);
468
    } else {
469
      SEQ_LCD_PrintFormattedString("Dly. ");
470
    }
174 tk 471
 
319 tk 472
    /////////////////////////////////////////////////////////////////////////
473
    if( ui_selected_item == ITEM_LAYER_B_SELECT && ui_cursor_flash ) {
474
      SEQ_LCD_PrintSpaces(6);
475
    } else {
476
      SEQ_LCD_PrintFormattedString("Par.  ");
477
    }
478
 
479
    /////////////////////////////////////////////////////////////////////////
480
    if( ui_selected_item == ITEM_DRUM_SELECT && ui_cursor_flash ) {
481
      SEQ_LCD_PrintSpaces(5);
482
    } else {
483
      SEQ_LCD_PrintTrackDrum(visible_track, selected_drum, (char *)seq_core_trk[visible_track].name);
484
    }
485
 
486
    /////////////////////////////////////////////////////////////////////////
487
    SEQ_LCD_PrintSpaces(1);
488
    if( ui_selected_item == ITEM_DRUM_NOTE && ui_cursor_flash ) {
489
      SEQ_LCD_PrintSpaces(3);
490
    } else {
491
      SEQ_LCD_PrintNote(0x24);
492
    }
493
    SEQ_LCD_PrintSpaces(1);
494
 
495
    /////////////////////////////////////////////////////////////////////////
496
    if( ui_selected_item == ITEM_DRUM_VEL_N && ui_cursor_flash ) {
497
      SEQ_LCD_PrintSpaces(5);
498
    } else {
499
      SEQ_LCD_PrintFormattedString(" %3d ", 100);
500
    }
501
 
502
    /////////////////////////////////////////////////////////////////////////
503
    if( ui_selected_item == ITEM_DRUM_VEL_A && ui_cursor_flash ) {
504
      SEQ_LCD_PrintSpaces(5);
505
    } else {
506
      SEQ_LCD_PrintFormattedString(" %3d ", 127);
507
    }
178 tk 508
  } else {
319 tk 509
    /////////////////////////////////////////////////////////////////////////
510
    SEQ_LCD_PrintSpaces(4);
300 tk 511
 
319 tk 512
    /////////////////////////////////////////////////////////////////////////
513
    SEQ_LCD_PrintSpaces(2);
514
    if( ui_selected_item == ITEM_LAYER_SELECT && ui_cursor_flash ) {
515
      SEQ_LCD_PrintChar(' ');
300 tk 516
    } else {
319 tk 517
      SEQ_LCD_PrintChar('A' + selected_layer);
300 tk 518
    }
319 tk 519
    SEQ_LCD_PrintSpaces(4);
520
 
521
    /////////////////////////////////////////////////////////////////////////
522
    if( ui_selected_item == ITEM_LAYER_CONTROL && ui_cursor_flash ) {
523
      SEQ_LCD_PrintSpaces(24);
524
    } else {
525
      SEQ_LCD_PrintString("CC #001 ModWheel        ");
526
    }
178 tk 527
  }
174 tk 528
 
319 tk 529
  SEQ_LCD_PrintString("Name DONE");
178 tk 530
 
174 tk 531
  return 0; // no error
532
}
533
 
534
 
535
/////////////////////////////////////////////////////////////////////////////
536
// Initialisation
537
/////////////////////////////////////////////////////////////////////////////
538
s32 SEQ_UI_TRKEVNT_Init(u32 mode)
539
{
540
  // install callback routines
541
  SEQ_UI_InstallButtonCallback(Button_Handler);
542
  SEQ_UI_InstallEncoderCallback(Encoder_Handler);
543
  SEQ_UI_InstallLEDCallback(LED_Handler);
544
  SEQ_UI_InstallLCDCallback(LCD_Handler);
545
 
178 tk 546
  preset_copied = 0;
547
 
548
  u8 track;
549
  for(track=0; track<SEQ_CORE_NUM_TRACKS; ++track)
319 tk 550
    old_event_mode[track] = SEQ_CC_Get(track, SEQ_CC_MIDI_EVNT_MODE);
178 tk 551
 
174 tk 552
  return 0; // no error
553
}
176 tk 554
 
555
 
319 tk 556
#if 0
176 tk 557
/////////////////////////////////////////////////////////////////////////////
558
// Help function to print a constant value (4 characters)
559
/////////////////////////////////////////////////////////////////////////////
560
static s32 PrintCValue(u8 track, u8 const_ix)
561
{
318 tk 562
  u8 value = SEQ_CC_Get(track, SEQ_CC_LAY_CONST_A1 + 16*const_ix);
176 tk 563
 
564
  switch( SEQ_LAYER_GetCControlType(track, const_ix) ) {
565
    case SEQ_LAYER_ControlType_None:
566
      SEQ_LCD_PrintSpaces(4);
567
      break;
568
 
569
    case SEQ_LAYER_ControlType_Note:
278 tk 570
      SEQ_LCD_PrintChar(' ');
176 tk 571
      SEQ_LCD_PrintNote(value);
572
      break;
573
 
574
    case SEQ_LAYER_ControlType_Velocity:
575
    case SEQ_LAYER_ControlType_CC:
278 tk 576
      SEQ_LCD_PrintFormattedString(" %3d", value);
176 tk 577
      break;
578
 
579
    case SEQ_LAYER_ControlType_Length:
178 tk 580
      SEQ_LCD_PrintGatelength(value);
176 tk 581
      break;
582
 
583
    case SEQ_LAYER_ControlType_CMEM_T:
584
    {
585
      u8 cmem_track = value % SEQ_CORE_NUM_TRACKS;
278 tk 586
      SEQ_LCD_PrintFormattedString("G%dT%d", (cmem_track >> 2)+1, (cmem_track & 3)+1);
176 tk 587
    }
588
    break;
589
 
590
    default:
278 tk 591
      SEQ_LCD_PrintString(" ???");
176 tk 592
      break;
593
  }
594
 
595
  return 0; // no error
596
}
319 tk 597
#endif
178 tk 598
 
599
/////////////////////////////////////////////////////////////////////////////
600
// Copies preset
601
/////////////////////////////////////////////////////////////////////////////
602
s32 CopyPreset(u8 track)
603
{
604
  preset_copied = 1;
319 tk 605
  old_event_mode[track] = SEQ_CC_Get(track, SEQ_CC_MIDI_EVNT_MODE);
318 tk 606
  return SEQ_LAYER_CopyPreset(track, 0, 0); // 0=all settings, 0=triggers initialized
178 tk 607
}