home *** CD-ROM | disk | FTP | other *** search
- /* SKELETON.C Skeleton module for Lattice C.
-
- (c) 1987 Todor Fay
- */
-
- #include "exec/exec.h"
- #include "exec/types.h"
- #include "soundscape.h"
- #include "intuition/intuition.h"
-
- /* Images for input and output icons of the module. */
-
- extern struct Image *inimage, *outimage;
-
- /* Define your own state structure for edit routines. */
-
- struct State {
- long length; /* Always has a length field first. */
-
- /* You supply remaining fields. */
-
- };
-
- /* Declare a state structure. */
-
- struct State state = { sizeof(state) - 4, };
-
- /* Pick an ID for your port, and a name. * /
-
- #define PORT_ID 255
- #define PORT_NAME "myportname"
-
- /* The id for this port, returned by AddMidiPort: */
-
- short thisport;
-
- /* Base Pointers to SoundScape and Intuition */
-
- long SoundScapeBase;
- long IntuitionBase;
-
- outcode(note)
-
- /* This is your output routine. It is called by the packet
- router whenever it has a MIDI event for you. Do something
- with the event, then return.
- */
-
- struct Note *note;
-
- {
- FreeNode(note);
- }
-
- opencode(direction)
-
- /* Depending on the direction, open the module for operation.
- Return 1 if successful, 0 if not.
- */
-
- char direction;
-
- {
- if (direction) {
- /* Code to init for sending events. */
- }
- else {
- /* Code to init for receiving events. */
- }
- return(1);
- }
-
- closecode(direction)
-
- {
- if (direction) {
- /* Code to close down sending events. */
- }
- else {
- /* Code to take care of stopping receiving events. */
- }
- return(1);
- }
-
- editcode(direction,command,buffer);
-
- char direction;
- char command;
- struct State *buffer;
-
- {
- switch (command) {
- case USEREDIT :
- if (direction) {
- /* Your edit routine for left icon here. */
- }
- else {
- /* Your edit routine for right icon here. */
- }
- break;
- case SAVESTATE :
- /* Your routine to save to a file here. */
- case GETSTATE :
- movmem(&state,buffer,sizeof(state));
- break;
- case LOADSTATE :
- movmem(buffer,&state,sizeof(state));
- state.length = (sizeof(state) - 4);
- /* Your routine to load a file here. */
- break;
- case SETSTATE :
- movmem(buffer,&state,sizeof(state));
- state.length = (sizeof(state) - 4);
- break;
- }
- }
-
-
- main() {
- IntuitionBase = OpenLibrary("intuition.library",0);
- SoundScapeBase = OpenLibrary("soundscape.library",0);
- if (SoundScapeBase) {
- CloseLibrary(SoundScapeBase);
- thisport = AddMidiPort(opencode,closecode,editcode,outcode,
- &inimage,&outimage,PORT_ID,PORT_NAME);
- SetTaskPri(FindTask(0),-20);
- while (MidiPort(thisport)) Delay(100);
- }
- CloseLibrary(IntuitionBase);
- }
-