text3d
[carveJwlIkooP6JGAAIwe30JlM.git] / audio.h
diff --git a/audio.h b/audio.h
index 5caa759e01fdc7b00182f025eb36d03950520e5d..d52f410defd3cebef94613ba19c348e3612d85b6 100644 (file)
--- a/audio.h
+++ b/audio.h
 VG_STATIC float audio_occlusion_current = 0.0f,
              k_audio_occlusion_rate  = 1.0f;
 
-VG_STATIC int   k_audio_debug_soundscape = 0;
+VG_STATIC int k_audio_debug_soundscape = 0;
 
 audio_clip audio_board[] =
 {
-   { .path="sound/skate.ogg" },
+   { .path="sound/skate_hpf.ogg" },
    { .path="sound/wheel.ogg" },
    { .path="sound/slide.ogg" },
-   { .path="sound/reverb.ogg" },
-   { .path="sound/grind_loop.ogg" },
    { .path="sound/grind_enter.ogg" },
-   { .path="sound/grind_exit.ogg" }
+   { .path="sound/grind_exit.ogg" },
+   { .path="sound/grind_loop.ogg" },
+   { .path="sound/woodslide.ogg" },
+   { .path="sound/metalscrape.ogg" },
+   { .path="sound/slidetap.ogg" }
+};
+
+audio_clip audio_taps[] =
+{
+   { .path="sound/tap0.ogg" },
+   { .path="sound/tap1.ogg" },
+   { .path="sound/tap2.ogg" },
+   { .path="sound/tap3.ogg" }
+};
+
+audio_clip audio_hits[] =
+{
+   { .path="sound/hit0.ogg" },
+   { .path="sound/hit1.ogg" },
+   { .path="sound/hit2.ogg" },
+   { .path="sound/hit3.ogg" },
+   { .path="sound/hit4.ogg" }
 };
 
 audio_clip audio_splash =
@@ -101,6 +120,7 @@ audio_clip audio_gate_ambient = {
 .path = "sound/gate_ambient.ogg"
 };
 
+#if 0
 audio_player ambient_player =
 {
    .name = "Ambience"
@@ -110,6 +130,7 @@ audio_player audio_rewind_player =
 {
    .name = "Rewind"
 };
+#endif
 
 audio_clip audio_rewind[] = {
 { .path = "sound/rewind_start.ogg" },
@@ -124,6 +145,7 @@ audio_clip audio_ui[] = {
    { .path = "sound/ui_ding.ogg" },
 };
 
+#if 0
 audio_player ambient_sprites[4] =
 {
    { .name = "Ambient Sprites 0" },
@@ -166,9 +188,11 @@ 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 );
@@ -182,13 +206,17 @@ VG_STATIC void audio_init(void)
    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_ambience, vg_list_size(audio_ambience), NULL );
    audio_clip_loadn( &audio_splash, 1, NULL );
    audio_clip_loadn( &audio_gate_pass, 1, NULL );
    audio_clip_loadn( &audio_gate_lap, 1, NULL );
    audio_clip_loadn( &audio_gate_ambient, 1, NULL );
+
    audio_clip_loadn( audio_jumps, vg_list_size(audio_jumps), NULL );
    audio_clip_loadn( audio_lands, vg_list_size(audio_lands), NULL );
    audio_clip_loadn( audio_water, vg_list_size(audio_water), NULL );
@@ -201,6 +229,7 @@ VG_STATIC void audio_init(void)
    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;
 
@@ -215,6 +244,7 @@ VG_STATIC void audio_init(void)
    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 );
@@ -230,6 +260,7 @@ VG_STATIC void audio_init(void)
    audio_player_playclip( &audio_player_gate, &audio_gate_ambient );
 
    audio_unlock();
+#endif
 
    vg_var_push( (struct vg_var){
       .name = "aud_debug_soundscape",
@@ -246,6 +277,38 @@ VG_STATIC void audio_init(void)
       .opt_f32 = { .clamp = 0 },
       .persistent = 1
    });
+
+   audio_lock();
+   audio_set_lfo_wave( 0, k_lfo_polynomial_bipolar, 80.0f );
+   audio_set_lfo_frequency( 0, 20.0f );
+   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)
@@ -336,17 +399,14 @@ VG_STATIC enum audio_sprite_type audio_sample_sprite_random( v3f origin,
 
    world_instance *world = get_active_world();
    
-   if( ray_world( world, pos, (v3f){0.0f,-1.0f,0.0f}, &contact ) )
-   {
-      struct world_material *mat = ray_hit_material( world, &contact );
+   if( ray_world( world, pos, (v3f){0.0f,-1.0f,0.0f}, &contact ) ){
+      struct world_surface *mat = ray_hit_surface( world, &contact );
 
-      if( mat->info.surface_prop == k_surface_prop_grass) 
-      {
+      if( mat->info.surface_prop == k_surface_prop_grass){
          v3_copy( contact.pos, output );
          return k_audio_sprite_type_grass;
       }
-      else
-      {
+      else{
 #if 0
          vg_line( pos, contact.pos, 0xff0000ff );
          vg_line_pt3( contact.pos, 0.3f, 0xff0000ff );