.path = "sound/gate_ambient.ogg"
};
-#if 0
-audio_player ambient_player =
-{
- .name = "Ambience"
-};
-
-audio_player audio_rewind_player =
-{
- .name = "Rewind"
-};
-#endif
-
audio_clip audio_rewind[] = {
{ .path = "sound/rewind_start.ogg" },
{ .path = "sound/rewind_end_1.5.ogg" },
{ .path = "sound/ui_ding.ogg" },
};
-#if 0
-audio_player ambient_sprites[4] =
-{
- { .name = "Ambient Sprites 0" },
- { .name = "Ambient Sprites 1" },
- { .name = "Ambient Sprites 2" },
- { .name = "Ambient Sprites 3" },
-};
-
-audio_player audio_player0 =
-{
- .name = "Player0",
-};
-
-audio_player audio_player1 =
-{
- .name = "Player1",
-};
-
-audio_player audio_player2 =
-{
- .name = "Player2",
-};
-
-audio_player audio_player3 =
-{
- .name = "Player3",
-};
-
-audio_player audio_player4 =
-{
- .name = "Player4",
-};
-
-audio_player audio_player_extra =
-{
- .name = "PlayerInst"
-};
-
-audio_player audio_player_gate =
-{
- .name = "Gate"
-};
-#endif
-
VG_STATIC void audio_init(void)
{
-#if 0
- audio_player_init( &audio_player0 );
- audio_player_init( &audio_player1 );
- audio_player_init( &audio_player2 );
- audio_player_init( &audio_player3 );
- audio_player_init( &audio_player4 );
- audio_player_init( &audio_player_gate );
- audio_player_init( &ambient_player );
- audio_player_init( &ambient_sprites[0] );
- audio_player_init( &ambient_sprites[1] );
- audio_player_init( &ambient_sprites[2] );
- audio_player_init( &ambient_sprites[3] );
- audio_player_init( &audio_player_extra );
- audio_player_init( &audio_rewind_player );
-#endif
-
audio_clip_loadn( audio_board, vg_list_size(audio_board), NULL );
audio_clip_loadn( audio_taps, vg_list_size(audio_taps), NULL );
audio_clip_loadn( audio_hits, vg_list_size(audio_hits), NULL );
audio_clip_loadn( audio_rewind, vg_list_size(audio_rewind), NULL );
audio_clip_loadn( audio_ui, vg_list_size(audio_ui), NULL );
-#if 0
- audio_lock();
- u32 flags = AUDIO_FLAG_LOOP|AUDIO_FLAG_SPACIAL_3D;
-
- audio_player_set_flags( &audio_player0, flags );
- audio_player_set_flags( &audio_player1, flags );
- audio_player_set_flags( &audio_player2, flags );
- audio_player_set_flags( &audio_player4, flags );
- audio_player_set_flags( &audio_player_gate, flags );
- audio_player_set_flags( &audio_player3, AUDIO_FLAG_LOOP );
- audio_player_set_flags( &ambient_player, AUDIO_FLAG_LOOP );
- audio_player_set_flags( &ambient_sprites[0], AUDIO_FLAG_SPACIAL_3D );
- audio_player_set_flags( &ambient_sprites[1], AUDIO_FLAG_SPACIAL_3D );
- audio_player_set_flags( &ambient_sprites[2], AUDIO_FLAG_SPACIAL_3D );
- audio_player_set_flags( &ambient_sprites[3], AUDIO_FLAG_SPACIAL_3D );
-
- audio_player_set_vol( &ambient_player, 1.0f );
- audio_player_set_vol( &audio_player_gate, 0.0f );
- audio_player_set_vol( &audio_player_extra, 1.0f );
- audio_player_set_vol( &audio_rewind_player, 0.2f );
- audio_player_set_flags( &audio_rewind_player, 0x00 );
-
- audio_player_playclip( &audio_player0, &audio_board[0] );
- audio_player_playclip( &audio_player1, &audio_board[1] );
- audio_player_playclip( &audio_player2, &audio_board[2] );
- audio_player_playclip( &audio_player3, &audio_board[3] );
- audio_player_playclip( &audio_player4, &audio_board[4] );
- audio_player_playclip( &ambient_player, &audio_ambience[0] );
- audio_player_playclip( &audio_player_gate, &audio_gate_ambient );
-
- audio_unlock();
-#endif
-
vg_var_push( (struct vg_var){
.name = "aud_debug_soundscape",
.data = &k_audio_debug_soundscape,
audio_unlock();
}
-VG_STATIC void audio_update(void)
-{
-#if 0
- static u32 flapflop = 0x00;
- static audio_channel *channel = NULL;
-
- u32 next = floorf( vg.time / 0.1f );
-
- if( flapflop != next )
- {
- flapflop = next;
-
- audio_lock();
- channel = audio_channel_crossfade( channel,
- &audio_music[ next & 0x1 ], 0.05f,
- AUDIO_FLAG_LOOP|AUDIO_FLAG_SPACIAL_3D
- );
- channel = audio_channel_set_spacial( channel,
- (v3f){ -22.3f, 60.1f, -52.7f },
- 50.0f );
-
- audio_channel_sidechain_lfo( channel, 0, 1.0f );
- audio_unlock();
- }
-#endif
-}
-
VG_STATIC void audio_free(void)
{
/* TODO! */
vg_warn( "UNIMPLEMENTED: audio_free()\n" );
}
-VG_STATIC void audio_sample_occlusion( v3f origin )
-{
- float d = 0.0f,
- sample_dist = 880.0f;
-
- int sample_count = 8;
-
- int lv = 0;
- v3f last;
- v3_zero(last);
-
- world_instance *world = get_active_world();
-
- for( int i=0; i<sample_count; i++ )
- {
- v3f dir;
- vg_rand_dir( dir );
-
- ray_hit contact;
- contact.dist = 15.0f;
-
- if( ray_world( world, origin, dir, &contact ) )
- {
- d += contact.dist;
-
-#if 0
- vg_line( origin, contact.pos, 0xff0000ff );
- vg_line_pt3( contact.pos, 0.1f, 0xff0000ff );
-
- if( lv )
- vg_line( contact.pos, last, 0xffffffff );
-#endif
-
- v3_copy( contact.pos, last );
- lv = 1;
- }
- else
- {
- v3f p1;
- v3_muladds( origin, dir, sample_dist, p1 );
-
-#if 0
- vg_line( origin, p1, 0xffcccccc );
-#endif
-
- d += sample_dist;
- lv = 0;
- }
-
- }
-
- float occlusion = 1.0f - (d * (1.0f/(sample_dist*(float)sample_count))),
- rate = VG_TIMESTEP_FIXED * k_audio_occlusion_rate,
- target = powf( vg_maxf(occlusion,0.0f), 6.0f );
- audio_occlusion_current = vg_lerpf( audio_occlusion_current, target, rate );
-}
-
enum audio_sprite_type
{
k_audio_sprite_type_none,
output[0] = pos[0];
output[1] = 0.0f;
output[2] = pos[2];
+
+ float dist = fabsf(output[1] - origin[1]);
- if( world->water.enabled )
+ if( world->water.enabled && dist<=40.0f )
return k_audio_sprite_type_water;
else
return k_audio_sprite_type_none;
}
-VG_STATIC void audio_debug_soundscapes(void)
+VG_STATIC void audio_ambient_sprite_play( v3f co, audio_clip *clip )
{
- if( !k_audio_debug_soundscape ) return;
+ audio_lock();
+ u32 channel_id = 31342352;
+ audio_channel *ch = audio_get_group_idle_channel( channel_id, 4 );
+
+ if( ch ){
+ audio_channel_init( ch, clip, AUDIO_FLAG_SPACIAL_3D );
+ audio_channel_group( ch, channel_id );
+ audio_channel_set_spacial( ch, co, 80.0f );
+ audio_channel_edit_volume( ch, 1.0f, 1 );
+ ch = audio_relinquish_channel( ch );
+ }
+ audio_unlock();
+}
- char buf[64];
- snprintf( buf, 31, "occlusion: %.5f", audio_occlusion_current );
+VG_STATIC void audio_ambient_sprites_update( world_instance *world, v3f co )
+{
+ static float accum = 0.0f;
+ accum += vg.frame_delta;
- vg_uictx.cursor[0] = 450;
- vg_uictx.cursor[1] = 10;
- vg_uictx.cursor[2] = audio_occlusion_current * 200.0f;
- vg_uictx.cursor[3] = 20;
+ if( accum > 0.1f )
+ accum -= 0.1f;
+ else return;
- ui_fill_rect( vg_uictx.cursor, 0x55cccccc );
- ui_text( vg_uictx.cursor, buf, 1, 0 );
+ v3f sprite_pos;
+ enum audio_sprite_type sprite_type =
+ audio_sample_sprite_random( co, sprite_pos );
+
+ if( sprite_type != k_audio_sprite_type_none ){
+ if( sprite_type == k_audio_sprite_type_grass ){
+ audio_ambient_sprite_play( sprite_pos, &audio_grass[rand()%4] );
+ }
+ else if( sprite_type == k_audio_sprite_type_water ){
+ if( world->water.enabled )
+ audio_ambient_sprite_play( sprite_pos, &audio_water[rand()%6] );
+ }
+ }
}
#endif /* AUDIO_H */
*/
#define SR_NETWORKED
+#define VG_DEVWINDOW
#include "common.h"
#include "conf.h"
#include "steam.h"
#include "font.h"
-
#include "player.h"
static player_instance localplayer;
VG_STATIC struct player_avatar localplayer_avatar;
/* 'systems' are completely loaded now */
/* load home world */
- //world_load( &world_global.worlds[0], "maps/mp_gridmap.mdl" );
- world_load( &world_global.worlds[0], "maps/mp_mtzero.mdl" );
+ world_load( &world_global.worlds[0], "maps/mp_gridmap.mdl" );
+ //world_load( &world_global.worlds[0], "maps/mp_mtzero.mdl" );
#if 0
world_load( &world_global.worlds[1], "maps/mp_gridmap.mdl" );
player__pre_update( &localplayer );
world_update( get_active_world(), localplayer.rb.co );
-
- audio_update();
+ audio_ambient_sprites_update( get_active_world(), localplayer.rb.co );
}
}
world_instance *world = get_active_world();
menu_crap_ui();
- audio_debug_soundscapes();
render_view_framebuffer_ui();
-
-#if 0
- player_physics_gui();
-#endif
-}
-
-VG_STATIC void run_debug_info(void)
-{
-#if 0
- char buf[40];
-
- snprintf( buf, 40, "%.2fm/s", v3_length( player.rb.v ) );
- ui_text( (ui_px [2]){ 0, 0 }, buf, 1, k_text_align_left );
-
- snprintf( buf, 40, "%.2f %.2f %.2f m/s",
- player.phys.a[0], player.phys.a[1], player.phys.a[2] );
- ui_text( (ui_px [2]){ 0, 20 }, buf, 1, k_text_align_left );
-
- snprintf( buf, 40, "pos %.2f %.2f %.2f",
- player.phys.rb.co[0], player.phys.rb.co[1], player.phys.rb.co[2] );
- ui_text( (ui_px [2]){ 0, 40 }, buf, 1, k_text_align_left );
-
- if( vg_input.controller_handle )
- {
- for( int i=0; i<vg_list_size(vg_input.controller_axises); i++ )
- {
- snprintf( buf, 40, "%.2f", vg_input.controller_axises[i] );
- ui_text( (ui_px [2]){ 0, (i+3)*20 }, buf, 1, k_text_align_left );
- }
- }
- else
- {
- ui_text( (ui_px [2]){ 0, 60 },
- "Gamepad not ready", 1, k_text_align_left );
- }
-#endif
}