Skip to content

Commit

Permalink
massign with an extra parameter selecting port
Browse files Browse the repository at this point in the history
  • Loading branch information
vlazzarini committed Dec 15, 2017
1 parent 85735ad commit 771d0e2
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Engine/entry1.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ OENTRY opcodlst_1[] = {
{ "xout", S(XOUT_MAX),0, 1, "", "*", xoutset, NULL, NULL, NULL },
{ "setksmps", S(SETKSMPS),0, 1, "", "i", setksmpsset, NULL, NULL },
{ "ctrlinit",S(CTLINIT),0,1, "", "im", ctrlinit, NULL, NULL, NULL},
{ "massign",S(MASSIGN), 0,1, "", "iip",massign_p, NULL, NULL, NULL},
{ "massign.iS",S(MASSIGNS), 0,1, "", "iSp",massign_S, NULL, NULL, NULL},
{ "massign",S(MASSIGN), 0,1, "", "iipo",massign_p, NULL, NULL, NULL},
{ "massign.iS",S(MASSIGNS), 0,1, "", "iSpo",massign_S, NULL, NULL, NULL},
{ "turnon", S(TURNON), 0,1, "", "io", turnon, NULL, NULL, NULL},
{ "turnon.S", S(TURNON), 0,1, "", "So", turnon_S, NULL, NULL, NULL},
{ "remoteport", S(REMOTEPORT), 0,1, "", "i", remoteport, NULL, NULL, NULL},
Expand Down
2 changes: 1 addition & 1 deletion Engine/musmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ static int process_rt_event(CSOUND *csound, int sensType)
MCHNBLK *chn;
/* realtime or Midifile */
mep = csound->midiGlobals->Midevtblk;
chn = csound->m_chnbp[mep->chan];
chn = csound->m_chnbp[mep->chan + mep->dev*MAXCHAN];
if ((rfd = getRemoteChnRfd(csound, mep->chan+1))) { /* RM: USE CHAN + 1 */
if (rfd == GLOBAL_REMOT)
MIDIGlobevt(csound, mep);
Expand Down
2 changes: 2 additions & 0 deletions H/midiops.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,15 @@ typedef struct {
MYFLT *chnl;
STRINGDAT *insno;
MYFLT *iresetctls;
MYFLT *iport;
} MASSIGNS;

typedef struct {
OPDS h;
MYFLT *chnl;
MYFLT *insno;
MYFLT *iresetctls;
MYFLT *iport;
} MASSIGN;

typedef struct {
Expand Down
7 changes: 3 additions & 4 deletions InOut/midirecv.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ void midi_ctl_reset(CSOUND *csound, int16 chan)

void m_chanmsg(CSOUND *csound, MEVENT *mep)
{
MCHNBLK *chn = csound->m_chnbp[mep->chan];
MCHNBLK *chn = csound->m_chnbp[mep->chan + mep->dev*MAXCHAN];
int16 n;
MYFLT *fp;

Expand Down Expand Up @@ -377,7 +377,7 @@ void m_chn_init_all(CSOUND *csound)
csound->engineState.instrtxtp[defaultinsno] == NULL);
if (defaultinsno > (int) csound->engineState.maxinsno)
defaultinsno = 0; /* no instruments */
for (chan = (int16) 0; chan < (int16) 16; chan++) {
for (chan = (int16) 0; chan < (int16) (MAXCHAN*MAXPORT); chan++) {
/* alloc a midi control blk for midi channel */
/* & assign default instrument number */
csound->m_chnbp[chan] =
Expand Down Expand Up @@ -415,7 +415,7 @@ int m_chinsno(CSOUND *csound, int chan, int insno, int reset_ctls)
MCHNBLK *chn;
MEVENT mev;

if (chan < 0 || chan > 15)
if (chan < 0 || chan >= MAXCHAN*MAXPORT)
return csound->InitError(csound, Str("illegal channel number"));
chn = csound->m_chnbp[chan];
if (insno <= 0) {
Expand Down Expand Up @@ -568,7 +568,6 @@ int sensMidi(CSOUND *csound)
mep->dat1 = mmsg->bData[1];
mep->dat2 = mmsg->bData[2];
mep->dev = mmsg->bData[3];
printf("Dev=%lld \n", mep->dev);
/* Enter the input event into a buffer used by 'midiin'. */
if (mep->type != SYSTEM_TYPE) {
MIDIMESSAGE *pMessage =
Expand Down
2 changes: 1 addition & 1 deletion InOut/pmidi.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ static int OpenMidiInDevice_(CSOUND *csound, void **userData, const char *dev)
NULL, 512L, (PmTimeProcPtr) NULL, NULL);
// record device number so we can potentially send
// streams to different internal ports
next->devnum = dev[0] == 'a' ? 0 : i;
next->devnum = dev[0] == 'x' ? i : 0;
if (UNLIKELY(retval != pmNoError)) {
// Prevent leaking memory from "data"
if (data) {
Expand Down
8 changes: 4 additions & 4 deletions OOps/midiops.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ int massign_p(CSOUND *csound, MASSIGN *p)
int chnl = (int)(*p->chnl + FL(0.5));
int resetCtls;
int retval = OK;

printf("%lf \n", *p->iport);
resetCtls = (*p->iresetctls == FL(0.0) ? 0 : 1);
if (--chnl >= 0)
retval = m_chinsno(csound, chnl, (int) *p->insno, resetCtls);
retval = m_chinsno(csound, chnl + (int) (*p->iport*MAXCHAN) - 1, (int) *p->insno, resetCtls);
else {
for (chnl = 0; chnl < 16; chnl++) {
for (chnl = 0; chnl < MAXCHAN*MAXPORT; chnl++) {
if (m_chinsno(csound, chnl, (int) *p->insno, resetCtls) != OK)
retval = NOTOK;
}
Expand All @@ -86,7 +86,7 @@ int massign_S(CSOUND *csound, MASSIGNS *p)
if (--chnl >= 0)
retval = m_chinsno(csound, chnl, (int) instno, resetCtls);
else {
for (chnl = 0; chnl < 16; chnl++) {
for (chnl = 0; chnl < MAXCHAN*MAXPORT; chnl++) {
if (m_chinsno(csound, chnl, (int) instno, resetCtls) != OK)
retval = NOTOK;
}
Expand Down
5 changes: 3 additions & 2 deletions include/csoundCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ extern int ISSTRCOD(MYFLT);
#define DFLT_DBFS (FL(32768.0))

#define MAXOCTS 8
#define MAXCHAN 16 /* 16 MIDI channels; only one port for now */
#define MAXCHAN 16 /* 16 MIDI channels; 16 ports */
#define MAXPORT 16

/* A440 tuning factor */
#define ONEPT (csound->A4/430.5389646099018460319362438314060262605)
Expand Down Expand Up @@ -1475,7 +1476,7 @@ typedef struct NAME__ {
MYFLT *auxspin;
OPARMS *oparms;
/** reserve space for up to 4 MIDI devices */
MCHNBLK *m_chnbp[64];
MCHNBLK *m_chnbp[MAXCHAN*MAXPORT];
int dither_output;
MYFLT onedsr, sicvt;
MYFLT tpidsr, pidsr, mpidsr, mtpdsr;
Expand Down

0 comments on commit 771d0e2

Please sign in to comment.