audio_clip_loadn( audio_challenge, VG_ARRAY_LEN(audio_challenge), NULL );
vg_audio_lock();
- audio_lfo *bump_lfo = vg_audio_get_first_idle_lfo();
- VG_ASSERT( bump_lfo );
-
- vg_audio_set_lfo_polynomial_bipolar( bump_lfo, 80.0f );
- vg_audio_set_lfo_frequency( bump_lfo, 20.0f );
-
- air_audio_data.channel = vg_audio_get_first_idle_channel();
- VG_ASSERT( air_audio_data.channel );
- audio_channel_init( air_audio_data.channel, &air_synth, 0 );
+ air_audio_data.channel_id = vg_audio_get_first_idle_channel();
+ VG_ASSERT( air_audio_data.channel_id );
+ vg_audio_set_channel_clip( air_audio_data.channel_id, &air_synth );
+ vg_audio_start_channel( air_audio_data.channel_id );
vg_audio_unlock();
}
void audio_ambient_sprite_play( v3f co, audio_clip *clip )
{
- audio_lock();
+ vg_audio_lock();
u16 group_id = 0xfff0;
- audio_channel *ch = audio_get_group_idle_channel( group_id, 4 );
-
- if( ch ){
- audio_channel_init( ch, clip, AUDIO_FLAG_SPACIAL_3D );
- audio_channel_group( ch, group_id );
- audio_channel_set_spacial( ch, co, 80.0f );
- audio_channel_edit_volume( ch, 1.0f, 1 );
- ch = audio_relinquish_channel( ch );
+ if( vg_audio_count_channels_in_group( group_id ) < 4 )
+ {
+ vg_audio_oneshot_3d( clip, co, 80.0f, 1.0f, group_id, 0 );
}
- audio_unlock();
+ vg_audio_unlock();
}
enum audio_sprite_type world_audio_sample_sprite_random(v3f origin, v3f output);
SDL_SpinLock sl;
/* not used in locking */
- audio_channel *channel;
+ audio_channel_id channel_id;
}
extern air_audio_data;
next = objective->id_next;
v3_fill( objective->transform.s, 1.0f );
}
- audio_lock();
- audio_oneshot( &audio_challenge[5], 1.0f, 0.0f );
- audio_unlock();
+ vg_audio_lock();
+ vg_audio_oneshot( &audio_challenge[5], 1.0f, 0.0f, 0, 0 );
+ vg_audio_unlock();
}
else if( button_down( k_srbind_mback ) )
{
_world.active_challenge_id = 0;
_world.challenge_target = NULL;
_world.challenge_timer = 0.0f;
- audio_lock();
- audio_oneshot_3d( &audio_challenge[6], localplayer.rb.co, 30.0f, 1.0f );
- audio_unlock();
+ vg_audio_lock();
+ vg_audio_oneshot_3d( &audio_challenge[6], localplayer.rb.co, 30.0f, 1.0f, 0, 0 );
+ vg_audio_unlock();
vg_info( "Challenge expired due to player being out of range.\n" );
}
}
else
{
vg_info( "pass challenge point\n" );
- audio_lock();
- audio_oneshot_3d( &audio_challenge[0], localplayer.rb.co, 30.0f, 1.0f );
- audio_unlock();
+ vg_audio_lock();
+ vg_audio_oneshot_3d( &audio_challenge[0], localplayer.rb.co, 30.0f, 1.0f, 0, 0 );
+ vg_audio_unlock();
}
}
else
{
vg_success( "challenge win\n" );
- audio_lock();
- audio_oneshot( &audio_challenge[2], 1.0f, 0.0f );
- audio_unlock();
+ vg_audio_lock();
+ vg_audio_oneshot( &audio_challenge[2], 1.0f, 0.0f, 0, 0 );
+ vg_audio_unlock();
if( objective->id_win )
{
}
else
{
- audio_lock();
- audio_oneshot_3d( &audio_challenge[6], localplayer.rb.co, 30.0f, 1.0f );
- audio_unlock();
+ vg_audio_lock();
+ vg_audio_oneshot_3d( &audio_challenge[6], localplayer.rb.co, 30.0f, 1.0f, 0, 0 );
+ vg_audio_unlock();
vg_error( "challenge failed, filter was not met\n" );
if( world_clear_event( k_world_event_challenge ) )
if( state == k_ui_button_click )
{
- audio_lock();
- audio_oneshot( &audio_ui[0], 1.0f, 0.0f );
- audio_unlock();
+ vg_audio_lock();
+ vg_audio_oneshot( &audio_ui[0], 1.0f, 0.0f, 0, 0 );
+ vg_audio_unlock();
return 1;
}
else return 0;
if( state == k_ui_button_click )
{
- audio_lock();
- audio_oneshot( &audio_ui[0], 1.0f, 0.0f );
- audio_unlock();
+ vg_audio_lock();
+ vg_audio_oneshot( &audio_ui[0], 1.0f, 0.0f, 0, 0 );
+ vg_audio_unlock();
return 1;
}
else return 0;
if( *p_row != row_prev )
{
- audio_lock();
- audio_oneshot( &audio_ui[3], 1.0f, 0.0f );
- audio_unlock();
+ vg_audio_lock();
+ vg_audio_oneshot( &audio_ui[3], 1.0f, 0.0f, 0, 0 );
+ vg_audio_unlock();
}
return *p_row;
if( button_down( k_srbind_mclose ) )
{
- audio_lock();
- audio_oneshot( &audio_ui[3], 1.0f, 0.0f );
- audio_unlock();
+ vg_audio_lock();
+ vg_audio_oneshot( &audio_ui[3], 1.0f, 0.0f, 0, 0 );
+ vg_audio_unlock();
skaterift.activity = k_skaterift_default;
srinput.state = k_input_state_resume;
return;
if( menu_button( ctx, c, R==2, 1, "No" ) || button_down( k_srbind_mback ) )
{
- audio_lock();
- audio_oneshot( &audio_ui[3], 1.0f, 0.0f );
- audio_unlock();
+ vg_audio_lock();
+ vg_audio_oneshot( &audio_ui[3], 1.0f, 0.0f, 0, 0 );
+ vg_audio_unlock();
menu.web_link = NULL;
}
{
if( button_down( k_srbind_mback ) )
{
- audio_lock();
- audio_oneshot( &audio_ui[3], 1.0f, 0.0f );
- audio_unlock();
+ vg_audio_lock();
+ vg_audio_oneshot( &audio_ui[3], 1.0f, 0.0f, 0, 0 );
+ vg_audio_unlock();
vg_settings_close();
srinput.state = k_input_state_resume;
}
if( menu_button( ctx, b, R == 1, 1, "Nah" ) || button_down( k_srbind_mback ) )
{
- audio_lock();
- audio_oneshot( &audio_ui[3], 1.0f, 0.0f );
- audio_unlock();
+ vg_audio_lock();
+ vg_audio_oneshot( &audio_ui[3], 1.0f, 0.0f, 0, 0 );
+ vg_audio_unlock();
skaterift.activity = k_skaterift_default;
return;
}
if( menu.main_index == VG_ARRAY_LEN(opts) )
menu.main_index --;
- audio_lock();
- audio_oneshot( &audio_ui[3], 1.0f, 0.0f );
- audio_unlock();
+ vg_audio_lock();
+ vg_audio_oneshot( &audio_ui[3], 1.0f, 0.0f, 0, 0 );
+ vg_audio_unlock();
}
ui_px x = 0, spacer = 8;
menu_checkbox( ctx, list, R == 1, "Auto connect to global server", &network_client.auto_connect );
menu_heading( ctx, list, "Audio/Video", 0 );
- menu_slider( ctx, list, R == 2, "Volume", 0, 100, &vg_audio.external_global_volume, "%.f%%" );
+ menu_slider( ctx, list, R == 2, "Volume", 0, 100, &_vg_audio.master_volume_ui, "%.f%%" );
menu_slider( ctx, list, R == 3, "Resolution", 0, 100, &k_render_scale, "%.f%%" );
menu_checkbox( ctx, list, R == 4, "Motion Blur", &k_blur_effect );
if( button_down( k_srbind_mback ) && menu_backable_to_exit )
{
- audio_lock();
- audio_oneshot( &audio_ui[3], 1.0f, 0.0f );
- audio_unlock();
+ vg_audio_lock();
+ vg_audio_oneshot( &audio_ui[3], 1.0f, 0.0f, 0, 0 );
+ vg_audio_unlock();
srinput.state = k_input_state_resume;
skaterift.activity = k_skaterift_default;
}
{
_cutscene.state = k_cutscene_state_playing;
- audio_lock();
+ vg_audio_lock();
for( u32 j=0; j<af_arrcount( &_cutscene.meta.audios ); j++ )
{
ent_audio *audio = af_arritm( &_cutscene.meta.audios, j );
- ent_audio_clip *clip = af_arritm( &_cutscene.meta.audio_clips,
- audio->clip_start );
+ ent_audio_clip *clip = af_arritm( &_cutscene.meta.audio_clips, audio->clip_start );
if( audio->flags & AUDIO_FLAG_AUTO_START )
{
- audio_channel *ch;
+ const u16 group = 0xfff1;
+ const u32 flags = AUDIO_FLAG_CUTSCENE;
+
if( audio->flags & AUDIO_FLAG_SPACIAL_3D )
- {
- ch = audio_oneshot_3d( &clip->_.clip, audio->transform.co,
- audio->transform.s[0],
- audio->volume );
- }
+ vg_audio_oneshot_3d( &clip->_.clip, audio->transform.co, audio->transform.s[0], audio->volume, group,flags);
else
- ch = audio_oneshot( &clip->_.clip, 1.0f, 0.0f );
-
- if( ch )
- audio_channel_group( ch, 0xfff1 );
+ vg_audio_oneshot( &clip->_.clip, 1.0f, 0.0f, group, flags );
}
}
- audio_unlock();
+ vg_audio_unlock();
}
void _cutscene_subtitle( const char *text )
void _cutscene_unload(void)
{
vg_info( "Unloading cutscene\n" );
-
- audio_lock();
- for( u32 i=0; i<AUDIO_CHANNELS; i++ )
- {
- audio_channel *ch = &vg_audio.channels[i];
- if( ch->allocated && (ch->group == 0xfff1) )
- audio_channel_fadeout( ch, 1.0f );
- }
- audio_unlock();
+ vg_audio_fadeout_flagged_audio( AUDIO_FLAG_CUTSCENE, 1.0f );
for( u32 i=0; i<_cutscene.unique_refs; i ++ )
mdl_sync_std_unload( &_cutscene.refs[i].mdl );
clip->_.clip.path = af_str( &_cutscene.meta.af,
clip->_.file.pstr_path );
clip->_.clip.flags = audio->flags;
- clip->_.clip.data = NULL;
+ clip->_.clip.any_data = NULL;
clip->_.clip.size = 0;
}
{
if( _cutscene.state == k_cutscene_state_unloading )
{
- audio_lock();
- for( u32 i=0; i<AUDIO_CHANNELS; i++ )
- {
- audio_channel *ch = &vg_audio.channels[i];
- if( ch->allocated && (ch->group == 0xfff1) )
- {
- audio_unlock();
- return;
- }
- }
- audio_unlock();
+ if( !vg_audio_flagged_stopped( AUDIO_FLAG_CUTSCENE ) )
+ return;
vg_allocator_free( _cutscene.arena );
_cutscene.arena = NULL;
void player__use_model( u16 reg_id )
{
- addon_cache_unwatch( k_addon_type_player,
- localplayer.playermodel_view_slot );
- localplayer.playermodel_view_slot =
- addon_cache_create_viewer( k_addon_type_player, reg_id );
+ addon_cache_unwatch( k_addon_type_player, localplayer.playermodel_view_slot );
+ localplayer.playermodel_view_slot = addon_cache_create_viewer( k_addon_type_player, reg_id );
}
void player__bind(void)
*/
void player__pass_gate( u32 id )
{
- audio_lock();
- audio_oneshot( &audio_gate_pass, 1.0f, 0.0f );
- audio_unlock();
+ vg_audio_lock();
+ vg_audio_oneshot( &audio_gate_pass, 1.0f, 0.0f, 0, 0 );
+ vg_audio_unlock();
world_instance *world = &_world.main;
ent_gate *gate = af_arritm( &world->ent_gate, mdl_entity_id_id(id) );
return;
}
- if( stress ){
+ if( stress )
+ {
temp_filter = 20;
- audio_lock();
- audio_oneshot_3d( &audio_hits[vg_randu32(&vg.rand)%5],
- stress->co, 20.0f, 1.0f );
- audio_unlock();
+ vg_audio_lock();
+ vg_audio_oneshot_3d( &audio_hits[vg_randu32(&vg.rand)%5], stress->co, 20.0f, 1.0f, 0, 0 );
+ vg_audio_unlock();
}
}
player_get_anim( bindings[i].anim, bindings[i].name );
}
-void player__skate_kill_audio(void){
+void player__skate_kill_audio(void)
+{
vg_audio_lock();
- if( player_skate.aud_main ){
- player_skate.aud_main =
- audio_channel_fadeout( player_skate.aud_main, 0.1f );
+ if( player_skate.aud_main )
+ {
+ player_skate.aud_main = vg_audio_crossfade( player_skate.aud_main, NULL, 0.1f );
}
- if( player_skate.aud_air ){
- player_skate.aud_air =
- audio_channel_fadeout( player_skate.aud_air, 0.1f );
+ if( player_skate.aud_air )
+ {
+ player_skate.aud_air = vg_audio_crossfade( player_skate.aud_air, NULL, 0.1f );
}
- if( player_skate.aud_slide ){
- player_skate.aud_slide =
- audio_channel_fadeout( player_skate.aud_slide, 0.1f );
+ if( player_skate.aud_slide )
+ {
+ player_skate.aud_slide = vg_audio_crossfade( player_skate.aud_slide, NULL, 0.1f );
}
vg_audio_unlock();
}
v3_muladds( state->trick_euler, state->trick_vel, vg.time_fixed_delta,
state->trick_euler );
- if( !carry_on && (state->trick_time + vg.time_fixed_delta/interval >= next_end) ){
+ if( !carry_on && (state->trick_time + vg.time_fixed_delta/interval >= next_end) )
+ {
state->trick_time = 0.0f;
state->trick_euler[0] = roundf( state->trick_euler[0] );
state->trick_euler[1] = roundf( state->trick_euler[1] );
v3_zero( state->trick_vel );
vg_audio_lock();
- audio_oneshot_3d( &audio_flips[vg_randu32(&vg.rand)%4],
- localplayer.rb.co, 40.0f, 1.0f );
+ vg_audio_oneshot_3d( &audio_flips[vg_randu32(&vg.rand)%4], localplayer.rb.co, 40.0f, 1.0f, 0, 0 );
vg_audio_unlock();
}
else
else
state->trick_input_collect = 0.0f;
- if( state->activity <= k_skate_activity_air_to_grind ){
- if( trick && (state->trick_input_collect < 0.1f) ){
- if( state->trick_time == 0.0f ){
+ if( state->activity <= k_skate_activity_air_to_grind )
+ {
+ if( trick && (state->trick_input_collect < 0.1f) )
+ {
+ if( state->trick_time == 0.0f )
+ {
vg_audio_lock();
- audio_oneshot_3d( &audio_flips[vg_randu32(&vg.rand)%4],
- localplayer.rb.co, 40.0f, 1.0f );
+ vg_audio_oneshot_3d( &audio_flips[vg_randu32(&vg.rand)%4], localplayer.rb.co, 40.0f, 1.0f, 0, 0 );
vg_audio_unlock();
}
- if( state->trick_time < 0.1f ){
+ if( state->trick_time < 0.1f )
+ {
v3_zero( state->trick_vel );
- if( trick == k_trick_type_kickflip ){
+ if( trick == k_trick_type_kickflip )
+ {
state->trick_vel[0] = 3.0f;
}
- else if( trick == k_trick_type_shuvit ){
+ else if( trick == k_trick_type_shuvit )
+ {
state->trick_vel[2] = 3.0f;
}
- else if( trick == k_trick_type_treflip ){
+ else if( trick == k_trick_type_treflip )
+ {
state->trick_vel[0] = 2.0f;
state->trick_vel[2] = 2.0f;
}
gate = vg_minf( 1.0f, fabsf(player_replay.track_velocity) );
}
- f32
- vol_main = sqrtf( (1.0f-air)*attn*(1.0f-slide) * 0.4f ) * gate,
+ f32 vol_main = sqrtf( (1.0f-air)*attn*(1.0f-slide) * 0.4f ) * gate,
vol_air = sqrtf( air *attn * 0.5f ) * gate,
vol_slide = sqrtf( (1.0f-air)*attn*slide * 0.25f ) * gate;
- const u32 flags = AUDIO_FLAG_SPACIAL_3D|AUDIO_FLAG_LOOP;
-
- if( !player_skate.aud_air ){
- player_skate.aud_air = audio_get_first_idle_channel();
- if( player_skate.aud_air )
- audio_channel_init( player_skate.aud_air, &audio_board[1], flags );
+ if( !player_skate.aud_air )
+ {
+ audio_channel_id channel_id = vg_audio_get_first_idle_channel();
+ if( channel_id )
+ {
+ player_skate.aud_air = channel_id;
+ vg_audio_set_channel_clip( channel_id, &audio_board[1] );
+ vg_audio_set_channel_spacial_falloff( channel_id, animator->root_co, 40.0f );
+ vg_audio_set_channel_volume( channel_id, 0.0, 1 );
+ vg_audio_add_channel_flags( channel_id, AUDIO_FLAG_LOOP );
+ vg_audio_start_channel( channel_id );
+ }
}
- if( !player_skate.aud_slide ){
- player_skate.aud_slide = audio_get_first_idle_channel();
- if( player_skate.aud_slide )
- audio_channel_init( player_skate.aud_slide, &audio_board[2], flags );
+ if( !player_skate.aud_slide )
+ {
+ audio_channel_id channel_id = vg_audio_get_first_idle_channel();
+ if( channel_id )
+ {
+ player_skate.aud_slide = channel_id;
+ vg_audio_set_channel_clip( channel_id, &audio_board[2] );
+ vg_audio_set_channel_spacial_falloff( channel_id, animator->root_co, 40.0f );
+ vg_audio_set_channel_volume( channel_id, 0.0, 1 );
+ vg_audio_add_channel_flags( channel_id, AUDIO_FLAG_LOOP );
+ vg_audio_start_channel( channel_id );
+ }
}
-
/* brrrrrrrrrrrt sound for tiles and stuff
* --------------------------------------------------------*/
- float sidechain_amt = 0.0f,
- hz = vg_maxf( speed * 2.0f, 2.0f );
+ f32 sidechain_amt = 0.0f;
+ f32 bump_hz = vg_maxf( speed * 2.0f, 2.0f );
- if( (animator->surface == k_surface_prop_tiles) &&
- (animator->activity < k_skate_activity_grind_any) )
+ if( (animator->surface == k_surface_prop_tiles) && (animator->activity < k_skate_activity_grind_any) )
sidechain_amt = 1.0f;
else
sidechain_amt = 0.0f;
- audio_set_lfo_frequency( 0, hz );
- audio_set_lfo_wave( 0, k_lfo_polynomial_bipolar,
- vg_lerpf( 250.0f, 80.0f, attn ) );
+ if( player_skate.lfo_bumps == 0 )
+ {
+ audio_channel_id lfo_id = vg_audio_get_first_idle_lfo();
+ if( lfo_id )
+ {
+ player_skate.lfo_bumps = lfo_id;
+ vg_audio_set_lfo_polynomial_bipolar( lfo_id, 80.0f );
+ vg_audio_set_lfo_frequency( lfo_id, bump_hz );
+ vg_audio_start_lfo( lfo_id );
+ }
+ }
+ else
+ {
+ vg_audio_set_lfo_polynomial_bipolar( player_skate.lfo_bumps, vg_lerpf( 250.0f, 80.0f, attn ) );
+ vg_audio_set_lfo_frequency( player_skate.lfo_bumps, bump_hz );
+ }
- if( player_skate.sample_change_cooldown > 0.0f ){
+ if( player_skate.sample_change_cooldown > 0.0f )
+ {
player_skate.sample_change_cooldown -= vg.time_frame_delta;
}
- else{
+ else
+ {
int sample_type = k_skate_sample_concrete;
- if( animator->activity == k_skate_activity_grind_5050 ){
+ if( animator->activity == k_skate_activity_grind_5050 )
+ {
if( animator->surface == k_surface_prop_metal )
sample_type = k_skate_sample_metal_scrape_generic;
else
if( animator->surface == k_surface_prop_metal ){
sample_type = k_skate_sample_metal_scrape_generic;
}
- else{
+ else
+ {
#if 0
float a = v3_dot( localplayer.rb.to_world[2],
state->grind_dir );
sample_type = k_skate_sample_concrete_scrape_wood;
}
}
- else if( animator->activity == k_skate_activity_grind_boardslide ){
+ else if( animator->activity == k_skate_activity_grind_boardslide )
+ {
if( animator->surface == k_surface_prop_metal )
sample_type = k_skate_sample_metal_scrape_generic;
else
sample_type = k_skate_sample_concrete_scrape_wood;
}
- audio_clip *relevant_samples[] = {
+ audio_clip *relevant_samples[] =
+ {
&audio_board[0],
&audio_board[0],
&audio_board[7],
&audio_board[5]
};
- if( (player_skate.main_sample_type != sample_type) || (!player_skate.aud_main) )
+ if( (player_skate.main_sample_type != sample_type) || !player_skate.aud_main )
{
- player_skate.aud_main =
- audio_channel_crossfade( player_skate.aud_main,
- relevant_samples[sample_type],
- 0.06f, flags );
+ audio_channel_id channel_id = player_skate.aud_main;
+ if( channel_id )
+ channel_id = vg_audio_crossfade( channel_id, relevant_samples[sample_type], 0.06f );
+ else
+ {
+ channel_id = vg_audio_get_first_idle_channel();
+
+ if( channel_id )
+ {
+ vg_audio_set_channel_clip( channel_id, relevant_samples[sample_type] );
+ vg_audio_add_channel_flags( channel_id, AUDIO_FLAG_LOOP );
+ vg_audio_start_channel( channel_id );
+ }
+ }
+
player_skate.sample_change_cooldown = 0.1f;
player_skate.main_sample_type = sample_type;
- }
- }
-
- if( player_skate.lfo_bumps == NULL )
- {
- audio_lfo *lfo = vg_audio_get_first_idle_lfo();
- if( lfo )
- {
- player_skate.lfo_bumps = lfo;
- vg_audio_set_lfo_polynomial_bipolar( lfo, 80.0f );
- vg_audio_set_lfo_frequency( lfo, 20.0f );
- vg_audio_start_lfo( lfo );
+ player_skate.aud_main = channel_id;
}
}
if( player_skate.aud_main )
{
- player_skate.aud_main->ui_colour = 0x00103efe;
- vg_audio_channel_set_spacial_falloff( player_skate.aud_main, animator->root_co, 40.0f );
- audio_channel_edit_volume( player_skate.aud_main, vol_main, 1 );
- audio_channel_sidechain_lfo( player_skate.aud_main, 0, sidechain_amt );
+ //player_skate.aud_main->ui_colour = 0x00103efe;
+ vg_audio_set_channel_spacial_falloff( player_skate.aud_main, animator->root_co, 40.0f );
+ vg_audio_set_channel_volume( player_skate.aud_main, vol_main, 0 );
+ vg_audio_sidechain_lfo_to_channel( player_skate.aud_main, player_skate.lfo_bumps, sidechain_amt );
float rate = 1.0f + (attn-0.5f)*0.2f;
- audio_channel_set_sampling_rate( player_skate.aud_main, rate );
+ vg_audio_set_channel_sampling_rate( player_skate.aud_main, rate );
}
- if( player_skate.aud_slide ){
- player_skate.aud_slide->colour = 0x00103efe;
- audio_channel_set_spacial( player_skate.aud_slide,
- animator->root_co, 40.0f );
- //audio_channel_slope_volume( player_skate.aud_slide, 0.05f, vol_slide );
- audio_channel_edit_volume( player_skate.aud_slide, vol_slide, 1 );
- audio_channel_sidechain_lfo( player_skate.aud_slide, 0, sidechain_amt );
+ if( player_skate.aud_slide )
+ {
+ //player_skate.aud_slide->ui_colour = 0x00103efe;
+ vg_audio_set_channel_spacial_falloff( player_skate.aud_slide, animator->root_co, 40.0f );
+ vg_audio_set_channel_volume( player_skate.aud_slide, vol_slide, 0 );
+ vg_audio_sidechain_lfo_to_channel( player_skate.aud_slide, player_skate.lfo_bumps, sidechain_amt );
}
- if( player_skate.aud_air ){
- player_skate.aud_air->colour = 0x00103efe;
- audio_channel_set_spacial( player_skate.aud_air,
- animator->root_co, 40.0f );
- //audio_channel_slope_volume( player_skate.aud_air, 0.05f, vol_air );
- audio_channel_edit_volume( player_skate.aud_air, vol_air, 1 );
+ if( player_skate.aud_air )
+ {
+ //player_skate.aud_air->ui_colour = 0x00103efe;
+ vg_audio_set_channel_spacial_falloff( player_skate.aud_air, animator->root_co, 40.0f );
+ vg_audio_set_channel_volume( player_skate.aud_air, vol_air, 0 );
}
vg_audio_unlock();
}
-void player__skate_post_update(void){
+void player__skate_post_update(void)
+{
struct player_skate_state *state = &player_skate.state;
- for( int i=0; i<player_skate.possible_jump_count; i++ ){
+ for( int i=0; i<player_skate.possible_jump_count; i++ )
+ {
jump_info *jump = &player_skate.possible_jumps[i];
- if( jump->log_length == 0 ){
+ if( jump->log_length == 0 )
vg_fatal_error( "assert: jump->log_length == 0\n" );
- }
- for( int j=0; j<jump->log_length - 1; j ++ ){
+ for( int j=0; j<jump->log_length - 1; j ++ )
+ {
float brightness = jump->score*jump->score*jump->score;
v3f p1;
v3_lerp( jump->log[j], jump->log[j+1], brightness, p1 );
vg_audio_lock();
if( id == k_player_skate_soundeffect_jump ){
- audio_oneshot_3d( &audio_jumps[vg_randu32(&vg.rand)%2], pos, 40.0f, volume );
+ vg_audio_oneshot_3d( &audio_jumps[vg_randu32(&vg.rand)%2], pos, 40.0f, volume, 0, 0 );
}
else if( id == k_player_skate_soundeffect_tap ){
- audio_oneshot_3d( &audio_taps[vg_randu32(&vg.rand)%4], pos, 40.0f, volume );
+ vg_audio_oneshot_3d( &audio_taps[vg_randu32(&vg.rand)%4], pos, 40.0f, volume, 0, 0);
}
else if( id == k_player_skate_soundeffect_land_good ){
- audio_oneshot_3d( &audio_lands[vg_randu32(&vg.rand)%3], pos, 40.0f, volume );
+ vg_audio_oneshot_3d( &audio_lands[vg_randu32(&vg.rand)%3], pos, 40.0f, volume, 0, 0 );
}
else if( id == k_player_skate_soundeffect_land_bad ){
- audio_oneshot_3d( &audio_lands[vg_randu32(&vg.rand)%2+3], pos, 40.0f, volume );
+ vg_audio_oneshot_3d( &audio_lands[vg_randu32(&vg.rand)%2+3], pos, 40.0f, volume, 0, 0 );
}
else if( id == k_player_skate_soundeffect_grind_metal ){
- audio_oneshot_3d( &audio_board[3], pos, 40.0f, volume );
+ vg_audio_oneshot_3d( &audio_board[3], pos, 40.0f, volume, 0, 0 );
}
else if( id == k_player_skate_soundeffect_grind_wood ){
- audio_oneshot_3d( &audio_board[8], pos, 40.0f, volume );
+ vg_audio_oneshot_3d( &audio_board[8], pos, 40.0f, volume, 0, 0 );
}
vg_audio_unlock();
/* vectors representing the direction of the axels in localspace */
v3f truckv0[2];
- audio_channel *aud_main, *aud_slide, *aud_air;
- audio_lfo *lfo_bumps;
+ audio_channel_id aud_main, aud_slide, aud_air;
+ audio_channel_id lfo_bumps;
enum mdl_surface_prop surface, audio_surface;
int wheel_contacts[2];
if( (w->state.step_phase != walk_phase) &&
(w->state.activity == k_walk_activity_ground ) )
{
- audio_lock();
- if( w->surface == k_surface_prop_concrete ){
- audio_oneshot_3d(
+ vg_audio_lock();
+ if( w->surface == k_surface_prop_concrete )
+ {
+ vg_audio_oneshot_3d(
&audio_footsteps[vg_randu32(&vg.rand) % 4],
- localplayer.rb.co, 40.0f, 1.0f
+ localplayer.rb.co, 40.0f, 1.0f, 0, 0
);
}
- else if( w->surface == k_surface_prop_grass ){
- audio_oneshot_3d(
+ else if( w->surface == k_surface_prop_grass )
+ {
+ vg_audio_oneshot_3d(
&audio_footsteps_grass[ vg_randu32(&vg.rand) % 6 ],
- localplayer.rb.co, 40.0f, 1.0f
+ localplayer.rb.co, 40.0f, 1.0f, 0, 0
);
}
- else if( w->surface == k_surface_prop_wood ){
- audio_oneshot_3d(
+ else if( w->surface == k_surface_prop_wood )
+ {
+ vg_audio_oneshot_3d(
&audio_footsteps_wood[ vg_randu32(&vg.rand) % 6 ],
- localplayer.rb.co, 40.0f, 1.0f
+ localplayer.rb.co, 40.0f, 1.0f, 0, 0
);
}
- audio_unlock();
+ vg_audio_unlock();
}
w->state.step_phase = walk_phase;
}
-void player__walk_update(void){
+void player__walk_update(void)
+{
struct player_walk *w = &player_walk;
if( (w->state.activity == k_walk_activity_air) ||
void player__walk_sfx_oneshot( u8 id, v3f pos, f32 volume )
{
- audio_lock();
+ vg_audio_lock();
- if( id == k_player_walk_soundeffect_splash ){
- audio_oneshot_3d( &audio_splash, pos, 40.0f, 1.0f );
- }
+ if( id == k_player_walk_soundeffect_splash )
+ vg_audio_oneshot_3d( &audio_splash, pos, 40.0f, 1.0f, 0, 0 );
- audio_unlock();
+ vg_audio_unlock();
}
int sample_index;
world_audio_sample_distances( localplayer.rb.co, &sample_index, &dist );
- audio_lock();
+ vg_audio_lock();
vg_dsp.echo_distances[sample_index] = dist;
v3f ears = { 1.0f,0.0f,0.0f };
m3x3_mulv( g_render.cam.transform, ears, ears );
- v3_copy( ears, _vg_audio.listener_right_ear_direction );
- v3_copy( g_render.cam.transform[3], _vg_audio.listener_position );
+ v3_copy( ears, _vg_audio.controls.listener_right_ear_direction );
+ v3_copy( g_render.cam.transform[3], _vg_audio.controls.listener_position );
if( localplayer.gate_waiting )
- m4x3_mulv( localplayer.gate_waiting->transport, _vg_audio.listener_position, _vg_audio.listener_position );
+ m4x3_mulv( localplayer.gate_waiting->transport, _vg_audio.controls.listener_position, _vg_audio.controls.listener_position );
- v3_copy( localplayer.rb.v, _vg_audio.listener_velocity );
- audio_unlock();
+ v3_copy( localplayer.rb.v, _vg_audio.controls.listener_velocity );
+ vg_audio_unlock();
vehicle_update_post();
skaterift_autosave_update();
#include "audio.h"
#include "world_audio.h"
-void world_fadeout_audio( world_instance *world )
-{
- audio_lock();
- for( u32 i=0; i<AUDIO_CHANNELS; i++ )
- {
- audio_channel *ch = &vg_audio.channels[i];
-
- if( ch->allocated && (ch->flags & AUDIO_FLAG_WORLD) )
- audio_channel_fadeout( ch, 1.0f );
- }
- audio_unlock();
-}
-
/*
* Trace out a random point, near the player to try and determine water areas
*/
float dist = 200.0f;
- for( int i=0; i<10; i++ ){
- if( ray_world( &_world.main, rc, rd, &ray,
- k_material_flag_ghosts ) ){
+ for( int i=0; i<10; i++ )
+ {
+ if( ray_world( &_world.main, rc, rd, &ray, k_material_flag_ghosts ) )
+ {
dist = (float)i*5.0f + ray.dist;
break;
}
- else{
+ else
v3_muladds( rc, rd, ray.dist, rc );
- }
}
distances[si] = dist;
- if( vg_audio.inspector_open && vg_lines.enabled )
+ if( _vg_audio.inspector_open && vg_lines.enabled )
{
for( int i=0; i<14; i++ )
{
for( u32 k=0; k<audio->clip_count; k++ )
{
- ent_audio_clip *clip = af_arritm( &world->ent_audio_clip,
- audio->clip_start+k );
+ ent_audio_clip *clip = af_arritm( &world->ent_audio_clip, audio->clip_start+k );
if( clip->_.file.pack_size )
{
* external audio uses it */
vg_linear_clear( vg_mem.scratch );
- void *data = vg_linear_alloc( vg_mem.scratch,
- clip->_.file.pack_size );
+ void *data = vg_linear_alloc( vg_mem.scratch, clip->_.file.pack_size );
mdl_fread_pack_file( &world->meta, &clip->_.file, data );
clip->_.clip.path = NULL;
clip->_.clip.flags = audio->flags;
- clip->_.clip.data = data;
+ clip->_.clip.any_data = data;
clip->_.clip.size = size;
}
else
clip->_.clip.path = af_str( &world->meta.af,
clip->_.file.pstr_path );
clip->_.clip.flags = audio->flags;
- clip->_.clip.data = NULL;
+ clip->_.clip.any_data = NULL;
clip->_.clip.size = 0;
}
bar += p;
if( chance < bar )
{
- audio_lock();
+ vg_audio_lock();
if( audio->behaviour == k_channel_behaviour_unlimited )
{
- audio_channel *ch = audio_get_first_idle_channel();
-
- if( ch )
+ audio_channel_id channel_id = vg_audio_get_first_idle_channel();
+ if( channel_id )
{
- audio_channel_init( ch, &clip->_.clip,
- audio->flags|AUDIO_FLAG_WORLD );
- audio_channel_set_spacial( ch, sound_co, audio->transform.s[0] );
- audio_channel_edit_volume( ch, audio->volume, 1 );
- audio_relinquish_channel( ch );
+ vg_audio_add_channel_flags( channel_id, AUDIO_FLAG_WORLD | AUDIO_FLAG_RELINQUISHED );
+ vg_audio_set_channel_clip( channel_id, &clip->_.clip );
+ vg_audio_set_channel_spacial_falloff( channel_id, sound_co, audio->transform.s[0] );
+ vg_audio_set_channel_volume( channel_id, audio->volume, 1 );
+ vg_audio_start_channel( channel_id );
}
}
else if( audio->behaviour == k_channel_behaviour_discard_if_full )
{
- audio_channel *ch =
- audio_get_group_idle_channel( audio->group,
- audio->max_channels );
-
- if( ch )
+ /* TODO This and above are the same */
+ if( vg_audio_count_channels_in_group( audio->group ) < audio->max_channels )
{
- audio_channel_init( ch, &clip->_.clip,
- audio->flags | AUDIO_FLAG_WORLD );
- audio_channel_group( ch, audio->group );
- audio_channel_set_spacial( ch, sound_co, audio->transform.s[0] );
- audio_channel_edit_volume( ch, audio->volume, 1 );
- ch = audio_relinquish_channel( ch );
+ audio_channel_id channel_id = vg_audio_get_first_idle_channel();
+ if( channel_id )
+ {
+ vg_audio_add_channel_flags( channel_id, AUDIO_FLAG_WORLD | AUDIO_FLAG_RELINQUISHED );
+ vg_audio_set_channel_clip( channel_id, &clip->_.clip );
+ vg_audio_set_channel_spacial_falloff( channel_id, sound_co, audio->transform.s[0] );
+ vg_audio_set_channel_volume( channel_id, audio->volume, 1 );
+ vg_audio_start_channel( channel_id );
+ }
}
}
- else if( audio->behaviour == k_channel_behaviour_crossfade_if_full)
+ else if( audio->behaviour == k_channel_behaviour_crossfade_if_full )
{
- audio_channel *ch =
- audio_get_group_idle_channel( audio->group,
- audio->max_channels );
-
- /* group is full */
- if( !ch )
+ if( vg_audio_count_channels_in_group( audio->group ) >= audio->max_channels )
{
- audio_channel *existing =
- audio_get_group_first_active_channel( audio->group );
-
- if( existing )
- {
- if( existing->source == &clip->_.clip )
- {
- audio_unlock();
- return k_entity_call_result_OK;
- }
-
- existing->group = 0;
- existing = audio_channel_fadeout(existing, audio->crossfade);
- }
-
- ch = audio_get_first_idle_channel();
+ audio_channel_id channel_id = vg_audio_get_first_active_channel_in_group( audio->group );
+ if( channel_id )
+ vg_audio_crossfade( channel_id, &clip->_.clip, audio->crossfade );
}
-
- if( ch )
+ else
{
- audio_channel_init( ch, &clip->_.clip,
- audio->flags | AUDIO_FLAG_WORLD );
- audio_channel_group( ch, audio->group );
- audio_channel_fadein( ch, audio->crossfade );
- ch = audio_relinquish_channel( ch );
+ audio_channel_id channel_id = vg_audio_get_first_idle_channel();
+ if( channel_id )
+ {
+ vg_audio_add_channel_flags( channel_id, AUDIO_FLAG_WORLD|AUDIO_FLAG_RELINQUISHED );
+ vg_audio_set_channel_clip( channel_id, &clip->_.clip );
+ vg_audio_set_channel_spacial_falloff( channel_id, sound_co, audio->transform.s[0] );
+ vg_audio_set_channel_volume( channel_id, audio->volume, 1 );
+ vg_audio_start_channel( channel_id );
+ }
}
}
- audio_unlock();
+ vg_audio_unlock();
return k_entity_call_result_OK;
}
}
/* pre-load step aka waiting for audio to end. */
if( _world.loader_state == k_world_loader_unloading_current )
{
- bool all_world_audio_stopped = 1;
- audio_lock();
- for( u32 i=0; i<AUDIO_CHANNELS; i++ )
- {
- audio_channel *ch = &vg_audio.channels[i];
- if( ch->allocated && (ch->flags & AUDIO_FLAG_WORLD))
- {
- if( !audio_channel_finished( ch ) )
- {
- all_world_audio_stopped = 0;
- break;
- }
- }
- }
- audio_unlock();
-
- if( !all_world_audio_stopped )
+ if( !vg_audio_flagged_stopped( AUDIO_FLAG_WORLD ) )
return;
_skaterift_script_unlink_all_challenges();
}
}
else
- world_fadeout_audio( &_world.main );
+ vg_audio_fadeout_flagged_audio( AUDIO_FLAG_WORLD, 1.0f );
_world.loader_reg = reg;
_world.loader_instance = world;
if( button_down( k_srbind_mhub ) )
{
- audio_lock();
- audio_oneshot( &audio_ui[3], 1.0f, 0.0f );
- audio_unlock();
+ vg_audio_lock();
+ vg_audio_oneshot( &audio_ui[3], 1.0f, 0.0f, 0, 0 );
+ vg_audio_unlock();
go_to_super = 1;
}
}