Exemple #1
0
void Out_next_a(IOUnit *unit, int inNumSamples)
{
	//Print("Out_next_a %d\n", unit->mNumInputs);
	World *world = unit->mWorld;
	int bufLength = world->mBufLength;
	int numChannels = unit->mNumInputs - 1;

	float fbusChannel = ZIN0(0);
	if (fbusChannel != unit->m_fbusChannel) {
		unit->m_fbusChannel = fbusChannel;
		uint32 busChannel = (uint32)fbusChannel;
		uint32 lastChannel = busChannel + numChannels;

		if (!(lastChannel > world->mNumAudioBusChannels)) {
			unit->m_bus = world->mAudioBus + (busChannel * bufLength);
			unit->m_busTouched = world->mAudioBusTouched + busChannel;
		}
	}

	float *out = unit->m_bus;
	int32 *touched = unit->m_busTouched;
	int32 bufCounter = unit->mWorld->mBufCounter;
	for (int i=0; i<numChannels; ++i, out+=bufLength) {
		ACQUIRE_BUS_AUDIO((int32)fbusChannel + i);
		float *in = IN(i+1);
		if (touched[i] == bufCounter) Accum(inNumSamples, out, in);
		else {
			Copy(inNumSamples, out, in);
			touched[i] = bufCounter;
		}
		RELEASE_BUS_AUDIO((int32)fbusChannel + i);
		//Print("out %d %g %g\n", i, in[0], out[0]);
	}
}
/*----------------------------------------------------------------------------------------------*/
void Correlator::Correlate()
{
	int32_t lcv, leftover;
	CPX *if_data;
	NCO_Command_S *f;
	Correlation_S *c;
	Correlator_State_S *s;

	IncStartTic();

	if((packet_count % MEASUREMENT_INT) == 0)
	{
		TakeMeasurements();
	}

	for(lcv = 0; lcv < MAX_CHANNELS; lcv++)
	{
		if(states[lcv].active)
		{
			s = &states[lcv];
			c = &correlations[lcv];
			f = &feedback[lcv];
			if_data = &packet.data[0];
			leftover = SAMPS_MS;

			/* If the rollover occurs in this packet */
			if(s->rollover <= SAMPS_MS)
			{
				/* Do the actual accumulation */
				Accum(s, c, if_data, s->rollover);

				/* Remaining number of samples to be processed in this ms packet of data */
				leftover = SAMPS_MS - s->rollover;
				if_data += s->rollover;

				/* Update the code/carrier phase etc */
				UpdateState(s, s->rollover);

				/* Dump the accumulation */
				DumpAccum(s, c, f, lcv);

				if(s->active == 0)
					continue;

				/* Now process remaining segment of IF data  */
				if(s->rollover <= leftover) /* Rollover occurs in THIS packet of data */
				{
					/* Do the actual accumulation */
					Accum(s, c, if_data, s->rollover);

					/* Remaining number of samples to be processed in this ms packet of data */
					leftover -= s->rollover;
					if_data += s->rollover;

					/* Update the code/carrier phase etc */
					UpdateState(s, s->rollover);

					/* Dump the accumulation */
					DumpAccum(s, c, f, lcv);

					if(s->active == 0)
						continue;

					/* Do the actual accumulation */
					Accum(s, c, if_data, leftover);

					/* Update the code/carrier phase etc */
					UpdateState(s, leftover);

				}
				else /* Rollover occurs in NEXT packet of data */
				{
					/* Do the actual accumulation */
					Accum(s, c, if_data, leftover);

					/* Update the code/carrier phase */
					UpdateState(s, leftover);
				}

			}
			else /* Just accumulate, no dumping */
			{
				/* Do the actual accumulation */
				Accum(s, c, if_data, SAMPS_MS);

				/* Update the code/carrier phase */
				UpdateState(s, SAMPS_MS);
			}
		} //!< end if active
	} //!< end for

	IncStopTic();

}