Sunday, September 19, 2010

Version 1.7: Longer chords, larger playback buttons

Incorporated some good user feedback about extending the length of chord playback. Agreed, they were too short before. Harder to hear the intervals within. Hopefully it will be a bit easier now.

Technical detail: I use Cubase 5.5 to generate all 157 sound files. There are two octave's worth of single notes, used to build the interval sequences, and another ~125 sound files made up individual chords (11 types, each with an octave's worth of chords).  Needless to say this requires serious automation.

Building chords with Cubase 5.5

In the code I have stored each file's resource ID in a large hashmap, where the key is an integer array containing the actual pitch intervals making up the chord.

public static final class ChordIntervalResourceMap
    public final static HashMap<int[], int[]> chordMap = new HashMap<int[], int[]>();
        chordMap.put(Consts.ChordIntervals.MAJOR_TRIAD, majorTriadResourceArray);
        chordMap.put(Consts.ChordIntervals.MINOR_TRIAD, minorTriadResourceArray);
        chordMap.put(Consts.ChordIntervals.AUGMENTED_TRIAD, augmentedTriadResourceArray);
        chordMap.put(Consts.ChordIntervals.DIMINISHED_TRIAD, diminishedTriadResourceArray);
        chordMap.put(Consts.ChordIntervals.MAJOR_SEVENTH, majorSeventhResourceArray);
        chordMap.put(Consts.ChordIntervals.MINOR_SEVENTH, minorSeventhResourceArray);
        chordMap.put(Consts.ChordIntervals.AUGMENTED_SEVENTH, augmentedSeventhResourceArray);
        chordMap.put(Consts.ChordIntervals.DOMINANT_SEVENTH, dominantSeventhResourceArray);
        chordMap.put(Consts.ChordIntervals.DIMINISHED_SEVENTH, diminishedSeventhResourceArray);
        chordMap.put(Consts.ChordIntervals.HALF_DIMINISHED_SEVENTH, halfDiminishedSeventhResourceArray);
        chordMap.put(Consts.ChordIntervals.MINOR_MAJOR_SEVENTH, minorMajorSeventhResourceArray);

public static int[] majorTriadResourceArray =
    R.raw.c_maj_triad, R.raw.csharp_maj_triad, R.raw.d_maj_triad, R.raw.dsharp_maj_triad,
    R.raw.e_maj_triad, R.raw.f_maj_triad, R.raw.fsharp_maj_triad, R.raw.g_maj_triad,
    R.raw.gsharp_maj_triad, R.raw.a_maj_triad, R.raw.asharp_maj_triad, R.raw.b_maj_triad 
The reason for all this is very simple: I build and store integer interval arrays in both the Intervals activity and the Chords activity. Thus I can reuse code. The intervals can be used to just play single notes in a sequence, or they can be used as keys in the above hashmap to obtain chord files. Handy!

No comments:

Post a Comment