remote.h

Go to the documentation of this file.
00001 /*
00002     remote.h:
00003 
00004     Copyright (C) 2006 by Barry Vercoe
00005 
00006     This file is not yet part of Csound.
00007 
00008     The Csound Library is free software; you can redistribute it
00009     and/or modify it under the terms of the GNU Lesser General Public
00010     License as published by the Free Software Foundation; either
00011     version 2.1 of the License, or (at your option) any later version.
00012 
00013     Csound is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016     GNU Lesser General Public License for more details.
00017 
00018     You should have received a copy of the GNU Lesser General Public
00019     License along with Csound; if not, write to the Free Software
00020     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00021     02111-1307 USA
00022 */
00023 
00024 #ifndef CSOUND_REMOTE_H
00025 #define CSOUND_REMOTE_H
00026 
00027 #ifdef HAVE_SOCKETS
00028 #ifdef WIN32
00029 #include <winsock.h>
00030 #else
00031 #include <sys/socket.h>
00032 #include <netinet/in.h>
00033 #include <arpa/inet.h>
00034 #ifdef HAVE_UNISTD_H
00035 #  include <unistd.h>
00036 #endif
00037 #endif
00038 #endif /* HAVE_SOCKETS */
00039 
00040 #include <stdlib.h>
00041 #include <stdio.h>
00042 #ifdef HAVE_SYS_TYPES_H
00043 #  include <sys/types.h>
00044 #endif
00045 #include <string.h>
00046 #include <errno.h>
00047 
00048 
00049 void m_chanmsg(CSOUND *csound, MEVENT *mep);   /* called from midirecv & musmon */
00050 char remoteID(CSOUND *csound);
00051 
00052 #define REMOT_PORT 40002
00053 
00054 #define SCOR_EVT 1
00055 #define MIDI_EVT 2
00056 #define MIDI_MSG 3
00057 #define MAXSEND (sizeof(EVTBLK) + 2*sizeof(int))
00058 #define GLOBAL_REMOT -99
00059 
00060 typedef struct {                        /* Remote Communication buffer          */
00061     int         len;                    /* lentot = len + type + data used      */
00062     int         type;
00063     char        data[MAXSEND];
00064 } REMOT_BUF;
00065 
00066 #ifdef HAVE_SOCKETS
00067 
00068 
00069 typedef struct {
00070     char *adr;
00071     int   rfd;
00072 } SOCK;
00073 
00074 typedef struct {
00075   SOCK *socksout; /* = NULL; */
00076   int *socksin; /* = NULL; */
00077   int *insrfd_list; /* = NULL; */
00078   int *chnrfd_list; /* = NULL; */
00079   int insrfd_count; /* = 0; */
00080   int chnrfd_count; /* = 0; */
00081   int  *insrfd; /* = NULL; */
00082   int  *chnrfd; /* = NULL; */
00083   char *ipadrs; /* = NULL; */
00084   struct sockaddr_in to_addr;
00085   struct sockaddr_in local_addr;
00086   REMOT_BUF CLsendbuf;          /* rt evt output Communications buffer */
00087   int   remote_port;            /* = 40002 default */
00088 } REMOTE_GLOBALS;
00089 
00090 #endif /* HAVE_SOCKETS */
00091 
00092 typedef struct {                        /* structs for INSTR 0 opcodes */
00093     OPDS    h;
00094     MYFLT   *port;
00095 } REMOTEPORT;
00096 
00097 typedef struct {                        /* structs for INSTR 0 opcodes */
00098     OPDS    h;
00099     MYFLT   *str1, *str2, *insno[64];
00100 } INSREMOT;
00101 
00102 typedef struct {                                /* structs for INSTR 0 opcodes */
00103     OPDS    h;
00104     MYFLT   *str1, *insno[64];
00105 } INSGLOBAL;
00106 
00107 typedef struct {
00108     OPDS    h;
00109     MYFLT   *str1, *str2, *chnum[16];
00110 } MIDREMOT;
00111 
00112 typedef struct {                                /* structs for INSTR 0 opcodes */
00113     OPDS    h;
00114     MYFLT   *str1, *chnum[16];
00115 } MIDGLOBAL;
00116 
00117 int CLsend(CSOUND *csound, int conn, void *data, int length);
00118 int SVrecv(CSOUND *csound, int conn, void *data, int length);
00119 
00120 /* musmon:      divert a score insno event to a remote machine */
00121 int insSendevt(CSOUND *p, EVTBLK *evt, int rfd);
00122 
00123 /* musmon:      send an event (funcs, reverbs) to all active remote machines */
00124 int insGlobevt(CSOUND *p, EVTBLK *evt);
00125 
00126 /* musmon:      divert a MIDI channel event to a remote machine */
00127 int MIDIsendevt(CSOUND *p, MEVENT *evt, int rfd);
00128 
00129 /* musmon:      send a MIDI channel event (ctrlrs, reverbs) to all
00130    active remote machines */
00131 int MIDIGlobevt(CSOUND *p, MEVENT *evt);
00132 
00133 /* midirecv:    divert a MIDI channel message to a remote machine */
00134 int MIDIsend_msg(CSOUND *p, MEVENT *evt, int rfd);
00135 
00136 /* midirecv:    send a MIDI channel message (ctrlrs, reverbs) to all
00137    active remote machines */
00138 int MIDIGlob_msg(CSOUND *p, MEVENT *evt);
00139 
00140 /* musmon: returns the active input sockets # */
00141 int* getRemoteSocksIn(CSOUND *csound);
00142 
00143 /* musmon: determine whether an instrument accepts remove events */
00144 int getRemoteInsRfd(CSOUND *csound, int insno);
00145 
00146 /* musmon: determine how many instruments accept remove events */
00147 int getRemoteInsRfdCount(CSOUND *csound);
00148 
00149 /* musmon: determine whether MIDI channel accepts remove events */
00150 int getRemoteChnRfd(CSOUND *csound, int chan);
00151 
00152 #endif      /* CSOUND_REMOTE_H */

Generated on Sun Nov 9 00:04:52 2008 for Csound and CsoundAC by  doxygen 1.5.6