     else
       path
 
-  constructor: (@root) ->
+  constructor: (@aroma, @root) ->
     @file_cache = {}
 
   get_module: (module_name, callback) ->
     path = module_name.replace /\./g, '/'
     path = "#{path}.lua"
-    @get_file path, callback
-
-  get_file: (path, callback) ->
+    @get_file path, null, callback
+
+  get_file: (path, loader, callback) ->
     path = @real_path path
 
     return callback @file_cache[path] if @file_cache[path]?
-    # find loader
-    loader = null
-    for name, tuple of @loaders
-      {match: match, load: load} = tuple
-      if match.call this, path
-        loader = load
-        break
-
-    loader = @default_loader unless loader?
+
+    loader = @loaders[loader] if loader
+    loader = @default_loader unless loader
+
     @on_fail = -> callback null
 
     loader.call this, path, (result) =>


    image: (msg, callback) ->
      [_, path] = msg
      get_image_data path, (image_bytes, width, height) ->
        if !image_bytes
          callback ["error", "Failed to find image: #{path}"]
        else
          callback ["success", image_bytes, width, height]

    audio: (msg, callback) ->
      [_, path, type] = msg
      @audio.new_source path, type, (source_id) ->
        if source_id isnt null
          callback ["success", source_id]
        else

class Aroma.Audio
  constructor: ->
    @sources = []
    @context = new webkitAudioContext

  stop_all: ->
