Subversion Repositories svn.mios32

Rev

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

Rev 1771 Rev 1794
Line 1... Line 1...
1
// $Id: seq_midi_in.c 1771 2013-05-05 14:30:16Z tk $
1
// $Id: seq_midi_in.c 1794 2013-05-31 19:25:43Z tk $
2
/*
2
/*
3
 * MIDI IN Routines
3
 * MIDI IN Routines
4
 *
4
 *
5
 * ==========================================================================
5
 * ==========================================================================
6
 *
6
 *
Line 110... Line 110...
110
// For External Control functions:
110
// For External Control functions:
111
// 0 disables MIDI In, 1..16 define the MIDI channel which should be used
111
// 0 disables MIDI In, 1..16 define the MIDI channel which should be used
112
u8 seq_midi_in_ext_ctrl_channel;
112
u8 seq_midi_in_ext_ctrl_channel;
113
// which IN port should be used? (0: All)
113
// which IN port should be used? (0: All)
114
mios32_midi_port_t seq_midi_in_ext_ctrl_port;
114
mios32_midi_port_t seq_midi_in_ext_ctrl_port;
-
 
115
// and which optional out port? (0: Off)
-
 
116
mios32_midi_port_t seq_midi_in_ext_ctrl_out_port;
115
// external controller assignments
117
// external controller assignments
116
u8 seq_midi_in_ext_ctrl_asg[SEQ_MIDI_IN_EXT_CTRL_NUM];
118
u8 seq_midi_in_ext_ctrl_asg[SEQ_MIDI_IN_EXT_CTRL_NUM];
117
119
118
// For Record function:
120
// For Record function:
119
// 0 disables MIDI In, 1..16 define the MIDI channel which should be used
121
// 0 disables MIDI In, 1..16 define the MIDI channel which should be used
Line 179... Line 181...
179
    seq_midi_in_options[bus].ALL = 0; // disable all options
181
    seq_midi_in_options[bus].ALL = 0; // disable all options
180
  }
182
  }
181
183
182
  seq_midi_in_ext_ctrl_channel = 0; // 0 disables MIDI IN
184
  seq_midi_in_ext_ctrl_channel = 0; // 0 disables MIDI IN
183
  seq_midi_in_ext_ctrl_port = DEFAULT; // All ports
185
  seq_midi_in_ext_ctrl_port = DEFAULT; // All ports
-
 
186
  seq_midi_in_ext_ctrl_out_port = 0; // off
184
187
185
  seq_midi_in_ext_ctrl_asg[SEQ_MIDI_IN_EXT_CTRL_MORPH] = 1;
188
  seq_midi_in_ext_ctrl_asg[SEQ_MIDI_IN_EXT_CTRL_MORPH] = 1;
186
  seq_midi_in_ext_ctrl_asg[SEQ_MIDI_IN_EXT_CTRL_SCALE] = 3;
189
  seq_midi_in_ext_ctrl_asg[SEQ_MIDI_IN_EXT_CTRL_SCALE] = 3;
187
  seq_midi_in_ext_ctrl_asg[SEQ_MIDI_IN_EXT_CTRL_PATTERN_G1] = 112;
190
  seq_midi_in_ext_ctrl_asg[SEQ_MIDI_IN_EXT_CTRL_PATTERN_G1] = 112;
188
  seq_midi_in_ext_ctrl_asg[SEQ_MIDI_IN_EXT_CTRL_PATTERN_G2] = 113;
191
  seq_midi_in_ext_ctrl_asg[SEQ_MIDI_IN_EXT_CTRL_PATTERN_G2] = 113;
Line 262... Line 265...
262
265
263
  if( pc_mode >= SEQ_MIDI_IN_EXT_CTRL_PC_MODE_NUM )
266
  if( pc_mode >= SEQ_MIDI_IN_EXT_CTRL_PC_MODE_NUM )
264
    return "UnknwnMde";
267
    return "UnknwnMde";
265
268
266
  return ext_ctrl_pc_mode_str[pc_mode];
269
  return ext_ctrl_pc_mode_str[pc_mode];
-
 
270
}
-
 
271
-
 
272
-
 
273
/////////////////////////////////////////////////////////////////////////////
-
 
274
// since there is currently no better place (somebody could expect this function in SEQ_MIDI_OUT...)
-
 
275
/////////////////////////////////////////////////////////////////////////////
-
 
276
extern s32 SEQ_MIDI_IN_ExtCtrlSend(u8 ext_ctrl, u8 value)
-
 
277
{
-
 
278
  if( seq_midi_in_ext_ctrl_out_port && seq_midi_in_ext_ctrl_channel ) {
-
 
279
    mios32_midi_port_t port = seq_midi_in_ext_ctrl_out_port;
-
 
280
    mios32_midi_chn_t chn = seq_midi_in_ext_ctrl_channel - 1;
-
 
281
-
 
282
    u8 cc = seq_midi_in_ext_ctrl_asg[ext_ctrl];
-
 
283
    if( cc <= 127 ) {
-
 
284
      MUTEX_MIDIOUT_TAKE;
-
 
285
      MIOS32_MIDI_SendCC(port, chn, cc, value);
-
 
286
      MUTEX_MIDIOUT_GIVE;    
-
 
287
    }
-
 
288
-
 
289
    u8 pc_mode = seq_midi_in_ext_ctrl_asg[SEQ_MIDI_IN_EXT_CTRL_PC_MODE];
-
 
290
    if( (pc_mode == SEQ_MIDI_IN_EXT_CTRL_PC_MODE_PATTERNS && ext_ctrl >= SEQ_MIDI_IN_EXT_CTRL_PATTERN_G1 && ext_ctrl <= SEQ_MIDI_IN_EXT_CTRL_PATTERN_G4) ||
-
 
291
    (pc_mode == SEQ_MIDI_IN_EXT_CTRL_PC_MODE_SONG && ext_ctrl == SEQ_MIDI_IN_EXT_CTRL_SONG) ||
-
 
292
    (pc_mode == SEQ_MIDI_IN_EXT_CTRL_PC_MODE_PHRASE && ext_ctrl == SEQ_MIDI_IN_EXT_CTRL_PHRASE) ) {
-
 
293
      MUTEX_MIDIOUT_TAKE;
-
 
294
      MIOS32_MIDI_SendProgramChange(port, chn, value);
-
 
295
      MUTEX_MIDIOUT_GIVE;    
-
 
296
    }
-
 
297
  }
-
 
298
-
 
299
  return 0;
267
}
300
}
268
301
269
302
270
/////////////////////////////////////////////////////////////////////////////
303
/////////////////////////////////////////////////////////////////////////////
271
// resets note stacks used for transposer/arpeggiator
304
// resets note stacks used for transposer/arpeggiator
Line 867... Line 900...
867
900
868
  case 0x63: // NRPN MSB (selects track)
901
  case 0x63: // NRPN MSB (selects track)
869
    nrpn_msb = value;
902
    nrpn_msb = value;
870
    break;
903
    break;
871
904
872
  case 0x06: // NRPN Value LSB (sets parameter)
905
  case 0x06: // NRPN Value MSB (sets parameter)
873
    if( nrpn_msb < SEQ_CORE_NUM_TRACKS && seq_midi_in_ext_ctrl_asg[SEQ_MIDI_IN_EXT_CTRL_NRPN_ENABLED] )
906
    if( nrpn_msb < SEQ_CORE_NUM_TRACKS && seq_midi_in_ext_ctrl_asg[SEQ_MIDI_IN_EXT_CTRL_NRPN_ENABLED] )
874
      SEQ_CC_MIDI_Set(nrpn_msb, nrpn_lsb, value);
907
      SEQ_CC_MIDI_Set(nrpn_msb, nrpn_lsb, value);
875
    break;
908
    break;
876
  }
909
  }
877
910