#include audio/context.js
#include sound/sndmgr.js
#include sound/sndlibrary.js
#include sound/sndpacks.js

const MamiSoundContext = function() {
    const audioCtx = new MamiAudioContext;
    const manager = new MamiSoundManager(audioCtx);
    const library = new MamiSoundLibrary(manager);
    const packs = new MamiSoundPacks;

    let pack = new MamiSoundPack;

    const pub = {};

    Object.defineProperties(pub, {
        audio: { value: audioCtx, enumerable: true },
        manager: { value: manager, enumerable: true },
        library: { value: library, enumerable: true },
        packs: { value: packs, enumerable: true },

        pack: {
            get: () => pack,
            set: value => {
                if(typeof value !== 'object' || typeof value.getEventSound !== 'function')
                    throw 'value is not a valid soundpack';
                pack = value;
            },
            enumerable: true,
        },

        ready: { get: audioCtx.isReady, enumerable: true },
        volume: { get: audioCtx.getVolume, set: audioCtx.setVolume, enumerable: true },
        muted: { get: audioCtx.isMuted, set: audioCtx.setMuted, enumerable: true },
    });

    pub.reset = audioCtx.reset;

    return Object.freeze(pub);
};
