int MixedProcessedAudioStream::parseAudioData(PacketType type, const QByteArray& packetAfterStreamProperties, int numAudioSamples) {

    QByteArray outputBuffer;
    emit processSamples(packetAfterStreamProperties, outputBuffer);
    
    _ringBuffer.writeData(outputBuffer.data(), outputBuffer.size());

    return packetAfterStreamProperties.size();
}
Example #2
0
void CDttSP::runSwitch()
{
	if (m_have == 0) {
		// First time, apply ramp down
		for (unsigned int i = 0U; i < m_fade; i++) {
			float w = 1.0F - float(i) / float(m_fade);

			m_bufferI[i] *= w;
			m_bufferQ[i] *= w;
		}

		::memset(m_bufferI + m_fade, 0x00, m_tail);
		::memset(m_bufferQ + m_fade, 0x00, m_tail);

		m_have++;
	} else if (m_have < m_want) {
		// in medias res
		::memset(m_bufferI, 0x00, m_frames * sizeof(float));
		::memset(m_bufferQ, 0x00, m_frames * sizeof(float));

		m_have++;
	} else {
		// Last time, apply ramp up
		for (unsigned int i = 0U; i < m_fade; i++) {
			float w = float(i) / float(m_fade);

			m_bufferI[i] *= w;
			m_bufferQ[i] *= w;
		}

		m_trx   = m_trxNext;
		m_state = m_stateLast;

		m_want = 0U;
		m_have = 0U;
	}

	processSamples(m_bufferI, m_bufferQ, m_frames);
}
Example #3
0
void StopWatch::sprint(char **str, size_t *size)
{
    if (kVerbose) fprintf(stderr, "printing\n");
    mAlreadyPrinted = true;
    if (0 == mDataLen)
    {
        return;
    }
    if (mDataLen > 0 && mData[mDataLen - 1].mIsStart)
    {
        stop();
    }
    if (kVerbose) SNPRINTF_OR_RETURN(*str, *size, "# Got %d samples for %s\n", mDataLen, mName);
    processSamples();

    SNPRINTF_OR_RETURN(*str, *size, "# StopWatch %s total/cumulative duration %f Samples: %d\n",
                       mName, mDuration, mNum);
    printThroughput(str, size);
    printAverageMinMax(str, size);

    if (printRaw)
    {
        // print comment header and summary values.

        SNPRINTF_OR_RETURN(*str, *size, "# Name Iterations  Duration Min MinIdx Max MaxIdx SizeKbytes\n");
        SNPRINTF_OR_RETURN(*str, *size, "%s %d %f %f %d %f %d %d\n", mName, mNum, mDuration,
                           mMinDuration, mMinIdx, mMaxDuration, mMaxIdx, mSizeKbytes);
        // print each duration sample
        for (size_t i = 0; i < mDataLen / 2; ++i)
        {
            long second = mData[i * 2].mTime.tv_sec - mStart.tv_sec;
            long nano = mData[i * 2].mTime.tv_nsec - mStart.tv_nsec;

            SNPRINTF_OR_RETURN(*str, *size, "%f %f\n", double(second) + double(nano) / 1.0e9, mDeltas[i]);
        }
    }

}
Example #4
0
void CDttSP::runPlay()
{
	processSamples(m_bufferI, m_bufferQ, m_frames);
}
Example #5
0
void KX_ObstacleSimulationTOI_cells::sampleRVO(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavMeshObj, 
					   const float maxDeltaAngle)
{
	vset(activeObst->nvel, 0.f, 0.f);
	float vmax = vlen(activeObst->dvel);

	float* spos = new float[2*m_maxSamples];
	int nspos = 0;

	if (!m_adaptive)
	{
		const float cvx = activeObst->dvel[0]*m_bias;
		const float cvy = activeObst->dvel[1]*m_bias;
		float vmax = vlen(activeObst->dvel);
		const float vrange = vmax*(1-m_bias);
		const float cs = 1.0f / (float)m_sampleRadius*vrange;

		for (int y = -m_sampleRadius; y <= m_sampleRadius; ++y)
		{
			for (int x = -m_sampleRadius; x <= m_sampleRadius; ++x)
			{
				if (nspos < m_maxSamples)
				{
					const float vx = cvx + (float)(x+0.5f)*cs;
					const float vy = cvy + (float)(y+0.5f)*cs;
					if (vx*vx+vy*vy > sqr(vmax+cs/2)) continue;
					spos[nspos*2+0] = vx;
					spos[nspos*2+1] = vy;
					nspos++;
				}
			}
		}
		processSamples(activeObst, activeNavMeshObj, m_obstacles, m_levelHeight, vmax, spos, cs/2, 
			nspos,  activeObst->nvel, m_maxToi, m_velWeight, m_curVelWeight, m_collisionWeight, m_toiWeight);
	}
	else
	{
		int rad;
		float res[2];
		float cs;
		// First sample location.
		rad = 4;
		res[0] = activeObst->dvel[0]*m_bias;
		res[1] = activeObst->dvel[1]*m_bias;
		cs = vmax*(2-m_bias*2) / (float)(rad-1);

		for (int k = 0; k < 5; ++k)
		{
			const float half = (rad-1)*cs*0.5f;

			nspos = 0;
			for (int y = 0; y < rad; ++y)
			{
				for (int x = 0; x < rad; ++x)
				{
					const float vx = res[0] + x*cs - half;
					const float vy = res[1] + y*cs - half;
					if (vx*vx+vy*vy > sqr(vmax+cs/2)) continue;
					spos[nspos*2+0] = vx;
					spos[nspos*2+1] = vy;
					nspos++;
				}
			}

			processSamples(activeObst, activeNavMeshObj, m_obstacles, m_levelHeight, vmax, spos, cs/2, 
				nspos,  res, m_maxToi, m_velWeight, m_curVelWeight, m_collisionWeight, m_toiWeight);

			cs *= 0.5f;
		}
		vcpy(activeObst->nvel, res);
	}
}