Songlib: chord

Song Li Buser

Revision Date: February 4, 2013

Printable Version


The chord family of functions plays multiple notes at the same time. The family follows the n/r/d convention and also has alternatives where notes are passed in an array rather than variadically.

    void chord(double duration,int instrument,
        int baseOctave,int basePitch,...,(int) 0);

    void nchord(double duration,int instrument,
        int baseNumberedNote,...,(int) 0);

    void rchord(double duration,RRA *r,...,(int) 0);

    void dchord(double duration,int *data,int length,...,(int) 0);

    void achord(double duration,int instrument,
        int baseOctave,int basePitch,int *offsets,int length);
    
    void nachord(double duration,int instrument,
        int baseNumberedNote,int *offsets,int length);

For chord and nchord, the variadic part is a list of offsets from the numbered base note and is terminated by a zero. For rchord, the variadic part is additional RRA objects to play simultaneously. For dchord, the variadic part is additional data/length pairs.

The achord function takes a base octave/pitch pair and an array of offsets, The nachord function takes a numbered note as the base and an array of offsets. The offset arrays have length length.

As an example, the following line plays a three-note chord:

    chord(4,guitar,3,C,3,5,7,(int) 0);

The notes played are C, F (which is C + 5 semitones), and G (which is C + 7 semitones). The following calls are equivalent:

    nChord(4,guitar,C3,5,7,(int) 0);
    rchord(4,getNumberedNote(C3),getNumberedNote(F3),getNumberedNote(G3),(int) 0);

The separation between the starts of the notes in the chord is controlled by the controlFunctions? setting.

Other simple chord functions

Certain semitone delta combinations are so common, songlib has shortcut functions. In the following pairs of calls, the two calls in the pair are equivalent:

    chord(H,inst,octave,C,+4,+7,(int) 0);
    maj(H,inst,octave,C);

    chord(H,inst,octave,D,+3,+7,(int) 0);
    min(H,inst,octave,D);

    chord(H,inst,octave,E,+3,+6,(int) 0);
    dim(H,inst,octave,E);

    chord(H,inst,octave,F,+4,+8,(int) 0);
    aug(H,inst,octave,F);

See also: play, bend, trill, draw?, silence?, stride?

lusth@cs.ua.edu