Hendrix000007

TRACK CLASS

Mar 29th, 2014
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.91 KB | None | 0 0
  1. ----THIS IS THE TRACK CLASS I CALL INSIDE THE MAIN FILE------
  2. Track = {}
  3.     function Track:new()
  4.         Track.instanceTable = {}   
  5.             Track.activeTrack = {}
  6.            
  7.             Track.instanceTable = {
  8.                 [1] = {
  9.                         trackSnd = audio.loadStream( "Sound/Tracks/01.mp3", { volume=100} ),
  10.                         trackName = "track_01.mp3",
  11.                         trackStart = {  [1] = {5000, 3000},
  12.                                 [2] = {15000, 3000},
  13.                             },
  14.                         },
  15.                     }
  16.  
  17.        
  18.                 function Track:play( track, part )
  19.                     local chan = audio.findFreeChannel()
  20.                             local snd = Track.instanceTable[track].trackSnd, {channel = chan}
  21.                             local begin = Track.instanceTable[track].trackStart[part][1]
  22.                     local stop = Track.instanceTable[track].trackStart[part][2]
  23.                     print(begin, stop)
  24.                             local seek = audio.seek(begin, snd)
  25.                             audio.play(snd)
  26.                             audio.stopWithDelay(stop, chan)
  27.                 end    
  28.  
  29.     end
  30. return Track
Advertisement
Add Comment
Please, Sign In to add comment