void test_cute_filter_runner_ArgvFilter() {
	char const *argv[] = { "dummy", "testsuite1", "testsuite2#test1",
			"testsuite2#test3", 0 };
	std::vector<std::string> args;
	std::copy(argv + 1, argv + sizeof(argv) / sizeof(*argv) - 1,
			std::back_inserter(args));
	cute::runner_aux::ArgvTestFilter filter1("", args);
	ASSERT(filter1.shouldRun("any"));
	cute::runner_aux::ArgvTestFilter filter2("testsuite1", args);
	ASSERT(filter2.shouldrunsuite);
	ASSERT(filter2.shouldRun("test"));
	ASSERT(filter2.shouldRun("test1"));
	ASSERT(filter2.shouldRun("test2"));
	ASSERT(filter2.shouldRun("test3"));
	ASSERT(filter2.shouldRun("test4"));
	cute::runner_aux::ArgvTestFilter filter3("dummy", args);

	ASSERT(!filter3.shouldrunsuite);
	cute::runner_aux::ArgvTestFilter filter4("testsuite2", args);
	ASSERT(filter4.shouldrunsuite);
	ASSERT(!filter4.shouldRun("test"));
	ASSERT(filter4.shouldRun("test1"));
	ASSERT(!filter4.shouldRun("test2"));
	ASSERT(filter4.shouldRun("test3"));
	ASSERT(!filter4.shouldRun("test4"));

}
示例#2
0
/*
 *			M A I N
 */
int
main(int argc, char **argv)
{
    unsigned char	*inbuf;
    unsigned char	*outbuf;
    int	*rout, *gout, *bout;
    long int	out_width;
    long int	i;
    int	eof_seen;

    if ( !get_args( argc, argv ) )  {
	(void)fputs(usage, stderr);
	bu_exit ( 1, NULL );
    }

    /* autosize input? */
    if ( fileinput && autosize ) {
	unsigned long int	w, h;
	if ( fb_common_file_size(&w, &h, file_name, 3) ) {
	    file_width = (long)w;
	} else {
	    fprintf(stderr, "pixhalve: unable to autosize\n");
	}
    }
    out_width = file_width/2;

    /* Allocate 1-scanline input & output buffers */
    inbuf = malloc( 3*file_width+8 );
    outbuf = malloc( 3*(out_width+2)+8 );

    /* Allocate 5 integer arrays for each color */
    /* each width+2 elements wide */
    for ( i=0; i<5; i++ )  {
	rlines[i] = (int *)bu_calloc( (file_width+4)+1, sizeof(long), "rlines" );
	glines[i] = (int *)bu_calloc( (file_width+4)+1, sizeof(long), "glines" );
	blines[i] = (int *)bu_calloc( (file_width+4)+1, sizeof(long), "blines" );
    }

    /* Allocate an integer array for each color, for output */
    rout = (int *)bu_malloc( out_width * sizeof(long) + 8, "rout" );
    gout = (int *)bu_malloc( out_width * sizeof(long) + 8, "gout" );
    bout = (int *)bu_malloc( out_width * sizeof(long) + 8, "bout" );

    /*
     *  Prime the pumps with 5 lines of image.
     *  Repeat the bottom most line three times to generate a "fill"
     *  line on the bottom.  This will have to be matched on the top.
     */
    if ( fread( inbuf, 3, file_width, infp ) != file_width )  {
	perror(file_name);
	fprintf(stderr, "pixhalve:  fread error\n");
	bu_exit (1, NULL);
    }
    separate( &rlines[0][2], &glines[0][2], &blines[0][2], inbuf, file_width );
    separate( &rlines[1][2], &glines[1][2], &blines[1][2], inbuf, file_width );
    separate( &rlines[2][2], &glines[2][2], &blines[2][2], inbuf, file_width );
    for ( i=3; i<5; i++ )  {
	if ( fread( inbuf, 3, file_width, infp ) != file_width )  {
	    perror(file_name);
	    fprintf(stderr, "pixhalve:  fread error\n");
	    bu_exit (1, NULL);
	}
	separate( &rlines[i][2], &glines[i][2], &blines[i][2],
		  inbuf, file_width );
    }

    eof_seen = 0;
    for (;;)  {
	filter3( rout, rlines, out_width );
	filter5( gout, glines, out_width );
	filter5( bout, blines, out_width );
	combine( outbuf, rout, gout, bout, out_width );
	if ( fwrite( (void*)outbuf, 3, out_width, stdout ) != out_width )  {
	    perror("stdout");
	    bu_exit (2, NULL);
	}

	/* Ripple down two scanlines, and acquire two more */
	if ( fread( inbuf, 3, file_width, infp ) != file_width )  {
	    if ( eof_seen >= 2 )  break;
	    /* EOF, repeat last line 2x for final output line */
	    eof_seen++;
	    /* Fall through */
	}
	ripple( rlines, 5 );
	ripple( glines, 5 );
	ripple( blines, 5 );
	separate( &rlines[4][2], &glines[4][2], &blines[4][2],
		  inbuf, file_width );

	if ( fread( inbuf, 3, file_width, infp ) != file_width )  {
	    if ( eof_seen >= 2 )  break;
	    /* EOF, repeat last line 2x for final output line */
	    eof_seen++;
	    /* Fall through */
	}
	ripple( rlines, 5 );
	ripple( glines, 5 );
	ripple( blines, 5 );
	separate( &rlines[4][2], &glines[4][2], &blines[4][2],
		  inbuf, file_width );
    }

    bu_free(rlines, "rlines");
    bu_free(glines, "glines");
    bu_free(blines, "blines");
    bu_free(rout, "rout");
    bu_free(gout, "gout");
    bu_free(bout, "bout");
}
void run_function() {
    ASSERT(!filter_node_count, NULL);

    const size_t number_of_filters = 3;

    input_filter<type1> i_filter;
    middle_filter<type1, type2> m_filter;
    output_filter<type2> o_filter;

    unsigned limit = 1;
    // Test pipeline that contains number_of_filters filters
    for( unsigned i=0; i<number_of_filters; ++i)
        limit *= number_of_filter_types;
    // Iterate over possible filter sequences
    for( unsigned numeral=0; numeral<limit; ++numeral ) {
        unsigned temp = numeral;
        tbb::filter::mode filter_type[number_of_filter_types];
        for( unsigned i=0; i<number_of_filters; ++i, temp/=number_of_filter_types ) 
            filter_type[i] = filter_table[temp%number_of_filter_types];

        tbb::filter_t<void, type1> filter1( filter_type[0], i_filter );
        tbb::filter_t<type1, type2> filter2( filter_type[1], m_filter );
        tbb::filter_t<type2, void> filter3( filter_type[2], o_filter );
        ASSERT(filter_node_count==3, "some filter nodes left after previous iteration?");
        // Create filters sequence when parallel_pipeline() is being run
        tbb::parallel_pipeline( n_tokens, filter1 & filter2 & filter3 );
        check_and_reset();

        // Create filters sequence partially outside parallel_pipeline() and also when parallel_pipeline() is being run
        tbb::filter_t<void, type2> filter12;
        filter12 = filter1 & filter2;
        tbb::parallel_pipeline( n_tokens, filter12 & filter3 );
        check_and_reset();

        tbb::filter_t<void, void> filter123 = filter12 & filter3;
        // Run pipeline twice with the same filter sequence
        for( unsigned i = 0; i<2; i++ ) {
            tbb::parallel_pipeline( n_tokens, filter123 );
            check_and_reset();
        }

        // Now copy-construct another filter_t instance, and use it to run pipeline
        {
            tbb::filter_t<void, void> copy123( filter123 );
            tbb::parallel_pipeline( n_tokens, copy123 );
            check_and_reset();
        }

        // Construct filters and create the sequence when parallel_pipeline() is being run
        tbb::parallel_pipeline( n_tokens, 
                   tbb::make_filter<void, type1>(filter_type[0], i_filter) &
                   tbb::make_filter<type1, type2>(filter_type[1], m_filter) &
                   tbb::make_filter<type2, void>(filter_type[2], o_filter) );
        check_and_reset();

        // Construct filters, make a copy, destroy the original filters, and run with the copy
        int cnt = filter_node_count;
        {
            tbb::filter_t<void, void>* p123 = new tbb::filter_t<void,void> (
                   tbb::make_filter<void, type1>(filter_type[0], i_filter) &
                   tbb::make_filter<type1, type2>(filter_type[1], m_filter) &
                   tbb::make_filter<type2, void>(filter_type[2], o_filter) );
            ASSERT(filter_node_count==cnt+5, "filter node accounting error?");
            tbb::filter_t<void, void> copy123( *p123 );
            delete p123;
            ASSERT(filter_node_count==cnt+5, "filter nodes deleted prematurely?");
            tbb::parallel_pipeline( n_tokens, copy123 );
            check_and_reset();
        }
        ASSERT(filter_node_count==cnt, "scope ended but filter nodes not deleted?");

#if __TBB_LAMBDAS_PRESENT
        tbb::atomic<int> counter;
        counter = max_counter;
        // Construct filters using lambda-syntax and create the sequence when parallel_pipeline() is being run;
        tbb::parallel_pipeline( n_tokens, 
            tbb::make_filter<void, type1>(filter_type[0], [&counter]( tbb::flow_control& control ) -> type1 {
                    if( --counter < 0 )
                        control.stop();
                    return type1(); }
            ) &
            tbb::make_filter<type1, type2>(filter_type[1], []( type1 /*my_storage*/ ) -> type2 {
                    return type2(); }
            ) &
            tbb::make_filter<type2, void>(filter_type[2], [] ( type2 ) -> void { 
                    tmp_counter++; }
            ) 
        );
        check_and_reset();
#endif
    }
    ASSERT(!filter_node_count, "filter_node objects leaked");
}
示例#4
0
文件: wb_vad.c 项目: Leephan/vad
 /******************************************************************************  
 *  
 *     Function     : filter_bank  
 *     Purpose      : Divide input signal into bands and calculate level of  
 *                    the signal in each band  
 *  
 *******************************************************************************  
 */   
 static void filter_bank(   
   VadVars *st,   /* i/o : State struct               */   
   float in[],   /* i   : input frame                */   
   float level[] /* 0   : signal levels at each band */   
 )   
 {   
   Word16 i;   
   float tmp_buf[FRAME_LEN];   
   /* shift input 1 bit down for safe scaling */   
   for (i = 0; i < FRAME_LEN; i++) {   
     tmp_buf[i] = in[i]/2.0f;   
   }   
   /* run the filter bank */   
   for (i = 0;i < FRAME_LEN/2; i++) {   
     filter5(&tmp_buf[2*i],&tmp_buf[2*i+1],st->a_data5[0]);   
   }   
   for (i = 0;i < FRAME_LEN/4; i++) {   
     filter5(&tmp_buf[4*i],&tmp_buf[4*i+2],st->a_data5[1]);   
     filter5(&tmp_buf[4*i+1],&tmp_buf[4*i+3],st->a_data5[2]);   
   }   
   for (i = 0; i < FRAME_LEN/8; i++)   
   {   
      filter5(&tmp_buf[8*i], &tmp_buf[8*i+4], st->a_data5[3]);   
      filter5(&tmp_buf[8*i+2], &tmp_buf[8*i+6], st->a_data5[4]);   
      filter3(&tmp_buf[8*i+3],&tmp_buf[8*i+7],&st->a_data3[0]);   
   }   
   for (i = 0; i < FRAME_LEN/16; i++)   
   {   
      filter3(&tmp_buf[16*i+0], &tmp_buf[16*i+8], &st->a_data3[1]);   
      filter3(&tmp_buf[16*i+4], &tmp_buf[16*i+12], &st->a_data3[2]);   
      filter3(&tmp_buf[16*i+6], &tmp_buf[16*i+14], &st->a_data3[3]);   
   }   
   for (i = 0; i < FRAME_LEN/32; i++)   
   {   
      filter3(&tmp_buf[32*i+0], &tmp_buf[32*i+16], &st->a_data3[4]);   
      filter3(&tmp_buf[32*i+8], &tmp_buf[32*i+24], &st->a_data3[5]);   
   }   
   /* calculate levels in each frequency band */   
   /* 4800 - 6400 Hz*/   
   level[11] = level_calculation(tmp_buf, &st->sub_level[11],   
                 FRAME_LEN/4-48, FRAME_LEN/4, 4, 1, 0.25);   
   /* 4000 - 4800 Hz*/   
   level[10] = level_calculation(tmp_buf, &st->sub_level[10],   
                 FRAME_LEN/8-24, FRAME_LEN/8, 8, 7, 0.5);   
   /* 3200 - 4000 Hz*/   
   level[9] = level_calculation(tmp_buf, &st->sub_level[9],   
                FRAME_LEN/8-24, FRAME_LEN/8, 8, 3, 0.5);   
   /* 2400 - 3200 Hz*/   
   level[8] = level_calculation(tmp_buf, &st->sub_level[8],   
                FRAME_LEN/8-24, FRAME_LEN/8, 8, 2, 0.5);   
   /* 2000 - 2400 Hz*/   
   level[7] = level_calculation(tmp_buf, &st->sub_level[7],   
                FRAME_LEN/16-12, FRAME_LEN/16, 16, 14, 1.0);   
   /* 1600 - 2000 Hz*/   
   level[6] = level_calculation(tmp_buf, &st->sub_level[6],   
                FRAME_LEN/16-12, FRAME_LEN/16, 16, 6, 1.0);   
   /* 1200 - 1600 Hz*/   
   level[5] = level_calculation(tmp_buf, &st->sub_level[5],   
                FRAME_LEN/16-12, FRAME_LEN/16, 16, 4, 1.0);   
   /* 800 - 1200 Hz*/   
   level[4] = level_calculation(tmp_buf, &st->sub_level[4],   
                FRAME_LEN/16-12, FRAME_LEN/16, 16, 12, 1.0);   
   /* 600 - 800 Hz*/   
   level[3] = level_calculation(tmp_buf, &st->sub_level[3],   
                FRAME_LEN/32-6, FRAME_LEN/32, 32, 8, 2.0);   
   /* 400 - 600 Hz*/   
   level[2] = level_calculation(tmp_buf, &st->sub_level[2],   
                FRAME_LEN/32-6, FRAME_LEN/32, 32, 24, 2.0);   
   /* 200 - 400 Hz*/   
   level[1] = level_calculation(tmp_buf, &st->sub_level[1],   
                FRAME_LEN/32-6, FRAME_LEN/32, 32, 16, 2.0);   
   /* 0 - 200 Hz*/   
   level[0] = level_calculation(tmp_buf, &st->sub_level[0],   
                FRAME_LEN/32-6, FRAME_LEN/32, 32, 0, 2.0);   
 }   
示例#5
0
void run_filter_set(
        input_filter<t1>& i_filter,
        middle_filter<t1,t2>& m_filter,
        output_filter<t2>& o_filter,
        mode_array *filter_type,
        final_assert_type my_t) {
    tbb::filter_t<void, t1> filter1( filter_type[0], i_filter );
    tbb::filter_t<t1, t2> filter2( filter_type[1], m_filter );
    tbb::filter_t<t2, void> filter3( filter_type[2], o_filter );
    ASSERT(filter_node_count==3, "some filter nodes left after previous iteration?");
    resetCounters();
    // Create filters sequence when parallel_pipeline() is being run
    tbb::parallel_pipeline( n_tokens, filter1 & filter2 & filter3 );
    checkCounters(my_t);

    // Create filters sequence partially outside parallel_pipeline() and also when parallel_pipeline() is being run
    tbb::filter_t<void, t2> filter12;
    filter12 = filter1 & filter2;
    resetCounters();
    tbb::parallel_pipeline( n_tokens, filter12 & filter3 );
    checkCounters(my_t);

    tbb::filter_t<void, void> filter123 = filter12 & filter3;
    // Run pipeline twice with the same filter sequence
    for( unsigned i = 0; i<2; i++ ) {
        resetCounters();
        tbb::parallel_pipeline( n_tokens, filter123 );
        checkCounters(my_t);
    }

    // Now copy-construct another filter_t instance, and use it to run pipeline
    {
        tbb::filter_t<void, void> copy123( filter123 );
        resetCounters();
        tbb::parallel_pipeline( n_tokens, copy123 );
        checkCounters(my_t);
    }

    // Construct filters and create the sequence when parallel_pipeline() is being run
    resetCounters();
    tbb::parallel_pipeline( n_tokens,
               tbb::make_filter<void, t1>(filter_type[0], i_filter) &
               tbb::make_filter<t1, t2>(filter_type[1], m_filter) &
               tbb::make_filter<t2, void>(filter_type[2], o_filter) );
    checkCounters(my_t);

    // Construct filters, make a copy, destroy the original filters, and run with the copy
    int cnt = filter_node_count;
    {
        tbb::filter_t<void, void>* p123 = new tbb::filter_t<void,void> (
               tbb::make_filter<void, t1>(filter_type[0], i_filter) &
               tbb::make_filter<t1, t2>(filter_type[1], m_filter) &
               tbb::make_filter<t2, void>(filter_type[2], o_filter) );
        ASSERT(filter_node_count==cnt+5, "filter node accounting error?");
        tbb::filter_t<void, void> copy123( *p123 );
        delete p123;
        ASSERT(filter_node_count==cnt+5, "filter nodes deleted prematurely?");
        resetCounters();
        tbb::parallel_pipeline( n_tokens, copy123 );
        checkCounters(my_t);
    }

    // construct a filter with temporaries
    {
        tbb::filter_t<void, void> my_filter;
        fill_chain<t1,t2>( my_filter, filter_type, i_filter, m_filter, o_filter );
        resetCounters();
        tbb::parallel_pipeline( n_tokens, my_filter );
        checkCounters(my_t);
    }
    ASSERT(filter_node_count==cnt, "scope ended but filter nodes not deleted?");
}
示例#6
0
//=========================================================
// HandleAnimEvent - catches the monster-specific messages
// that occur when tagged animation frames are played.
//
// Returns number of events handled, 0 if none.
//=========================================================
void CNPC_AlienGrunt::HandleAnimEvent( animevent_t *pEvent )
{
	switch( pEvent->event )
	{
	case AGRUNT_AE_HORNET1:
	case AGRUNT_AE_HORNET2:
	case AGRUNT_AE_HORNET3:
	case AGRUNT_AE_HORNET4:
	case AGRUNT_AE_HORNET5:
		{
			// m_vecEnemyLKP should be center of enemy body
			Vector vecArmPos;
			QAngle angArmDir;
			Vector vecDirToEnemy;
			QAngle angDir;

			if (HasCondition( COND_SEE_ENEMY) && GetEnemy())
			{
				Vector vecEnemyLKP = GetEnemy()->GetAbsOrigin();

				vecDirToEnemy = ( ( vecEnemyLKP ) - GetAbsOrigin() );
				VectorAngles( vecDirToEnemy, angDir );
				VectorNormalize( vecDirToEnemy );
			}
			else
			{
				angDir = GetAbsAngles();
				angDir.x = -angDir.x;

				Vector vForward;
				AngleVectors( angDir, &vForward );
				vecDirToEnemy = vForward;
			}

			DoMuzzleFlash();

			// make angles +-180
			if (angDir.x > 180)
			{
				angDir.x = angDir.x - 360;
			}

		//	SetBlending( 0, angDir.x );
			GetAttachment( "0", vecArmPos, angArmDir );

			vecArmPos = vecArmPos + vecDirToEnemy * 32;
		
			CPVSFilter filter( GetAbsOrigin() );
			te->Sprite( filter, 0.0,
				&vecArmPos, iAgruntMuzzleFlash, random->RandomFloat( 0.4, 0.8 ), 128 );

			CBaseEntity *pHornet = CBaseEntity::Create( "hornet", vecArmPos, QAngle( 0, 0, 0 ), this );

			Vector vForward;
			AngleVectors( angDir, &vForward );
	
			pHornet->SetAbsVelocity( vForward * 300 );
			pHornet->SetOwnerEntity( this );
			
			EmitSound( "Weapon_Hornetgun.Single" );

			CHL1BaseNPC *pHornetMonster = (CHL1BaseNPC *)pHornet->MyNPCPointer();

			if ( pHornetMonster )
			{
				pHornetMonster->SetEnemy( GetEnemy() );
			}
		}
		break;

	case AGRUNT_AE_LEFT_FOOT:
		// left foot
		{
			CPASAttenuationFilter filter2( this );
			EmitSound( filter2, entindex(), "AlienGrunt.LeftFoot" );
		}
		break;
	case AGRUNT_AE_RIGHT_FOOT:
		// right foot
		{
			CPASAttenuationFilter filter3( this );
			EmitSound( filter3, entindex(), "AlienGrunt.RightFoot" );
		}
		break;

	case AGRUNT_AE_LEFT_PUNCH:
		{
			Vector vecMins = GetHullMins();
			Vector vecMaxs = GetHullMaxs();
			vecMins.z = vecMins.x;
			vecMaxs.z = vecMaxs.x;

			CBaseEntity *pHurt = CheckTraceHullAttack( AGRUNT_MELEE_DIST, vecMins, vecMaxs, sk_agrunt_dmg_punch.GetFloat(), DMG_CLUB );
			CPASAttenuationFilter filter4( this );
			
			if ( pHurt )
			{
				if ( pHurt->GetFlags() & ( FL_NPC | FL_CLIENT ) )
					 pHurt->ViewPunch( QAngle( -25, 8, 0) );

				Vector vRight;
				AngleVectors( GetAbsAngles(), NULL, &vRight, NULL );

				// OK to use gpGlobals without calling MakeVectors, cause CheckTraceHullAttack called it above.
				if ( pHurt->IsPlayer() )
				{
					// this is a player. Knock him around.
					pHurt->SetAbsVelocity( pHurt->GetAbsVelocity() + vRight * 250 );
				}

				EmitSound(filter4, entindex(), "AlienGrunt.AttackHit" );

				Vector vecArmPos;
				QAngle angArmAng;
				GetAttachment( 0, vecArmPos, angArmAng );
				SpawnBlood(vecArmPos, g_vecAttackDir, pHurt->BloodColor(), 25);// a little surface blood.
			}
			else
			{
				// Play a random attack miss sound
				EmitSound(filter4, entindex(), "AlienGrunt.AttackMiss" );
			}
		}
		break;

	case AGRUNT_AE_RIGHT_PUNCH:
		{
			Vector vecMins = GetHullMins();
			Vector vecMaxs = GetHullMaxs();
			vecMins.z = vecMins.x;
			vecMaxs.z = vecMaxs.x;

			CBaseEntity *pHurt = CheckTraceHullAttack( AGRUNT_MELEE_DIST, vecMins, vecMaxs, sk_agrunt_dmg_punch.GetFloat(), DMG_CLUB );
			CPASAttenuationFilter filter5( this );
				
			if ( pHurt )
			{
				if ( pHurt->GetFlags() & ( FL_NPC | FL_CLIENT ) )
					 pHurt->ViewPunch( QAngle( 25, 8, 0) );

				// OK to use gpGlobals without calling MakeVectors, cause CheckTraceHullAttack called it above.
				if ( pHurt->IsPlayer() )
				{
					// this is a player. Knock him around.
					Vector vRight;
					AngleVectors( GetAbsAngles(), NULL, &vRight, NULL );
					pHurt->SetAbsVelocity( pHurt->GetAbsVelocity() + vRight * -250 );
				}

				EmitSound( filter5, entindex(), "AlienGrunt.AttackHit" );

				Vector vecArmPos;
				QAngle angArmAng;
				GetAttachment( 0, vecArmPos, angArmAng );
				SpawnBlood(vecArmPos, g_vecAttackDir, pHurt->BloodColor(), 25);// a little surface blood.
			}
			else
			{
				// Play a random attack miss sound
				EmitSound( filter5, entindex(), "AlienGrunt.AttackMiss" );
			}
		}
		break;

	default:
		BaseClass::HandleAnimEvent( pEvent );
		break;
	}
}
示例#7
0
/****************************************************************************
 *
 *     Function     : filter_bank
 *     Purpose      : Divides input signal into 9-bands and calculas level of
 *                    the signal in each band 
 *
 ***************************************************************************/
void filter_bank(vadState1 *st,  /* i/o : State struct               */
                        Word16 in[],   /* i   : input frame                */
                        Word16 level[] /* 0   : signal levels at each band */
                        )
{
  Word16 i;
  Word16 tmp_buf[FRAME_LEN];

  /* calculate the filter bank */

  first_filter_stage(in, tmp_buf, st->a_data5[0]);
  
  for (i = 0; i < FRAME_LEN/4; i++)
  {
     filter5(&tmp_buf[4*i], &tmp_buf[4*i+2], st->a_data5[1]);
     filter5(&tmp_buf[4*i+1], &tmp_buf[4*i+3], st->a_data5[2]);
  }
  for (i = 0; i < FRAME_LEN/8; i++)
  {
     filter3(&tmp_buf[8*i+0], &tmp_buf[8*i+4], &st->a_data3[0]);
     filter3(&tmp_buf[8*i+2], &tmp_buf[8*i+6], &st->a_data3[1]);
     filter3(&tmp_buf[8*i+3], &tmp_buf[8*i+7], &st->a_data3[4]);
  }
  
  for (i = 0; i < FRAME_LEN/16; i++)
  {
     filter3(&tmp_buf[16*i+0], &tmp_buf[16*i+8], &st->a_data3[2]);
     filter3(&tmp_buf[16*i+4], &tmp_buf[16*i+12], &st->a_data3[3]);
  }
  
  /* calculate levels in each frequency band */
  
  /* 3000 - 4000 Hz*/
  level[8] = level_calculation(tmp_buf, &st->sub_level[8], FRAME_LEN/4-8,
                               FRAME_LEN/4, 4, 1, 15);
  
  /* 2500 - 3000 Hz*/  
  level[7] = level_calculation(tmp_buf, &st->sub_level[7], FRAME_LEN/8-4,
                               FRAME_LEN/8, 8, 7, 16);
  
  /* 2000 - 2500 Hz*/
  level[6] = level_calculation(tmp_buf, &st->sub_level[6], FRAME_LEN/8-4,
                               FRAME_LEN/8, 8, 3, 16);
  
  /* 1500 - 2000 Hz*/
  level[5] = level_calculation(tmp_buf, &st->sub_level[5], FRAME_LEN/8-4,
                               FRAME_LEN/8, 8, 2, 16);
  
  /* 1000 - 1500 Hz*/
  level[4] = level_calculation(tmp_buf, &st->sub_level[4], FRAME_LEN/8-4,
                               FRAME_LEN/8, 8, 6, 16);
  
  /* 750 - 1000 Hz*/
  level[3] = level_calculation(tmp_buf, &st->sub_level[3], FRAME_LEN/16-2,
                               FRAME_LEN/16, 16, 4, 16);
  
  /* 500 - 750 Hz*/
  level[2] = level_calculation(tmp_buf, &st->sub_level[2], FRAME_LEN/16-2,
                               FRAME_LEN/16, 16, 12, 16);
  
  /* 250 - 500 Hz*/
  level[1] = level_calculation(tmp_buf, &st->sub_level[1], FRAME_LEN/16-2,
                               FRAME_LEN/16, 16, 8, 16);
  
  /* 0 - 250 Hz*/
  level[0] = level_calculation(tmp_buf, &st->sub_level[0], FRAME_LEN/16-2,
                               FRAME_LEN/16, 16, 0, 16);
  
}
示例#8
0
//=========================================================
// HandleAnimEvent - catches the monster-specific messages
// that occur when tagged animation frames are played.
//
// Returns number of events handled, 0 if none.
//=========================================================
void CNPC_Vortigaunt::HandleAnimEvent( animevent_t *pEvent )
{
    // ALERT( at_console, "event %d : %f\n", pEvent->event, pev->frame );
    switch( pEvent->event )
    {
    case ISLAVE_AE_CLAW:
    {
        // SOUND HERE!
        CBaseEntity *pHurt = CheckTraceHullAttack( 40, Vector(-10,-10,-10), Vector(10,10,10), sk_islave_dmg_claw.GetFloat(), DMG_SLASH );
        CPASAttenuationFilter filter( this );
        if ( pHurt )
        {
            if ( pHurt->GetFlags() & ( FL_NPC | FL_CLIENT ) )
                pHurt->ViewPunch( QAngle( 5, 0, -18 ) );

            // Play a random attack hit sound
            enginesound->EmitSound( filter, entindex(), CHAN_WEAPON, pAttackHitSounds[ random->RandomInt(0,ARRAYSIZE(pAttackHitSounds)-1) ], 1.0, ATTN_NORM, 0, m_iVoicePitch );
        }
        else
            // Play a random attack miss sound
            enginesound->EmitSound( filter, entindex(), CHAN_WEAPON, pAttackMissSounds[ random->RandomInt(0,ARRAYSIZE(pAttackMissSounds)-1) ], 1.0, ATTN_NORM, 0, m_iVoicePitch );
    }
    break;

    case ISLAVE_AE_CLAWRAKE:
    {
        CBaseEntity *pHurt = CheckTraceHullAttack( 40, Vector(-10,-10,-10), Vector(10,10,10), sk_islave_dmg_clawrake.GetFloat(), DMG_SLASH );
        CPASAttenuationFilter filter2( this );
        if ( pHurt )
        {
            if ( pHurt->GetFlags() & ( FL_NPC | FL_CLIENT ) )
                pHurt->ViewPunch( QAngle( 5, 0, 18 ) );

            enginesound->EmitSound( filter2, entindex(), CHAN_WEAPON, pAttackHitSounds[ random->RandomInt(0,ARRAYSIZE(pAttackHitSounds)-1) ], 1.0, ATTN_NORM, 0, m_iVoicePitch );
        }
        else
            enginesound->EmitSound( filter2, entindex(), CHAN_WEAPON, pAttackMissSounds[ random->RandomInt(0,ARRAYSIZE(pAttackMissSounds)-1) ], 1.0, ATTN_NORM, 0, m_iVoicePitch );
    }
    break;

    case ISLAVE_AE_ZAP_POWERUP:
    {
        // speed up attack when on hard
        if ( g_iSkillLevel == SKILL_HARD )
            m_flPlaybackRate = 1.5;

        Vector v_forward;
        GetVectors( &v_forward, NULL, NULL );

        CBroadcastRecipientFilter filter;
        te->DynamicLight( filter, 0.0, &GetAbsOrigin(), 125, 200, 100, 2, 120, 0.2 / m_flPlaybackRate, 0 );

        if ( m_hDead != NULL )
        {
            WackBeam( -1, m_hDead );
            WackBeam( 1, m_hDead );
        }
        else
        {
            ArmBeam( -1 );
            ArmBeam( 1 );
            BeamGlow( );
        }

        CPASAttenuationFilter filter3( this );
        enginesound->EmitSound( filter3, entindex(), CHAN_WEAPON, "debris/zap4.wav", 1, ATTN_NORM, 0, 100 + m_iBeams * 10 );

// Huh?  Model doesn't have multiple texturegroups, commented this out.  -LH
//			m_nSkin = m_iBeams / 2;
    }
    break;

    case ISLAVE_AE_ZAP_SHOOT:
    {
        ClearBeams( );

        if ( m_hDead != NULL )
        {
            Vector vecDest = m_hDead->GetAbsOrigin() + Vector( 0, 0, 38 );
            trace_t trace;
            UTIL_TraceHull( vecDest, vecDest, GetHullMins(), GetHullMaxs(),MASK_SOLID, m_hDead, COLLISION_GROUP_NONE, &trace );

            if ( !trace.startsolid )
            {
                CBaseEntity *pNew = Create( "monster_alien_slave", m_hDead->GetAbsOrigin(), m_hDead->GetAbsAngles() );

                pNew->AddSpawnFlags( 1 );
                WackBeam( -1, pNew );
                WackBeam( 1, pNew );
                UTIL_Remove( m_hDead );
                break;
            }
        }

        ClearMultiDamage();

        ZapBeam( -1 );
        ZapBeam( 1 );

        CPASAttenuationFilter filter4( this );
        enginesound->EmitSound( filter4, entindex(), CHAN_WEAPON, "hassault/hw_shoot1.wav", 1, ATTN_NORM, 0, random->RandomInt( 130, 160 ) );
        ApplyMultiDamage();

        m_flNextAttack = gpGlobals->curtime + random->RandomFloat( 0.5, 4.0 );
    }
    break;

    case ISLAVE_AE_ZAP_DONE:
    {
        ClearBeams();
    }
    break;

    default:
        BaseClass::HandleAnimEvent( pEvent );
        break;
    }
}