components/prboom/mmus2mid.c
//
// FirstChannelAvailable()
//
// Return the next unassigned MIDI channel number
//
// The assignment for MUS channel 15 is not counted in the caculation, that
// being percussion and always assigned to MIDI channel 9 (base 0).
//
// Passed the array of MIDI channels assigned to MUS channels
// Returns the maximum channel number unassigned unless that is 9 in which
// case 10 is returned.
//
// killough 10/7/98: changed char parameter, return values to int
FirstChannelAvailable()
Return the next unassigned MIDI channel number

The assignment for MUS channel 15 is not counted in the caculation, that
being percussion and always assigned to MIDI channel 9 (base 0).

Passed the array of MIDI channels assigned to MUS channels
Returns the maximum channel number unassigned unless that is 9 in which
case 10 is returned.

killough 10/7/98: changed char parameter, return values to int
FirstChannelAvailable () Return the next unassigned MIDI channel number The assignment for MUS channel 15 is not counted in the caculation that being percussion and always assigned to MIDI channel 9 ( base 0 ) . Passed the array of MIDI channels assigned to MUS channels Returns the maximum channel number unassigned unless that is 9 in which case 10 is returned . killough 10 / 7 / 98 : changed char parameter return values to int
static int FirstChannelAvailable(int MUS2MIDchannel[])
{
  int i ;
  int max = -1 ;
  for (i = 0; i < 15; i++)
    if (MUS2MIDchannel[i] > max)
      max = MUS2MIDchannel[i];
  return (max == 8 ? 10 : max+1); 
}
static int FirstChannelAvailable ( int MUS2MIDchannel [ ] ) { int i ; int max = -1 ; for ( i = 0 ; i < 15 ; i ++ ) if ( MUS2MIDchannel [ i ] > max ) max = MUS2MIDchannel [ i ] ; return ( max == 8 ? 10 : max + 1 ) ; }
FirstChannelAvailable()
Return the next unassigned MIDI channel number
FirstChannelAvailable () Return the next unassigned MIDI channel number
// find the largest MIDI channel assigned so far // skip MIDI channel 9 (percussion)