Skip to content

Commit

Permalink
Merge pull request #181 from jacobtylerwalls/sharps-setter
Browse files Browse the repository at this point in the history
Fix clearing of alteredPitches when setting sharps
  • Loading branch information
jacobtylerwalls authored Apr 29, 2022
2 parents b46230e + 20e5926 commit e2e781d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class KeySignature extends base.Music21Object {
}

set sharps(s: number) {
this._alteredPitchesCache = [];
this._alteredPitchesCache = undefined;
this._sharps = s;
}

Expand Down
6 changes: 6 additions & 0 deletions tests/moduleTests/key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,10 @@ export default function tests() {

assert.equal(k.width, 42, 'checking width');
});

test('music21.key.KeySignature setting sharps updates alteredPitches', assert => {
const ks = new music21.key.KeySignature();
ks.sharps = -4;
assert.equal(`${ks.alteredPitches.map(p => p.name)}`, 'B-,E-,A-,D-');
});
}

0 comments on commit e2e781d

Please sign in to comment.