]> git.notmuchmail.org Git - scherzo/log
scherzo
10 years agoFix high octave numbers (8+) to not be interpreted as 0. master
Carl Worth [Thu, 3 Oct 2013 17:52:59 +0000 (10:52 -0700)]
Fix high octave numbers (8+) to not be interpreted as 0.

A user recently noticed that the highest key on the piano (A8) was
showing up as A0 in scherzo, (the lowest note on the piano). The bug
was that scherzo was using only 3 bits for the octave number, which
obviously only covers the range [0:7].

ISO octave numbers, (and the octave numbers needed for a piano), are
the range [0:8]. So adding one bit to the octave storage does the
trick here.

10 years agoRespell a note if it triggers a key change.
Carl Worth [Thu, 3 Oct 2013 17:47:11 +0000 (10:47 -0700)]
Respell a note if it triggers a key change.

It looks a bit odd to play a G-major scale, see the G-major key
signature pop up, but see a G-flat on the staff at the end of the
scale instead of the expected F-sharp.

Fix this by respelling the note when the key signature changes.

10 years agoListen for MIDI event through ALSA "virtual" rawmidi interface
Carl Worth [Wed, 2 Oct 2013 18:10:49 +0000 (11:10 -0700)]
Listen for MIDI event through ALSA "virtual" rawmidi interface

This allows for connecting up any MIDI device (hardware or software)
through programs such as aconnect or qjackctl that allow one to
connect MIDI outputs to inputs. This is quite convenient for
connecting a virtual keyboard (such as vkeybd or vmpk) to scherzo.

It can also be used to connect a real, hardware MIDI keyboard to
scherzo, but we keep around the code that does a direct connection to
/dev/midi1 since that simplifies things by reducing one step in the
usage, (the user needn't run aconnect nor qjackctl to make the
connection).

10 years agoPrefer flats rather than sharps when converting from MIDI
Carl Worth [Tue, 1 Oct 2013 19:20:06 +0000 (12:20 -0700)]
Prefer flats rather than sharps when converting from MIDI

It's ambiguous before we look at the key, (which often tells us what
to do). But when the key doesn't indicate, we can really say flat from
above or sharp from below.

The preference for choosing flat here is so that if we input a scale
such as Db major, we get that key signature (with 5 flats) rather than
the rather unlikely key of C# with 7 sharps.

10 years agoFix key signature setting to accept an enharmonic pitch
Carl Worth [Tue, 1 Oct 2013 19:06:31 +0000 (12:06 -0700)]
Fix key signature setting to accept an enharmonic pitch

If the user asks for a key with a specific, real, name such a Cb or B,
then the user will get that key.

But if the user asks for a key that is not a real name, (such as B#),
then the user will get a real key that is enharmonic, (such as C in
this case).

10 years agoFix in-key note spelling for MIDI input
Carl Worth [Tue, 1 Oct 2013 18:18:29 +0000 (11:18 -0700)]
Fix in-key note spelling for MIDI input

I originally wrote and tested the key-guided note spelling code while
at the computer, and not near a MIDI keyboard. So I failed to notice
that I added this code to a code path that only affected computer
keyboard input.

Shift this over to affect all notes pressed.

10 years agoAutomatically change key whenever user plays a major scale.
Carl Worth [Tue, 1 Oct 2013 18:14:41 +0000 (11:14 -0700)]
Automatically change key whenever user plays a major scale.

This is a very convenient way to access this functionality directly
from the piano keyboard, without having to use the computer keyboard
at all.

10 years agoDon't bother displaying names for intervals and octaves.
Carl Worth [Tue, 1 Oct 2013 18:01:46 +0000 (11:01 -0700)]
Don't bother displaying names for intervals and octaves.

This is an attempt to reduce some flashing of the name while playing
chords.

10 years agoAlways redraw notes on note-press or note-release
Carl Worth [Tue, 1 Oct 2013 17:54:25 +0000 (10:54 -0700)]
Always redraw notes on note-press or note-release

I had previously had some strange idea about leaving the chord up on
releases. I can't remember why I had thought that was a good idea, but
I don't like it now.

While in the area, remove some redundant calls to gtk_widget_queue_draw.

10 years agoAdd a little space between key signature and notes.
Carl Worth [Tue, 1 Oct 2013 17:41:32 +0000 (10:41 -0700)]
Add a little space between key signature and notes.

Otherwise, it was hard to tell which accidentals belonged to notes,
and which to accidentals.

10 years agoSpell input notes according to key
Carl Worth [Tue, 1 Oct 2013 17:36:58 +0000 (10:36 -0700)]
Spell input notes according to key

Previously, scherzo always preferred the sharp form of any note
pressed on the keyboard. Now, it uses the key to resolve any ambiguous
spellings of notes pressed.

This also means that chord spellings will now fit the key much more
nicely. (For example, in the key of F major, one will now see a Bb
major triad, rather than the very-odd-looking A# major triad).

10 years agoMove key-signature code to new scherzo-key.c and scherzo-key.h
Carl Worth [Tue, 1 Oct 2013 16:54:44 +0000 (09:54 -0700)]
Move key-signature code to new scherzo-key.c and scherzo-key.h

This will facilitate sharing of this code between score.c and scherzo.c.

10 years agoRespect the key when drawing notes.
Carl Worth [Tue, 1 Oct 2013 16:41:42 +0000 (09:41 -0700)]
Respect the key when drawing notes.

Don't print accidentals when they are already in the key, and add
naturals when needed because of they key.

10 years agoAdd a keybinding for Enter to clear all notes
Carl Worth [Tue, 1 Oct 2013 15:57:15 +0000 (08:57 -0700)]
Add a keybinding for Enter to clear all notes

This shouldn't actually be necessary, but in case there are ever any
stuck notes, this can help to clear them.

10 years agoRework computer keyboard input to be mapped piano keyboard
Carl Worth [Tue, 1 Oct 2013 15:47:34 +0000 (08:47 -0700)]
Rework computer keyboard input to be mapped piano keyboard

Instead of using computer keyboard letter names for piano note names,
(which allowed only entering natural notes), we now map the piano
keyboard onto the computer keyboard. The naturals are on the home row,
(middle C is on 'A' and the next higher C is on 'K'), and the sharps
map onto the top row in the obvious position, (C# on 'W, D# on 'E',
etc.).

10 years agoAdd support for drawing a key signature
Carl Worth [Tue, 1 Oct 2013 15:18:43 +0000 (08:18 -0700)]
Add support for drawing a key signature

This works correctly for treble and bass clefs and up to 7 sharps or 7
flats.

The key does not yet influence the way notes are drawn, (which
accidentals are displayed), nor yet how chord names are determined.

10 years agoFix bugs in mismatched spelling of chord name and notes
Carl Worth [Mon, 30 Sep 2013 05:42:15 +0000 (22:42 -0700)]
Fix bugs in mismatched spelling of chord name and notes

When the notes of a chord were re-spelled to match the degrees of the
matching signature, the root note was not being updated, so the
chord-name symbol still reflected the name of the un-respelled root
note. This was a bug introduced in the recent shakeup to do analysis
more entirely in the scherzo layer without using score_note_t.

Fixing this required a fair amount of refactoring. Hopefully the
result is cleaner and more maintainable.

10 years agoFix to resize staff when ledger lines are no longer needed
Carl Worth [Mon, 30 Sep 2013 00:33:40 +0000 (17:33 -0700)]
Fix to resize staff when ledger lines are no longer needed

This restores the original behavior which was inadvertently lost in
some recet code refactoring.

10 years agoMake score_note_t entirely private to score.c
Carl Worth [Mon, 30 Sep 2013 00:33:28 +0000 (17:33 -0700)]
Make score_note_t entirely private to score.c

And drop the remaining functions that are no longer being used.

(These were easy to find as the only remaining functions in score.h
referencing score_note_t.)

10 years agoMakefile: Add -Wmissing-declarations compiler option
Carl Worth [Mon, 30 Sep 2013 00:30:30 +0000 (17:30 -0700)]
Makefile: Add -Wmissing-declarations compiler option

Some recent code changes should obsolesce some functions, so it will
be nice to have compiler help in finding them.

10 years agoChange the various score add_note functions to not return a score_note_t.
Carl Worth [Mon, 30 Sep 2013 00:25:19 +0000 (17:25 -0700)]
Change the various score add_note functions to not return a score_note_t.

With the callers no longer doing anything with this return value, we
can now drop it entirely.

10 years agoUse a pitch_t rather than a score_note_t for challenge
Carl Worth [Mon, 30 Sep 2013 00:24:19 +0000 (17:24 -0700)]
Use a pitch_t rather than a score_note_t for challenge

This continues the recent trend of removing the use of this
score-specific data structure from the scherzo layer above score.

10 years agoFix scherzo to use pitch_t rather than score_note_t for computation
Carl Worth [Sun, 29 Sep 2013 21:56:47 +0000 (14:56 -0700)]
Fix scherzo to use pitch_t rather than score_note_t for computation

The score_note_t type is constructed as a side effect of performing
drawing. This is a poor fit for scherzo's computation and reasoning
since it often wants to perform analysis on notes that it has never
drawn.

Meanwhile, the new pitch_t is a simple integer, making it very easy
for scherzo to use pitch_t in all of its calculations.

The goal is for no functional changes with this commit, but we know
that some bugs have likely been changed or moved around.

10 years agoEncode octave within pitch_t value
Carl Worth [Sat, 28 Sep 2013 19:18:01 +0000 (12:18 -0700)]
Encode octave within pitch_t value

This simplifies the code quite a bit. Instead of passing around pairs
of (pitch, octave) all over the place a simple pitch_t value suffices.

10 years agoDrop the enumerated pitch values.
Carl Worth [Fri, 27 Sep 2013 23:11:40 +0000 (16:11 -0700)]
Drop the enumerated pitch values.

It's really just as easy to use macros such as PITCH_LITERAL,
PITCH_NAME, or PITCH_ACCIDENTAL in some combination instead of using
an enumerated pitch_t value.

In place of the enum, we now have pitch_t as a uint32_t type.

The real purpose for doing this is to prepare for pitch_t to be able
to hold the octave as well which should be remarkably convenient.

10 years agoPort all code from score_pitch* to pitch*
Carl Worth [Fri, 27 Sep 2013 22:36:28 +0000 (15:36 -0700)]
Port all code from score_pitch* to pitch*

Tracking the new interface in pitch.h, (and deleting the compatibility
defines from score.h).

10 years agoMove large portions of score.h to new pitch.h file.
Carl Worth [Fri, 27 Sep 2013 22:21:52 +0000 (15:21 -0700)]
Move large portions of score.h to new pitch.h file.

This is in preparation for doing more score-independent reasoning
about pitches.

At this point, compatibility defines are left in place so that none of
the code has to change yet.

10 years agoAbbreviate "unknown chord" to a simple question mark
Carl Worth [Fri, 27 Sep 2013 15:28:40 +0000 (08:28 -0700)]
Abbreviate "unknown chord" to a simple question mark

This gets the idea across, and is less distracting when it appears
transiently while pressing or releasing the notes of a chord.

10 years agoUse matched chord signature to guide spelling of note on staff.
Carl Worth [Fri, 27 Sep 2013 15:24:53 +0000 (08:24 -0700)]
Use matched chord signature to guide spelling of note on staff.

We now use the chord's signature to choose the correct spelling of
each enharmonic note. For example, an A mjor triad has a C-sharp in
it, not a D-flat. We can determine this since a major triad should
have a note of the 3 scale degree (as recorded in the chord
signature).

Still to be done is to draw note heads without collision, draw
accidentals without collision, and to improve the heuristic for
deciding between ambiguous chord signatures.

10 years agoFix signature for "sus" chord
Carl Worth [Fri, 27 Sep 2013 15:23:05 +0000 (08:23 -0700)]
Fix signature for "sus" chord

This signature had an ''augmented'' 3rd in it rather than the perfect
4th that was intended. The perfect 4th is the thing that will allow
the chord to be spelled correctly.

10 years agoPut all chord signatures into a single array
Carl Worth [Fri, 27 Sep 2013 05:36:00 +0000 (22:36 -0700)]
Put all chord signatures into a single array

This simplifies the code quite a bit. Instead of a big switch
statement based on number of notes in the chord, with each case a
nearly-identical for loop, we can have one single for loop for all
signatures.

More importantly, this means that after the for loop has matched a
signature, we can have a single variable pointing to the matching
signature. That will be important for using the signature to guide in
spelling the chord correctly, which we hope to do soon.

10 years agoDon't print the inversion names
Carl Worth [Fri, 27 Sep 2013 05:12:14 +0000 (22:12 -0700)]
Don't print the inversion names

These were just too long for a very little bit of information,
(perhaps in the future I'll decide to bring back the inversion
information but with a style such as C/G for a C major triad in 2nd
inversion).

10 years agoUse abbreviated names for intervals
Carl Worth [Fri, 27 Sep 2013 04:50:53 +0000 (21:50 -0700)]
Use abbreviated names for intervals

10 years agoDon't print root pitch for octaves and intervals
Carl Worth [Fri, 27 Sep 2013 04:48:47 +0000 (21:48 -0700)]
Don't print root pitch for octaves and intervals

The bare pitch name looked too much like a major triad.

10 years agoAdd voicings of m6/9 and m6/♭9 with no 5th.
Carl Worth [Fri, 27 Sep 2013 04:43:35 +0000 (21:43 -0700)]
Add voicings of m6/9 and m6/♭9 with no 5th.

This clears up a FIXME comment suggesting that we were missing some
chords with perfect 5ths. The comment was somewhat incorrect. One
chord was present all along. One should have been present, but was
incorrect (until the last commit). The third was legitimately missing
(until the last commit).

Now that we have all of these in place with perfect 5ths, we can also
add the versions voiced with no 5th at all and delete the comment.

10 years agoFix bug preventing recognition of m6/9 and add m6/♭9
Carl Worth [Fri, 27 Sep 2013 04:41:52 +0000 (21:41 -0700)]
Fix bug preventing recognition of m6/9 and add m6/♭9

The line that was supposed to detect m6/9 had an incorrect signature
identical to the signature of 6/9 (causing m6/9 to never be
recognized).

While we're at it, add m6/♭9 as well.

10 years agoAdd voicings for 7th chords without 3rd and without 5th
Carl Worth [Fri, 27 Sep 2013 04:32:30 +0000 (21:32 -0700)]
Add voicings for 7th chords without 3rd and without 5th

This does introduce a few more ambiguities. I need to write a mode
soon to search out and print all the ambiguous chords.

10 years agoComment a couple of ambiguous chords
Carl Worth [Thu, 26 Sep 2013 21:56:18 +0000 (14:56 -0700)]
Comment a couple of ambiguous chords

I noticed these while going through Bach's Prelude #1, comparing what
scherzo gave with what Andrea Pauly gave for each chord.

The right thing to do is probably to make scherzo display all chord
names (and spellings) when more than one chord naming can be matched
against a set of notes.

10 years agoDrop 'm' before half-diminished or diminished symbol
Carl Worth [Thu, 26 Sep 2013 15:30:55 +0000 (08:30 -0700)]
Drop 'm' before half-diminished or diminished symbol

The chord no longer has minor quality once it's half-diminished or
diminished.  Putting the 'm' in there was just confusing.

10 years agoAdd +M7sus and +7sus chords
Carl Worth [Thu, 26 Sep 2013 15:02:52 +0000 (08:02 -0700)]
Add +M7sus and +7sus chords

I'm not sure why I didn't have these here before, when I had +M9sus
and +9sus.

10 years agoReduce overuse of superscripting in chord names.
Carl Worth [Thu, 26 Sep 2013 15:00:27 +0000 (08:00 -0700)]
Reduce overuse of superscripting in chord names.

In particular, the presence of "sus" now no longer triggers
superscripting in the rest of the chord name, (since I've moved "sus"
to the end of the chord name instead).

10 years agoAdd some 7th chords with an added, altered 9th interval
Carl Worth [Thu, 26 Sep 2013 14:54:44 +0000 (07:54 -0700)]
Add some 7th chords with an added, altered 9th interval

These are named 7#9, 7b9, 7b5#9, and 7b5b9.

10 years agoRecognize the 6/9 chord and the m6/9 chord
Carl Worth [Thu, 26 Sep 2013 14:47:36 +0000 (07:47 -0700)]
Recognize the 6/9 chord and the m6/9 chord

Starting to add chords mentioned in the first couple of pages of Jazz
Chord Progression by Bill Boyd.

10 years agoAdd 11th chords
Carl Worth [Thu, 26 Sep 2013 14:43:19 +0000 (07:43 -0700)]
Add 11th chords

Working from:

http://en.wikipedia.org/wiki/Chord_notation#11ths

I still have some confusion about half-diminished and diminished
chords larger than 7th chords. The 9th and 11th versions of these as
currently programmed seem inconsistent. So I need to double-check
against some additional sources rather than just relying on wikipedia.

10 years agoAdd some flat-5 variants of 9th chords
Carl Worth [Thu, 26 Sep 2013 03:17:00 +0000 (20:17 -0700)]
Add some flat-5 variants of 9th chords

I also noticed these when reading the following about 11th chords:

Omission of the 5th in a sharpened 11th chord reduces its
sound to a flat-five chord.

[http://en.wikipedia.org/wiki/Chord_notation#11ths]

10 years agoAdd sus (sus4) versions of the ninth chords.
Carl Worth [Thu, 26 Sep 2013 03:01:20 +0000 (20:01 -0700)]
Add sus (sus4) versions of the ninth chords.

As I was reading about 11th chords here:

http://en.wikipedia.org/wiki/Chord_notation#11ths

I noticed that an 11th chord voiced without a 3rd becomes a 9sus4
chord. So let's recognize those.

10 years agoSpecify sus4 chords with a Perfect 4th rather than a raised 3rd.
Carl Worth [Thu, 26 Sep 2013 02:55:55 +0000 (19:55 -0700)]
Specify sus4 chords with a Perfect 4th rather than a raised 3rd.

This is much more clear, (and will help when I actually write the code
to spell these correctly on the staff itself).

10 years agoAdd ninth chords.
Carl Worth [Thu, 26 Sep 2013 02:49:35 +0000 (19:49 -0700)]
Add ninth chords.

I worked from the list in this table:

http://en.wikipedia.org/wiki/Chord_notation#9ths

and included some generalizations, (including the voicings without the
5th as mentioned on the page above).

I did not yet add any "sus" variations. I'm not sure how useful those
are.

10 years agoAdd recognition of sus2 and sus (sus4) chords.
Carl Worth [Thu, 26 Sep 2013 01:03:19 +0000 (18:03 -0700)]
Add recognition of sus2 and sus (sus4) chords.

I'm not sure that all of this is exactly correct, but I'm trying to
implement the rules described here:

http://en.wikipedia.org/wiki/Chord_notation#Suspended_chords

10 years agoAdd recognition of 6, m6, and 7-flat-5 chords.
Carl Worth [Thu, 26 Sep 2013 00:23:17 +0000 (17:23 -0700)]
Add recognition of 6, m6, and 7-flat-5 chords.

One trick here is the ambiguity that, for example, C6 looks the same
as Am7 in first inversion and Cm7 looks the same as D#6 in 3rd
inversion. We rework the recognition code a bit so that chords with a
smaller inversion number will be preferred over chords with a larger
inversion number. That way, with the above examples, scherzo will
report C6 and Cm7 rather than "Am7 1st inversion" and "D#6 3rd
inversion".

10 years agoDrop the "M" from the name for a major triad.
Carl Worth [Wed, 25 Sep 2013 22:13:49 +0000 (15:13 -0700)]
Drop the "M" from the name for a major triad.

It's simpler (and well-understood) that a "C" chord is a "C major
triad". We don't need to call it "CM".

10 years agoTake advantage of pango markup to draw superscripted chord names.
Carl Worth [Wed, 25 Sep 2013 22:07:22 +0000 (15:07 -0700)]
Take advantage of pango markup to draw superscripted chord names.

Now instead of things like "C Major triad" we have shorter names like
"CM". Instead of "Augmented" we have a superscripted degree symbol,
etc.

10 years agoSwitch to using pango, not cairo_show_text for chord names
Carl Worth [Wed, 25 Sep 2013 22:06:36 +0000 (15:06 -0700)]
Switch to using pango, not cairo_show_text for chord names

The motivation here is to enable sub-scripting of chord symbols.

10 years agoDetect the root pitch of chord and display it
Carl Worth [Tue, 24 Sep 2013 04:31:24 +0000 (21:31 -0700)]
Detect the root pitch of chord and display it

One ugly thing here is that any accidental in the chord name is in a
different font than the accidental on the stave.

10 years agoAdd a few initializations to quiet compiler warnings.
Carl Worth [Mon, 23 Sep 2013 04:10:58 +0000 (21:10 -0700)]
Add a few initializations to quiet compiler warnings.

My manual analysis says that none of these are strictly necessary,
(the various conditionals currently ensure that none of the variables
are ever used uninitialized). But "gcc -O2" likes to complain, so
these initializations keep it quiet.

10 years agoDefault to compiling with debugging symbols.
Carl Worth [Mon, 23 Sep 2013 04:07:21 +0000 (21:07 -0700)]
Default to compiling with debugging symbols.

Which is obviously much more convenient for debugging.

The user can still override this with something like:

make CFLAGS=-O2

10 years agoAdd support for recognizing inverted chords.
Carl Worth [Mon, 23 Sep 2013 04:06:29 +0000 (21:06 -0700)]
Add support for recognizing inverted chords.

This isn't using any fancy figured-bass-derived names for these
yet. For now, it's just spelling things out as "1st inversion", "2nd
inversion", etc.

10 years agoSwitch to a degree-specific scheme for specifying chord signatures
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:

{{1, 0}, {4, +1}} /* Augmented 4th */
{{1, 0}, {5, -1}} /* Diminished 5th */

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.

10 years agoAllow computer-keyboard input of accidentals, and draw accidentals.
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.

10 years agoAdd a new SCORE_PITCH macro and rename SCORE_PITCH_VALUE to SCORE_PITCH_LITERAL
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).

10 years agoDon't bother looking at signatures that we know can't match
Carl Worth [Thu, 19 Sep 2013 14:40:58 +0000 (07:40 -0700)]
Don't bother looking at signatures that we know can't match

Only look at signatures which have a length the same as the number of
notes in the current chord being analyzed.

10 years agoRe-order the signatures array for the seventh chords
Carl Worth [Wed, 18 Sep 2013 18:22:51 +0000 (11:22 -0700)]
Re-order the signatures array for the seventh chords

It seems easier for me to think about these ordered from widest triad
to narrowest, and the from widest seventh to narrowest.

10 years agoSimplify chord-signature matching by dropping duplicates first
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.

10 years agoAvoid duplicating notes within note_group_t and score_staff_t
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.

10 years agoFix bugs in analysis for out-of-order chords
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).

10 years agoAdd analysis support for octaves
Carl Worth [Wed, 18 Sep 2013 03:36:43 +0000 (20:36 -0700)]
Add analysis support for octaves

It just looked stupid for scherzo to call a perfect octave, "unknown
or not a chord".

10 years agoFix chord analysis for intervals larger than an octave
Carl Worth [Wed, 18 Sep 2013 03:21:00 +0000 (20:21 -0700)]
Fix chord analysis for intervals larger than an octave

By simply repeatedly subtracting 12 from any larger-than-octave intervals.

10 years agoAdd support for pedal
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.

10 years agoAllow keys 0-8 to specify desired octave.
Carl Worth [Tue, 17 Sep 2013 23:40:06 +0000 (16:40 -0700)]
Allow keys 0-8 to specify desired octave.

This allows specifying notes across a wider range than a single octave
with the computer keyboard.

10 years agoDon't put up "unknown chord" for a single note
Carl Worth [Tue, 17 Sep 2013 23:29:50 +0000 (16:29 -0700)]
Don't put up "unknown chord" for a single note

It's obviously just a single note, and not anything else, so don't say
anything.

10 years agoAdd recognition of intervals.
Carl Worth [Tue, 17 Sep 2013 23:02:21 +0000 (16:02 -0700)]
Add recognition of intervals.

This is quite easy with the same machinery as the chord recognition.

10 years agoAdd recognition of 7th chords
Carl Worth [Tue, 17 Sep 2013 21:34:55 +0000 (14:34 -0700)]
Add recognition of 7th chords

There's still no recognition of chords in anything but root position,
(and the accidentals are still not yet drawn on the staff).

10 years agoAdd preliminary chord analysis
Carl Worth [Tue, 17 Sep 2013 21:17:37 +0000 (14:17 -0700)]
Add preliminary chord analysis

With this commit, challenges are disabled (for the moment), and
scherzo will analyze the notes pressed as a chord.

Currently, only the four basic types of triads (augemented, major,
minor, and dminished) are recognized, and these only in root position.

10 years agoFix the broken SCORE_PITCH_NAME macro to work correctly
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.

10 years agoRename mnemon data file from "scherzo" to "scherzo-notes"
Carl Worth [Tue, 17 Sep 2013 19:23:56 +0000 (12:23 -0700)]
Rename mnemon data file from "scherzo" to "scherzo-notes"

This is in preparation for having "scherzo-chords" and others.

12 years agoUpdate sub-module path for menmon with a relative path.
Carl Worth [Tue, 10 Apr 2012 22:45:20 +0000 (15:45 -0700)]
Update sub-module path for menmon with a relative path.

This is an attempt to give people cloning scherzo a chance for it to
actually work.

12 years agoAdd ability to perform input with computer (not midi) keyboard.
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.

12 years agoAdd some color coding of input notes.
Carl Worth [Wed, 28 Sep 2011 00:12:39 +0000 (17:12 -0700)]
Add some color coding of input notes.

Red for an incorrect note, and green for correct. (The challenge notes
remain black.)

12 years agoShrink staves once ledger lines are no longer needed.
Carl Worth [Tue, 27 Sep 2011 04:58:45 +0000 (21:58 -0700)]
Shrink staves once ledger lines are no longer needed.

This is not extremely aggressive. It will only shrink once a staff has
no notes left.

12 years agoAdd correct sizing/spacing of staves and braces for ledger lines.
Carl Worth [Tue, 27 Sep 2011 04:45:43 +0000 (21:45 -0700)]
Add correct sizing/spacing of staves and braces for ledger lines.

At this point, we're ready to run quizzes for any white key on the
piano.

12 years agoDraw ledger lines.
Carl Worth [Tue, 27 Sep 2011 03:57:42 +0000 (20:57 -0700)]
Draw ledger lines.

It's almost getting to be a usable program now.

12 years agoDon't queue up as many widget redraws.
Carl Worth [Mon, 26 Sep 2011 17:36:09 +0000 (10:36 -0700)]
Don't queue up as many widget redraws.

For multiple MIDI messages in a single buffer, only queue a single redraw.

GTK+ should be coalescing these anyway, but we might as well not make
it work any harder than it has too.

12 years agoFix another bug with stuck notes.
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.

Fix this silly bug.

12 years agoFix bug with stuck notes when challenge would switch staves.
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).

12 years agoIntegrate some simple mnemon quizzing into scherzo.
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).

12 years agoAdd mnemon code as a git submodule
Carl Worth [Mon, 26 Sep 2011 00:54:06 +0000 (17:54 -0700)]
Add mnemon code as a git submodule

The scherzo code will be taking advantage of the mnemon code as if
it were a library of sorts.

12 years agoOpen MIDI device and display notes being played in real time.
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.

12 years agoIgnore the .deps directory.
Carl Worth [Fri, 23 Sep 2011 14:17:24 +0000 (07:17 -0700)]
Ignore the .deps directory.

This contains generated files only, nothing we want under revision control.

12 years agoStart drawing some very rudimentary notes.
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.

12 years agoMakefile: Fix automatic generation of dependencies.
Carl Worth [Fri, 23 Sep 2011 06:04:07 +0000 (23:04 -0700)]
Makefile: Fix automatic generation of dependencies.

Without this, updates to the header file were not triggering rebuilds
of the source. Things are much more convenient with this.

12 years agoRestructure code to manually add staves, braces, and notes.
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.

12 years agoIncrease the default staff height just a bit.
Carl Worth [Sat, 17 Sep 2011 23:06:34 +0000 (16:06 -0700)]
Increase the default staff height just a bit.

At a height of 48, it's more comfortable to view, (while still having
a line_width of 1.0 for the staff lines).

12 years agoMake the brace and clef symbols scale with the staff.
Carl Worth [Sat, 17 Sep 2011 18:48:25 +0000 (11:48 -0700)]
Make the brace and clef symbols scale with the staff.

All looks much better now, (even if the size calculations are simply
empirically-derived linear fits to what looks good to me).

12 years agoAdd some scaling controls with plus/minus keybindings.
Carl Worth [Sat, 17 Sep 2011 16:17:42 +0000 (09:17 -0700)]
Add some scaling controls with plus/minus keybindings.

Total cheese in that the symbols (braces and clefs) don't change size yet,
but at least the line widths snap to nice integers.

12 years agoAdd some (particularly cheesy) drawing of a brace and clefs on the grand staff.
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).

12 years agoDraw a second staff (and vertical lines at the beginning and end of staff).
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).

12 years agoStart drawing something
Carl Worth [Sat, 17 Sep 2011 03:41:17 +0000 (20:41 -0700)]
Start drawing something

So far, just a few simple staff lines.

12 years agoAdd a .gitignore file.
Carl Worth [Sat, 17 Sep 2011 03:40:53 +0000 (20:40 -0700)]
Add a .gitignore file.

12 years agoInitial commit of scherzo.
Carl Worth [Sat, 17 Sep 2011 03:08:49 +0000 (20:08 -0700)]
Initial commit of scherzo.

Nothing more than a simple GTK+ window so far.