------------------------ Музыка и звуки -------------------------------
MUSIC_ON = true
SOUND_ON = true
VOLUME_MUSIC = 0.6
VOLUME_SOUND = 0.6
musicChannel = mixer.get_chan('ogg-sampler')
soundChannel = mixer.get_chan('ogg-sampler')


musicMenu = synth.data(io.file("music/gongs.ogg"))
soundMove = synth.data(io.file("music/sfx_movement_footstepsloop4_fast.ogg"))
soundButton = synth.data(io.file("music/sfx_sounds_button8.ogg"))
soundImpact = synth.data(io.file("music/sfx_sounds_impact1.ogg"))

currentMusic = function () return musicMenu end

MUSIC_ID = mixer.aplay_chan(musicChannel, currentMusic(), VOLUME_MUSIC, -1)

walksound = function(s)
            if not SOUND_ON then return end
            mixer.aplay_chan(soundChannel, soundMove, VOLUME_SOUND, 1)
            end

cantwalksound = function(s)
            if not SOUND_ON then return end
            mixer.aplay_chan(soundChannel, soundImpact, VOLUME_SOUND, 1)
            end

buttonsound = function(s)
            if not SOUND_ON then return end
            mixer.aplay_chan(soundChannel, soundButton, VOLUME_SOUND, 1)
            end


local f = io.open(SAVESOUNDSTATE, 'r')
if f then
    f:close()
    local d = dump.load(SAVESOUNDSTATE)
    MUSIC_ON, SOUND_ON = d[1], d[2]
    if not MUSIC_ON then mixer.stop(MUSIC_ID) end
    end --if
