/*
* Audio
*/
-static void player_audio(void)
+VG_STATIC void player_audio(void)
{
struct player_phys *phys = &player.phys;
audio_lock();
-
- double revert_delta = vg_time - last_revert;
- if( phys->on_board && (!_air && l2) && (fabsf(phys->slip) > 0.5f) &&
- (revert_delta > 0.7) )
+
+ double revert_delta = vg.time - last_revert;
+ if( phys->on_board && (!_air && l2) && (revert_delta > 0.7) &&
+ (player.air_time > 0.5f) )
{
audio_player_set_position( &audio_player_extra, phys->rb.co );
audio_player_set_flags( &audio_player_extra, AUDIO_FLAG_SPACIAL_3D );
audio_player_set_vol( &audio_player_extra, 2.0f );
- audio_player_playclip( &audio_player_extra, &audio_lands[rand()%5] );
- last_revert = vg_time;
+ if( (fabsf(phys->slip) > 0.75f) )
+ {
+ audio_player_playclip( &audio_player_extra, &audio_lands[rand()%2+3] );
+ }
+ else
+ {
+ audio_player_playclip( &audio_player_extra, &audio_lands[rand()%3] );
+ }
+
+ last_revert = vg.time;
}
static float air = 0.0f;
- air = vg_lerpf(air, phys->in_air? 1.0f: 0.0f, 5.0f*ktimestep);
+ air = vg_lerpf( air, phys->in_air? 1.0f: 0.0f, 5.0f*vg.time_delta );
/* Spacial info */
v3f ears = { 1.0f,0.0f,0.0f };
v3f delta;
- float *cam = player.camera[3],
+ float *cam = camera_pos,
*pos = phys->rb.co;
audio_player_set_position( &audio_player0, phys->rb.co );
audio_player_set_position( &audio_player_gate, world.render_gate_pos );
audio_player_set_vol( &audio_player_gate, 5.0f );
- v3_sub( phys->rb.co, player.camera[3], delta );
+ v3_sub( phys->rb.co, camera_pos, delta );
v3_normalize( delta );
- m3x3_mulv( player.camera, ears, ears );
+ m3x3_mulv( camera_mtx, ears, ears );
/* TODO, Make function */
v3_copy( ears, vg_audio.listener_ears );
- v3_copy( player.camera[3], vg_audio.listener_pos );
+ v3_copy( camera_pos, vg_audio.listener_pos );
/* Tunnel / occlusion */
- audio_sample_occlusion( player.camera[3] );
+ audio_sample_occlusion( camera_pos );
int sprite_avail = -1;
for( int i=0; i<vg_list_size(ambient_sprites); i++ )
vol1 = air *attn,
vol2 = (1.0f-air)*attn*slide;
- audio_player_set_vol( &audio_player0, vol0 );
- audio_player_set_vol( &audio_player1, vol1 );
- audio_player_set_vol( &audio_player2, vol2 );
+ audio_player_set_vol( &audio_player0, vol0*vg.time_rate );
+ audio_player_set_vol( &audio_player1, vol1*vg.time_rate );
+ audio_player_set_vol( &audio_player2, vol2*vg.time_rate );
float reverb_amt = vol0 * audio_occlusion_current * 0.5f;
audio_player_set_pan( &audio_player3, 0.0f );
- audio_player_set_vol( &audio_player3, reverb_amt );
+ audio_player_set_vol( &audio_player3, reverb_amt*vg.time_rate );
}
#if 0
world_audio_update( cam, ears );
#endif
audio_unlock();
+
+ if( player.phys.in_air )
+ player.air_time += vg.time_delta;
+ else
+ player.air_time = 0.0f;
+
}
#endif /* PLAYER_AUDIO_H */