Пример #1
0
SCErr meth_b_query(World *inWorld, int inSize, char *inData, ReplyAddress *inReply)
{
	sc_msg_iter msg(inSize, inData);

	small_scpacket packet;

	int numbufs = msg.remain() >> 2;
	packet.adds("/b_info");
	packet.maketags(numbufs * 4 + 1);
	packet.addtag(',');

	while (msg.remain()) {
		int bufindex = msg.geti();
		SndBuf* buf = World_GetBuf(inWorld, bufindex);

		packet.addtag('i');
		packet.addtag('i');
		packet.addtag('i');
		packet.addtag('f');
		packet.addi(bufindex);
		packet.addi(buf->frames);
		packet.addi(buf->channels);
		packet.addf(buf->samplerate);
	}

	if (packet.size()) {
		CallSequencedCommand(SendReplyCmd, inWorld, packet.size(), packet.data(), inReply);
	}

	return kSCErr_None;
}
bool BufGenCmd::Stage3()
{
	SndBuf* buf = World_GetBuf(mWorld, mBufIndex);
	*buf = mSndBuf;
	mWorld->mSndBufUpdates[mBufIndex].writes ++ ;
	return true;
}
Пример #3
0
SCErr meth_b_fill(World *inWorld, int inSize, char *inData, ReplyAddress* /*inReply*/)
{
	sc_msg_iter msg(inSize, inData);
	int bufindex = msg.geti();
	SndBuf* buf = World_GetBuf(inWorld, bufindex);
	if (!buf) return kSCErr_Failed;

	float *data = buf->data;
	int numSamples = buf->samples;

	while (msg.remain() >= 12)
	{
		int32 start = msg.geti();
		int32 n = msg.geti();
		float32 value = msg.getf();
		int32 end = start+n-1;

		if (end < 0 || start >= numSamples) continue;

		start = sc_clip(start, 0, numSamples-1);
		end   = sc_clip(end,   0, numSamples-1);

		for (int i=start; i<=end; ++i) data[i] = value;
	}

	return kSCErr_None;
}
bool BufAllocCmd::Stage3()
{
	SndBuf* buf = World_GetBuf(mWorld, mBufIndex);
	*buf = mSndBuf;
	mWorld->mSndBufUpdates[mBufIndex].writes ++ ;
	SEND_COMPLETION_MSG;
	return true;
}
Пример #5
0
SCErr meth_b_getn(World *inWorld, int inSize, char *inData, ReplyAddress* inReply)
{
	sc_msg_iter msg(inSize, inData);
	int bufindex = msg.geti();
	SndBuf* buf = World_GetBuf(inWorld, bufindex);
	if (!buf) return kSCErr_Failed;

	float *data = buf->data;
	int32 maxIndex = buf->samples;

	// figure out how many tags to allocate
	int numcontrols = 0;
	int numheads = msg.remain() >> 3;

	while (msg.remain()) {
		msg.geti(); // skip start
		int32 n = msg.geti();
		numcontrols += n;
	}

	big_scpacket packet;
	packet.adds("/b_setn");
	packet.maketags(numheads * 2 + numcontrols + 2);
	packet.addtag(',');

	// start over at beginning of message
	msg.init(inSize, inData);
	msg.geti(); // skip buf index

	packet.addtag('i');
	packet.addi(bufindex);

	while (msg.remain()) {
		int32 start = msg.geti();
		int32 n = msg.geti();
		int32 end = start+n-1;

		if (start < 0 || end >= maxIndex || start > end)
			return kSCErr_IndexOutOfRange;

		packet.addtag('i');
		packet.addtag('i');
		packet.addi(start);
		packet.addi(n);

		for (int i=start; i<=end; ++i) {
			packet.addtag('f');
			packet.addf(data[i]);
		}
	}

	if (packet.size()) {
		CallSequencedCommand(SendReplyCmd, inWorld, packet.size(), packet.data(), inReply);
	}

	return kSCErr_None;
}
bool BufReadChannelCmd::Stage3()
{
	SndBuf* buf = World_GetBuf(mWorld, mBufIndex);
	buf->samplerate = mSampleRate;
	if (mLeaveFileOpen) buf->mask = buf->mask1 = -1;

	mWorld->mSndBufUpdates[mBufIndex].writes ++ ;
	SEND_COMPLETION_MSG;
	return true;
}
bool BufFreeCmd::Stage3()
{
	SndBuf *buf = World_GetBuf(mWorld, mBufIndex);

	SndBuf_Init(buf);
	mWorld->mSndBufUpdates[mBufIndex].writes ++ ;
	SEND_COMPLETION_MSG;

	return true;
}
Пример #8
0
SCErr meth_b_set(World *inWorld, int inSize, char *inData, ReplyAddress* /*inReply*/)
{
	sc_msg_iter msg(inSize, inData);
	int bufindex = msg.geti();
	SndBuf* buf = World_GetBuf(inWorld, bufindex);
	if (!buf) return kSCErr_Failed;

	float *data = buf->data;
	uint32 numSamples = buf->samples;

	while (msg.remain() >= 8)
	{
		uint32 sampleIndex = msg.geti();
		float32 value = msg.getf();
		if (sampleIndex < numSamples)
		{
			data[sampleIndex] = value;
		} else return kSCErr_IndexOutOfRange;

	}
	return kSCErr_None;
}
Пример #9
0
SCErr meth_b_get(World *inWorld, int inSize, char *inData, ReplyAddress* inReply)
{
	sc_msg_iter msg(inSize, inData);
	int bufindex = msg.geti();
	SndBuf* buf = World_GetBuf(inWorld, bufindex);
	if (!buf) return kSCErr_Failed;

	float *data = buf->data;
	uint32 maxIndex = buf->samples;

	int numheads = msg.remain() >> 2;

	big_scpacket packet;
	packet.adds("/b_set");
	packet.maketags(numheads * 2 + 2);
	packet.addtag(',');
	packet.addtag('i');
	packet.addi(bufindex);

	while (msg.remain() >= 4)
	{
		uint32 index = msg.geti();
		if (index >= maxIndex)
			return kSCErr_IndexOutOfRange;
		packet.addtag('i');
		packet.addtag('f');
		packet.addi(index);
		packet.addf(data[index]);
	}

	if (packet.size()) {
		CallSequencedCommand(SendReplyCmd, inWorld, packet.size(), packet.data(), inReply);
	}

	return kSCErr_None;
}