示例#1
0
static inline int
midi_adlib_event1(guint8 command, guint8 note, guint8 velocity)
{
	guint8 channel, oper;

	channel = command & 0x0f;
	oper = command & 0xf0;

	switch (oper) {    
	case 0x80:
		adlib_stop_note(channel, note, velocity);
		return 0;
	case 0x90:  
		adlib_start_note(channel,note,velocity);
		return 0;
	case 0xe0:    /* Pitch bend needs scaling? */
		SEQ_BENDER(dev, channel, ((note << 8) & velocity));
		SEQ_DUMPBUF();
		break;
	case 0xb0:    /* CC changes.  we ignore. */
		/* XXXX we need to parse out 0x07 volume, at least. */
		return 0;
	case 0xd0:    /* aftertouch */
		SEQ_CHN_PRESSURE(dev, channel, note);
		SEQ_DUMPBUF();    
		return 0;
	default:
		printf("ADLIB: Unknown event %02x\n", command);
		return 0;
	}
  
	SEQ_DUMPBUF();
	return 0;
}
示例#2
0
文件: hmiplay.c 项目: paud/d2x-xl
void set_chn_pressure(int channel, int vel)
{    
	int i;
	
#ifdef WANT_AWE32
	if (card_info.synth_type == SYNTH_TYPE_SAMPLE
	    && card_info.synth_subtype == SAMPLE_TYPE_AWE32)    
	{
		AWE_CHN_PRESSURE(synth_dev,channel,vel);
	}
	else
#endif
	{
		for (i=0; i<card_info.nr_voices;i++)
		  if (voices[i].channel == channel)
		    SEQ_CHN_PRESSURE(synth_dev,i,vel);
	}    
}
示例#3
0
void
do_midi_msg(int synthno, unsigned char *msg, int mlen)
{
	switch (msg[0] & 0xf0)
	  {
	  case 0x90:
		  if (msg[2] != 0)
		    {
			    STORE(SEQ_START_NOTE(synthno, msg[0] & 0x0f, msg[1], msg[2]));
			    break;
		    }
		  msg[2] = 64;

	  case 0x80:
		  STORE(SEQ_STOP_NOTE(synthno, msg[0] & 0x0f, msg[1], msg[2]));
		  break;

	  case 0xA0:
		  STORE(SEQ_KEY_PRESSURE(synthno, msg[0] & 0x0f, msg[1], msg[2]));
		  break;

	  case 0xB0:
		  STORE(SEQ_CONTROL(synthno, msg[0] & 0x0f,
				    msg[1], msg[2]));
		  break;

	  case 0xC0:
		  STORE(SEQ_SET_PATCH(synthno, msg[0] & 0x0f, msg[1]));
		  break;

	  case 0xD0:
		  STORE(SEQ_CHN_PRESSURE(synthno, msg[0] & 0x0f, msg[1]));
		  break;

	  case 0xE0:
		  STORE(SEQ_BENDER(synthno, msg[0] & 0x0f,
			      (msg[1] & 0x7f) | ((msg[2] & 0x7f) << 7)));
		  break;

	  default:
		  /* printk( "MPU: Unknown midi channel message %02x\n",  msg[0]); */
		  ;
	  }
}
static int
mlib_store_chn_voice_msg (mlib_desc * desc, mlib_track * track, int *optr,
			  unsigned char *evbuf, int len)
{

  unsigned char chn, pgm, note, vel;

  chn = evbuf[0] & 0x0f;	/* Midi channel */

  if (track->init_chn == -1)
    track->init_chn = chn;
  else if (chn != track->init_chn)
    track->flags |= TRK_MULTICHN;

  track->chnmask |= (1 << chn);	/* Update channel mask */

  switch (evbuf[0] & 0xf0)
    {
    case 0x90:			/* Note on */
      vel = evbuf[2];
      note = evbuf[1];

      if (vel != 0)
	{			/* Velocity given -> true note on event */
	  track->flags |= TRK_NOTES;

	  if (note > track->max_note)
	    track->max_note = note;

	  if (note < track->min_note)
	    track->min_note = note;

	  if (track->noteon_time == -1)
	    track->noteon_time = track->current_time;

	  if (vel != 64)
	    track->flags |= TRK_VEL_NOTEON;

	  STORE (SEQ_START_NOTE (0, chn, note, vel));
	  if (chn == 9)		/* Drum channel */
	    track->drum_map[note] = note;
	  break;		/* NOTE! The break is here, not later */
	}
      /* Note on with zero G -> note off with vel=64. */
      /* Fall to the next case */
      evbuf[2] = 64;		/* Velocity for the note off handler */

    case 0x80:			/* Note off */
      vel = evbuf[2];
      note = evbuf[1];

      if (vel != 64)
	track->flags |= TRK_VEL_NOTEOFF;
      STORE (SEQ_STOP_NOTE (0, chn, note, vel));
      break;

    case 0xA0:			/* Polyphonic key pressure/Aftertouch */
      track->flags |= TRK_POLY_AFTERTOUCH | TRK_AFTERTOUCH;
      STORE (SEQ_KEY_PRESSURE (0, chn, note, vel));
      break;

    case 0xB0:			/* Control change */
      {
	unsigned short value = evbuf[2];	/* Incorrect */
	unsigned char ctl = evbuf[1];

	track->flags |= TRK_CONTROLS;
	STORE (SEQ_CONTROL (0, chn, ctl, value));
      }
      break;

    case 0xC0:			/* Program change */
      pgm = evbuf[1];
      if (track->init_pgm == -1)
	track->init_pgm = pgm;
      else if (pgm != track->init_pgm)
	track->flags |= TRK_MULTIPGM;

      track->pgm_map[pgm] = pgm;
      STORE (SEQ_SET_PATCH (0, chn, pgm));
      break;

    case 0xD0:			/* Channel pressure/Aftertouch */
      track->flags |= TRK_AFTERTOUCH;
      STORE (SEQ_CHN_PRESSURE (0, chn, evbuf[1]));
      break;

    case 0xE0:			/* Pitch bend change */
      track->flags |= TRK_BENDER;
      STORE (SEQ_BENDER
	     (0, chn, (evbuf[1] & 0x7f) + ((evbuf[2] & 0x7f) << 7)));
      break;

    default:
      mlib_seterr ("Internal error: Unexpected midi event");
      fprintf (stderr, "Internal error: Unexpected midi event %02x\n",
	       evbuf[0]);

      return 0;
    }

  return 1;
}
示例#5
0
void
do_midi_msg(int synthno, unsigned char *msg, int mlen)
{
    switch (msg[0] & 0xf0)
    {
    case 0x90:
        if (msg[2] != 0)
        {
            STORE(SEQ_START_NOTE(synthno, msg[0] & 0x0f, msg[1], msg[2]));
            break;
        }
        msg[2] = 64;

    case 0x80:
        STORE(SEQ_STOP_NOTE(synthno, msg[0] & 0x0f, msg[1], msg[2]));
        break;

    case 0xA0:
        STORE(SEQ_KEY_PRESSURE(synthno, msg[0] & 0x0f, msg[1], msg[2]));
        break;

    case 0xB0:
        STORE(SEQ_CONTROL(synthno, msg[0] & 0x0f,
                          msg[1], msg[2]));
        break;

    case 0xC0:
        STORE(SEQ_SET_PATCH(synthno, msg[0] & 0x0f, msg[1]));
        break;

    case 0xD0:
        STORE(SEQ_CHN_PRESSURE(synthno, msg[0] & 0x0f, msg[1]));
        break;

    case 0xE0:
        STORE(SEQ_BENDER(synthno, msg[0] & 0x0f,
                         (msg[1] & 0x7f) | ((msg[2] & 0x7f) << 7)));
        break;

    default:
#ifdef CONFIG_DEBUG_PRINTK
        /* printk( "MPU: Unknown midi channel message %02x\n",  msg[0]); */
#else
        /* ;
#endif
        ;
    }
}
EXPORT_SYMBOL(do_midi_msg);

static void
midi_outc(int midi_dev, int data)
{
    int             timeout;

    for (timeout = 0; timeout < 3200; timeout++)
        if (midi_devs[midi_dev]->outputc(midi_dev, (unsigned char) (data & 0xff)))
        {
            if (data & 0x80)	/*
				 * Status byte
				 */
                prev_out_status[midi_dev] =
                    (unsigned char) (data & 0xff);	/*
									 * Store for running status
									 */
            return;	/*
					 * Mission complete
					 */
        }
    /*
     * Sorry! No space on buffers.
     */
#ifdef CONFIG_DEBUG_PRINTK
    printk("Midi send timed out\n");
#else
    ;
#endif
}