Vlue

Music Player

Dec 24th, 2014
154
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Vlue~
  2. #Music_Player.play(:jbells)
  3. module Music_Player
  4.   SOUNDS = {
  5.     :basic => 'Audio/SE/Switch1'
  6.   }
  7.   NOTES = {
  8.     :d => [SOUNDS[:basic],80],
  9.     :e => [SOUNDS[:basic],85],
  10.     :f => [SOUNDS[:basic],90],
  11.     :g => [SOUNDS[:basic],95],
  12.     :A => [SOUNDS[:basic],100],
  13.     :B => [SOUNDS[:basic],105],
  14.     :C => [SOUNDS[:basic],110],
  15.     :D => [SOUNDS[:basic],115],
  16.     :E => [SOUNDS[:basic],120],
  17.   }
  18.   SONGS = {
  19.     :jbells => {
  20.       :notes => [:A,:A,:A,0,:A,:A,:A,0,:A,:C,:d,:f,:g,
  21.                 0,0,:B,:B,:B,:B,:B,:f,:f,[:f,10],[:f,10],:f,:d,:d,
  22.                 :f,[:d,20],:E],
  23.       :tempo => 15,
  24.     }
  25.   }
  26.   def self.play(sym)
  27.     return unless SONGS[sym]
  28.     @current_song = SONGS[sym]
  29.     @current_note = 0
  30.     @current_time = 0
  31.   end
  32.   def self.update
  33.     return unless @current_song
  34.     if @current_time <= 0
  35.       note = @current_song[:notes][@current_note]
  36.       @current_time = @current_song[:tempo]
  37.       if note != 0
  38.         if note.is_a?(Array)
  39.           se = NOTES[note[0]]
  40.           @current_time = note[1]
  41.         else
  42.           se = NOTES[note]
  43.         end
  44.         Audio.se_play(se[0],100,se[1])
  45.       end
  46.       @current_note += 1
  47.     end
  48.     @current_time -= 1
  49.     stop if @current_note == @current_song[:notes].size
  50.   end
  51.   def self.stop
  52.     @current_song = nil
  53.     @current_note = nil
  54.     @current_time = nil
  55.   end
  56. end
  57.    
  58. class Scene_Base
  59.   alias music_player_update update
  60.   def update
  61.     music_player_update
  62.     Music_Player.update
  63.   end
  64. end
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×