Subversion Repositories svn.mios32

Rev

Rev 1787 | Rev 1806 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1787 Rev 1794
Line 1... Line 1...
1
// $Id: seq_ui.c 1787 2013-05-19 15:23:20Z tk $
1
// $Id: seq_ui.c 1794 2013-05-31 19:25:43Z tk $
2
/*
2
/*
3
 * User Interface Routines
3
 * User Interface Routines
4
 *
4
 *
5
 * ==========================================================================
5
 * ==========================================================================
6
 *
6
 *
Line 40... Line 40...
40
#include "seq_layer.h"
40
#include "seq_layer.h"
41
#include "seq_cc.h"
41
#include "seq_cc.h"
42
#include "seq_record.h"
42
#include "seq_record.h"
43
#include "seq_midi_sysex.h"
43
#include "seq_midi_sysex.h"
44
#include "seq_midi_port.h"
44
#include "seq_midi_port.h"
-
 
45
#include "seq_midi_in.h"
45
#include "seq_blm.h"
46
#include "seq_blm.h"
46
47
47
#include "file.h"
48
#include "file.h"
48
#include "seq_file.h"
49
#include "seq_file.h"
49
#include "seq_file_t.h"
50
#include "seq_file_t.h"
Line 3188... Line 3189...
3188
  return 0; // value hasn't been changed
3189
  return 0; // value hasn't been changed
3189
}
3190
}
3190
3191
3191
3192
3192
/////////////////////////////////////////////////////////////////////////////
3193
/////////////////////////////////////////////////////////////////////////////
3193
// Increments a CC within given min/max range
3194
// Sends the current CC parameter of the given track to seq_midi_in_ext_ctrl_out_port
3194
// OUT: 1 if value has been changed, otherwise 0
-
 
3195
/////////////////////////////////////////////////////////////////////////////
3195
/////////////////////////////////////////////////////////////////////////////
3196
s32 SEQ_UI_CC_Inc(u8 cc, u8 min, u8 max, s32 incrementer)
3196
s32 SEQ_UI_CC_SendParameter(u8 track, u8 cc)
3197
{
3197
{
-
 
3198
  if( seq_midi_in_ext_ctrl_asg[SEQ_MIDI_IN_EXT_CTRL_NRPN_ENABLED] &&
-
 
3199
      seq_midi_in_ext_ctrl_out_port &&
-
 
3200
      seq_midi_in_ext_ctrl_channel ) {
3198
  u8 visible_track = SEQ_UI_VisibleTrackGet();
3201
    mios32_midi_port_t port = seq_midi_in_ext_ctrl_out_port;
3199
  int new_value = SEQ_CC_Get(visible_track, cc);
3202
    mios32_midi_chn_t chn = seq_midi_in_ext_ctrl_channel - 1;
3200
  int prev_value = new_value;
3203
    u8 mapped_cc;
-
 
3204
    s32 value = SEQ_CC_MIDI_Get(track, cc, &mapped_cc);
3201
3205
3202
  if( incrementer >= 0 ) {
3206
    if( value >= 0 ) {
-
 
3207
      MUTEX_MIDIOUT_TAKE;
3203
    if( (new_value += incrementer) >= max )
3208
      MIOS32_MIDI_SendCC(port, chn, 0x63, track);
3204
      new_value = max;
3209
      MIOS32_MIDI_SendCC(port, chn, 0x62, mapped_cc);
3205
  } else {
-
 
3206
    if( (new_value += incrementer) < min )
3210
      MIOS32_MIDI_SendCC(port, chn, 0x06, value & 0x7f);
3207
      new_value = min;
3211
      MUTEX_MIDIOUT_GIVE;
-
 
3212
    }
3208
  }
3213
  }
3209
3214
3210
  if( new_value == prev_value )
-
 
3211
    return 0; // no change
3215
  return 0; // no error
3212
-
 
3213
  SEQ_CC_Set(visible_track, cc, new_value);
-
 
3214
-
 
3215
  // set same value for all selected tracks
-
 
3216
  u8 track;
-
 
3217
  for(track=0; track<SEQ_CORE_NUM_TRACKS; ++track)
-
 
3218
    if( track != visible_track && SEQ_UI_IsSelectedTrack(track) )
-
 
3219
      SEQ_CC_Set(track, cc, new_value);
-
 
3220
-
 
3221
  return 1; // value changed
-
 
3222
}
3216
}
3223
-
 
3224
3217
3225
/////////////////////////////////////////////////////////////////////////////
3218
/////////////////////////////////////////////////////////////////////////////
3226
// Sets a CC value on all selected tracks
3219
// Sets a CC value on all selected tracks
3227
// OUT: 1 if value has been changed, otherwise 0
3220
// OUT: 1 if value has been changed, otherwise 0
3228
/////////////////////////////////////////////////////////////////////////////
3221
/////////////////////////////////////////////////////////////////////////////
Line 3231... Line 3224...
3231
  u8 visible_track = SEQ_UI_VisibleTrackGet();
3224
  u8 visible_track = SEQ_UI_VisibleTrackGet();
3232
  int prev_value = SEQ_CC_Get(visible_track, cc);
3225
  int prev_value = SEQ_CC_Get(visible_track, cc);
3233
3226
3234
  if( value == prev_value )
3227
  if( value == prev_value )
3235
    return 0; // no change
3228
    return 0; // no change
3236
-
 
3237
  SEQ_CC_Set(visible_track, cc, value);
-
 
3238
3229
3239
  // set same value for all selected tracks
3230
  // set same value for all selected tracks
3240
  u8 track;
3231
  u8 track;
3241
  for(track=0; track<SEQ_CORE_NUM_TRACKS; ++track)
3232
  for(track=0; track<SEQ_CORE_NUM_TRACKS; ++track) {
3242
    if( track != visible_track && SEQ_UI_IsSelectedTrack(track) )
3233
    if( SEQ_UI_IsSelectedTrack(track) ) {
3243
      SEQ_CC_Set(track, cc, value);
3234
      SEQ_CC_Set(track, cc, value);
-
 
3235
      SEQ_UI_CC_SendParameter(track, cc);
-
 
3236
    }
-
 
3237
  }
3244
3238
3245
  return 1; // value changed
3239
  return 1; // value changed
3246
}
3240
}
-
 
3241
-
 
3242
-
 
3243
/////////////////////////////////////////////////////////////////////////////
-
 
3244
// Increments a CC within given min/max range
-
 
3245
// OUT: 1 if value has been changed, otherwise 0
-
 
3246
/////////////////////////////////////////////////////////////////////////////
-
 
3247
s32 SEQ_UI_CC_Inc(u8 cc, u8 min, u8 max, s32 incrementer)
-
 
3248
{
-
 
3249
  u8 visible_track = SEQ_UI_VisibleTrackGet();
-
 
3250
  int new_value = SEQ_CC_Get(visible_track, cc);
-
 
3251
-
 
3252
  if( incrementer >= 0 ) {
-
 
3253
    if( (new_value += incrementer) >= max )
-
 
3254
      new_value = max;
-
 
3255
  } else {
-
 
3256
    if( (new_value += incrementer) < min )
-
 
3257
      new_value = min;
-
 
3258
  }
-
 
3259
-
 
3260
  // set value
-
 
3261
  SEQ_UI_CC_Set(cc, new_value);
-
 
3262
-
 
3263
  return 1; // value changed
-
 
3264
}
-
 
3265
3247
3266
3248
/////////////////////////////////////////////////////////////////////////////
3267
/////////////////////////////////////////////////////////////////////////////
3249
// Modifies a bitfield in a CC value to a given value
3268
// Modifies a bitfield in a CC value to a given value
3250
// OUT: 1 if value has been changed, otherwise 0
3269
// OUT: 1 if value has been changed, otherwise 0
3251
/////////////////////////////////////////////////////////////////////////////
3270
/////////////////////////////////////////////////////////////////////////////
Line 3257... Line 3276...
3257
3276
3258
  new_value = (new_value & ~flag_mask) | value;
3277
  new_value = (new_value & ~flag_mask) | value;
3259
3278
3260
  if( new_value == prev_value )
3279
  if( new_value == prev_value )
3261
    return 0; // no change
3280
    return 0; // no change
3262
-
 
3263
  SEQ_CC_Set(visible_track, cc, new_value);
-
 
3264
3281
3265
  // do same modification for all selected tracks
3282
  // do same modification for all selected tracks
3266
  u8 track;
3283
  u8 track;
3267
  for(track=0; track<SEQ_CORE_NUM_TRACKS; ++track)
3284
  for(track=0; track<SEQ_CORE_NUM_TRACKS; ++track) {
3268
    if( track != visible_track && SEQ_UI_IsSelectedTrack(track) ) {
3285
    if( SEQ_UI_IsSelectedTrack(track) ) {
3269
      int new_value = SEQ_CC_Get(track, cc);
3286
      int new_value = SEQ_CC_Get(track, cc);
3270
      new_value = (new_value & ~flag_mask) | value;
3287
      new_value = (new_value & ~flag_mask) | value;
3271
      SEQ_CC_Set(track, cc, new_value);
3288
      SEQ_CC_Set(track, cc, new_value);
-
 
3289
      SEQ_UI_CC_SendParameter(track, cc);
-
 
3290
    }
3272
    }
3291
  }
3273
3292
3274
  return 1; // value changed
3293
  return 1; // value changed
3275
}
3294
}
3276
3295