extends Node

func _init():
	Globals.set("audio", self)

func play_sound(var snd):
	get_node("sounds").play(snd)
	
func set_global_pitch_scale(var scale):
	get_node("sounds").set_default_pitch_scale(scale)
	get_node("music").set_pitch_scale(scale)
	
	
func play_stream(var stream):
	get_node("music").set_stream(stream)
	get_node("music").play()
	
func play_random_stream():
	var streams = get_node("preloaded").get_resource_list()
	randomize()
	var rand = randi() % streams.size()
	get_node("music").set_stream(get_node("preloaded").get_resource(streams[rand]))
	get_node("music").play()
	
func change_music_volume(var new_volume):
	get_node("music").set_volume(new_volume)
	if new_volume == 0:
		get_node("music").set_paused(true)
	elif !get_node("music").is_paused():
		audio.get_node("music").set_paused(false)
	
	



