prefect
Home Engineering Audio Biking Publications Photo Gallery Personal Info
DACS: MIDI Handler Header, midi.h
 
  next up previous contents
Next: MIDI Handler Code, midi.c Up: MIDI Controller Previous: Main Program Code, midictrl.c   Contents

MIDI Handler Header, midi.h

This is the header file for midi.c. It defines several command bytes from the MIDI protocol as well as gives function prototypes for the MIDI functions.
/*****************************************************************************
 * DACS : Distributed Audio Control System
 *============================================================================
 *         File: midi.c
 *       Author: Stephen S. Richardson
 * Date Created: 04.21.97
 *  Environment: GNU C Compiler (GCC) v2.7.1, Linux i486 v2.0.28
 *        Build: make
 *============================================================================
 * The code, executables, documentation, firmware images, and all related
 * material of DACS are  
 * Copyright (C) 1997 Stephen S. Richardson - ALL RIGHTS RESERVED
 *****************************************************************************/

#ifndef _midi
#define _midi

#define MIDIDATABUFSZ   10            /* size of the MIDI data buffer */

/* run status */
#define MSTART          0x01          /* "start" received */
#define MSTOP           0x02          /* "stop" received */
#define MCONT           0x03          /* "continue" received */


#define MIDICMD_NOTEOFF 0x80          /* note off */
#define MIDICMD_NOTEON  0x90          /* note on */
#define MIDICMD_AFTER   0xA0          /* aftertouch */
#define MIDICMD_CONTROL 0xB0          /* controller */
#define MIDICMD_PROGRAM 0xC0          /* program change */
#define MIDICMD_PRESS   0xD0          /* channel pressure */
#define MIDICMD_BEND    0xE0          /* pitch wheel */

#define MIDICMD_SYSEXST 0xF0          /* sysex start */
#define MIDICMD_SYSEXEN 0xF7          /* sysex end */

#define MIDICMD_MTCQF   0xF1          /* MIDI time code quarter frame */
#define MIDICMD_SPP     0xF2          /* song position pointer */
#define MIDICMD_SONGSEL 0xF3          /* song select */
#define MIDICMD_TUNEREQ 0xF6          /* tune request */

#define MIDICMD_CLOCK   0xF8          /* realtime: clock */
#define MIDICMD_START   0xFA          /* realtime: start */
#define MIDICMD_CONT    0xFB          /* realtime: continue */
#define MIDICMD_STOP    0xFC          /* realtime: stop */
#define MIDICMD_ASENSE  0xFE          /* realtime: active sense */
#define MIDICMD_RESET   0xFF          /* realtime: reset */


/* generic logical MIDI protocol handling structure */
struct midi_stream {
  int fd;                             /* file descriptor for device */
  unsigned char cmd;                  /* current command */
  unsigned char chan;                 /* current channel for command */
  unsigned char data[MIDIDATABUFSZ];  /* data for command */
  unsigned char obuf[MIDIDATABUFSZ];  /* output buffer for device */
  unsigned char *dptr;                /* pointer to current data */
  unsigned int dcount;                /* 'countdown' expected bytes for cmd */
  unsigned long int midiclock;        /* MIDI clock */
  unsigned char runstatus;            /* MIDI run status */
  unsigned char resetflag;            /* MIDI reset flag */
  unsigned char validdata;            /* is cmd valid? */
};

/* function prototypes */
int midi_openser (char *devnam, int bd);
int midi_openmidi (char *devnam);
void midi_readstream (struct midi_stream *ms);
int midi_datawaiting (struct midi_stream *ms);

#endif


Steve Richardson 2000-07-06
Table of Contents

[PDF] [Whole document in PDF 1.9MB]

[more photos and information]

 
Page last modified:
Copyright © 1993-2000 prefect - All Rights Reserved.