Excellent question. This is a core problem in procedural music generation and algorithmic composition. The choice of method depends entirely on the desired musical outcome.
Let's break down the methods and their musical implications.
Let's define our terms:
- Source Rhythm: A list of start times (e.g.,
[0, 0.5, 0.75]). This is the rhythm you want to apply.
- Target Notes: A list of notes (with pitches and start times) that define the harmony (e.g.,
[C4 at 0.0, G4 at 0.5]). This is the harmony you want to impose the rhythm onto.
The goal is to create a new list of notes that has the start times from the Source Rhythm and the pitches from the Target Notes. The question is: for each start time in the source rhythm, which pitch do we pick from the target?
Here’s a detailed comparison of the three methods.
Method 1: Lesser Than (or "Previous Note" / "Floor")
This is the most musically conventional and generally the best method for applying rhythm to chord progressions.
- Logic: For each timing in the
source_rhythm, find the note in the target_notes that has the latest start time that is less than or equal to the source timing.
- Musical Analogy: This perfectly models how harmony works in a lead sheet. A chord (e.g., C major) is considered active from the moment it appears until the very moment the next chord (e.g., G major) begins. Any rhythmic note played during that time will use the C major harmony.
Example:
- Source Rhythm:
[0, 0.25, 0.6, 0.8]
- Target Notes:
[C4 at 0.0, G4 at 0.5] (A C chord for the first half, G chord for the second half)
Let's map it:
- Rhythmic hit at
0: The latest note at or before 0 is C4 at 0.0. -> Play C4.
- Rhythmic hit at
0.25: The latest note at or before 0.25 is C4 at 0.0. -> Play C4.
- Rhythmic hit at
0.6: The latest note at or before 0.6 is G4 at 0.5. -> Play G4.
- Rhythmic hit at
0.8: The latest note at or before 0.8 is G4 at 0.5. -> Play G4.
Resulting Notes: [C4 at 0, C4 at 0.25, G4 at 0.6, G4 at 0.8]
Pros:
- Musically Intuitive: This is how musicians naturally interpret chord changes.
- Predictable and Stable: It avoids unexpected harmonic changes and always respects the harmonic structure.
- Handles Sparse Harmony: Works perfectly for your main use case of 1-2 chords per bar. If there's only one chord at time
0, all rhythmic hits will correctly use that chord's pitch.
Cons:
- No Anticipation: It cannot create "anticipations," where a note of the next chord is played slightly before the chord change. This is a common musical device, but this method won't produce it.
Verdict: Highly Recommended. This should be your default choice.
Method 2: Closest
This is a good general-purpose method that often gives similar results to "Lesser Than," but with some key differences.
- Logic: For each timing in the
source_rhythm, find the note in the target_notes whose start time has the smallest absolute difference.
- Tie-Breaking: You need a rule for when a rhythm hit is exactly halfway between two target notes (e.g., rhythm at
0.25, target notes at 0 and 0.5). Do you pick the earlier or later one? Picking the earlier one makes it behave more like the "Lesser Than" method.
Example (using the same data):
- Source Rhythm:
[0, 0.25, 0.6, 0.8]
- Target Notes:
[C4 at 0.0, G4 at 0.5]
Let's map it:
- Rhythmic hit at
0: Closest is C4 at 0.0. -> Play C4.
- Rhythmic hit at
0.25: Is it closer to 0.0 (diff 0.25) or 0.5 (diff 0.25)? It's a tie. Let's use the tie-breaking rule "pick earlier". -> Play C4.
- Rhythmic hit at
0.6: Is it closer to 0.0 (diff 0.6) or 0.5 (diff 0.1)? Closer to 0.5. -> Play G4.
- Rhythmic hit at
0.8: Is it closer to 0.0 (diff 0.8) or 0.5 (diff 0.3)? Closer to 0.5. -> Play G4.
Resulting Notes: [C4 at 0, C4 at 0.25, G4 at 0.6, G4 at 0.8] (Same as "Lesser Than" in this case).
Now, let's see where it differs. Change the rhythm slightly:
- Source Rhythm:
[0, 0.4, 0.6, 0.8]
- Rhythmic hit at
0.4: Is it closer to 0.0 (diff 0.4) or 0.5 (diff 0.1)? Closer to 0.5. -> Play G4.
- This creates an anticipation! The G4 is played before the G chord officially starts at
0.5.
Pros:
- Flexible: Can create both standard phrasing and harmonic anticipations, making it sound a bit more "human" or "jazzy."
- Robust: It's a good general-purpose geometric approach that always finds a match.
Cons:
- Less Predictable: The anticipations it creates might not always be musically desirable. It can make the harmony sound "messy" if not used carefully.
- Requires a Tie-Breaking Rule: Adds a small amount of implementation complexity.
Verdict: A strong alternative. Good if you want the possibility of creating harmonic anticipations.
Method 3: Greater Than (or "Next Note" / "Ceiling")
This method is the least common and has very specific, often strange, musical results.
- Logic: For each timing in the
source_rhythm, find the note in the target_notes that has the earliest start time that is greater than or equal to the source timing.
- Musical Analogy: This is like every rhythmic note is looking ahead to the next harmonic event. It creates a feeling of constant, and often jarring, anticipation.
Example (using the same data):
- Source Rhythm:
[0, 0.25, 0.6, 0.8]
- Target Notes:
[C4 at 0.0, G4 at 0.5]
Let's map it:
- Rhythmic hit at
0: The earliest note at or after 0 is C4 at 0.0. -> Play C4.
- Rhythmic hit at
0.25: The earliest note at or after 0.25 is G4 at 0.5. -> Play G4. (Very early anticipation!)
- Rhythmic hit at
0.6: The earliest note at or after 0.6 is... uh oh. There isn't one.
- Edge Case: What do you do for notes that occur after the last harmonic event? You could loop back to the first chord, or just use the last available chord. Let's assume we use the last available one.
- Rhythmic hit at
0.6: Use last available. -> Play G4.
- Rhythmic hit at
0.8: Use last available. -> Play G4.
Resulting Notes: [C4 at 0, G4 at 0.25, G4 at 0.6, G4 at 0.8]
Pros:
- Creates Unique Effects: Can be used for specific, highly syncopated and anticipatory musical styles.
Cons:
- Musically Unintuitive: The results often sound "wrong" or "early" in a conventional harmonic context.
- Problematic Edge Cases: You must decide what to do for rhythmic hits that fall after the last target note in the bar.
Verdict: Not recommended for general-purpose use. Use only if you are trying to achieve a specific, strange, and highly anticipatory effect.
Summary and Recommendation
| Method | Best For | Musical Feel |
|---|
| Lesser Than (Floor) | Applying rhythm to chord progressions (your use case). | Conventional, stable, harmonically correct. |
| Closest | General-purpose mapping, creating subtle humanization. | Stable, but with potential for tasteful anticipations. |
| Greater Than (Ceiling) | Special effects and avant-garde composition. | Unsettling, constantly anticipating, often "wrong" sounding. |
Final Answer: For your primary purpose of adding rhythm to 1-2 chord bars, the Lesser Than (Previous Note) method is unequivocally the best choice. It is the most robust, predictable, and musically conventional option that will give you the results you expect.
I would recommend implementing the Lesser Than method as your default, and perhaps offering the Closest method as a user-selectable alternative for more "adventurous" phrasing. Avoid the "Greater Than" method unless you have a very specific artistic reason for it.