<commit_before>(function() {



var Sound = function(game) {
    this.sounds = [];
    game.EventEmitter(this);

    return this;
}

Sound.prototype.load = function(urls, name) {
    var asset = this.loader.load(urls, name).get();
    var sound = this.createSound(asset);
    this.sounds.push(sound);

    this.emit("soundadd", [sound]);

    return this;
}

Sound.prototype.get = function(id) {
    return this.loader.get(id);
}

Sound.prototype.play = function(id) {
    var sound = this.get(id);
    if(sound) sound.play();

    return this;
}

Sound.prototype.pause = function(id) {
    var sound = this.get(id);
    if(sound) sound.pause();

    return this;
}

Sound.prototype.stop = function(id) {
    var sound = this.get(id);
    if(sound) sound.stop();

    return this;
}

Sound.prototype.setLoader = function(loader) {
    this.loader = loader;

    return this;
}







/*
 * SoundInstance
 *
 * SoundInstance respresents a sound, with some additional information and methods.
 * It looks like an Asset, but it includes play, pause and stop function.
 */

var createSound = function(asset) {
    if(!asset.element && asset.blobURL) {
        asset.element = document.createElement("audio");
        asset.element.setAttribute("src", asset.blobURL);
    }


    asset.play = function() {
        if(this.element) {
            this.element.load();
            this.element.play();
        }
        else {
            console.warn("WARN: Asset.play(): No element! Are you sure this Asset loaded successfully?");
        }
        return this;
    }

    asset.pause = function() {
        if(this.element) {
            this.element.pause();
        }
        else {
            console.warn("WARN: Asset.pause(): No element! Are you sure this Asset loaded successfully?");
        }
        return this;
    }

    asset.stop = function() {
        if(this.element) {
            this.element.pause();
            this.element.currentTime = 0;
        }
        else {
            console.warn("WARN: Asset.stop(): No element! Are you sure this Asset loaded successfully?");
        }
        return this;
    }


    return asset;
}

Sound.prototype.createSound = createSound;




var Plugin = {
    name: "sound-basic",<commit_msg>Tweaked sound-basic<commit_after>(function() {



var Sound = function(game) {
    this.sounds = [];
    game.EventEmitter(this);

    return this;
}

Sound.prototype.load = function(urls, name) {
    var asset = this.loader.load(urls, name).get();
    var sound = this.createSound(asset);
    this.sounds.push(sound);

    this.emit("soundadd", [sound]);

    return this;
}

Sound.prototype.get = function(id) {
    return this.loader.get(id);
}

Sound.prototype.play = function(id) {
    var sound = this.get(id);
    if(sound) sound.play();

    return this;
}

Sound.prototype.pause = function(id) {
    var sound = this.get(id);
    if(sound) sound.pause();

    return this;
}

Sound.prototype.stop = function(id) {
    var sound = this.get(id);
    if(sound) sound.stop();

    return this;
}

Sound.prototype.setLoader = function(loader) {
    this.loader = loader;

    return this;
}







/*
 * SoundInstance
 *
 * SoundInstance respresents a sound, with some additional information and methods.
 * It looks like an Asset, but it includes play, pause and stop function.
 */

var createSound = function(asset) {
    asset.on("success", function() {
        if(!asset.element && asset.blobURL) {
            asset.element = document.createElement("audio");
            asset.element.setAttribute("src", asset.blobURL);
        }


        asset.play = function() {
            this.element.load();
            this.element.play();

            return this;
        }

        asset.pause = function() {
            this.element.pause();

            return this;
        }

        asset.stop = function() {
            this.element.pause();
            this.element.currentTime = 0;

            return this;
        }

    });


    return asset;
}

Sound.prototype.createSound = createSound;




var Plugin = {
    name: "sound-basic",
{'fraction_non_alphanumeric': 0.13525390625, 'fraction_numerical': 0.00048828125, 'mean_word_length': 2.288121990369181, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6857289', 'n_tokens_mistral': 1263, 'n_tokens_neox': 1206, 'n_words': 279}