Carl Worth [Sun, 22 Sep 2013 22:57:14 +0000 (15:57 -0700)]
Switch to a degree-specific scheme for specifying chord signatures
The old scheme specified each chord signature by the number of half
steps between the root note and each note of the chord. This made it
impossible to distinguish between alternate names of enharmonic chords
(such as an augmented 4th and a diminished 5th which both have 6 half
steps).
The new specification indicates which degree should appear in the
chord, and which modification each degree has, (from -2 to +2 half
steps).
So, under the old scheme an augmented 5th/diminished 4th would appear as:
{0, 6} /* Half steps from root to each note */
And in the new scheme these can be identified separately as:
We don't yet have much of a user-visibile change with this commit,
(other than that the above interval will now only be identified as a
"Diminished 5th" rathern than the "Augmented 4th/Diminished 5th" we
had before).
But this gives us the necessary information we will need in order to
correctly spell chords on a staff after the chord has been identified.
Carl Worth [Sun, 22 Sep 2013 22:15:03 +0000 (15:15 -0700)]
Allow computer-keyboard input of accidentals, and draw accidentals.
All accidentals are drawn assuming the key of C major, for now. That is,
natural symbols will not be drawn, but all other accidental symbols will
be drawn.
No care is taken to avoid accidentals colliding with each other when drawn.
Carl Worth [Sun, 22 Sep 2013 21:29:41 +0000 (14:29 -0700)]
Add a new SCORE_PITCH macro and rename SCORE_PITCH_VALUE to SCORE_PITCH_LITERAL
The original SCORE_PITCH_VALUE macro was of limited use. It could only
be used with literal values such as "G" and "FLAT" and could not be
used to construct a score_pitch_t value from two variables. This was
particularly useless since a user could just use a literal value of
SCORE_PITCH_Gf instead of SCORE_PITCH_VALUE(G, FLAT).
So we rename SCORE_PITCH_VALUE to SCORE_PITCH_LITERAL to make its
limitations more clear in its name. (The one important use remaining
for the macro is in the initial construction of the score_pitch_t
values for the enum declaration).
And here we add the SCORE_PITCH macro which *can* be used to construct
a score_pitch_t value from two variables, (one holding the pitch name,
and one holding the accidental).
Carl Worth [Wed, 18 Sep 2013 18:21:34 +0000 (11:21 -0700)]
Simplify chord-signature matching by dropping duplicates first
Previously, all the duplicate notes were still present in the chord
while trying to determine if the duplicate matched. Now, we cull out
the duplicates before looking for a match, which makes the matching
code much simpler.
Carl Worth [Wed, 18 Sep 2013 18:00:02 +0000 (11:00 -0700)]
Avoid duplicating notes within note_group_t and score_staff_t
Previously, it was possible to have notes "stick" on the staff and not
clear off after releasing the note or pedal in some circumstances. We
fix a number of these bugs by checking to see if a note is already
present in a list before adding a duplicate copy of it.
Carl Worth [Wed, 18 Sep 2013 03:41:32 +0000 (20:41 -0700)]
Fix bugs in analysis for out-of-order chords
When the various notes of a chord were in different octaves, scherzo
was sometimes getting confused and was unable to match the chord to
its known signatures. We fix this by adding a secondary sort, (first
sort by absolute pitch to find bass note so to compute relative pitch,
and then second sort by relative pitch).
Carl Worth [Wed, 18 Sep 2013 03:04:06 +0000 (20:04 -0700)]
Add support for pedal
As scherzo listens to the pedal, it will analyze the chord harmony based on
notes that continue to sustain due to the pedal.
I'm not 100% comfortable with the empirically-derived value of 64 for
the sustain pedal. I'd feel a bit better if I had found a symbolic
constant for this in the ALSA header files. As things stand now, I'm
not sure if the sustain pedal on another keyboard will return the same
value.
Carl Worth [Tue, 17 Sep 2013 20:31:04 +0000 (13:31 -0700)]
Fix the broken SCORE_PITCH_NAME macro to work correctly
For no good reason, the score_pitch_name_t enum had previously been
defined with pre-shifted values. That could have worked, but the
SCORE_PITCH_NAME macro was shiftin the masked value down as if the
enum values were not pre-shifted. So SCORE_PITCH_NAME was yielding
unexpected values, (that did not correspond to score_pitch_name_t
enum values).
We fix this by making the enum sane, (with unshifted values), leaving
the shifting in place in SCORE_PIATCH_NAME and tracking the new style
of the enum by adding shifting to the SCORE_PITCH_VALUE macro.
That is, the macro that is changed by this commit reamins working, and
the macro that is left unchaged by this commit is now fixed.
Carl Worth [Wed, 28 Sep 2011 00:34:55 +0000 (17:34 -0700)]
Add ability to perform input with computer (not midi) keyboard.
This is useful for testing when away from a keyboard, and also useful
in its own right for ensuring that the user knows the names of the
notes (not just their position on the piano keyboard).
When using a computer keyboard for input only the note name itself is
needed---the correct octave is chosen automatically.
Carl Worth [Mon, 26 Sep 2011 17:34:52 +0000 (10:34 -0700)]
Fix another bug with stuck notes.
When multiple MIDI messages were received in a single buffer, the code
was neglecting to advance the string pointer it was using to
parse. This was causing it to parse the first message several times
and ignore all following messages.
Carl Worth [Mon, 26 Sep 2011 16:42:20 +0000 (09:42 -0700)]
Fix bug with stuck notes when challenge would switch staves.
In this case we were failing to remove a note beacuse we were looking
at the new staff (where the new challenge is) rather than the old staff
where the note was originally created.
Fix this by having each note remember the staff it's created on. This
also impacts the API a bit (no longer need a staff argument to
remove_note, so drop the "_staff" portion of the name from both
add_note and remove_note).
Carl Worth [Mon, 26 Sep 2011 06:34:46 +0000 (23:34 -0700)]
Integrate some simple mnemon quizzing into scherzo.
This will be a lot more interesting once we start drawing ledger lines
and accidentals. But it's already useful for white-key practice for
the notes directly on the staff. Could definitely use better feedback
such as different colors (or even just different horizontal spacing
for challenge vs. response notes).
Carl Worth [Sat, 24 Sep 2011 21:39:56 +0000 (14:39 -0700)]
Open MIDI device and display notes being played in real time.
Every time a key on the MIDI input device is pressed, a whole note appears
on the appropriate staff. When the key is released, the note disappears.
No ledger lines are drawn yet, and there appears to be a bug where notes
get stuck on (refusing to disappear after a key is released) triggered
most easily by pressing *many* keys simultaneously several times.
Carl Worth [Fri, 23 Sep 2011 06:04:53 +0000 (23:04 -0700)]
Start drawing some very rudimentary notes.
I'm picking the correct (but hard-coded by glyph index) noteheads
out of the Gonville font. But I'm not drawing any stems nor flags
yet. Also the spacing between the notes isn't interesting yet, nor
do I have measure lines, nor ledger lines.
Oh, and the notes I added here for testing aren't even musically
interesting either. Anyway, we're still getting started obviously.
Carl Worth [Fri, 23 Sep 2011 00:22:22 +0000 (17:22 -0700)]
Restructure code to manually add staves, braces, and notes.
Previously, the program was hard-coded to draw a grand staff, (two staves
connected by a brace). Now, at the level of the score library, each staff
and any braces are added manually and any set of staves and braces can be
drawn, (the only the two-staves-connected-by-one-brace has been tested).
There's also functionality for ading notes, though no notes are drawn yet.
Carl Worth [Sat, 17 Sep 2011 15:55:09 +0000 (08:55 -0700)]
Add some (particularly cheesy) drawing of a brace and clefs on the grand staff.
This assumes the presence of the Gonville-26 and Gonville-Brace fonts, (by
Simon Tatham). Though it would be simple enough to change the code to use
any Lilypond-compatible font, (if the glyph selection were also update or
just fixed to lookup glyphs by name instead of hard-coding the index).
Carl Worth [Sat, 17 Sep 2011 06:55:51 +0000 (23:55 -0700)]
Draw a second staff (and vertical lines at the beginning and end of staff).
This is almost the grand staff necessary for a piano score, (missing
the brace). The _draw_grand_staff function is a bit too specialized. A
more general approach will involve the ability to add an arbitrary
number of staffs (staves?) to the score, and selectively tie some
together (with or without a brace).