Subversion Repositories svn.mios32

Rev

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

Rev Author Line No. Line
1298 tk 1
// $Id: scs_config.cpp 1960 2014-02-09 20:21:24Z tk $
2
/*
3
 * Local SCS Configuration
4
 *
5
 * ==========================================================================
6
 *
7
 *  Copyright (C) 2011 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 <string.h>
20
#include "tasks.h"
21
 
1334 tk 22
#include <scs.h>
23
#include "scs_config.h"
24
 
25
#include <file.h>
26
 
27
#include <app.h>
28
#include <MbCvEnvironment.h>
1347 tk 29
#include <MbCvTables.h>
1334 tk 30
 
1298 tk 31
#include <uip.h>
32
#include "uip_task.h"
33
#include "osc_client.h"
34
#include "osc_server.h"
35
 
1492 tk 36
#include <midi_port.h>
1530 tk 37
#include <midi_router.h>
1492 tk 38
 
1299 tk 39
#include "mbcv_map.h"
1298 tk 40
#include "mbcv_file.h"
41
#include "mbcv_file_p.h"
42
#include "mbcv_patch.h"
1911 tk 43
#include "mbcv_lre.h"
1298 tk 44
 
45
 
46
/////////////////////////////////////////////////////////////////////////////
1334 tk 47
// Local variables
1298 tk 48
/////////////////////////////////////////////////////////////////////////////
49
 
50
static u8 extraPage;
51
 
1299 tk 52
static u8 selectedCv;
1338 tk 53
static u8 selectedLfo;
1394 tk 54
static u8 selectedEnv1; // currently only 1, just to be prepared...
1912 tk 55
static u8 selectedEnv2; // currently only 1, just to be prepared...
1298 tk 56
static u8 selectedRouterNode;
57
static u8 selectedIpPar;
58
static u8 selectedOscPort;
1917 tk 59
static u8 selectedScope;
1299 tk 60
static u8 monPageOffset;
1298 tk 61
 
1334 tk 62
// we need a reference to this environment very often
63
static MbCvEnvironment* env;
1299 tk 64
 
1298 tk 65
 
66
/////////////////////////////////////////////////////////////////////////////
67
// String Conversion Functions
68
/////////////////////////////////////////////////////////////////////////////
69
static void stringEmpty(u32 ix, u16 value, char *label)   { label[0] = 0; }
70
static void stringDec(u32 ix, u16 value, char *label)    { sprintf(label, "%3d  ", value); }
71
static void stringDecP1(u32 ix, u16 value, char *label)  { sprintf(label, "%3d  ", value+1); }
1653 tk 72
//static void stringDecPM(u32 ix, u16 value, char *label)  { sprintf(label, "%3d  ", (int)value - 64); }
1338 tk 73
static void stringDecPM128(u32 ix, u16 value, char *label)  { sprintf(label, "%3d  ", (int)value - 128); }
1653 tk 74
//static void stringDec03(u32 ix, u16 value, char *label)  { sprintf(label, "%03d  ", value); }
1298 tk 75
static void stringDec0Dis(u32 ix, u16 value, char *label){ sprintf(label, value ? "%3d  " : "---  ", value); }
1299 tk 76
static void stringDec4(u32 ix, u16 value, char *label)   { sprintf(label, "%4d ", value); }
1298 tk 77
static void stringDec5(u32 ix, u16 value, char *label)   { sprintf(label, "%5d", value); }
1653 tk 78
//static void stringHex2(u32 ix, u16 value, char *label)    { sprintf(label, " %02X  ", value); }
79
//static void stringHex2O80(u32 ix, u16 value, char *label) { sprintf(label, " %02X  ", value | 0x80); }
1298 tk 80
static void stringOnOff(u32 ix, u16 value, char *label)  { sprintf(label, " [%c] ", value ? 'x' : ' '); }
1394 tk 81
static void stringCurve(u32 ix, u16 value, char *label)  { sprintf(label, value ? "Exp. " : "Lin. "); }
1298 tk 82
 
1914 tk 83
static void stringCvUpdateRate(u32 ix, u16 value, char *label) {
84
  u32 updateRate = (value+1) * 500; // Hz
85
  if( value < 10000 ) {
86
    sprintf(label, "%d.%dk", updateRate / 1000, (updateRate % 1000) / 100);
87
  } else {
88
    sprintf(label, "%3dk", updateRate / 1000);
89
  }
90
}
91
 
1298 tk 92
static void stringNote(u32 ix, u16 value, char *label)
93
{
94
  const char noteTab[12][3] = { "C-", "C#", "D-", "D#", "E-", "F-", "F#", "G-", "G#", "A-", "A#", "B-" };
95
 
96
  // print "---" if note number is 0
97
  if( value == 0 )
98
    sprintf(label, "---  ");
99
  else {
100
    u8 octave = value / 12;
101
    u8 note = value % 12;
102
 
103
    // print semitone and octave (-2): up to 4 chars
104
    sprintf(label, "%s%d  ",
105
        noteTab[note],
106
        (int)octave-2);
107
  }
108
}
109
 
1917 tk 110
static void stringScopeSource(u32 ix, u16 value, char *label)
1887 tk 111
{
1917 tk 112
  if( value >= 1 && value <= CV_SE_NUM ) {
113
    sprintf(label, "CV%d ", value);
1887 tk 114
  } else {
1917 tk 115
    sprintf(label, "--- ");
1887 tk 116
  }
117
}
118
 
1917 tk 119
static void stringScopeTrigger(u32 ix, u16 value, char *label)
120
{
121
  if( value <= 100 ) {
122
    sprintf(label, "P%3d%% ", value);
123
  } else if( value <= 201 ) {
124
    sprintf(label, "N%3d%% ", value-101);
125
  } else if( value <= 201+14 ) {
126
    const char *triggerString[14] = {
127
      "PGate",
128
      "NGate",
129
      "64th",
130
      "32th",
131
      "16th",
132
      "8th",
133
      "1beat",
134
      "2beat",
135
      "3beat",
136
      "4beat",
137
      "5beat",
138
      "6beat",
139
      "7beat",
140
      "8beat"
141
    };
142
    sprintf(label, triggerString[value-202]);
143
  } else {
144
    sprintf(label, "??? ");
145
  }
146
}
147
 
1299 tk 148
static void stringAoutIf(u32 ix, u16 value, char *label)
149
{
1334 tk 150
  char *name = (char *)MBCV_MAP_IfNameGet(MBCV_MAP_IfGet()); // 8 chars max
1299 tk 151
  if( ix == 0 ) {
152
    label[0] = ' ';
1312 tk 153
    memcpy(label+1, (char *)name, 4);
1299 tk 154
  } else {
1312 tk 155
    memcpy(label, (char *)(name + 4), 5);
1299 tk 156
  }
157
  label[5] = 0;
158
}
159
 
1312 tk 160
static void stringCvMode(u32 ix, u16 value, char *label)
161
{
1347 tk 162
  static const char mode[MBCV_MIDI_EVENT_MODE_NUM+1][6] = {
1312 tk 163
    "Note ",
164
    "Vel. ",
165
    "Aft. ",
166
    " CC  ",
167
    "NRPN ",
168
    "PBnd ",
1347 tk 169
    "CMin ",
170
    "CMid ",
171
    "CMax ",
1312 tk 172
    "???? ",
173
  };
174
 
1347 tk 175
  sprintf(label, mode[(value < MBCV_MIDI_EVENT_MODE_NUM) ? value : MBCV_MIDI_EVENT_MODE_NUM]);
1312 tk 176
}
177
 
178
static void stringCvPlayMode(u32 ix, u16 value, char *label)
179
{
180
  static const char playMode[4][6] = {
181
    "Mono ",
182
    "Leg. ",
183
    "Poly ",
184
    "???? ",
185
  };
186
 
187
  sprintf(label, playMode[value&3]);
188
}
189
 
190
static void stringCvTranspose(u32 ix, u16 value, char *label) { if( value >= 8 ) sprintf(label, " +%d  ", value-8); else sprintf(label, " -%d  ", 8-value); }
191
 
1338 tk 192
static void stringCvPortamentoMode(u32 ix, u16 value, char *label)
193
{
194
  static const char portamentoMode[4][6] = {
195
    "Norm ",
196
    "CGld ",
197
    "Glis ",
198
    "???? ",
199
  };
200
 
201
  sprintf(label, portamentoMode[value&3]);
202
}
203
 
1397 tk 204
static void stringCvCurve(u32 ix, u16 value, char *label) { memcpy(label, env->mbCv[selectedCv].mbCvVoice.getAoutCurveName(), 5); label[5] = 0; }
1299 tk 205
static void stringCvCaliMode(u32 ix, u16 value, char *label) { memcpy(label, MBCV_MAP_CaliNameGet(), 5); label[5] = 0; }
206
 
1338 tk 207
static void stringArpDir(u32 ix, u16 value, char *label)
208
{
209
  const char dirLabel[7][5] = { " Up ", "Down", "Up&D", "D&Up", "U&D2", "D&U2", "Rand" };
210
  if( value < 7 )
211
    strcpy(label, dirLabel[value]);
212
  else
213
    sprintf(label, "%3d ", value);
214
}
215
 
1347 tk 216
static void stringLfoRate(u32 ix, u16 value, char *label)
217
{
218
#if 0  
219
  sprintf(label, "%3d  ", value);
220
#else
221
  // rate in Herz
222
  float hz = 500.0 / (65536.0 / (float)mbCvLfoTable[value]);
223
  if( env->mbCv[selectedCv].mbCvLfo[selectedLfo].lfoModeFast )
224
    hz *= env->updateSpeedFactor;
225
 
226
  if( hz < 1.0 ) {
227
    sprintf(label, ".%03d ", (int)(hz*1000));
228
  } else if( hz < 10.0 ) {
229
    sprintf(label, "%d.%02d ", (int)hz, (int)(hz*100) % 100);
230
  } else if( hz < 100.0 ) {
231
    sprintf(label, "%2d.%d ", (int)hz, (int)((hz*10)) % 10);
232
  } else {
233
    sprintf(label, "%4d ", (int)hz);
234
  }
235
#endif
236
}
237
 
1338 tk 238
static void stringLfoWave(u32 ix, u16 value, char *label)
239
{
1394 tk 240
  const char waveLabel[9][5] = {
1338 tk 241
    "Sine",
242
    "Tri.",
243
    "Saw.",
244
    "Puls",
245
    "Rnd.",
246
    "PSin",
247
    "PTri",
248
    "PSaw",
249
    "PPul",
250
  };
251
 
1394 tk 252
  if( value < 10 )
1338 tk 253
    strcpy(label, waveLabel[value]);
254
  else
255
    sprintf(label, "%3d ", value);
256
}
257
 
1298 tk 258
static void stringInPort(u32 ix, u16 value, char *label)
259
{
1492 tk 260
  sprintf(label, MIDI_PORT_InNameGet(value));
1298 tk 261
}
262
 
263
static void stringOutPort(u32 ix, u16 value, char *label)
264
{
1492 tk 265
  sprintf(label, MIDI_PORT_OutNameGet(value));
1298 tk 266
}
267
 
268
static void stringRouterChn(u32 ix, u16 value, char *label)
269
{
270
  if( value == 0 )
271
    sprintf(label, "---  ");
272
  else if( value == 17 )
273
    sprintf(label, "All  ");
274
  else
275
    sprintf(label, "%3d  ", value);
276
}
277
 
278
static void stringOscPort(u32 ix, u16 value, char *label)
279
{
280
  sprintf(label, "OSC%d", value+1);
281
}
282
 
283
static void stringOscMode(u32 ix, u16 value, char *label)
284
{
285
  sprintf(label, " %s", OSC_CLIENT_TransferModeShortNameGet(value));
286
}
287
 
288
static void stringOscModeFull(u32 ix, u16 value, char *line1, char *line2)
289
{
290
  // print CC parameter on full screen (2x20)
291
  sprintf(line1, "OSC%d Transfer Mode:", selectedOscPort+1);
292
  sprintf(line2, "%s", OSC_CLIENT_TransferModeFullNameGet(value));
293
}
294
 
295
static void stringIpPar(u32 ix, u16 value, char *label)
296
{
297
  const char ipParLabel[3][6] = { "Host", "Mask", "Gate" };
298
  strcpy(label, ipParLabel[(selectedIpPar < 3) ? selectedIpPar : 0]);
299
}
300
 
301
static void stringRemoteIp(u32 ix, u16 value, char *label)
302
{
303
  char buffer[16];
304
  u32 ip = OSC_SERVER_RemoteIP_Get(selectedOscPort);
305
 
306
  sprintf(buffer, "%3d.%3d.%3d.%3d",
307
      (ip >> 24) & 0xff,
308
      (ip >> 16) & 0xff,
309
      (ip >>  8) & 0xff,
310
      (ip >>  0) & 0xff);  
311
 
312
  memcpy(label, (char *)&buffer[ix*SCS_MENU_ITEM_WIDTH], SCS_MENU_ITEM_WIDTH);
313
  label[SCS_MENU_ITEM_WIDTH] = 0;
314
}
315
 
316
static void stringIp(u32 ix, u16 value, char *label)
317
{
318
  char buffer[16];
319
 
320
  // 3 items combined to a 15 char IP string
321
  if( UIP_TASK_DHCP_EnableGet() && !UIP_TASK_ServicesRunning() ) {
322
    sprintf(buffer, "???.???.???.???");
323
  } else {
324
    u32 ip = 0;
325
    switch( selectedIpPar ) {
326
    case 0: ip = UIP_TASK_IP_EffectiveAddressGet(); break;
327
    case 1: ip = UIP_TASK_EffectiveNetmaskGet(); break;
328
    case 2: ip = UIP_TASK_EffectiveGatewayGet(); break;
329
    }
330
 
331
    sprintf(buffer, "%3d.%3d.%3d.%3d",
332
        (ip >> 24) & 0xff,
333
        (ip >> 16) & 0xff,
334
        (ip >>  8) & 0xff,
335
        (ip >>  0) & 0xff);  
336
  }
337
  memcpy(label, (char *)&buffer[ix*SCS_MENU_ITEM_WIDTH], SCS_MENU_ITEM_WIDTH);
338
  label[SCS_MENU_ITEM_WIDTH] = 0;
339
}
340
 
341
 
342
/////////////////////////////////////////////////////////////////////////////
343
// Parameter Selection Functions
344
/////////////////////////////////////////////////////////////////////////////
345
static u16  selectNOP(u32 ix, u16 value)    { return value; }
346
 
347
static void selectSAVE_Callback(char *newString)
348
{
349
  s32 status;
350
 
1453 tk 351
  if( (status=MBCV_PATCH_StoreGlobal(newString)) < 0 ) {
1298 tk 352
    char buffer[100];
353
    sprintf(buffer, "Patch %s", newString);
354
    SCS_Msg(SCS_MSG_ERROR_L, 1000, "Failed to store", buffer);
355
  } else {
356
    char buffer[100];
357
    sprintf(buffer, "Patch %s", newString);
358
    SCS_Msg(SCS_MSG_L, 1000, buffer, "stored!");
359
  }
360
}
361
static u16  selectSAVE(u32 ix, u16 value)
362
{
363
  return SCS_InstallEditStringCallback(selectSAVE_Callback, "SAVE", mbcv_file_p_patch_name, MBCV_FILE_P_FILENAME_LEN);
364
}
365
 
366
static void selectLOAD_Callback(char *newString)
367
{
368
  s32 status;
369
 
370
  if( newString[0] != 0 ) {
1453 tk 371
    if( (status=MBCV_PATCH_LoadGlobal(newString)) < 0 ) {
1298 tk 372
      char buffer[100];
373
      sprintf(buffer, "Patch %s", newString);
374
      SCS_Msg(SCS_MSG_ERROR_L, 1000, "Failed to load", buffer);
375
    } else {
376
      char buffer[100];
377
      sprintf(buffer, "Patch %s", newString);
378
      SCS_Msg(SCS_MSG_L, 1000, buffer, "loaded!");
379
    }
380
  }
381
}
382
static u8 getListLOAD_Callback(u8 offset, char *line)
383
{
384
  MUTEX_SDCARD_TAKE;
385
  s32 status = FILE_GetFiles("/", "MIO", line, 2, offset);
386
  MUTEX_SDCARD_GIVE;
387
  if( status < 1 ) {
388
    sprintf(line, "<no .MIO files>");
389
    status = 0;
390
  }
391
  return status;
392
}
393
static u16  selectLOAD(u32 ix, u16 value)
394
{
395
  return SCS_InstallEditBrowserCallback(selectLOAD_Callback, getListLOAD_Callback, "LOAD", 9, 2);
396
}
397
 
398
static void selectRemoteIp_Callback(u32 newIp)
399
{
400
  OSC_SERVER_RemoteIP_Set(selectedOscPort, newIp);
401
  OSC_SERVER_Init(0);
402
}
403
 
404
static u16 selectRemoteIp(u32 ix, u16 value)
405
{
406
  u32 initialIp = OSC_SERVER_RemoteIP_Get(selectedOscPort);
407
  SCS_InstallEditIpCallback(selectRemoteIp_Callback, "IP:", initialIp);
408
  return value;
409
}
410
 
411
static void selectIpEnter_Callback(u32 newIp)
412
{
413
  switch( selectedIpPar ) {
414
  case 0: UIP_TASK_IP_AddressSet(newIp); break;
415
  case 1: UIP_TASK_NetmaskSet(newIp); break;
416
  case 2: UIP_TASK_GatewaySet(newIp); break;
417
  }
418
}
419
 
420
static u16 selectIpEnter(u32 ix, u16 value)
421
{
422
  const char headerString[3][6] = { "Host:", "Netm:", "Gate:" };
423
 
424
  if( selectedIpPar < 3 ) {
425
    u32 initialIp = 0;
426
 
427
    switch( selectedIpPar ) {
428
    case 0: initialIp = UIP_TASK_IP_AddressGet(); break;
429
    case 1: initialIp = UIP_TASK_NetmaskGet(); break;
430
    case 2: initialIp = UIP_TASK_GatewayGet(); break;
431
    }
432
    SCS_InstallEditIpCallback(selectIpEnter_Callback, (char *)headerString[selectedIpPar], initialIp);
433
  }
434
  return value;
435
}
436
 
437
 
438
/////////////////////////////////////////////////////////////////////////////
439
// Parameter Access Functions
440
/////////////////////////////////////////////////////////////////////////////
441
static u16  dummyGet(u32 ix)              { return 0; }
442
static void dummySet(u32 ix, u16 value)   { }
443
 
1299 tk 444
static u16  cvGet(u32 ix)              { return selectedCv; }
445
static void cvSet(u32 ix, u16 value)
446
{
447
  selectedCv = value;
448
  MBCV_MAP_CaliModeSet(selectedCv, MBCV_MAP_CaliModeGet()); // change calibration mode to new pin
449
}
450
 
1334 tk 451
static u16  cvChnGet(u32 ix)            { return env->mbCv[selectedCv].mbCvMidiVoice.midivoiceChannel; }
452
static void cvChnSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvMidiVoice.midivoiceChannel = value; }
1312 tk 453
 
1334 tk 454
static u16  cvEventGet(u32 ix)            { return (u32)env->mbCv[selectedCv].mbCvVoice.voiceEventMode; }
455
static void cvEventSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvVoice.voiceEventMode = (mbcv_midi_event_mode_t)value; }
1312 tk 456
 
457
static u16  cvPlayModeGet(u32 ix)
458
{
459
  return
1334 tk 460
    (env->mbCv[selectedCv].mbCvVoice.voiceLegato ? 1 : 0) |
461
    (env->mbCv[selectedCv].mbCvVoice.voicePoly ? 2 : 0);
1312 tk 462
}
463
static void cvPlayModeSet(u32 ix, u16 value)
464
{
1334 tk 465
  env->mbCv[selectedCv].mbCvVoice.voiceLegato = (value & 1) ? 1 : 0;
466
  env->mbCv[selectedCv].mbCvVoice.voicePoly = (value & 2) ? 1 : 0;
1312 tk 467
}
468
 
1397 tk 469
static u16  cvInvGateGet(u32 ix)            { return env->mbCv[selectedCv].mbCvVoice.voiceGateInverted; }
470
static void cvInvGateSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvVoice.voiceGateInverted = value; }
1312 tk 471
 
1960 tk 472
static u16  cvExtGateThrsGet(u32 ix)            { return env->mbCv[selectedCv].mbCvVoice.voiceExternalGateThreshold; }
473
static void cvExtGateThrsSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvVoice.voiceExternalGateThreshold = value; }
474
 
1334 tk 475
static u16  cvSplitLowerGet(u32 ix)            { return env->mbCv[selectedCv].mbCvMidiVoice.midivoiceSplitLower; }
476
static void cvSplitLowerSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvMidiVoice.midivoiceSplitLower = value; }
1312 tk 477
 
1334 tk 478
static u16  cvSplitUpperGet(u32 ix)            { return env->mbCv[selectedCv].mbCvMidiVoice.midivoiceSplitUpper; }
479
static void cvSplitUpperSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvMidiVoice.midivoiceSplitUpper = value; }
1312 tk 480
 
1334 tk 481
static u16  cvPitchRangeGet(u32 ix)            { return env->mbCv[selectedCv].mbCvVoice.voicePitchrange; }
482
static void cvPitchRangeSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvVoice.voicePitchrange = value; }
1312 tk 483
 
1334 tk 484
static u16  cvTranspOctGet(u32 ix)            { return env->mbCv[selectedCv].mbCvVoice.voiceTransposeOctave + 8; }
485
static void cvTranspOctSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvVoice.voiceTransposeOctave = (int)value - 8; }
1312 tk 486
 
1334 tk 487
static u16  cvTranspSemiGet(u32 ix)            { return env->mbCv[selectedCv].mbCvVoice.voiceTransposeSemitone + 8; }
488
static void cvTranspSemiSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvVoice.voiceTransposeSemitone = (int)value - 8; }
1312 tk 489
 
1338 tk 490
static u16  cvFinetuneGet(u32 ix)            { return env->mbCv[selectedCv].mbCvVoice.voiceFinetune + 128; }
491
static void cvFinetuneSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvVoice.voiceFinetune = (int)value - 128; }
492
 
493
static u16  cvPortamentoGet(u32 ix)            { return env->mbCv[selectedCv].mbCvVoice.voicePortamentoRate; }
494
static void cvPortamentoSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvVoice.voicePortamentoRate = value; }
495
 
1394 tk 496
static u16  cvPortamentoModeGet(u32 ix)            { return env->mbCv[selectedCv].mbCvVoice.getPortamentoMode(); }
497
static void cvPortamentoModeSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvVoice.setPortamentoMode(value); }
1338 tk 498
 
499
static u16  cvSusKeyGet(u32 ix)            { return env->mbCv[selectedCv].mbCvVoice.voiceSusKey; }
500
static void cvSusKeySet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvVoice.voiceSusKey = value; }
501
 
1960 tk 502
static u16  cvForceToScaleGet(u32 ix)            { return env->mbCv[selectedCv].mbCvVoice.voiceForceToScale; }
503
static void cvForceToScaleSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvVoice.voiceForceToScale = value; }
504
 
1334 tk 505
static u16  cvCCGet(u32 ix)            { return env->mbCv[selectedCv].mbCvMidiVoice.midivoiceCCNumber; }
506
static void cvCCSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvMidiVoice.midivoiceCCNumber = value; }
1312 tk 507
 
508
static u16  cvPortGet(u32 ix)
509
{
1397 tk 510
  return env->mbCv[selectedCv].mbCvMidiVoice.getPortEnabled(ix);
1312 tk 511
}
512
static void cvPortSet(u32 ix, u16 value)
513
{
1397 tk 514
  env->mbCv[selectedCv].mbCvMidiVoice.setPortEnabled(ix, value ? 1 : 0);
1312 tk 515
}
516
 
1338 tk 517
 
1912 tk 518
/////////////////////////////////////////////////////////////////////////////
519
// ARP
520
/////////////////////////////////////////////////////////////////////////////
521
 
1338 tk 522
static u16  arpOnGet(u32 ix)            { return env->mbCv[selectedCv].mbCvArp.arpEnabled; }
523
static void arpOnSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvArp.arpEnabled = value; }
524
 
1394 tk 525
static u16  arpDirGet(u32 ix)            { return env->mbCv[selectedCv].mbCvArp.arpDirGet(); }
526
static void arpDirSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvArp.arpDirSet(value); }
1338 tk 527
 
528
static u16  arpSpeedGet(u32 ix)            { return env->mbCv[selectedCv].mbCvArp.arpSpeed; }
529
static void arpSpeedSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvArp.arpSpeed = value; }
530
 
531
static u16  arpGatelenGet(u32 ix)            { return env->mbCv[selectedCv].mbCvArp.arpGatelength; }
532
static void arpGatelenSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvArp.arpGatelength = value; }
533
 
534
static u16  arpRangeGet(u32 ix)            { return env->mbCv[selectedCv].mbCvArp.arpOctaveRange; }
535
static void arpRangeSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvArp.arpOctaveRange = value; }
536
 
537
static u16  arpSortGet(u32 ix)            { return env->mbCv[selectedCv].mbCvArp.arpSortedNotes; }
538
static void arpSortSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvArp.arpSortedNotes = value; }
539
 
540
static u16  arpHoldGet(u32 ix)            { return env->mbCv[selectedCv].mbCvArp.arpHoldMode; }
541
static void arpHoldSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvArp.arpHoldMode = value; }
542
 
543
static u16  arpSyncGet(u32 ix)            { return env->mbCv[selectedCv].mbCvArp.arpSyncMode; }
544
static void arpSyncSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvArp.arpSyncMode = value; }
545
 
546
static u16  arpCACGet(u32 ix)            { return env->mbCv[selectedCv].mbCvArp.arpConstantCycle; }
547
static void arpCACSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvArp.arpConstantCycle = value; }
548
 
549
static u16  arpOneshotGet(u32 ix)            { return env->mbCv[selectedCv].mbCvArp.arpOneshotMode; }
550
static void arpOneshotSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvArp.arpOneshotMode = value; }
551
 
552
static u16  arpEasyChordGet(u32 ix)            { return env->mbCv[selectedCv].mbCvArp.arpEasyChordMode; }
553
static void arpEasyChordSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvArp.arpEasyChordMode = value; }
554
 
1912 tk 555
 
556
/////////////////////////////////////////////////////////////////////////////
557
// LFO
558
/////////////////////////////////////////////////////////////////////////////
559
 
1338 tk 560
static u16  lfoGet(u32 ix)            { return selectedLfo; }
561
static void lfoSet(u32 ix, u16 value) { selectedLfo = value; }
562
 
563
static u16  lfoWaveGet(u32 ix)
564
{
1394 tk 565
  return env->mbCv[selectedCv].mbCvLfo[selectedLfo].lfoWaveform;
1338 tk 566
}
567
static void lfoWaveSet(u32 ix, u16 value)
568
{
1394 tk 569
  env->mbCv[selectedCv].mbCvLfo[selectedLfo].lfoWaveform = value;
1338 tk 570
}
571
 
572
static u16  lfoAmplitudeGet(u32 ix)            { return env->mbCv[selectedCv].mbCvLfo[selectedLfo].lfoAmplitude + 128; }
573
static void lfoAmplitudeSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvLfo[selectedLfo].lfoAmplitude = value - 128; }
574
 
575
static u16  lfoRateGet(u32 ix)            { return env->mbCv[selectedCv].mbCvLfo[selectedLfo].lfoRate; }
576
static void lfoRateSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvLfo[selectedLfo].lfoRate = value; }
577
 
1347 tk 578
static u16  lfoClkSyncGet(u32 ix)            { return env->mbCv[selectedCv].mbCvLfo[selectedLfo].lfoModeClkSync; }
579
static void lfoClkSyncSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvLfo[selectedLfo].lfoModeClkSync = value; }
1338 tk 580
 
1347 tk 581
static u16  lfoKeySyncGet(u32 ix)            { return env->mbCv[selectedCv].mbCvLfo[selectedLfo].lfoModeKeySync; }
582
static void lfoKeySyncSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvLfo[selectedLfo].lfoModeKeySync = value; }
1338 tk 583
 
1347 tk 584
static u16  lfoOneshotGet(u32 ix)            { return env->mbCv[selectedCv].mbCvLfo[selectedLfo].lfoModeOneshot; }
585
static void lfoOneshotSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvLfo[selectedLfo].lfoModeOneshot = value; }
1338 tk 586
 
1347 tk 587
static u16  lfoModeFastGet(u32 ix)            { return env->mbCv[selectedCv].mbCvLfo[selectedLfo].lfoModeFast; }
588
static void lfoModeFastSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvLfo[selectedLfo].lfoModeFast = value; }
589
 
1338 tk 590
static u16  lfoDelayGet(u32 ix)            { return env->mbCv[selectedCv].mbCvLfo[selectedLfo].lfoDelay; }
1347 tk 591
static void lfoDelaySet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvLfo[selectedLfo].lfoDelay = value; }
1338 tk 592
 
593
static u16  lfoPhaseGet(u32 ix)            { return env->mbCv[selectedCv].mbCvLfo[selectedLfo].lfoPhase; }
1347 tk 594
static void lfoPhaseSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvLfo[selectedLfo].lfoPhase = value; }
1338 tk 595
 
596
static u16  lfoDepthCvGet(u32 ix)            { return env->mbCv[selectedCv].mbCvLfo[selectedLfo].lfoDepthPitch + 128; }
597
static void lfoDepthCvSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvLfo[selectedLfo].lfoDepthPitch = value - 128; }
598
 
599
static u16  lfoDepthLfoAmpGet(u32 ix)            { return env->mbCv[selectedCv].mbCvLfo[selectedLfo].lfoDepthLfoAmplitude + 128; }
600
static void lfoDepthLfoAmpSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvLfo[selectedLfo].lfoDepthLfoAmplitude = value - 128; }
601
 
602
static u16  lfoDepthLfoRateGet(u32 ix)            { return env->mbCv[selectedCv].mbCvLfo[selectedLfo].lfoDepthLfoRate + 128; }
603
static void lfoDepthLfoRateSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvLfo[selectedLfo].lfoDepthLfoRate = value - 128; }
604
 
1398 tk 605
static u16  lfoDepthEnv1RateGet(u32 ix)            { return env->mbCv[selectedCv].mbCvLfo[selectedLfo].lfoDepthEnv1Rate + 128; }
606
static void lfoDepthEnv1RateSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvLfo[selectedLfo].lfoDepthEnv1Rate = value - 128; }
1338 tk 607
 
1398 tk 608
static u16  lfoDepthEnv2RateGet(u32 ix)            { return env->mbCv[selectedCv].mbCvLfo[selectedLfo].lfoDepthEnv2Rate + 128; }
609
static void lfoDepthEnv2RateSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvLfo[selectedLfo].lfoDepthEnv2Rate = value - 128; }
1338 tk 610
 
611
 
1912 tk 612
/////////////////////////////////////////////////////////////////////////////
613
// ENV1
614
/////////////////////////////////////////////////////////////////////////////
1338 tk 615
 
1912 tk 616
static u16  env1AmplitudeGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv1[selectedEnv1].envAmplitude + 128; }
617
static void env1AmplitudeSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv1[selectedEnv1].envAmplitude = value - 128; }
1338 tk 618
 
1912 tk 619
static u16  env1DelayGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv1[selectedEnv1].envDelay; }
620
static void env1DelaySet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv1[selectedEnv1].envDelay = value; }
1338 tk 621
 
1912 tk 622
static u16  env1AttackGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv1[selectedEnv1].envAttack; }
623
static void env1AttackSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv1[selectedEnv1].envAttack = value; }
1338 tk 624
 
1912 tk 625
static u16  env1DecayGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv1[selectedEnv1].envDecay; }
626
static void env1DecaySet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv1[selectedEnv1].envDecay = value; }
1338 tk 627
 
1912 tk 628
static u16  env1SustainGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv1[selectedEnv1].envSustain; }
629
static void env1SustainSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv1[selectedEnv1].envSustain = value; }
1338 tk 630
 
1912 tk 631
static u16  env1ReleaseGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv1[selectedEnv1].envRelease; }
632
static void env1ReleaseSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv1[selectedEnv1].envRelease = value; }
1338 tk 633
 
1960 tk 634
static u16  env1CurvePosGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv1[selectedEnv1].envCurvePos; }
635
static void env1CurvePosSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv1[selectedEnv1].envCurvePos = value; }
1338 tk 636
 
1960 tk 637
static u16  env1CurveNegGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv1[selectedEnv1].envCurveNeg; }
638
static void env1CurveNegSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv1[selectedEnv1].envCurveNeg = value; }
639
 
1912 tk 640
static u16  env1ClkSyncGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv1[selectedEnv1].envModeClkSync; }
641
static void env1ClkSyncSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv1[selectedEnv1].envModeClkSync = value; }
1338 tk 642
 
1912 tk 643
static u16  env1KeySyncGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv1[selectedEnv1].envModeKeySync; }
644
static void env1KeySyncSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv1[selectedEnv1].envModeKeySync = value; }
1338 tk 645
 
1912 tk 646
static u16  env1OneshotGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv1[selectedEnv1].envModeOneshot; }
647
static void env1OneshotSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv1[selectedEnv1].envModeOneshot = value; }
1338 tk 648
 
1912 tk 649
static u16  env1ModeFastGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv1[selectedEnv1].envModeFast; }
650
static void env1ModeFastSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv1[selectedEnv1].envModeFast = value; }
1394 tk 651
 
1912 tk 652
static u16  env1DepthCvGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv1[selectedEnv1].envDepthPitch + 128; }
653
static void env1DepthCvSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv1[selectedEnv1].envDepthPitch = value - 128; }
1394 tk 654
 
1912 tk 655
static u16  env1DepthLfo1AmpGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv1[selectedEnv1].envDepthLfo1Amplitude + 128; }
656
static void env1DepthLfo1AmpSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv1[selectedEnv1].envDepthLfo1Amplitude = value - 128; }
657
 
658
static u16  env1DepthLfo1RateGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv1[selectedEnv1].envDepthLfo1Rate + 128; }
659
static void env1DepthLfo1RateSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv1[selectedEnv1].envDepthLfo1Rate = value - 128; }
660
 
661
static u16  env1DepthLfo2AmpGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv1[selectedEnv1].envDepthLfo2Amplitude + 128; }
662
static void env1DepthLfo2AmpSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv1[selectedEnv1].envDepthLfo2Amplitude = value - 128; }
663
 
664
static u16  env1DepthLfo2RateGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv1[selectedEnv1].envDepthLfo2Rate + 128; }
665
static void env1DepthLfo2RateSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv1[selectedEnv1].envDepthLfo2Rate = value - 128; }
666
 
667
 
668
/////////////////////////////////////////////////////////////////////////////
669
// ENV2
670
/////////////////////////////////////////////////////////////////////////////
671
 
672
static u16  env2AmplitudeGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envAmplitude + 128; }
673
static void env2AmplitudeSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envAmplitude = value - 128; }
674
 
675
static u16  env2OffsetGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envOffset + 128; }
676
static void env2OffsetSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envOffset = value - 128; }
677
 
678
static u16  env2RateGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envRate; }
679
static void env2RateSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envRate = value; }
680
 
1960 tk 681
static u16  env2CurvePosGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envCurvePos; }
682
static void env2CurvePosSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envCurvePos = value; }
1912 tk 683
 
1960 tk 684
static u16  env2CurveNegGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envCurveNeg; }
685
static void env2CurveNegSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envCurveNeg = value; }
686
 
1912 tk 687
static u16  env2LastStepGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envLastStep; }
688
static void env2LastStepSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envLastStep = value; }
689
 
690
static u16  env2LoopAttackGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envLoopAttack; }
691
static void env2LoopAttackSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envLoopAttack = value; }
692
 
693
static u16  env2SustainStepGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envSustainStep; }
694
static void env2SustainStepSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envSustainStep = value; }
695
 
696
static u16  env2LoopReleaseGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envLoopRelease; }
697
static void env2LoopReleaseSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envLoopRelease = value; }
698
 
699
static u16  env2ClkSyncGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envModeClkSync; }
700
static void env2ClkSyncSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envModeClkSync = value; }
701
 
702
static u16  env2KeySyncGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envModeKeySync; }
703
static void env2KeySyncSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envModeKeySync = value; }
704
 
705
static u16  env2OneshotGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envModeOneshot; }
706
static void env2OneshotSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envModeOneshot = value; }
707
 
708
static u16  env2ModeFastGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envModeFast; }
709
static void env2ModeFastSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envModeFast = value; }
710
 
711
static u16  env2DepthCvGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envDepthPitch + 128; }
712
static void env2DepthCvSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envDepthPitch = value - 128; }
713
 
714
static u16  env2DepthLfo1AmpGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envDepthLfo1Amplitude + 128; }
715
static void env2DepthLfo1AmpSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envDepthLfo1Amplitude = value - 128; }
716
 
717
static u16  env2DepthLfo1RateGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envDepthLfo1Rate + 128; }
718
static void env2DepthLfo1RateSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envDepthLfo1Rate = value - 128; }
719
 
720
static u16  env2DepthLfo2AmpGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envDepthLfo2Amplitude + 128; }
721
static void env2DepthLfo2AmpSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envDepthLfo2Amplitude = value - 128; }
722
 
723
static u16  env2DepthLfo2RateGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envDepthLfo2Rate + 128; }
724
static void env2DepthLfo2RateSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envDepthLfo2Rate = value - 128; }
725
 
726
static u16  env2StepLevelGet(u32 ix)            { return env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envLevel[ix]; }
727
static void env2StepLevelSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvEnv2[selectedEnv2].envLevel[ix] = value; }
728
 
729
 
730
/////////////////////////////////////////////////////////////////////////////
731
// AOUT
732
/////////////////////////////////////////////////////////////////////////////
733
 
1397 tk 734
static u16  cvCurveGet(u32 ix)            { return (u32)env->mbCv[selectedCv].mbCvVoice.getAoutCurve(); }
735
static void cvCurveSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvVoice.setAoutCurve(value); }
1299 tk 736
 
1397 tk 737
static u16  cvSlewRateGet(u32 ix)            { return env->mbCv[selectedCv].mbCvVoice.getAoutSlewRate(); }
738
static void cvSlewRateSet(u32 ix, u16 value) { env->mbCv[selectedCv].mbCvVoice.setAoutSlewRate(value); }
1299 tk 739
 
740
static u16  cvCaliModeGet(u32 ix)            { return MBCV_MAP_CaliModeGet(); }
1334 tk 741
static void cvCaliModeSet(u32 ix, u16 value) { MBCV_MAP_CaliModeSet(selectedCv, (aout_cali_mode_t)value); }
1299 tk 742
 
743
static u16  aoutIfGet(u32 ix)              { return MBCV_MAP_IfGet(); }
1334 tk 744
static void aoutIfSet(u32 ix, u16 value)   { MBCV_MAP_IfSet((aout_if_t)value); }
1299 tk 745
 
1914 tk 746
static u16  cvUpdateRateGet(u32 ix)            { return APP_CvUpdateRateFactorGet() - 1; }
747
static void cvUpdateRateSet(u32 ix, u16 value) { APP_CvUpdateRateFactorSet(value+1); }
748
 
1917 tk 749
static u16  scopeGet(u32 ix)            { return selectedScope; }
750
static void scopeSet(u32 ix, u16 value) { selectedScope = value; }
1887 tk 751
 
1917 tk 752
static u16  scopeSourceGet(u32 ix)            { return env->mbCvScope[selectedScope].getSource(); }
753
static void scopeSourceSet(u32 ix, u16 value) { env->mbCvScope[selectedScope].setSource(value); }
1887 tk 754
 
1917 tk 755
static u16  scopeOversamplingGet(u32 ix)            { return env->mbCvScope[selectedScope].getOversamplingFactor(); }
756
static void scopeOversamplingSet(u32 ix, u16 value) { env->mbCvScope[selectedScope].setOversamplingFactor(value); }
1887 tk 757
 
1917 tk 758
static u16  scopeTriggerGet(u32 ix)            { return env->mbCvScope[selectedScope].getTrigger(); }
759
static void scopeTriggerSet(u32 ix, u16 value) { env->mbCvScope[selectedScope].setTrigger(value); }
1912 tk 760
 
1917 tk 761
 
1912 tk 762
/////////////////////////////////////////////////////////////////////////////
763
// Router
764
/////////////////////////////////////////////////////////////////////////////
765
 
1298 tk 766
static u16  routerNodeGet(u32 ix)             { return selectedRouterNode; }
767
static void routerNodeSet(u32 ix, u16 value)  { selectedRouterNode = value; }
768
 
1530 tk 769
static u16  routerSrcPortGet(u32 ix)             { return MIDI_PORT_InIxGet((mios32_midi_port_t)midi_router_node[selectedRouterNode].src_port); }
770
static void routerSrcPortSet(u32 ix, u16 value)  { midi_router_node[selectedRouterNode].src_port = MIDI_PORT_InPortGet(value); }
1298 tk 771
 
1530 tk 772
static u16  routerSrcChnGet(u32 ix)              { return midi_router_node[selectedRouterNode].src_chn; }
773
static void routerSrcChnSet(u32 ix, u16 value)   { midi_router_node[selectedRouterNode].src_chn = value; }
1298 tk 774
 
1530 tk 775
static u16  routerDstPortGet(u32 ix)             { return MIDI_PORT_OutIxGet((mios32_midi_port_t)midi_router_node[selectedRouterNode].dst_port); }
776
static void routerDstPortSet(u32 ix, u16 value)  { midi_router_node[selectedRouterNode].dst_port = MIDI_PORT_OutPortGet(value); }
1298 tk 777
 
1530 tk 778
static u16  routerDstChnGet(u32 ix)              { return midi_router_node[selectedRouterNode].dst_chn; }
779
static void routerDstChnSet(u32 ix, u16 value)   { midi_router_node[selectedRouterNode].dst_chn = value; }
1298 tk 780
 
1912 tk 781
 
782
/////////////////////////////////////////////////////////////////////////////
783
// OSC/Network
784
/////////////////////////////////////////////////////////////////////////////
785
 
1298 tk 786
static u16  oscPortGet(u32 ix)            { return selectedOscPort; }
787
static void oscPortSet(u32 ix, u16 value) { selectedOscPort = value; }
788
static u16  oscRemotePortGet(u32 ix)            { return OSC_SERVER_RemotePortGet(selectedOscPort); }
789
static void oscRemotePortSet(u32 ix, u16 value) { OSC_SERVER_RemotePortSet(selectedOscPort, value); OSC_SERVER_Init(0); }
790
static u16  oscLocalPortGet(u32 ix)             { return OSC_SERVER_LocalPortGet(selectedOscPort); }
791
static void oscLocalPortSet(u32 ix, u16 value)  { OSC_SERVER_LocalPortSet(selectedOscPort, value);  OSC_SERVER_Init(0); }
792
static u16  oscModeGet(u32 ix)                  { return OSC_CLIENT_TransferModeGet(selectedOscPort); }
793
static void oscModeSet(u32 ix, u16 value)       { OSC_CLIENT_TransferModeSet(selectedOscPort, value); }
794
 
795
static u16  dhcpGet(u32 ix)                { return UIP_TASK_DHCP_EnableGet(); }
796
static void dhcpSet(u32 ix, u16 value)     { UIP_TASK_DHCP_EnableSet(value); }
797
static u16  selIpParGet(u32 ix)            { return selectedIpPar; }
798
static void selIpParSet(u32 ix, u16 value)
799
{
800
  selectedIpPar = value;
801
}
802
 
803
 
804
 
805
static void MSD_EnableReq(u32 enable)
806
{
807
  TASK_MSD_EnableSet(enable);
1334 tk 808
  SCS_Msg(SCS_MSG_L, 1000, "Mass Storage", (char *)(enable ? "enabled!" : "disabled!"));
1298 tk 809
}
810
 
811
/////////////////////////////////////////////////////////////////////////////
812
// Menu Structure
813
/////////////////////////////////////////////////////////////////////////////
814
 
1312 tk 815
const scs_menu_item_t pageCV[] = {
1453 tk 816
  SCS_ITEM(" CV  ", 0, CV_SE_NUM-1, cvGet, cvSet, selectNOP, stringDecP1, NULL),
1312 tk 817
  SCS_ITEM("Chn  ", 0, 16,    cvChnGet,      cvChnSet,      selectNOP, stringDec0Dis, NULL),
1334 tk 818
  SCS_ITEM("Mode ", 0, MBCV_MIDI_EVENT_MODE_NUM-1,    cvEventGet,     cvEventSet,     selectNOP, stringCvMode, NULL),
1312 tk 819
  SCS_ITEM("Play ", 0, 2,     cvPlayModeGet, cvPlayModeSet, selectNOP, stringCvPlayMode, NULL),
820
  SCS_ITEM("InvG ", 0, 1,     cvInvGateGet,  cvInvGateSet,  selectNOP, stringOnOff, NULL),
1960 tk 821
  SCS_ITEM("ExtG ", 0, 255,   cvExtGateThrsGet,cvExtGateThrsSet,  selectNOP, stringDec, NULL),
1312 tk 822
  SCS_ITEM("SplL ", 0, 127,   cvSplitLowerGet,cvSplitLowerSet,selectNOP, stringNote, NULL),
823
  SCS_ITEM("SplU ", 0, 127,   cvSplitUpperGet,cvSplitUpperSet,selectNOP, stringNote, NULL),
824
  SCS_ITEM("PRng ", 0, 24,    cvPitchRangeGet,cvPitchRangeSet,selectNOP, stringDec, NULL),
825
  SCS_ITEM("Oct. ", 0, 15,    cvTranspOctGet, cvTranspOctSet,selectNOP, stringCvTranspose, NULL),
826
  SCS_ITEM("Semi ", 0, 15,    cvTranspSemiGet,cvTranspSemiSet,selectNOP,stringCvTranspose, NULL),
1338 tk 827
  SCS_ITEM("Fine ", 0, 255,   cvFinetuneGet,  cvFinetuneSet, selectNOP, stringDecPM128, NULL),
828
  SCS_ITEM("Port ", 0, 255,   cvPortamentoGet,cvPortamentoSet,selectNOP, stringDec, NULL),
829
  SCS_ITEM("PMod ", 0, 2,     cvPortamentoModeGet,cvPortamentoModeSet,selectNOP, stringCvPortamentoMode, NULL),
830
  SCS_ITEM("SusK ", 0, 1,     cvSusKeyGet,    cvSusKeySet,    selectNOP, stringOnOff, NULL),
1960 tk 831
  SCS_ITEM("FtS  ", 0, 1,     cvForceToScaleGet, cvForceToScaleSet,    selectNOP, stringOnOff, NULL),
1912 tk 832
  SCS_ITEM(" CC  ", 0, 127,   cvCCGet,        cvCCSet,       selectNOP,stringDec, NULL),
1312 tk 833
  SCS_ITEM("USB1 ", 0, 1,           cvPortGet,      cvPortSet,      selectNOP, stringOnOff, NULL),
834
#if MIOS32_USB_MIDI_NUM_PORTS >= 2
835
  SCS_ITEM("USB2 ", 1, 1,           cvPortGet,      cvPortSet,      selectNOP, stringOnOff, NULL),
836
#endif
837
#if MIOS32_USB_MIDI_NUM_PORTS >= 3
838
  SCS_ITEM("USB3 ", 2, 1,           cvPortGet,      cvPortSet,      selectNOP, stringOnOff, NULL),
839
#endif
840
#if MIOS32_USB_MIDI_NUM_PORTS >= 4
841
  SCS_ITEM("USB4 ", 3, 1,           cvPortGet,      cvPortSet,      selectNOP, stringOnOff, NULL),
842
#endif
843
  SCS_ITEM("IN1  ", 4, 1,           cvPortGet,      cvPortSet,      selectNOP, stringOnOff, NULL),
844
  SCS_ITEM("IN2  ", 5, 1,           cvPortGet,      cvPortSet,      selectNOP, stringOnOff, NULL),
845
#if MIOS32_UART_NUM >= 3
846
  SCS_ITEM("IN3  ", 6, 1,           cvPortGet,      cvPortSet,      selectNOP, stringOnOff, NULL),
847
#endif
848
#if MIOS32_UART_NUM >= 4
849
  SCS_ITEM("IN4  ", 7, 1,           cvPortGet,      cvPortSet,      selectNOP, stringOnOff, NULL),
850
#endif
851
  SCS_ITEM("OSC1 ",12, 1,           cvPortGet,      cvPortSet,      selectNOP, stringOnOff, NULL),
852
  SCS_ITEM("OSC2 ",13, 1,           cvPortGet,      cvPortSet,      selectNOP, stringOnOff, NULL),
853
  SCS_ITEM("OSC3 ",14, 1,           cvPortGet,      cvPortSet,      selectNOP, stringOnOff, NULL),
854
  SCS_ITEM("OSC4 ",15, 1,           cvPortGet,      cvPortSet,      selectNOP, stringOnOff, NULL),
855
};
856
 
1338 tk 857
const scs_menu_item_t pageARP[] = {
1453 tk 858
  SCS_ITEM(" CV  ", 0, CV_SE_NUM-1, cvGet, cvSet, selectNOP, stringDecP1, NULL),
1338 tk 859
  SCS_ITEM(" On  ", 0,  1,          arpOnGet,       arpOnSet,       selectNOP, stringOnOff,  NULL),
860
  SCS_ITEM("Mode ", 0,  6,          arpDirGet,      arpDirSet,      selectNOP, stringArpDir, NULL),
861
  SCS_ITEM("Sort ", 0,  1,          arpSortGet,     arpSortSet,     selectNOP, stringOnOff,  NULL),
862
  SCS_ITEM("Hold ", 0,  1,          arpHoldGet,     arpHoldSet,     selectNOP, stringOnOff,  NULL),
863
  SCS_ITEM("Spd. ", 0, 63,          arpSpeedGet,    arpSpeedSet,    selectNOP, stringDecP1,  NULL),
864
  SCS_ITEM("GLn. ", 0, 31,          arpGatelenGet,  arpGatelenSet,  selectNOP, stringDecP1,  NULL),
865
  SCS_ITEM("Rnge ", 0,  7,          arpRangeGet,    arpRangeSet,    selectNOP, stringDecP1,  NULL),
866
  SCS_ITEM("Sync ", 0,  1,          arpSyncGet,     arpSyncSet,     selectNOP, stringOnOff,  NULL),
867
  SCS_ITEM("CAC  ", 0,  1,          arpCACGet,      arpCACSet,      selectNOP, stringOnOff,  NULL),
868
  SCS_ITEM("OSht ", 0,  1,          arpOneshotGet,  arpOneshotSet,  selectNOP, stringOnOff,  NULL),
869
  SCS_ITEM("Easy ", 0,  1,          arpEasyChordGet,arpEasyChordSet,selectNOP, stringOnOff,  NULL),
870
};
871
 
872
const scs_menu_item_t pageLFO[] = {
1453 tk 873
  SCS_ITEM(" CV  ", 0, CV_SE_NUM-1, cvGet, cvSet, selectNOP, stringDecP1, NULL),
1338 tk 874
  SCS_ITEM("LFO  ", 0,   1,         lfoGet,         lfoSet,         selectNOP, stringDecP1, NULL),
875
  SCS_ITEM("Ampl ", 0, 255,         lfoAmplitudeGet,lfoAmplitudeSet,selectNOP, stringDecPM128, NULL),
1347 tk 876
  SCS_ITEM("Rate ", 0, 255,         lfoRateGet,     lfoRateSet,     selectNOP, stringLfoRate, NULL),
877
  SCS_ITEM("Wave ", 0,   9,         lfoWaveGet,     lfoWaveSet,     selectNOP, stringLfoWave, NULL),
1338 tk 878
  SCS_ITEM("ClkS ", 0,   1,         lfoClkSyncGet,  lfoClkSyncSet,  selectNOP, stringOnOff, NULL),
879
  SCS_ITEM("KeyS ", 0,   1,         lfoKeySyncGet,  lfoKeySyncSet,  selectNOP, stringOnOff, NULL),
880
  SCS_ITEM("Dely ", 0, 255,         lfoDelayGet,    lfoDelaySet,    selectNOP, stringDec, NULL),
881
  SCS_ITEM("Phse ", 0, 255,         lfoPhaseGet,    lfoPhaseSet,    selectNOP, stringDec, NULL),
1912 tk 882
  SCS_ITEM("Fast ", 0,   1,         lfoModeFastGet, lfoModeFastSet, selectNOP, stringOnOff, NULL),
1338 tk 883
  SCS_ITEM("OSht ", 0,   1,         lfoOneshotGet,  lfoOneshotSet,  selectNOP, stringOnOff, NULL),
884
  SCS_ITEM("D.CV ", 0, 255,         lfoDepthCvGet,  lfoDepthCvSet,  selectNOP, stringDecPM128, NULL),
885
  SCS_ITEM("DLAmp", 0, 255,         lfoDepthLfoAmpGet,lfoDepthLfoAmpSet,selectNOP, stringDecPM128, NULL),
886
  SCS_ITEM("DLRte", 0, 255,         lfoDepthLfoRateGet,lfoDepthLfoRateSet,selectNOP, stringDecPM128, NULL),
1398 tk 887
  SCS_ITEM("DE1Rt", 0, 255,         lfoDepthEnv1RateGet,lfoDepthEnv1RateSet,selectNOP, stringDecPM128, NULL),
888
  SCS_ITEM("DE2Rt", 0, 255,         lfoDepthEnv2RateGet,lfoDepthEnv2RateSet,selectNOP, stringDecPM128, NULL),
1338 tk 889
};
890
 
1394 tk 891
const scs_menu_item_t pageENV1[] = {
1453 tk 892
  SCS_ITEM(" CV  ", 0, CV_SE_NUM-1, cvGet, cvSet, selectNOP, stringDecP1, NULL),
1912 tk 893
  SCS_ITEM("Ampl ", 0, 255,         env1AmplitudeGet,env1AmplitudeSet,selectNOP, stringDecPM128, NULL),
894
  SCS_ITEM("Dely ", 0, 255,         env1DelayGet,    env1DelaySet,    selectNOP, stringDec, NULL),
895
  SCS_ITEM("Atk. ", 0, 255,         env1AttackGet,   env1AttackSet,   selectNOP, stringDec, NULL),
896
  SCS_ITEM("Dec. ", 0, 255,         env1DecayGet,    env1DecaySet,    selectNOP, stringDec, NULL),
897
  SCS_ITEM("Sus. ", 0, 255,         env1SustainGet,  env1SustainSet,  selectNOP, stringDec, NULL),
898
  SCS_ITEM("Rel. ", 0, 255,         env1ReleaseGet,  env1ReleaseSet,  selectNOP, stringDec, NULL),
1960 tk 899
  SCS_ITEM("Cur+ ", 0, MBCV_ENV_NUM_CURVES-1, env1CurvePosGet, env1CurvePosSet, selectNOP, stringCurve, NULL),
900
  SCS_ITEM("Cur- ", 0, MBCV_ENV_NUM_CURVES-1, env1CurveNegGet, env1CurveNegSet, selectNOP, stringCurve, NULL),
1912 tk 901
  SCS_ITEM("ClkS ", 0,   1,         env1ClkSyncGet,  env1ClkSyncSet,  selectNOP, stringOnOff, NULL),
902
  SCS_ITEM("KeyS ", 0,   1,         env1KeySyncGet,  env1KeySyncSet,  selectNOP, stringOnOff, NULL),
903
  SCS_ITEM("Fast ", 0,   1,         env1ModeFastGet, env1ModeFastSet, selectNOP, stringOnOff, NULL),
904
  SCS_ITEM("OSht ", 0,   1,         env1OneshotGet,  env1OneshotSet,  selectNOP, stringOnOff, NULL),
905
  SCS_ITEM("D.CV ", 0, 255,         env1DepthCvGet,  env1DepthCvSet,  selectNOP, stringDecPM128, NULL),
906
  SCS_ITEM("DL1A ", 0, 255,         env1DepthLfo1AmpGet,env1DepthLfo1AmpSet,selectNOP, stringDecPM128, NULL),
907
  SCS_ITEM("DL1R ", 0, 255,         env1DepthLfo1RateGet,env1DepthLfo1RateSet,selectNOP, stringDecPM128, NULL),
908
  SCS_ITEM("DL2A ", 0, 255,         env1DepthLfo2AmpGet,env1DepthLfo2AmpSet,selectNOP, stringDecPM128, NULL),
909
  SCS_ITEM("DL2R ", 0, 255,         env1DepthLfo2RateGet,env1DepthLfo2RateSet,selectNOP, stringDecPM128, NULL),
1338 tk 910
};
911
 
1912 tk 912
const scs_menu_item_t pageENV2[] = {
913
  SCS_ITEM(" CV  ", 0, CV_SE_NUM-1, cvGet, cvSet, selectNOP, stringDecP1, NULL),
914
  SCS_ITEM("Ampl ", 0, 255,         env2AmplitudeGet,   env2AmplitudeSet,selectNOP, stringDecPM128, NULL),
915
  SCS_ITEM("Offs ", 0, 255,         env2OffsetGet,      env2OffsetSet,   selectNOP, stringDecPM128, NULL),
916
  SCS_ITEM("Rate ", 0, 255,         env2RateGet,        env2RateSet,     selectNOP, stringDec, NULL),
1960 tk 917
  SCS_ITEM("Cur+ ", 0, MBCV_ENV_NUM_CURVES-1, env2CurvePosGet, env2CurvePosSet, selectNOP, stringCurve, NULL),
918
  SCS_ITEM("Cur- ", 0, MBCV_ENV_NUM_CURVES-1, env2CurveNegGet, env2CurveNegSet, selectNOP, stringCurve, NULL),
1912 tk 919
  SCS_ITEM("Stps ", 0,  15,         env2LastStepGet,    env2LastStepSet, selectNOP, stringDecP1, NULL),
920
  SCS_ITEM("LpAt ", 0,  16,         env2LoopAttackGet,  env2LoopAttackSet,    selectNOP, stringDec, NULL),
921
  SCS_ITEM("SusS ", 0,  16,         env2SustainStepGet, env2SustainStepSet,    selectNOP, stringDec, NULL),
922
  SCS_ITEM("LpRl ", 0,  16,         env2LoopReleaseGet, env2LoopReleaseSet,    selectNOP, stringDec, NULL),
923
  SCS_ITEM("ClkS ", 0,   1,         env2ClkSyncGet,     env2ClkSyncSet,  selectNOP, stringOnOff, NULL),
924
  SCS_ITEM("KeyS ", 0,   1,         env2KeySyncGet,     env2KeySyncSet,  selectNOP, stringOnOff, NULL),
925
  SCS_ITEM("Fast ", 0,   1,         env2ModeFastGet,    env2ModeFastSet, selectNOP, stringOnOff, NULL),
926
  SCS_ITEM("OSht ", 0,   1,         env2OneshotGet,     env2OneshotSet,  selectNOP, stringOnOff, NULL),
927
  SCS_ITEM("D.CV ", 0, 255,         env2DepthCvGet,     env2DepthCvSet,  selectNOP, stringDecPM128, NULL),
928
  SCS_ITEM("DL1A ", 0, 255,         env2DepthLfo1AmpGet,env2DepthLfo1AmpSet,selectNOP, stringDecPM128, NULL),
929
  SCS_ITEM("DL1R ", 0, 255,         env2DepthLfo1RateGet,env2DepthLfo1RateSet,selectNOP, stringDecPM128, NULL),
930
  SCS_ITEM("DL2A ", 0, 255,         env2DepthLfo2AmpGet,env2DepthLfo2AmpSet,selectNOP, stringDecPM128, NULL),
931
  SCS_ITEM("DL2R ", 0, 255,         env2DepthLfo2RateGet,env2DepthLfo2RateSet,selectNOP, stringDecPM128, NULL),
932
  SCS_ITEM("Lvl1 ", 0, 255,         env2StepLevelGet,   env2StepLevelSet,selectNOP, stringDecPM128, NULL),
933
  SCS_ITEM("Lvl2 ", 1, 255,         env2StepLevelGet,   env2StepLevelSet,selectNOP, stringDecPM128, NULL),
934
  SCS_ITEM("Lvl3 ", 2, 255,         env2StepLevelGet,   env2StepLevelSet,selectNOP, stringDecPM128, NULL),
935
  SCS_ITEM("Lvl4 ", 3, 255,         env2StepLevelGet,   env2StepLevelSet,selectNOP, stringDecPM128, NULL),
936
  SCS_ITEM("Lvl5 ", 4, 255,         env2StepLevelGet,   env2StepLevelSet,selectNOP, stringDecPM128, NULL),
937
  SCS_ITEM("Lvl6 ", 5, 255,         env2StepLevelGet,   env2StepLevelSet,selectNOP, stringDecPM128, NULL),
938
  SCS_ITEM("Lvl7 ", 6, 255,         env2StepLevelGet,   env2StepLevelSet,selectNOP, stringDecPM128, NULL),
939
  SCS_ITEM("Lvl8 ", 7, 255,         env2StepLevelGet,   env2StepLevelSet,selectNOP, stringDecPM128, NULL),
940
  SCS_ITEM("Lvl9 ", 8, 255,         env2StepLevelGet,   env2StepLevelSet,selectNOP, stringDecPM128, NULL),
941
  SCS_ITEM("Lvl10", 9, 255,         env2StepLevelGet,   env2StepLevelSet,selectNOP, stringDecPM128, NULL),
942
  SCS_ITEM("Lvl11", 10, 255,        env2StepLevelGet,   env2StepLevelSet,selectNOP, stringDecPM128, NULL),
943
  SCS_ITEM("Lvl12", 11, 255,        env2StepLevelGet,   env2StepLevelSet,selectNOP, stringDecPM128, NULL),
944
  SCS_ITEM("Lvl13", 12, 255,        env2StepLevelGet,   env2StepLevelSet,selectNOP, stringDecPM128, NULL),
945
  SCS_ITEM("Lvl14", 13, 255,        env2StepLevelGet,   env2StepLevelSet,selectNOP, stringDecPM128, NULL),
946
  SCS_ITEM("Lvl15", 14, 255,        env2StepLevelGet,   env2StepLevelSet,selectNOP, stringDecPM128, NULL),
947
  SCS_ITEM("Lvl16", 15, 255,        env2StepLevelGet,   env2StepLevelSet,selectNOP, stringDecPM128, NULL),
948
};
949
 
1299 tk 950
const scs_menu_item_t pageAOUT[] = {
1453 tk 951
  SCS_ITEM(" CV  ", 0, CV_SE_NUM-1, cvGet, cvSet, selectNOP, stringDecP1, NULL),
1299 tk 952
  SCS_ITEM("Curve", 0, MBCV_MAP_NUM_CURVES-1, cvCurveGet, cvCurveSet, selectNOP, stringCvCurve, NULL),
953
  SCS_ITEM(" Slew", 0, 255,   cvSlewRateGet, cvSlewRateSet, selectNOP, stringDec4, NULL),
954
  SCS_ITEM(" Cali", 0, MBCV_MAP_NUM_CALI_MODES-1, cvCaliModeGet, cvCaliModeSet, selectNOP, stringCvCaliMode, NULL),
955
  SCS_ITEM(" Modu", 0, AOUT_NUM_IF-1, aoutIfGet, aoutIfSet, selectNOP, stringAoutIf, NULL),
956
  SCS_ITEM("le   ", 1, AOUT_NUM_IF-1, aoutIfGet, aoutIfSet, selectNOP, stringAoutIf, NULL),
1914 tk 957
  SCS_ITEM("UpdR",  0, APP_CV_UPDATE_RATE_FACTOR_MAX-1, cvUpdateRateGet, cvUpdateRateSet, selectNOP, stringCvUpdateRate, NULL),
1299 tk 958
};
959
 
1912 tk 960
const scs_menu_item_t pageScpe[] = {
1917 tk 961
  SCS_ITEM("Scpe",  0, CV_SCOPE_NUM-1,            scopeGet,             scopeSet,             selectNOP, stringDecP1, NULL),
962
  SCS_ITEM("Asgn",  0, MBCV_SCOPE_NUM_SOURCES-1,  scopeSourceGet,       scopeSourceSet,       selectNOP, stringScopeSource, NULL),
963
  SCS_ITEM("OSmp",  0, 255,                       scopeOversamplingGet, scopeOversamplingSet, selectNOP, stringDec, NULL),
964
  SCS_ITEM("Trg.",  0, MBCV_SCOPE_NUM_TRIGGERS-1, scopeTriggerGet,      scopeTriggerSet,      selectNOP, stringScopeTrigger, NULL),
1887 tk 965
};
966
 
1298 tk 967
const scs_menu_item_t pageROUT[] = {
1530 tk 968
  SCS_ITEM("Node", 0, MIDI_ROUTER_NUM_NODES-1,  routerNodeGet, routerNodeSet,selectNOP, stringDecP1, NULL),
1492 tk 969
  SCS_ITEM("SrcP", 0, MIDI_PORT_NUM_IN_PORTS-1, routerSrcPortGet, routerSrcPortSet,selectNOP, stringInPort, NULL),
1298 tk 970
  SCS_ITEM("Chn.", 0, 17,                       routerSrcChnGet, routerSrcChnSet,selectNOP, stringRouterChn, NULL),
1538 tk 971
  SCS_ITEM("DstP", 0, MIDI_PORT_NUM_OUT_PORTS-1, routerDstPortGet, routerDstPortSet,selectNOP, stringOutPort, NULL),
1298 tk 972
  SCS_ITEM("Chn.", 0, 17,                       routerDstChnGet, routerDstChnSet,selectNOP, stringRouterChn, NULL),
973
};
974
 
975
const scs_menu_item_t pageDsk[] = {
976
  SCS_ITEM("Load ", 0, 0,           dummyGet,        dummySet,        selectLOAD, stringEmpty, NULL),
977
  SCS_ITEM("Save ", 0, 0,           dummyGet,        dummySet,        selectSAVE, stringEmpty, NULL),
978
};
979
 
980
const scs_menu_item_t pageOSC[] = {
981
  SCS_ITEM("Port ", 0, 3,           oscPortGet,      oscPortSet,      selectNOP,  stringOscPort, NULL),
982
  SCS_ITEM("Remot", 0, 0,           dummyGet,        dummySet,        selectRemoteIp, stringRemoteIp, NULL),
983
  SCS_ITEM("e IP:", 1, 0,           dummyGet,        dummySet,        selectRemoteIp, stringRemoteIp, NULL),
984
  SCS_ITEM("     ", 2, 0,           dummyGet,        dummySet,        selectRemoteIp, stringRemoteIp, NULL),
985
  SCS_ITEM("RPort", 0, 65535,       oscRemotePortGet,oscRemotePortSet,selectNOP,      stringDec5,     NULL),
986
  SCS_ITEM("LPort", 0, 65535,       oscLocalPortGet, oscLocalPortSet, selectNOP,      stringDec5,     NULL),
987
  SCS_ITEM(" Mode", 0, OSC_CLIENT_NUM_TRANSFER_MODES-1, oscModeGet, oscModeSet, selectNOP, stringOscMode, stringOscModeFull),
988
};
989
 
990
const scs_menu_item_t pageNetw[] = {
991
  SCS_ITEM("DHCP ", 0, 1,           dhcpGet,         dhcpSet,         selectNOP,  stringOnOff, NULL),
992
  SCS_ITEM(" IP  ", 0, 2,           selIpParGet,     selIpParSet,     selectNOP,  stringIpPar, NULL),
993
  SCS_ITEM("     ", 0, 0,           dummyGet,        dummySet,        selectIpEnter,stringIp, NULL),
994
  SCS_ITEM("     ", 1, 0,           dummyGet,        dummySet,        selectIpEnter,stringIp, NULL),
995
  SCS_ITEM("     ", 2, 0,           dummyGet,        dummySet,        selectIpEnter,stringIp, NULL),
996
};
997
 
1299 tk 998
const scs_menu_item_t pageMON[] = {
999
  // dummy - will be overlayed in displayHook
1000
  SCS_ITEM("     ", 0, 0,           dummyGet,        dummySet,        selectNOP,      stringEmpty, NULL),
1001
};
1002
 
1298 tk 1003
const scs_menu_page_t rootMode0[] = {
1312 tk 1004
  SCS_PAGE(" CV  ", pageCV),
1338 tk 1005
  SCS_PAGE("ARP  ", pageARP),
1006
  SCS_PAGE("LFO  ", pageLFO),
1394 tk 1007
  SCS_PAGE("ENV1 ", pageENV1),
1912 tk 1008
  SCS_PAGE("ENV2 ", pageENV2),
1299 tk 1009
  SCS_PAGE("AOUT ", pageAOUT),
1912 tk 1010
  SCS_PAGE("Scpe ", pageScpe),
1298 tk 1011
  SCS_PAGE("Rout ", pageROUT),
1012
  SCS_PAGE("OSC  ", pageOSC),
1013
  SCS_PAGE("Netw ", pageNetw),
1299 tk 1014
  SCS_PAGE("Mon. ", pageMON),
1298 tk 1015
  SCS_PAGE("Disk ", pageDsk),
1016
};
1017
 
1018
 
1019
/////////////////////////////////////////////////////////////////////////////
1020
// This function can overrule the display output
1021
// If it returns 0, the original SCS output will be print
1022
// If it returns 1, the output copied into line1 and/or line2 will be print
1023
// If a line is not changed (line[0] = 0 or line[1] = 0), the original output
1024
// will be displayed - this allows to overrule only a single line
1025
/////////////////////////////////////////////////////////////////////////////
1026
static s32 displayHook(char *line1, char *line2)
1027
{
1028
  if( extraPage ) {
1029
    char msdStr[5];
1030
    TASK_MSD_FlagStrGet(msdStr);
1031
 
1911 tk 1032
    sprintf(line1, "      Enc Bank MSD  ");
1033
    sprintf(line2, "Panic %s  %2d  %s ",
1034
        MBCV_LRE_ConfigModeGet() ? "On " : "Cfg",
1035
        MBCV_LRE_BankGet()+1,
1298 tk 1036
        TASK_MSD_EnableGet() ? msdStr : "----");
1037
    return 1;
1038
  }
1039
 
1914 tk 1040
  // overlay on overload
1041
  if( APP_CvUpdateOverloadStatusGet() ) {
1042
    if( (MIOS32_TIMESTAMP_Get() % 100) > 50 )
1043
      sprintf(line1, "[-! CV  OVERLOAD !-]");
1044
  }
1045
 
1298 tk 1046
  // overlay in MSD mode (user should disable soon since this sucks performance)
1047
  if( TASK_MSD_EnableGet() ) {
1048
    char msdStr[5];
1049
    TASK_MSD_FlagStrGet(msdStr);
1050
 
1051
    sprintf(line1, "[ MSD ACTIVE: %s ]", msdStr);
1052
  }
1053
 
1054
  if( SCS_MenuStateGet() == SCS_MENU_STATE_MAINPAGE ) {
1299 tk 1055
    u8 fastRefresh = line1[0] == 0;
1653 tk 1056
//    u32 tick = SEQ_BPM_TickGet();
1057
//    u32 ticks_per_step = SEQ_BPM_PPQN_Get() / 4;
1058
//    u32 ticks_per_measure = ticks_per_step * 16;
1059
//    u32 measure = (tick / ticks_per_measure) + 1;
1060
//    u32 step = ((tick % ticks_per_measure) / ticks_per_step) + 1;
1298 tk 1061
 
1062
    if( line1[0] == 0 ) { // no MSD overlay?
1063
      if( MBCV_FILE_StatusMsgGet() )
1064
    sprintf(line1, MBCV_FILE_StatusMsgGet());
1065
      else
1912 tk 1066
    sprintf(line1, "Patch: %-8s  [%d]", mbcv_file_p_patch_name, selectedCv+1);
1298 tk 1067
    }
1895 tk 1068
    sprintf(line2, "%s   <    >   MENU", env->mbCvClock.isRunning ? "STOP" : "PLAY");
1298 tk 1069
 
1070
    // request LCD update - this will lead to fast refresh rate in main screen
1071
    if( fastRefresh )
1072
      SCS_DisplayUpdateRequest();
1073
 
1074
    return 1;
1075
  }
1076
 
1077
  if( SCS_MenuStateGet() == SCS_MENU_STATE_SELECT_PAGE ) {
1078
    if( line1[0] == 0 ) { // no MSD overlay?
1079
      if( MBCV_FILE_StatusMsgGet() )
1080
    sprintf(line1, MBCV_FILE_StatusMsgGet());
1081
      else
1082
    sprintf(line1, "Patch: %s", mbcv_file_p_patch_name);
1083
    }
1084
    return 1;
1085
  }
1086
 
1087
  if( SCS_MenuPageGet() == pageDsk ) {
1088
    // Disk page: we want to show the patch at upper line, and menu items at lower line
1089
    if( line1[0] == 0 ) { // no MSD overlay?
1090
      if( MBCV_FILE_StatusMsgGet() )
1091
    sprintf(line1, MBCV_FILE_StatusMsgGet());
1092
      else
1093
    sprintf(line1, "Patch: %s", mbcv_file_p_patch_name);
1094
    }
1095
    sprintf(line2, "Load Save");
1096
    return 1;
1097
  }
1098
 
1299 tk 1099
  if( SCS_MenuPageGet() == pageMON ) {
1100
    u8 fastRefresh = line1[0] == 0;
1101
 
1102
    int i;
1103
    for(i=0; i<SCS_NUM_MENU_ITEMS; ++i) {
1104
      u8 portIx = 1 + i + monPageOffset;
1105
 
1106
      if( fastRefresh ) { // no MSD overlay?
1492 tk 1107
    mios32_midi_port_t port = MIDI_PORT_InPortGet(portIx);
1108
    mios32_midi_package_t package = MIDI_PORT_InPackageGet(port);
1299 tk 1109
    if( port == 0xff ) {
1110
      strcat(line1, "     ");
1111
    } else if( package.type ) {
1112
      char buffer[6];
1492 tk 1113
      MIDI_PORT_EventNameGet(package, buffer, 5);
1299 tk 1114
      strcat(line1, buffer);
1115
    } else {
1492 tk 1116
      strcat(line1, MIDI_PORT_InNameGet(portIx));
1299 tk 1117
      strcat(line1, " ");
1118
    }
1119
 
1120
    // insert arrow at upper right corner
1492 tk 1121
    int numItems = MIDI_PORT_OutNumGet() - 1;
1299 tk 1122
    if( monPageOffset == 0 )
1306 tk 1123
      line1[19] = 3; // right arrow
1299 tk 1124
    else if( monPageOffset >= (numItems-SCS_NUM_MENU_ITEMS) )
1306 tk 1125
      line1[19] = 1; // left arrow
1299 tk 1126
    else
1127
      line1[19] = 2; // left/right arrow
1128
 
1129
      }
1130
 
1492 tk 1131
      mios32_midi_port_t port = MIDI_PORT_OutPortGet(portIx);
1132
      mios32_midi_package_t package = MIDI_PORT_OutPackageGet(port);
1299 tk 1133
      if( port == 0xff ) {
1134
    strcat(line2, "     ");
1135
      } else if( package.type ) {
1136
    char buffer[6];
1492 tk 1137
    MIDI_PORT_EventNameGet(package, buffer, 5);
1299 tk 1138
    strcat(line2, buffer);
1139
      } else {
1492 tk 1140
    strcat(line2, MIDI_PORT_OutNameGet(portIx));
1299 tk 1141
    strcat(line2, " ");
1142
      }
1143
    }
1144
 
1145
    // request LCD update - this will lead to fast refresh rate in monitor screen
1146
    if( fastRefresh )
1147
      SCS_DisplayUpdateRequest();
1148
 
1149
    return 1;
1150
  }
1151
 
1298 tk 1152
  return (line1[0] != 0) ? 1 : 0; // return 1 if MSD overlay
1153
}
1154
 
1155
 
1156
/////////////////////////////////////////////////////////////////////////////
1157
// This function is called when the rotary encoder is moved
1158
// If it returns 0, the encoder increment will be handled by the SCS
1159
// If it returns 1, the SCS will ignore the encoder
1160
/////////////////////////////////////////////////////////////////////////////
1161
static s32 encHook(s32 incrementer)
1162
{
1163
  if( extraPage )
1164
    return 1; // ignore encoder movements in extra page
1165
 
1299 tk 1166
  // encoder overlayed in monitor page to scroll through port list
1167
  if( SCS_MenuPageGet() == pageMON ) {
1492 tk 1168
    int numItems = MIDI_PORT_OutNumGet() - 1;
1299 tk 1169
    int newOffset = monPageOffset + incrementer;
1170
    if( newOffset < 0 )
1171
      newOffset = 0;
1172
    else if( (newOffset+SCS_NUM_MENU_ITEMS) >= numItems ) {
1173
      newOffset = numItems - SCS_NUM_MENU_ITEMS;
1174
      if( newOffset < 0 )
1175
    newOffset = 0;
1176
    }
1177
    monPageOffset = newOffset;
1178
  }
1179
 
1298 tk 1180
  return 0;
1181
}
1182
 
1183
 
1184
/////////////////////////////////////////////////////////////////////////////
1185
// This function is called when a button has been pressed or depressed
1186
// If it returns 0, the button movement will be handled by the SCS
1187
// If it returns 1, the SCS will ignore the button event
1188
/////////////////////////////////////////////////////////////////////////////
1189
static s32 buttonHook(u8 scsButton, u8 depressed)
1190
{
1191
  if( extraPage ) {
1911 tk 1192
    if( scsButton == SCS_PIN_SOFT5 && depressed ) { // selects/deselects extra page
1298 tk 1193
      extraPage = 0;
1911 tk 1194
      SCS_MsgStop();
1195
    } else {
1298 tk 1196
      switch( scsButton ) {
1197
      case SCS_PIN_SOFT1:
1198
    if( depressed )
1199
      return 1;
1911 tk 1200
    MBCV_MAP_ResetAllChannels();
1201
    SCS_Msg(SCS_MSG_L, 1000, "All Notes", "off!");
1298 tk 1202
    break;
1203
 
1204
      case SCS_PIN_SOFT2:
1205
    if( depressed )
1206
      return 1;
1911 tk 1207
    MBCV_LRE_ConfigModeSet(MBCV_LRE_ConfigModeGet() ? 0 : 1);
1298 tk 1208
    break;
1209
 
1911 tk 1210
      case SCS_PIN_SOFT3:
1211
    if( depressed )
1212
      return 1;
1213
    MBCV_LRE_BankSet((MBCV_LRE_BankGet() + 1) % MBCV_LRE_NUM_BANKS);
1214
    break;
1215
 
1216
      case SCS_PIN_SOFT4: {
1298 tk 1217
    u8 do_enable = TASK_MSD_EnableGet() ? 0 : 1;
1218
    if( depressed )
1219
      SCS_UnInstallDelayedActionCallback(MSD_EnableReq);
1220
    else {
1221
      if( !do_enable ) {
1222
        // wait a bit longer... normaly it would be better to print a warning that "unmounting via OS" is better
1223
        SCS_InstallDelayedActionCallback(MSD_EnableReq, 5000, do_enable);
1224
        SCS_Msg(SCS_MSG_DELAYED_ACTION_L, 5001, "", "to disable MSD USB!");
1225
      } else {
1226
        SCS_InstallDelayedActionCallback(MSD_EnableReq, 2000, do_enable);
1227
        SCS_Msg(SCS_MSG_DELAYED_ACTION_L, 2001, "", "to enable MSD USB!");
1228
      }
1229
    }
1230
      } break;
1231
      }
1232
    }
1233
 
1234
    return 1;
1235
  } else {
1236
    if( scsButton == SCS_PIN_SOFT5 && !depressed ) { // selects/deselects extra page
1237
      extraPage = 1;
1238
      return 1;
1239
    }
1240
 
1241
    if( SCS_MenuStateGet() == SCS_MENU_STATE_MAINPAGE ) {
1242
      if( depressed )
1243
    return 0;
1244
 
1245
      switch( scsButton ) {
1246
      case SCS_PIN_SOFT1: // Play/Stop
1895 tk 1247
    if( env->mbCvClock.isRunning )
1248
      env->mbCvClock.midiReceiveRealTimeEvent(DEFAULT, 0xfc); // stop
1249
    else
1250
      env->mbCvClock.midiReceiveRealTimeEvent(DEFAULT, 0xfa); // start
1298 tk 1251
    return 1;
1252
 
1253
      case SCS_PIN_SOFT2: { // previous song
1254
    MUTEX_SDCARD_TAKE;
1255
    //SEQ_PlayFileReq(-1, 1);
1256
    MUTEX_SDCARD_GIVE;
1257
    return 1;
1258
      }
1259
 
1260
      case SCS_PIN_SOFT3: { // next song
1261
    MUTEX_SDCARD_TAKE;
1262
    //SEQ_PlayFileReq(1, 1);
1263
    MUTEX_SDCARD_GIVE;
1264
    return 1;
1265
      }
1266
      }
1267
    }
1268
  }
1269
 
1270
  return 0; // no error
1271
}
1272
 
1273
 
1274
 
1275
/////////////////////////////////////////////////////////////////////////////
1276
// Initialisation of SCS Config
1277
// mode selects the used SCS config (currently only one available selected with 0)
1278
// return < 0 if initialisation failed
1279
/////////////////////////////////////////////////////////////////////////////
1912 tk 1280
s32 SCS_CONFIG_Init(u32 mode)
1298 tk 1281
{
1334 tk 1282
  env = APP_GetEnv();
1283
 
1298 tk 1284
  if( mode > 0 )
1285
    return -1;
1286
 
1287
  switch( mode ) {
1288
  case 0: {
1289
    // install table
1290
    SCS_INSTALL_ROOT(rootMode0);
1291
    SCS_InstallDisplayHook(displayHook);
1292
    SCS_InstallEncHook(encHook);
1293
    SCS_InstallButtonHook(buttonHook);
1299 tk 1294
    monPageOffset = 0;
1298 tk 1295
    break;
1296
  }
1297
  default: return -1; // mode not supported
1298
  }
1299
 
1300
  return 0; // no error
1301
}
1912 tk 1302
 
1303
 
1304
/////////////////////////////////////////////////////////////////////////////
1305
// Access functions for MBCV_BUTTON
1306
s32 SCS_CONFIG_CvSet(u8 cv)
1307
{
1308
  selectedCv = cv;
1309
  return 0; // no error
1310
}
1311
 
1312
s32 SCS_CONFIG_LfoSet(u8 lfo)
1313
{
1314
  selectedLfo = lfo;
1315
  SCS_ChangePage((scs_menu_item_t *)pageLFO);
1316
  return 0; // no error
1317
}
1318
 
1319
s32 SCS_CONFIG_EnvSet(u8 env)
1320
{
1321
  switch( env ) {
1322
  case 0:
1323
    SCS_ChangePage((scs_menu_item_t *)pageENV1);
1324
    selectedEnv1 = 0;
1325
    break;
1326
  case 1:
1327
    SCS_ChangePage((scs_menu_item_t *)pageENV2);
1328
    selectedEnv2 = 0;
1329
    break;
1330
  }
1331
 
1332
  return 0; // no error
1333
}
1334
 
1335
s32 SCS_CONFIG_ScopeSet(u8 scope)
1336
{
1917 tk 1337
  selectedScope = scope;
1912 tk 1338
  SCS_ChangePage((scs_menu_item_t *)pageScpe);
1339
  return 0; // no error
1340
}