2 SuperCollider real time audio synthesis system
3 Copyright (c) 2002 James McCartney. All rights reserved.
4 http://www.audiosynth.com
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #include "SC_Lib_Cintf.h"
24 #include "SC_SequencedCommand.h"
25 #include "scsynthsend.h"
28 #include "SC_Prototypes.h"
32 void SendDone(ReplyAddress
*inReply
, const char *inCommandName
)
34 small_scpacket packet
;
39 packet
.adds(inCommandName
);
40 SendReply(inReply
, packet
.data(), packet
.size());
43 void SendDoneWithIntValue(ReplyAddress
*inReply
, const char *inCommandName
, int value
)
45 small_scpacket packet
;
50 packet
.adds(inCommandName
);
53 SendReply(inReply
, packet
.data(), packet
.size());
56 void SendFailure(ReplyAddress
*inReply
, const char *inCommandName
, const char *errString
)
58 small_scpacket packet
;
64 packet
.adds(inCommandName
);
65 packet
.adds(errString
);
66 SendReply(inReply
, packet
.data(), packet
.size());
69 void SendFailureWithBufnum(ReplyAddress
*inReply
, const char *inCommandName
, const char *errString
, uint32 index
)
71 small_scpacket packet
;
77 packet
.adds(inCommandName
);
78 packet
.adds(errString
);
80 packet
.addi((int)index
);
81 SendReply(inReply
, packet
.data(), packet
.size());
84 void ReportLateness(ReplyAddress
*inReply
, float32 seconds
)
86 small_scpacket packet
;
92 SendReply(inReply
, packet
.data(), packet
.size());
95 SC_NamedObj::SC_NamedObj()
100 SC_NamedObj::~SC_NamedObj()
103 void SC_NamedObj::SetName(const int32
*inName
)
105 if (str4len(inName
) > (int)kSCNameLen
) return;
106 str4cpy(mName
, inName
);
110 void SC_NamedObj::SetName(const char *inName
)
112 if (str4len(inName
) > (int)kSCNameLen
) return;
113 str4cpy(mName
, inName
);
117 SC_LibCmd::SC_LibCmd(SC_CommandFunc inFunc
) : mFunc(inFunc
)
120 SCErr
SC_LibCmd::Perform(struct World
*inWorld
, int inSize
, char *inData
, ReplyAddress
*inReply
)
123 // int kSendError = 1; // i.e., 0x01 | 0x02;
125 err
= (mFunc
)(inWorld
, inSize
, inData
, inReply
);
128 } catch (std::exception
& exc
) {
129 if(inWorld
->mLocalErrorNotification
<= 0 && inWorld
->mErrorNotification
) {
130 CallSendFailureCommand(inWorld
, (char*)Name(), exc
.what(), inReply
);
131 scprintf("FAILURE IN SERVER %s %s\n", (char*)Name(), exc
.what());
133 return kSCErr_Failed
;
137 if (err
&& (inWorld
->mLocalErrorNotification
<= 0 && inWorld
->mErrorNotification
)) {
139 SC_ErrorString(err
, errstr
);
140 CallSendFailureCommand(inWorld
, (char*)Name(), errstr
, inReply
);
141 scprintf("FAILURE IN SERVER %s %s\n", (char*)Name(), errstr
);
146 SCErr
NewCommand(const char *inPath
, uint32 inCommandNumber
, SC_CommandFunc inFunc
)
149 sprintf(path
, "/%s", inPath
);
151 SC_LibCmd
*cmd
= new SC_LibCmd(inFunc
);
155 // support OSC commands without the leading slash
156 SC_LibCmd
*cmd2
= new SC_LibCmd(inFunc
);
157 cmd2
->SetName(inPath
);
160 // support integer OSC commands
161 gCmdArray
[inCommandNumber
] = cmd
;