Repository navigation
Find the next pitch of a cyclical scale where it is #2057
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
db35898
4de40a0
06aa2fe
d8600f4
aac3a91
6623cd7
7085364
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -320,6 +320,52 @@ def testDeriveHarmonicMinor(self): | |
| sc = scale.HarmonicMinorScale() | ||
| self.assertEqual(sc.derive(['C', 'D', 'E-', 'B']).name, 'C harmonic minor') | ||
|
|
||
| def testNextPitchOnCycle(self): | ||
| ''' | ||
| AI-assisted (Claude). | ||
| ''' | ||
| thirds = scale.CyclicalScale('d3', ['M3']) | ||
| self.assertEqual(str(thirds.nextPitch('c4')), 'D4') | ||
| self.assertEqual(str(thirds.nextPitch('g4')), 'A#4') | ||
| self.assertEqual(str(thirds.nextPitch('g4', Direction.DESCENDING)), 'F#4') | ||
| self.assertEqual(str(thirds.nextPitch('f#4')), 'A#4') | ||
|
|
||
| fifths = scale.CyclicalScale('c4', ['P5']) | ||
| self.assertEqual(str(fifths.nextPitch('g4')), 'D5') | ||
| self.assertEqual(str(fifths.nextPitch('g4', Direction.DESCENDING)), 'C4') | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for doing this test too -- important to see non-octave repeated here. Can we also add a test on multiple intervals that don't add up to an octave, like And also nextPitch tests on enharmonics (both higher DNN and lower DNN) still go to the correct pitches. thirds nextPitch on C##4 goes to F#4 not D4, etc. Thanks! |
||
|
|
||
| thirdsAndMinorThirds = scale.CyclicalScale('d3', ['M3', 'm3']) | ||
| self.assertEqual(str(thirdsAndMinorThirds.nextPitch('d4')), 'E4') | ||
| self.assertEqual(str(thirdsAndMinorThirds.nextPitch('d4', Direction.DESCENDING)), 'C#4') | ||
| self.assertEqual(str(thirdsAndMinorThirds.nextPitch('a4')), 'B4') | ||
| self.assertEqual(str(thirdsAndMinorThirds.nextPitch('a4', Direction.DESCENDING)), 'G#4') | ||
|
|
||
| def testNextPitchFromEnharmonic(self): | ||
| thirds = scale.CyclicalScale('d3', ['M3']) | ||
| for enharmonicOfD in ('c##4', 'e--4'): | ||
| self.assertEqual(str(thirds.nextPitch(enharmonicOfD)), 'F#4') | ||
| self.assertEqual(str(thirds.nextPitch(enharmonicOfD, Direction.DESCENDING)), 'B-3') | ||
|
|
||
| sc = scale.MajorScale('c4') | ||
| self.assertEqual(str(sc.nextPitch('b#3')), 'D4') | ||
| self.assertEqual(str(sc.nextPitch('d-4', Direction.DESCENDING)), 'C4') | ||
|
|
||
| def testNextPitchNodeNearOrigin(self): | ||
| thirds = scale.CyclicalScale('d3', ['M3']) | ||
| self.assertEqual(str(thirds.nextPitch('d4', stepSize=2)), 'A#4') | ||
|
|
||
| fifths = scale.CyclicalScale('c4', ['P5']) | ||
| self.assertEqual(str(fifths.nextPitch('f4', Direction.DESCENDING)), 'C4') | ||
|
|
||
| aMinor = scale.HarmonicMinorScale('a4') | ||
| self.assertEqual(str(aMinor.nextPitch('f##4')), 'G#4') | ||
| self.assertEqual(str(aMinor.nextPitch('a4', Direction.DESCENDING)), 'G#4') | ||
| self.assertEqual(str(aMinor.nextPitch('g4')), 'G#4') | ||
| self.assertEqual(str(aMinor.nextPitch('g4', Direction.DESCENDING)), 'F4') | ||
|
|
||
| gMinor = scale.HarmonicMinorScale('g4') | ||
| gMinor.nextPitch('a4') | ||
| self.assertEqual(str(gMinor.pitches[6]), 'F#5') | ||
| def testHarmonicMinorKeepsItsSeventhAfterNextPitch(self): | ||
| sc = scale.HarmonicMinorScale('g4') | ||
| sc.nextPitch('a4') | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future, it would be a big help to my review if you put GH comments like "moved into the
else:below" so I'm not wondering why all this is gone. Thanks!