Contents page

Rules for Tools/Clips


To store a sequence, Bars&Pipes strings the sequence's Events in a linked list, and stores the list in the `Clip' structure. Bars&Pipes uses a standard structure for handling many of its linked lists, the EventList structure. This has pointers to the top and current position within a linked list of Events. Bars&Pipes uses EventLists to place the sequence, as well as linked lists of Song Parameters, in a Clip. Here are the structures:

struct EventList {
    struct Event *first;    /* Top of the linked list. */
    struct Event *point;    /* Current position. */ };

struct Clip {
    struct Clip *next;          /* Next in list of Clips. */
    struct EventList events;    /* Sequence. */
    struct EventList chords;    /* List of chords. */
    struct EventList keys;      /* List of keys. */
    struct EventList lyrics;    /* List of lyrics. */
    struct EventList rhythm;    /* List of rhythms. */
    struct EventList dynamics;  /* List of dynamics. */
    struct TimeSigList timesig; /* Time signatures. */
    struct String *name;        /* Clip name. */
    struct String *notes;       /* Clip notes. */
    long begin;                 /* Time Clip begins. */
    long end;                   /* Time Clip ends. */
    unsigned char highnote;     /* Highest note. */
    unsigned char lownote;      /* Lowest note. */
    char locked;                /* Locking flag. */ };

     This is the linked list of MIDI Events that comprise the sequence.

`chords' `keys' `lyrics' `rhythm' `dynamics' `timesig'
     These are the Song Parameter lists.  Bars&Pipes uses variations on
     the standard Event structure for all of  the Song Parameters.
     Just as the NoteEvent structure maps onto the Event structure, so
     do the ChordEvent, KeyEvent, RhythmEvent, etc., structures.  These
     are documented in the include file, `bars.h'.  Inasmuch as it is
     unlikely that you will need to access these structures, we don't
     discuss them here. Likewise, TimeSigList is a special version of
     EventList that has a few extra fields pertaining to Time
     Signature.  If you are curious, look it up in `bars.h'.

`name' `notes'
     These are dynamic string fields.  They correspond to the Track
     name and notes entries.  To process dynamic strings, use the
     string handling functions `allocstring()' (see allocstring()),
     `freestring()' (see freestring()) and `stringtext()' (see
     stringtext()) in the Bars&Pipes library.

`begin' `end'
     These hold the starting and ending times of the Clip.  Usually,
     `begin' is 0; therefore `end' actually holds the length of the

`highnote' `lownote'
     Bars&Pipes stores the highest and lowest MIDI notes values from
     the sequence in `highnote' and `lownote' and uses these to
     determine the range of the sequence display in the main window.

     This is set whenever Bars&Pipes, a Tool, or an Accessory is
     working on the Clip.  This guarantees against two concurrent
     programs working on the same data at the same time.  The following
     routine attempts to lock a Clip, returning 1 if successful, 0 if

lockclip(clip) struct Clip *clip; {
    if (clip->locked) {
    clip->locked = 1;
    return(1); }

     Later, when done processing the Clip, you must clear locked to
     unlock the Clip:

          clip->locked = 0;
Bars&Pipes provides an extensive library of Clip manipulation routines, including calls to
clear (see clearclip()),
duplicate (see dupeclip()),
cut (see cutclip()),
copy (see copyclip()),
paste (see pasteclip()),
load (see loadclip()) and
save (see saveclip()) Clips.
These routines are all documented in the Bars&Pipes library.