<commit_before>import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/observable';
import { Subject } from 'rxjs/subject';

import { ScientificPitchNotation } from './classes/scientificPitchNotation';
import { GuitarString } from './classes/guitarString';
import { GuitarTuning } from './classes/guitarTuning';
import { Guitar } from './classes/guitar';

import { MusicNotationService } from './music-notation.service';

const GUITARS: Guitar[] = [
    {
        name: "Guitar",
        tunings: [
            {
                name: "Standard",
                strings: [
                    {baseTuning:{letter: "E", octave:4}, fret:null},
                    {baseTuning:{letter: "B", octave:3}, fret:null},
                    {baseTuning:{letter: "G", octave:3}, fret:null},
                    {baseTuning:{letter: "D", octave:3}, fret:null},
                    {baseTuning:{letter: "A", octave:2}, fret:null},
                    {baseTuning:{letter: "E", octave:2}, fret:null}
                ],
                fingerSpreadMetric: null
            },
            {
                name: "Drop D",
                strings: [
                    {baseTuning:{letter: "E", octave:4}, fret:null},
                    {baseTuning:{letter: "B", octave:3}, fret:null},
                    {baseTuning:{letter: "G", octave:3}, fret:null},
                    {baseTuning:{letter: "D", octave:3}, fret:null},
                    {baseTuning:{letter: "A", octave:2}, fret:null},
                    {baseTuning:{letter: "D", octave:2}, fret:null}
                ],
                fingerSpreadMetric: null
            },
            {
                name: "Open D",
                strings: [
                    {baseTuning:{letter: "D", octave:4}, fret:null},
                    {baseTuning:{letter: "A", octave:3}, fret:null},
                    {baseTuning:{letter: "F#", octave:3}, fret:null},
                    {baseTuning:{letter: "D", octave:3}, fret:null},
                    {baseTuning:{letter: "A", octave:2}, fret:null},
                    {baseTuning:{letter: "D", octave:2}, fret:null}
                ],
                fingerSpreadMetric: null
            },
            {
                name: "Open C",
                strings: [
                    {baseTuning:{letter: "G", octave:4}, fret:null},
                    {baseTuning:{letter: "E", octave:4}, fret:null},
                    {baseTuning:{letter: "C", octave:4}, fret:null},
                    {baseTuning:{letter: "G", octave:3}, fret:null},
                    {baseTuning:{letter: "E", octave:3}, fret:null},
                    {baseTuning:{letter: "C", octave:3}, fret:null}
                ],
                fingerSpreadMetric: null
            },
            {
                name: "Open G",
                strings: [
                    {baseTuning:{letter: "D", octave:4}, fret:null},
                    {baseTuning:{letter: "B", octave:3}, fret:null},
                    {baseTuning:{letter: "G", octave:3}, fret:null},
                    {baseTuning:{letter: "D", octave:3}, fret:null},
                    {baseTuning:{letter: "G", octave:2}, fret:null},
                    {baseTuning:{letter: "D", octave:2}, fret:null}
                ],
                fingerSpreadMetric: null
            }
        ],
        selectedTuning: {
                name: "Standard",
                strings: [
                    {baseTuning:{letter: "E", octave:4}, fret:null},
                    {baseTuning:{letter: "B", octave:3}, fret:null},
                    {baseTuning:{letter: "G", octave:3}, fret:null},
                    {baseTuning:{letter: "D", octave:3}, fret:null},
                    {baseTuning:{letter: "A", octave:2}, fret:null},
                    {baseTuning:{letter: "E", octave:2}, fret:null}
                ],
                fingerSpreadMetric: null
            }
    },
    {
        name: "Bass",
        tunings: [
            {
                name: "Standard",
                strings: [
                    {baseTuning:{letter: "G", octave:2}, fret:null},
                    {baseTuning:{letter: "D", octave:2}, fret:null},
                    {baseTuning:{letter: "A", octave:1}, fret:null},
                    {baseTuning:{letter: "E", octave:1}, fret:null}
                ],
                fingerSpreadMetric: null
            },
            {
                name: "Drop D",
                strings: [
                    {baseTuning:{letter: "G", octave:2}, fret:null},
                    {baseTuning:{letter: "D", octave:2}, fret:null},
                    {baseTuning:{letter: "A", octave:1}, fret:null},
                    {baseTuning:{letter: "D", octave:1}, fret:null}
                ],
                fingerSpreadMetric: null
            }
        ],
        selectedTuning: {
                name: "Standard",
                strings: [
                    {baseTuning:{letter: "G", octave:2}, fret:null},
                    {baseTuning:{letter: "D", octave:2}, fret:null},
                    {baseTuning:{letter: "A", octave:1}, fret:null},
                    {baseTuning:{letter: "E", octave:1}, fret:null}
                ],
                fingerSpreadMetric: null
            }
    }
];


@Injectable()
export class GuitarTablatureService {

    guitars = GUITARS;
    maxFrets = 19;

    constructor(private musicNotesService: MusicNotationService ) {};

    setGuitarStrings(guitarStrings: GuitarString[]): Promise<GuitarString[]> {
        //let resolvedNotes = guitarStrings.map(this.guitarStringToScientificPitchNotation);
        let resolvedNotes = guitarStrings.filter(function(string){return string.fret > 0; })
                                        .map(this.convertStringToResolvedPitchNumber)
                                        .map(this.convertNumberToSciPitchNotation);
        
        
        let returnedNotes = this.musicNotesService.setScientificPitch(resolvedNotes);

        //Eventually we want to swap this code with something from the result of this.musicNotesService
        return Promise.resolve(guitarStrings);
    };
    
    getGuitarOptions(): Promise<Guitar[]>{
        return Promise.resolve(this.guitars);
    };

    getTabsObservable(guitarTuning:GuitarTuning): Observable<GuitarTuning[]> {
        return this.musicNotesService.getScientificPitchSubject().map(pitches => this.getFingerings(guitarTuning, pitches));
    };

    resendTabs(): void{<commit_msg>Bug fix where Open Fingerings ignored<commit_after>import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/observable';
import { Subject } from 'rxjs/subject';

import { ScientificPitchNotation } from './classes/scientificPitchNotation';
import { GuitarString } from './classes/guitarString';
import { GuitarTuning } from './classes/guitarTuning';
import { Guitar } from './classes/guitar';

import { MusicNotationService } from './music-notation.service';

const GUITARS: Guitar[] = [
    {
        name: "Guitar",
        tunings: [
            {
                name: "Standard",
                strings: [
                    {baseTuning:{letter: "E", octave:4}, fret:null},
                    {baseTuning:{letter: "B", octave:3}, fret:null},
                    {baseTuning:{letter: "G", octave:3}, fret:null},
                    {baseTuning:{letter: "D", octave:3}, fret:null},
                    {baseTuning:{letter: "A", octave:2}, fret:null},
                    {baseTuning:{letter: "E", octave:2}, fret:null}
                ],
                fingerSpreadMetric: null
            },
            {
                name: "Drop D",
                strings: [
                    {baseTuning:{letter: "E", octave:4}, fret:null},
                    {baseTuning:{letter: "B", octave:3}, fret:null},
                    {baseTuning:{letter: "G", octave:3}, fret:null},
                    {baseTuning:{letter: "D", octave:3}, fret:null},
                    {baseTuning:{letter: "A", octave:2}, fret:null},
                    {baseTuning:{letter: "D", octave:2}, fret:null}
                ],
                fingerSpreadMetric: null
            },
            {
                name: "Open D",
                strings: [
                    {baseTuning:{letter: "D", octave:4}, fret:null},
                    {baseTuning:{letter: "A", octave:3}, fret:null},
                    {baseTuning:{letter: "F#", octave:3}, fret:null},
                    {baseTuning:{letter: "D", octave:3}, fret:null},
                    {baseTuning:{letter: "A", octave:2}, fret:null},
                    {baseTuning:{letter: "D", octave:2}, fret:null}
                ],
                fingerSpreadMetric: null
            },
            {
                name: "Open C",
                strings: [
                    {baseTuning:{letter: "G", octave:4}, fret:null},
                    {baseTuning:{letter: "E", octave:4}, fret:null},
                    {baseTuning:{letter: "C", octave:4}, fret:null},
                    {baseTuning:{letter: "G", octave:3}, fret:null},
                    {baseTuning:{letter: "E", octave:3}, fret:null},
                    {baseTuning:{letter: "C", octave:3}, fret:null}
                ],
                fingerSpreadMetric: null
            },
            {
                name: "Open G",
                strings: [
                    {baseTuning:{letter: "D", octave:4}, fret:null},
                    {baseTuning:{letter: "B", octave:3}, fret:null},
                    {baseTuning:{letter: "G", octave:3}, fret:null},
                    {baseTuning:{letter: "D", octave:3}, fret:null},
                    {baseTuning:{letter: "G", octave:2}, fret:null},
                    {baseTuning:{letter: "D", octave:2}, fret:null}
                ],
                fingerSpreadMetric: null
            }
        ],
        selectedTuning: {
                name: "Standard",
                strings: [
                    {baseTuning:{letter: "E", octave:4}, fret:null},
                    {baseTuning:{letter: "B", octave:3}, fret:null},
                    {baseTuning:{letter: "G", octave:3}, fret:null},
                    {baseTuning:{letter: "D", octave:3}, fret:null},
                    {baseTuning:{letter: "A", octave:2}, fret:null},
                    {baseTuning:{letter: "E", octave:2}, fret:null}
                ],
                fingerSpreadMetric: null
            }
    },
    {
        name: "Bass",
        tunings: [
            {
                name: "Standard",
                strings: [
                    {baseTuning:{letter: "G", octave:2}, fret:null},
                    {baseTuning:{letter: "D", octave:2}, fret:null},
                    {baseTuning:{letter: "A", octave:1}, fret:null},
                    {baseTuning:{letter: "E", octave:1}, fret:null}
                ],
                fingerSpreadMetric: null
            },
            {
                name: "<NAME>",
                strings: [
                    {baseTuning:{letter: "G", octave:2}, fret:null},
                    {baseTuning:{letter: "D", octave:2}, fret:null},
                    {baseTuning:{letter: "A", octave:1}, fret:null},
                    {baseTuning:{letter: "D", octave:1}, fret:null}
                ],
                fingerSpreadMetric: null
            }
        ],
        selectedTuning: {
                name: "Standard",
                strings: [
                    {baseTuning:{letter: "G", octave:2}, fret:null},
                    {baseTuning:{letter: "D", octave:2}, fret:null},
                    {baseTuning:{letter: "A", octave:1}, fret:null},
                    {baseTuning:{letter: "E", octave:1}, fret:null}
                ],
                fingerSpreadMetric: null
            }
    }
];


@Injectable()
export class GuitarTablatureService {

    guitars = GUITARS;
    maxFrets = 19;

    constructor(private musicNotesService: MusicNotationService ) {};

    setGuitarStrings(guitarStrings: GuitarString[]): Promise<GuitarString[]> {
        //let resolvedNotes = guitarStrings.map(this.guitarStringToScientificPitchNotation);
        let resolvedNotes = guitarStrings.filter(function(string){return string.fret !== null; })
                                        .map(this.convertStringToResolvedPitchNumber)
                                        .map(this.convertNumberToSciPitchNotation);
        
        
        let returnedNotes = this.musicNotesService.setScientificPitch(resolvedNotes);

        //Eventually we want to swap this code with something from the result of this.musicNotesService
        return Promise.resolve(guitarStrings);
    };
    
    getGuitarOptions(): Promise<Guitar[]>{
        return Promise.resolve(this.guitars);
    };

    getTabsObservable(guitarTuning:GuitarTuning): Observable<GuitarTuning[]> {
        return this.musicNotesService.getScientificPitchSubject().map(pitches => this.getFingerings(guitarTuning, pitches));
    };

    resendTabs(): void{
{'fraction_non_alphanumeric': 0.14262635587352873, 'fraction_numerical': 0.0077698284483421805, 'mean_word_length': 1.621496269409155, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6414661', 'n_tokens_mistral': 3929, 'n_tokens_neox': 3588, 'n_words': 683}