diff --git a/src/components/audioManagement/audioManagement.tsx b/src/components/audioManagement/audioManagement.tsx index 54361d0..6869370 100644 --- a/src/components/audioManagement/audioManagement.tsx +++ b/src/components/audioManagement/audioManagement.tsx @@ -101,7 +101,8 @@ class AudioManagement extends React.Component { this.repaintWaveform( this.props.sections, this.props.measures, - this.props.zoomLevel + this.props.zoomLevel, + this.props.secondsPerMeasure ); } @@ -125,7 +126,8 @@ class AudioManagement extends React.Component { this.repaintWaveform( this.props.sections, this.props.measures, - this.props.zoomLevel + this.props.zoomLevel, + this.props.secondsPerMeasure ); } @@ -165,11 +167,12 @@ class AudioManagement extends React.Component { private repaintWaveform( sections: NormalizedObjects
, measures: NormalizedObjects, - zoomLevel: number + zoomLevel: number, + timePerMeasure: number ) { this.getPeaks()?.segments.removeAll(); this.getPeaks()?.segments.add( - PeaksConfig.sectionsToSegment(sections, measures) + PeaksConfig.sectionsToSegment(sections, measures, timePerMeasure) ); this.getPeaks()?.points.removeAll(); this.getPeaks()?.points.add(PeaksConfig.measuresToPoints(measures)); diff --git a/src/components/audioManagement/peaksConfig.ts b/src/components/audioManagement/peaksConfig.ts index 91dd881..d36d01e 100644 --- a/src/components/audioManagement/peaksConfig.ts +++ b/src/components/audioManagement/peaksConfig.ts @@ -37,18 +37,21 @@ class PeaksConfig { static sectionsToSegment = ( sections: NormalizedObjects
, - measures: NormalizedObjects + measures: NormalizedObjects, + timePerMeasure: number ) => { let segments: SegmentAddOptions[] = []; sections.allIds.forEach(id => { const section = sections.byId[id]; + const start = measures.byId[section.measures[0]].time; + const end = start + timePerMeasure; + let segment: SegmentAddOptions = { id, labelText: section.type, - startTime: measures.byId[section.measures[0]].time, - endTime: - measures.byId[section.measures[section.measures.length - 1]].time, + startTime: start, + endTime: end, color: PeaksConfig.SECTIONTYPE_TO_COLOR.get(section.type), editable: false }; diff --git a/src/states/analysis/analysisSlice.test.ts b/src/states/analysis/analysisSlice.test.ts index 6681baf..12212f5 100644 --- a/src/states/analysis/analysisSlice.test.ts +++ b/src/states/analysis/analysisSlice.test.ts @@ -161,7 +161,7 @@ it("can remove sections after changing rhythm", () => { expect(state.sections.allIds.length).toBe(2); expect(state.sections.byId["BRIDGE_0_98"]).toBeDefined(); - expect(state.sections.byId["UNDEFINED_98_99"]).toBeDefined(); + expect(state.sections.byId["UNDEFINED_99_99"]).toBeDefined(); state = reducer(state, updatedRhythm({ bpm: 60 })); diff --git a/src/states/analysis/analysisUtil.ts b/src/states/analysis/analysisUtil.ts index 5057a56..de8d664 100644 --- a/src/states/analysis/analysisUtil.ts +++ b/src/states/analysis/analysisUtil.ts @@ -35,7 +35,7 @@ export const undefinedSection = (length: number) => { export const sectionInvalid = (section: Section) => { return ( - parseInt(section.measures[0]) >= + parseInt(section.measures[0]) > parseInt(section.measures[section.measures.length - 1]) ); }; @@ -82,7 +82,7 @@ export const mergeSections: ( //Add a new undefined block before the new section if (newSectionStart > currentSectionStart) { let section: Section = { - measures: ArrayUtil.range(currentSectionStart, newSectionStart), + measures: ArrayUtil.range(currentSectionStart, newSectionStart - 1), type: SectionType.UNDEFINED }; newSections.push(section); @@ -94,7 +94,7 @@ export const mergeSections: ( //Add a new undefined block after the new section if (newSectionEnd < currentSectionEnd) { let section: Section = { - measures: ArrayUtil.range(newSectionEnd, currentSectionEnd), + measures: ArrayUtil.range(newSectionEnd + 1, currentSectionEnd), type: SectionType.UNDEFINED }; newSections.push(section);