Path: utzoo!mnetor!uunet!husc6!rutgers!iuvax!pur-ee!j.cc.purdue.edu!ain From: ain@j.cc.purdue.edu (Patrick White) Newsgroups: comp.sources.amiga Subject: midi library (part 1 of 1) Message-ID: <6771@j.cc.purdue.edu> Date: 25 Mar 88 04:21:10 GMT Organization: PUCC Land, USA Lines: 599 Keywords: midi, library, part 1 of 1 Approved: ain@j.cc.purdue.edu (Pat White) Program Name: midi library (part 1 of 1) Submitted By: Pete Yadlowsky Summary: This is a midi library Poster Boy: Pat White (ain@j.cc.purdue.edu) Untested. NOTES: Not much we could do to test this, so we didn't bother. I reshar'ed it to separate docs, etc. example code posted to sources as it is source. -- Pat White (co-moderator comp.sources/binaries.amiga) UUCP: j.cc.purdue.edu!ain BITNET: PATWHITE@PURCCVM PHONE: (317) 743-8421 U.S. Mail: 320 Brown St. apt. 406, West Lafayette, IN 47906 ======================================== # This is a shell archive. # Remove everything above and including the cut line. # Then run the rest of the file through sh. #----cut here-----cut here-----cut here-----cut here----# #!/bin/sh # shar: Shell Archiver # Run the following text with /bin/sh to create: # asmsupp.i # midi.h # midi.i # midibase.h # midibase.i # This archive created: Sun Mar 20 16:49:59 1988 # By: Patrick White (PUCC Land, USA) echo shar: extracting asmsupp.i '(452 characters)' cat << \SHAR_EOF > asmsupp.i * * asmsupp.i - some handy (read essential) macros * ifnd _ASMSUPP_I _ASMSUPP_I set 1 ifnd EXEC_LIBRARIES_I include "exec/libraries.i" endc CLEAR macro moveq #0,\1 endm LINKSYS macro LINKLIB _LVO\1,\2 endm CALLSYS macro CALLLIB _LVO\1 endm XLIB macro xref _LVO\1 endm FUNCDEF macro public _LVO\1 LIBDEF _LVO\1 endm push macro movem.l \1,-(sp) endm pop macro movem.l (sp)+,\1 endm CLEARA macro suba.l \1,\1 endm endc SHAR_EOF if test 452 -ne "`wc -c asmsupp.i`" then echo shar: error transmitting asmsupp.i '(should have been 452 characters)' fi echo shar: extracting midi.h '(4193 characters)' cat << \SHAR_EOF > midi.h #ifndef MIDI_MIDI_H #define MIDI_MIDI_H #ifndef EXEC_LISTS_H #include #endif #ifndef EXEC_PORTS_H #include #endif /* midi.library structures & defines */ #define MIDINAME "midi.library" #define MIDIVERSION 1L struct MSource { struct Node Node; struct Image *Image; struct MinList RPList; APTR UserData; /* user data extension */ }; /* node types for Source */ #define NT_MSOURCE 0x20 #define NT_PERMMSOURCE 0x21 struct MDest { struct Node Node; struct Image *Image; struct MinList RPList; struct MsgPort *DestPort; APTR UserData; /* user data extension */ }; /* node types for Dest */ #define NT_MDEST 0x22 #define NT_PERMMDEST 0x23 struct RIMatch { UBYTE count; /* 0 for match all */ UBYTE match[3]; }; struct MRouteInfo { UWORD MsgFlags; UWORD ChanFlags; BYTE ChanOffset; BYTE NoteOffset; struct RIMatch SysExMatch; struct RIMatch CtrlMatch; }; /* Msg Flags for MRouteInfo structure and returned by MidiMsgType */ #define MMF_CHAN 0x00ff #define MMF_NOTEOFF 0x0001 #define MMF_NOTEON 0x0002 #define MMF_POLYPRESS 0x0004 #define MMF_CTRL 0x0008 #define MMF_PROG 0x0010 #define MMF_CHANPRESS 0x0020 #define MMF_PITCHBEND 0x0040 #define MMF_MODE 0x0080 #define MMF_SYSCOM 0x0100 #define MMF_SYSRT 0x0200 #define MMF_SYSEX 0x0400 struct MRoutePtr { struct MinNode node; struct MRoute *Route; }; struct MRoute { struct MSource *Source; struct MDest *Dest; struct MRoutePtr SRoutePtr, DRoutePtr; struct MRouteInfo RouteInfo; }; /* MIDI message defines - based on IMA MIDI Spec 1.0 except where noted */ /* Status Bytes */ /* Channel Voice Messages (1sssnnnn) */ #define MS_NOTEOFF 0x80 #define MS_NOTEON 0x90 #define MS_POLYPRESS 0xA0 #define MS_CTRL 0xB0 #define MS_MODE 0xB0 #define MS_PROG 0xC0 #define MS_CHANPRESS 0xD0 #define MS_PITCHBEND 0xE0 /* System Common Messages */ #define MS_SYSEX 0xF0 #define MS_SONGPOS 0xF2 #define MS_SONGSELECT 0xF3 #define MS_TUNEREQ 0xF6 #define MS_EOX 0xF7 /* System Real Time Messages */ #define MS_CLOCK 0xF8 #define MS_START 0xFA #define MS_CONTINUE 0xFB #define MS_STOP 0xFC #define MS_ACTVSENSE 0xFE #define MS_RESET 0xFF /* Standard Controllers (from MMA - 8-86) /* proportional MSB - 0-31, LSB - 32-63 */ #define MC_MODWHEEL 1 #define MC_BREATH 2 #define MC_FOOT 4 #define MC_PORTATIME 5 #define MC_DATAENTRY 6 #define MC_VOLUME 7 #define MC_BALANCE 8 #define MC_PAN 10 /* switches/pedals - either on(7F) or off(00) */ #define MC_SUSTAIN 64 #define MC_PORTA 65 #define MC_SUSTENUTO 66 #define MC_SOFTPEDAL 67 #define MC_HOLD2 69 #define MC_DATAINCR 96 #define MC_DATADECR 97 /* Channel Modes */ #define MM_LOCAL 122 #define MM_ALLOFF 123 #define MM_OMNIOFF 124 #define MM_OMNION 125 #define MM_MONO 126 #define MM_POLY 127 /* Sys/Ex ID numbers (from MMA as described in IMA bulletin) */ #define MID_SCI 0x01 #define MID_BIGBRIAR 0x02 #define MID_OCTAVEPLATEAU 0x03 #define MID_MOOG 0x04 #define MID_PASSPORT 0x05 #define MID_LEXICON 0x06 #define MID_OBERHEIM 0x10 #define MID_PAIA 0x11 #define MID_SIMMONS 0x12 #define MID_FAIRLIGHT 0x14 #define MID_BONTEMPI 0x20 #define MID_SIEL 0x21 #define MID_SYNTHAXE 0x23 #define MID_KAWAI 0x40 #define MID_ROLAND 0x41 #define MID_KORG 0x42 #define MID_YAMAHA 0x43 /* special Sys/Ex ID numbers: Non-Commercial, Non-Real Time, Real Time */ #define MID_NC 0x7d #define MID_NRT 0x7e #define MID_RT 0x7f /* handy macros */ /* pack high/low bytes of a word into midi format */ #define MIDI_HIBYTE(word) ( (word) >> 7 & 0x7f ) #define MIDI_LOBYTE(word) ( (word) & 0x7f ) /* unpack 2 midi bytes into a word */ #define MIDI_WORD(hi,lo) ( (hi & 0x7f) << 7 | (lo & 0x7f) ) /* midi.library routine declarations */ struct MSource *CreateMSource(), *FindMSource(); struct MDest *CreateMDest(), *FindMDest(); struct MRoute *CreateMRoute(), *MRouteSource(), *MRouteDest(), *MRoutePublic(); UBYTE *GetMidiMsg(); BOOL PutMidiMsg(); ULONG MidiMsgLength(), MidiMsgType(); #endif SHAR_EOF if test 4193 -ne "`wc -c midi.h`" then echo shar: error transmitting midi.h '(should have been 4193 characters)' fi echo shar: extracting midi.i '(3204 characters)' cat << \SHAR_EOF > midi.i ; midi/midi.i ifnd MIDI_MIDI_I MIDI_MIDI_I set 1 ifnd EXEC_LISTS_I include "exec/lists.i" endc MIDINAME macro dc.b 'midi.library',0 endm MIDIVERSION equ 1 STRUCTURE MSource,LN_SIZE APTR ms_Image STRUCT ms_RPList,MLH_SIZE APTR ms_UserData LABEL sizeof_MSource ; Node Types for MSource nodes NT_MSOURCE equ $20 NT_PERMMSOURCE equ $21 STRUCTURE MDest,LN_SIZE APTR md_Image STRUCT md_RPList,MLH_SIZE APTR md_DestPort APTR md_UserData LABEL sizeof_MDest ; Node Types for MDest nodes NT_MDEST equ $22 NT_PERMMDEST equ $23 STRUCTURE RIMatch,0 UBYTE rim_count STRUCT rim_match,3 LABEL sizeof_RIMatch STRUCTURE MRouteInfo,0 UWORD ri_MsgFlags UWORD ri_ChanFlags BYTE ri_ChanOffset BYTE ri_NoteOffset STRUCT ri_SysExMatch,sizeof_RIMatch STRUCT ri_CtrlMatch,sizeof_RIMatch LABEL sizeof_MRouteInfo ; Midi Msg Type Flags for RouteInfo and returned by MidiMsgType MMF_CHAN equ $00ff MMF_NOTEOFF equ $0001 MMF_NOTEON equ $0002 MMF_POLYPRESS equ $0004 MMF_CTRL equ $0008 MMF_PROG equ $0010 MMF_CHANPRESS equ $0020 MMF_PITCHBEND equ $0040 MMF_MODE equ $0080 MMF_SYSCOM equ $0100 MMF_SYSRT equ $0200 MMF_SYSEX equ $0400 STRUCTURE MRoutePtr,MLN_SIZE APTR rp_Route LABEL sizeof_MRoutePtr STRUCTURE MRoute,0 APTR mr_Source APTR mr_Dest STRUCT mr_SRoutePtr,sizeof_MRoutePtr STRUCT mr_DRoutePtr,sizeof_MRoutePtr STRUCT mr_RouteInfo,sizeof_MRouteInfo LABEL sizeof_MRoute ; MIDI message defines - based on IMA MIDI Spec 1.0 except where noted ; Status Bytes ; Channel Voice Messages (1sssnnnn) MS_NOTEOFF equ $80 MS_NOTEON equ $90 MS_POLYPRESS equ $A0 MS_CTRL equ $B0 MS_MODE equ $B0 MS_PROG equ $C0 MS_CHANPRESS equ $D0 MS_PITCHBEND equ $E0 ; System Common Messages MS_SYSEX equ $F0 MS_SONGPOS equ $F2 MS_SONGSELECT equ $F3 MS_TUNEREQ equ $F6 MS_EOX equ $F7 ; System Real Time Messages MS_CLOCK equ $F8 MS_START equ $FA MS_CONTINUE equ $FB MS_STOP equ $FC MS_ACTVSENSE equ $FE MS_RESET equ $FF ; Standard Controllers (from MMA - 8-86) ; proportional MSB - 0-31, LSB - 32-63 MC_MODWHEEL equ 1 MC_BREATH equ 2 MC_FOOT equ 4 MC_PORTATIME equ 5 MC_DATAENTRY equ 6 MC_VOLUME equ 7 MC_BALANCE equ 8 MC_PAN equ 10 ; switches/pedals - either on(7F) or off(00) MC_SUSTAIN equ 64 MC_PORTA equ 65 MC_SUSTENUTO equ 66 MC_SOFTPEDAL equ 67 MC_HOLD2 equ 69 MC_DATAINCR equ 96 MC_DATADECR equ 97 ; Channel Modes MM_LOCAL equ 122 MM_ALLOFF equ 123 MM_OMNIOFF equ 124 MM_OMNION equ 125 MM_MONO equ 126 MM_POLY equ 127 ; Sys/Ex ID numbers (from MMA as described in IMA bulletin) MID_SCI equ $01 MID_BIGBRIAR equ $02 MID_OCTAVEPLATEAU equ $03 MID_MOOG equ $04 MID_PASSPORT equ $05 MID_LEXICON equ $06 MID_OBERHEIM equ $10 MID_PAIA equ $11 MID_SIMMONS equ $12 MID_FAIRLIGHT equ $14 MID_BONTEMPI equ $20 MID_SIEL equ $21 MID_SYNTHAXE equ $23 MID_KAWAI equ $40 MID_ROLAND equ $41 MID_KORG equ $42 MID_YAMAHA equ $43 ; special Sys/Ex ID numbers: Non-Commercial, Non-Real Time, Real Time MID_NC equ $7d MID_NRT equ $7e MID_RT equ $7f endc SHAR_EOF if test 3204 -ne "`wc -c midi.i`" then echo shar: error transmitting midi.i '(should have been 3204 characters)' fi echo shar: extracting midibase.h '(1206 characters)' cat << \SHAR_EOF > midibase.h #ifndef MIDI_MIDIBASE_H #define MIDI_MIDIBASE_H /* midi.library MidiBase & related definitions (not for the casual midi user) */ #ifndef EXEC_LIBRARIES_H #include #endif #ifndef EXEC_SEMAPHORES_H #include #endif #ifndef LIBRARIES_DOS_H #include #endif #ifndef MIDI_MIDI_H #include #endif struct MidiBase { struct Library libnode; struct List SourceList,DestList; struct SignalSemaphore ListSemaphore; /* blocks Source/Dest list management */ struct SignalSemaphore RouteSemaphore; /* blocks RPList management & msg routing */ ULONG SegList; APTR SysBase,DosBase; }; struct MTaskInfo { /* set by caller */ char *Name; WORD Pri; void (*Entry)(); UWORD Stack; UWORD Sources; struct MNodeInfo *SourceList; UWORD Dests; struct MNodeInfo *DestList; /* set by midi.library */ struct SignalSemaphore Semaphore; /* locks task */ UWORD UsageCount; /* task's usage count */ struct MsgPort *TaskPort; /* task's MsgPort */ BPTR Segment; /* task's Segment */ }; struct MNodeInfo { char *Name; struct Image *Image; APTR Node; }; #endif SHAR_EOF if test 1206 -ne "`wc -c midibase.h`" then echo shar: error transmitting midibase.h '(should have been 1206 characters)' fi echo shar: extracting midibase.i '(1500 characters)' cat << \SHAR_EOF > midibase.i ; midi/midibase.i ifnd MIDI_MIDIBASE_I MIDI_MIDIBASE_I set 1 ifnd EXEC_LIBRARIES_I include "exec/libraries.i" endc ifnd EXEC_SEMAPHORES_I include "exec/semaphores.i" endc ifnd LIBRARIES_DOS_I include "libraries/dos.i" endc ifnd MIDI_MIDI_I include "midi/midi.i" endc STRUCTURE MidiBase,LIB_SIZE ; Library Base STRUCT ml_SourceList,LH_SIZE ; Source List STRUCT ml_DestList,LH_SIZE ; Dest List STRUCT ml_ListSemaphore,SS_SIZE ; locks source/dest lists - blocks Src & Dst list management ; (locked when LockBase is called) STRUCT ml_RouteSemaphore,SS_SIZE ; locks routes - blocks msg routing & RPList management in Src & Dst ULONG ml_SegList ; Segment List for the library ULONG ml_SysBase ; SysBase ULONG ml_DosBase ; DosBase LABEL sizeof_MidiBase STRUCTURE MTaskInfo,0 ; Task info structure for PermNodes APTR ti_Name ; Process Name WORD ti_Pri ; Process Priority APTR ti_Entry ; Entry point UWORD ti_Stack ; Stack Size UWORD ti_Sources ; source count APTR ti_SourceList ; source list UWORD ti_Dests ; dest count APTR ti_DestList ; dest list STRUCT ti_Semaphore,SS_SIZE ; signal semaphore for locking this task UWORD ti_UsageCount APTR ti_TaskPort ; task's MsgPort BPTR ti_Segment ; BPTR pointer to tasks segment LABEL sizeof_MTaskInfo STRUCTURE MNodeInfo,0 ; PermNode info structure APTR ni_Name ; Node Name APTR ni_Image ; Node Image APTR ni_Node ; Node pointer LABEL sizeof_MNodeInfo endc SHAR_EOF if test 1500 -ne "`wc -c midibase.i`" then echo shar: error transmitting midibase.i '(should have been 1500 characters)' fi # End of shell archive exit 0