<commit_before>import { Injectable } from '@angular/core';
import { Observable, ReplaySubject } from 'rxjs';

import { AudioPlayerService } from '../audio-player/audio-player.service';
import { ChartStoreService } from '../chart-store/chart-store.service';
import { ChartStore } from '../chart-store/chart-store';
import { ChartViewBuilderService } from './builder/chart-view-builder.service';
import { ChartViewControllerService } from './controller/chart-view-controller.service';
import { ChartViewPreparerService } from './preparer/chart-view-preparer.service';
import { ChartViewPrepared } from './chart-view-prepared';
import { ChartView } from './chart-view';

@Injectable()
export class ChartViewService {

    private chartViewSubject: ReplaySubject<ChartView>;
    private currentPreparedView: ChartViewPrepared;
    private currentView: ChartView;
    private renderedCurrentView: boolean;

    constructor(
        private audioPlayer: AudioPlayerService,
        private chartStore: ChartStoreService,
        private builder: ChartViewBuilderService,
        private controller: ChartViewControllerService,
        private preparer: ChartViewPreparerService,
    ) {
        this.renderedCurrentView = true;
        this.chartViewSubject = new ReplaySubject<ChartView>();
        this.chartStore.chart.combineLatest(this.controller.track, (chart, track) => {
            this.currentPreparedView = this.preparer.buildView(chart, track);
        }).subscribe(() => {
            this.updateView(0);  
        });
        this.audioPlayer.frameEvent.subscribe((time: number) => {
            this.updateView(time);
        });
        this.renderView();
        Observable.interval(16.7).subscribe((n) => {
            this.renderView();
        });
    }

    get view(): Observable<ChartView> {
        return this.chartViewSubject.asObservable();
    }<commit_msg>fix: Keep time when switching tracks<commit_after>import { Injectable } from '@angular/core';
import { Observable, ReplaySubject } from 'rxjs';

import { AudioPlayerService } from '../audio-player/audio-player.service';
import { ChartStoreService } from '../chart-store/chart-store.service';
import { ChartStore } from '../chart-store/chart-store';
import { ChartViewBuilderService } from './builder/chart-view-builder.service';
import { ChartViewControllerService } from './controller/chart-view-controller.service';
import { ChartViewPreparerService } from './preparer/chart-view-preparer.service';
import { ChartViewPrepared } from './chart-view-prepared';
import { ChartView } from './chart-view';

@Injectable()
export class ChartViewService {

    private chartViewSubject: ReplaySubject<ChartView>;
    private currentPreparedView: ChartViewPrepared;
    private currentView: ChartView;
    private currentTime: number;
    private renderedCurrentView: boolean;

    constructor(
        private audioPlayer: AudioPlayerService,
        private chartStore: ChartStoreService,
        private builder: ChartViewBuilderService,
        private controller: ChartViewControllerService,
        private preparer: ChartViewPreparerService,
    ) {
        this.currentTime = 0;
        this.renderedCurrentView = true;
        this.chartViewSubject = new ReplaySubject<ChartView>();
        this.chartStore.chart.combineLatest(this.controller.track, (chart, track) => {
            this.currentPreparedView = this.preparer.buildView(chart, track);
        }).subscribe(() => {
            this.updateView(this.currentTime);  
        });
        this.audioPlayer.frameEvent.subscribe((time: number) => {
            this.currentTime = time;
            this.updateView(time);
        });
        this.renderView();
        Observable.interval(16.7).subscribe((n) => {
            this.renderView();
        });
    }

    get view(): Observable<ChartView> {
        return this.chartViewSubject.asObservable();
    }
{'fraction_non_alphanumeric': 0.11909650924024641, 'fraction_numerical': 0.002053388090349076, 'mean_word_length': 3.378651685393258, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, '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': '4726702', 'n_tokens_mistral': 1029, 'n_tokens_neox': 1004, 'n_words': 206}