preview test while editing

This commit is contained in:
2020-06-14 15:05:03 +02:00
parent 55200dc742
commit 96566379eb
4 changed files with 16 additions and 3 deletions

View File

@@ -68,7 +68,9 @@ export class TextRenderingService {
const type = hasMatches ? LineType.chord : LineType.text;
const line = {type, text, chords: hasMatches ? cords : undefined};
return transpose ? this.transposeService.transpose(line, transpose.baseKey, transpose.targetKey) : line;
return transpose
? this.transposeService.transpose(line, transpose.baseKey, transpose.targetKey)
: this.transposeService.renderChords(line);
}
private getSectionTypeOfLine(line: string): SectionType {
@@ -107,7 +109,7 @@ export class TextRenderingService {
const chordCount = chords.reduce((acc: number, cur: Chord) => acc + cur.length, 0);
const lineCount = chordLine.replace(/\s/g, "").length;
const isChrod = chordCount * 2 > lineCount;
const isChrod = chordCount * 1.2 > lineCount;
return isChrod ? chords : [];
}

View File

@@ -23,6 +23,13 @@ export class TransposeService {
return {...line, text: renderedLine, chords};
}
public renderChords(line: Line): Line {
if (line.type !== LineType.chord) return line;
const renderedLine = this.renderLine(line.chords);
return {...line, text: renderedLine};
}
public getDistance(baseKey: string, targetKey: string): number {
const scale = getScaleType(baseKey);
return (