<commit_before>namespace United {

    export namespace Audio {

        export class Controller {

            private static controllerStore : { [key:string] : United.Audio.Controller } = {};

            private store: Sup.Audio.SoundPlayer[];
            public name: string;
            public defaultVolume: number;
            public volume: number;

            constructor(name: string,defaultVolume : number) {
                this.store = [];
                this.name = name;
                this.defaultVolume = United.Utils.clampNumber(defaultVolume,[0,1]);
                this.volume = this.defaultVolume;
                United.Audio.Controller.controllerStore[this.name] = this;
            }

            linkSound(SoundAsset: Sup.Audio.SoundPlayer) : void {
                this.store.push(SoundAsset);
            }

            public static setVolume(name: string,volume: number) : boolean {
                if(United.Utils.has(United.Audio.Controller.controllerStore,name)) {
                    return United.Audio.Controller.controllerStore[name].setVolume(volume);
                }
                return false;
            }

            setVolume(volume: number) : boolean {
                this.volume = United.Utils.clampNumber(volume,[0,1]);
                this.store.forEach( (SoundAsset : Sup.Audio.SoundPlayer) => {
                    SoundAsset.setVolume(this.volume);
                });
                return true;
            }

            reset(store?:boolean) : void {
                this.setVolume(this.defaultVolume);
                if(store) {
                    this.store = [];
                }
            }

        }

        export class Core {

            private static store : { [key:string] : United.Audio.Playlist} = {};
            public static active : string;

            public static addPlaylist(name: string,playlist: United.Audio.Playlist) {
                this.store[name] = playlist;
            }

            public static setPlaylist(name: string,trackID?: number) : void {
                if(this.store[name]) {
                    if(this.active) {
                        this.store[this.active].stop();
                        this.store[name].start();
                        this.active = name;
                    }
                    else {
                        this.active = name;
                        this.store[name].start();
                    }
                }
            }

            public static next() {
                this.store[this.active].next();
            }

            public static prev() {
                this.store[this.active].prev();
            }

            public static update() {
                if(this.active)
                    this.store[this.active].update();
            }

        }

        export type trackOption = {
            asset : string,
            title? : string
            defaultVolume? : number
        }

        export interface playlistOption {
            defaultTrack?: number
            autoStart?: boolean
            startRandom?: boolean
        }

        export class Playlist extends United.Addon {

            private activeTrack : number;
            public isPlaying : boolean = false;
            private soundInstance : Sup.Audio.SoundPlayer;
            private playlistSize : number;

            public startRandom : boolean = false;

            constructor(private tracksList : { [key:number] : United.Audio.trackOption },options?: playlistOption) {
                super({
                    defaultName: "Playlist"
                });
                this.playlistSize = United.Utils.objectSize(this.tracksList);
                let track : number;
                options = options || {};
                if(options.defaultTrack && !options.startRandom) {
                    track = options.defaultTrack;
                }
                else if(options.startRandom) {
                    track = United.Utils.getRandom(0,this.playlistSize);
                    this.startRandom = true;
                }
                else {
                    track = 0;
                }
                this.setTrack(track);

                if(options.autoStart) {
                    this.start();
                }
            }

            public getTitle(ID?: number) : string {
                if(ID) {
                    if(Utils.has(this.tracksList,ID)) {
                        return this.tracksList[ID].title || "Undefined title!";
                    }
                    return "Undefined Track ID!";<commit_msg>Fix: Make Audio.Playlist addon to a globalRestering scope<commit_after>namespace United {

    export namespace Audio {

        export class Controller {

            private static controllerStore : { [key:string] : United.Audio.Controller } = {};

            private store: Sup.Audio.SoundPlayer[];
            public name: string;
            public defaultVolume: number;
            public volume: number;

            constructor(name: string,defaultVolume : number) {
                this.store = [];
                this.name = name;
                this.defaultVolume = United.Utils.clampNumber(defaultVolume,[0,1]);
                this.volume = this.defaultVolume;
                United.Audio.Controller.controllerStore[this.name] = this;
            }

            linkSound(SoundAsset: Sup.Audio.SoundPlayer) : void {
                this.store.push(SoundAsset);
            }

            public static setVolume(name: string,volume: number) : boolean {
                if(United.Utils.has(United.Audio.Controller.controllerStore,name)) {
                    return United.Audio.Controller.controllerStore[name].setVolume(volume);
                }
                return false;
            }

            setVolume(volume: number) : boolean {
                this.volume = United.Utils.clampNumber(volume,[0,1]);
                this.store.forEach( (SoundAsset : Sup.Audio.SoundPlayer) => {
                    SoundAsset.setVolume(this.volume);
                });
                return true;
            }

            reset(store?:boolean) : void {
                this.setVolume(this.defaultVolume);
                if(store) {
                    this.store = [];
                }
            }

        }

        export class Core {

            private static store : { [key:string] : United.Audio.Playlist} = {};
            public static active : string;

            public static addPlaylist(name: string,playlist: United.Audio.Playlist) {
                this.store[name] = playlist;
            }

            public static setPlaylist(name: string,trackID?: number) : void {
                if(this.store[name]) {
                    if(this.active) {
                        this.store[this.active].stop();
                        this.store[name].start();
                        this.active = name;
                    }
                    else {
                        this.active = name;
                        this.store[name].start();
                    }
                }
            }

            public static next() {
                this.store[this.active].next();
            }

            public static prev() {
                this.store[this.active].prev();
            }

            public static update() {
                if(this.active)
                    this.store[this.active].update();
            }

        }

        export type trackOption = {
            asset : string,
            title? : string
            defaultVolume? : number
        }

        export interface playlistOption {
            defaultTrack?: number
            autoStart?: boolean
            startRandom?: boolean
        }

        export class Playlist extends United.Addon {

            private activeTrack : number;
            public isPlaying : boolean = false;
            private soundInstance : Sup.Audio.SoundPlayer;
            private playlistSize : number;

            public startRandom : boolean = false;

            constructor(private tracksList : { [key:number] : United.Audio.trackOption },options?: playlistOption) {
                super({
                    defaultName: "Playlist",
                    global: true
                });
                this.playlistSize = United.Utils.objectSize(this.tracksList);
                let track : number;
                options = options || {};
                if(options.defaultTrack && !options.startRandom) {
                    track = options.defaultTrack;
                }
                else if(options.startRandom) {
                    track = United.Utils.getRandom(0,this.playlistSize);
                    this.startRandom = true;
                }
                else {
                    track = 0;
                }
                this.setTrack(track);

                if(options.autoStart) {
                    this.start();
                }
            }

            public getTitle(ID?: number) : string {
                if(ID) {
                    if(Utils.has(this.tracksList,ID)) {
                        return this.tracksList[ID].title || "Undefined title!";
                    }
                    return "Undefined Track ID!";
{'fraction_non_alphanumeric': 0.09558665231431647, 'fraction_numerical': 0.0012917115177610333, 'mean_word_length': 1.2200716845878137, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1480522', 'n_tokens_mistral': 2256, 'n_tokens_neox': 2064, 'n_words': 412}