Ejemplo n.º 1
0
void
GameSoundBuffer::Play(void * data, int64 frames)
{
	float pan[2];
	pan[0] = fPanRight;
	pan[1] = fPanLeft;
	
	char * buffer = new char[fFrameSize * frames];
			
	FillBuffer(buffer, frames);
	
	switch (fFormat.format) {
		case gs_audio_format::B_GS_U8:
		{
			for (int64 i = 0; i < frames; i++) {
				ApplyMod((uint8*)data, (uint8*)buffer, i, fGain, pan);
				UpdateMods();
			}
		
			break;
		}
		
		case gs_audio_format::B_GS_S16:
		{		
			for (int64 i = 0; i < frames; i++) {
				ApplyMod((int16*)data, (int16*)buffer, i, fGain, pan);
				UpdateMods();
			}
		
			break;
		}
		
		case gs_audio_format::B_GS_S32:
		{
			for (int64 i = 0; i < frames; i++) {
				ApplyMod((int32*)data, (int32*)buffer, i, fGain, pan);
				UpdateMods();
			}
		
			break;
		}
 		
 		case gs_audio_format::B_GS_F:
 		{
			for (int64 i = 0; i < frames; i++) {
				ApplyMod((float*)data, (float*)buffer, i, fGain, pan);
				UpdateMods();
			}
		
			break;
		}
	}
	
	delete[] buffer;
}
Ejemplo n.º 2
0
void psMovementManager::UpdateVelocity()
{
    /// While the client is locked out the server will also reject any attempts to move.
    if (locked || !actor)
        return;

    // Start with the total of all applied movements
    psVelocity vel = move_total;
    
    // Apply special modifier, if we have one
    ApplyMod(vel);

    /** When falling or otherwise not on the ground we restrict movement.
     *  Some control is required to prevent collision detection issues,
     *  and to give the limited ability to turn or glide mid-flight.
     */
    onGround = actor->Movement().IsOnGround();

    // Apply mode's modifier
    vel *= actormode->modifier;
    if (onGround)  // Normal
    {

        #ifdef MOVE_DEBUG
            printf("On Ground: Applying velocity modifier (%.2f,%.2f,%.2f),(%.2f,%.2f,%.2f)\n",
                    actormode->modifier.move.x,actormode->modifier.move.y,actormode->modifier.move.z,
                    actormode->modifier.rotate.x,actormode->modifier.rotate.y,actormode->modifier.rotate.z);
            printf("On Ground: Changing velocity to (%.2f,%.2f,%.2f),(%.2f,%.2f,%.2f)\n",
                    vel.move.x,vel.move.y,vel.move.z,
                    vel.rotate.x,vel.rotate.y,vel.rotate.z);
        #endif

        // Set vertical
        actor->Movement().ClearWorldVelocity();
        actor->Movement().AddVelocity( csVector3(0,vel.move.y,0) );

        // Set horizontal
        actor->Movement().SetVelocity( csVector3(vel.move.x,0,vel.move.z) );
    
        // Set rotation
        actor->Movement().SetAngularVelocity( vel.rotate );

        // Update animating speed
        actor->SetAnimationVelocity( vel.move );
    }
    else  // Airborne
    {
        #ifdef MOVE_DEBUG
            printf("In Air: Adding velocity (%.2f,%.2f,%.2f),(%.2f,%.2f,%.2f)\n",
                    vel.move.x,vel.move.y,vel.move.z,
                    vel.rotate.x,vel.rotate.y,vel.rotate.z);
        #endif

        // Add to existing velocity
        if (vel.move.y <= 0 && (vel.move.x != 0 || vel.move.z != 0))
            actor->Movement().SetVelocity(csVector3(vel.move.x,0,vel.move.z));

        // Set rotation
        actor->Movement().SetAngularVelocity( vel.rotate );
    }
}
Ejemplo n.º 3
0
void
GameSoundBuffer::Play(void * data, int64 frames)
{
	// Mh... should we add some locking?
	if (!fIsPlaying)
		return;

	if (fFormat.channel_count == 2) {
		float pan[2];
		pan[0] = fPanRight * fGain;
		pan[1] = fPanLeft * fGain;

		char * buffer = new char[fFrameSize * frames];

		FillBuffer(buffer, frames);

		switch (fFormat.format) {
			case gs_audio_format::B_GS_U8:
			{
				for (int64 i = 0; i < frames; i++) {
					ApplyMod((uint8*)data, (uint8*)buffer, i, pan);
					UpdateMods();
				}

				break;
			}

			case gs_audio_format::B_GS_S16:
			{
				for (int64 i = 0; i < frames; i++) {
					ApplyMod((int16*)data, (int16*)buffer, i, pan);
					UpdateMods();
				}

				break;
			}

			case gs_audio_format::B_GS_S32:
			{
				for (int64 i = 0; i < frames; i++) {
					ApplyMod((int32*)data, (int32*)buffer, i, pan);
					UpdateMods();
				}

				break;
			}

			case gs_audio_format::B_GS_F:
			{
				for (int64 i = 0; i < frames; i++) {
					ApplyMod((float*)data, (float*)buffer, i, pan);
					UpdateMods();
				}

				break;
			}
		}
		delete[] buffer;
	} else if (fFormat.channel_count == 1) {
		// FIXME the output should be stereo, and we could pan mono sounds
		// here. But currently the output has the same number of channels as
		// the sound and we can't do this.
		// FIXME also, we don't handle the gain here.
		FillBuffer(data, frames);
	} else
		debugger("Invalid number of channels.");

}