1. -- 
  2. -- Copyright (c) 2012 Kevin Wellwood 
  3. -- All rights reserved. 
  4. -- 
  5. -- This source code is distributed under the Modified BSD License. For terms and 
  6. -- conditions, see license.txt. 
  7. -- 
  8.  
  9. with Events; 
  10.  
  11. pragma Elaborate_All( Events ); 
  12.  
  13. package Events.Audio is 
  14.  
  15.     PLAY_MUSIC_ID : constant Event_Id := To_Event_Id( "Play_Music" ); 
  16.  
  17.     -- A command to begin playing a looped music track. 
  18.     type Play_Music_Event is new Event with private; 
  19.     type A_Play_Music_Event is access all Play_Music_Event'Class; 
  20.  
  21.     -- Returns the filename of the music to play. 
  22.     function Get_Music_Name( this : not null access Play_Music_Event'Class ) return String; 
  23.     pragma Postcondition( Get_Music_Name'Result'Length > 0 ); 
  24.  
  25.     ---------------------------------------------------------------------------- 
  26.  
  27.     PLAY_SOUND_ID : constant Event_Id := To_Event_Id( "Play_Sound" ); 
  28.  
  29.     -- A command to play a sound effect once through. 
  30.     type Play_Sound_Event is new Event with private; 
  31.     type A_Play_Sound_Event is access all Play_Sound_Event'Class; 
  32.  
  33.     -- Returns the name of the sound effect to play. 
  34.     function Get_Sound_Name( this : not null access Play_Sound_Event'Class ) return String; 
  35.     pragma Postcondition( Get_Sound_Name'Result'Length > 0 ); 
  36.  
  37.     ---------------------------------------------------------------------------- 
  38.  
  39.     -- A command to stop any music currently playing. 
  40.     STOP_MUSIC_ID : constant Event_Id := To_Event_Id( "Stop_Music" ); 
  41.  
  42.     ---------------------------------------------------------------------------- 
  43.  
  44.     -- Queues a Play_Music_Event. 
  45.     procedure Queue_Play_Music( name : String ); 
  46.     pragma Precondition( name'Length > 0 ); 
  47.  
  48.     -- Queues a Play_Sound_Event. 
  49.     procedure Queue_Play_Sound( name : String ); 
  50.     pragma Precondition( name'Length > 0 ); 
  51.  
  52.     -- Queues a Stop_Music_Event. 
  53.     procedure Queue_Stop_Music; 
  54.  
  55. private 
  56.  
  57.     type Play_Sound_Event is new Event with 
  58.         record 
  59.             name : Unbounded_String; 
  60.         end record; 
  61.  
  62.     procedure Construct( this : access Play_Sound_Event; name : String ); 
  63.     pragma Precondition( name'Length > 0 ); 
  64.  
  65.     function To_String( this : access Play_Sound_Event ) return String; 
  66.  
  67.     ---------------------------------------------------------------------------- 
  68.  
  69.     type Play_Music_Event is new Event with 
  70.         record 
  71.             name : Unbounded_String; 
  72.         end record; 
  73.  
  74.     procedure Construct( this : access Play_Music_Event; name : String ); 
  75.     pragma Precondition( name'Length > 0 ); 
  76.  
  77.     function To_String( this : access Play_Music_Event ) return String; 
  78.  
  79. end Events.Audio;