function bgm_play(_key)
{
    var _mus = oAudioManager.bgm_map[$ _key];
    if _mus == undefined exit;
    
    if audio_is_playing(oAudioManager.bgm_current)
        audio_sound_gain(oAudioManager.bgm_current, 0, 1000);
    
    oAudioManager.bgm_next = _mus;
    oAudioManager.bgm_fade_timer = 60;
}

function bgm_stop()
{
    audio_stop_sound(oAudioManager.bgm_current);
    oAudioManager.bgm_current = noone;
}

function sfx_play(_key, _pitch_vary = 0.1, _vol_vary = 0.1)
{
    var _sfx = oAudioManager.sfx_map[$ _key];
    var _inst = audio_play_sound(_sfx, 1, false);
    
    var _pitch = 1.0 + (random(_pitch_vary * 2) - _pitch_vary);
    var _vol = oAudioManager.sfx_volume * (1.0 - random(_vol_vary));
    
    audio_sound_pitch(_inst, _pitch);
    audio_sound_gain(_inst, _vol, 0);
    return _inst;
}