Advertisement
Rafael_Sol_Maker

RAFAEL_SOL_MAKER's VX AUDIOFILE ENTENSION v.1.0

Nov 17th, 2011
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.50 KB | None | 0 0
  1. #===============================================================================
  2. #             RAFAEL_SOL_MAKER's VX AUDIOFILE ENTENSION v.1.0
  3. #        (Include implementations from 'Audio Position' 1.0, by OriginalWij)
  4. #-------------------------------------------------------------------------------
  5. # Description:  Complements the audio functions adding some new routines like
  6. #               'ME.last' e 'SE.last' to paly again the last effects ran
  7. #               recently. This version contains implementations from
  8. #               OriginalWij's script that adds the currently sound position
  9. #               (eg.: BGM.position), it could be very useful for sincronizations
  10. #               between then. In the future this script would be more powerful
  11. #               and give more control over all the audio files of your game.
  12. #-------------------------------------------------------------------------------
  13. # How to Use:   Just put the command of your preference, like:
  14. #                 my_var = RPG::BGS.position
  15. #               OBS.: If the sound is repeating or if it's already finishied,
  16. #               the total execution time (position) will continue to increment,
  17. #               until you stop it, to reset the counter.
  18. #-------------------------------------------------------------------------------
  19. # Special Thanks: OriginalWij
  20. #-------------------------------------------------------------------------------
  21. #===============================================================================
  22.  
  23. module RPG  
  24.  
  25.   class BGM < AudioFile
  26.     @@last = BGM.new
  27.     @@position = 0
  28.     def play
  29.       if @name.empty?
  30.         Audio.bgm_stop
  31.         @@last = BGM.new
  32.         @@position = 0
  33.       else
  34.         Audio.bgm_play("Audio/BGM/" + @name, @volume, @pitch)
  35.         @@last = self
  36.         @@position = Time.now
  37.       end
  38.     end
  39.    
  40.     def self.stop
  41.       Audio.bgm_stop
  42.       @@last = BGM.new
  43.       @@position = 0
  44.     end
  45.    
  46.     def self.fade(time)
  47.       Audio.bgm_fade(time)
  48.       @@last = BGM.new
  49.       @@position = 0
  50.     end
  51.    
  52.     def self.last
  53.       return @@last
  54.     end
  55.    
  56.     def self.position
  57.       return 0 if @@position == 0
  58.       return Time.now - @@position
  59.     end
  60.   end
  61.  
  62.   class BGS < AudioFile
  63.     @@last = BGS.new
  64.     @@position = 0
  65.     def play
  66.       if @name.empty?
  67.         Audio.bgs_stop
  68.         @@last = BGS.new
  69.         @@position = 0
  70.       else
  71.         Audio.bgs_play("Audio/BGS/" + @name, @volume, @pitch)
  72.         @@last = self
  73.         @@position = Time.now
  74.       end
  75.     end
  76.    
  77.     def self.stop
  78.       Audio.bgs_stop
  79.       @@last = BGS.new
  80.       @@position = 0
  81.     end
  82.    
  83.     def self.fade(time)
  84.       Audio.bgs_fade(time)
  85.       @@last = BGS.new
  86.       @@position = 0
  87.     end
  88.    
  89.     def self.last
  90.       return @@last
  91.     end
  92.  
  93.     def self.position
  94.       return 0 if @@position == 0
  95.       return Time.now - @@position
  96.     end
  97.   end
  98.  
  99.   class ME < AudioFile
  100.     @@last = ME.new
  101.     @@position = 0
  102.     def play
  103.       if @name.empty?
  104.         Audio.me_stop
  105.         @@last = ME.new
  106.         @@position = 0
  107.       else
  108.         Audio.me_play("Audio/ME/" + @name, @volume, @pitch)
  109.         @@last = self        
  110.         @@position = Time.now
  111.       end      
  112.     end
  113.    
  114.     def self.stop
  115.       Audio.me_stop
  116.       @@last = ME.new
  117.       @@position = 0
  118.     end
  119.    
  120.     def self.fade(time)
  121.       Audio.me_fade(time)
  122.       @@last = ME.new
  123.       @@position = 0
  124.     end
  125.    
  126.     def self.last
  127.       return @@last
  128.     end
  129.    
  130.     def self.position
  131.       return 0 if @@position == 0
  132.       return Time.now - @@position
  133.     end    
  134.   end  
  135.  
  136.   class SE < AudioFile
  137.     @@last = SE.new
  138.     @@position = 0
  139.     def play      
  140.       if @name.empty?
  141.         Audio.se_stop
  142.         @@last = SE.new
  143.         @@position = 0
  144.       else
  145.         Audio.se_play("Audio/SE/" + @name, @volume, @pitch)
  146.         @@last = self        
  147.         @@position = Time.now
  148.       end      
  149.     end
  150.    
  151.     def self.stop
  152.       Audio.se_stop
  153.       @@last = SE.new
  154.       @@position = 0
  155.     end
  156.    
  157.     def self.fade(time)
  158.       #Audio.se_fade(time) # IT DOESN'T EXISTS!!
  159.       #@@last = SE.new
  160.       #@@position = 0
  161.       raise(NotImplementedError,"Sound Effects(SE) fade isn't avaliable yet in this version of the script! Try iy out in the future!")
  162.     end
  163.    
  164.     def self.last
  165.       return @@last
  166.     end
  167.    
  168.     def self.position
  169.       return 0 if @@position == 0
  170.       return Time.now - @@position
  171.     end    
  172.   end
  173. end
  174.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement