Source Code (Use browser search to find items of interest.)
Class Index
kdelibs'NoteArray (./kdelibs/libkmid/notearray.h:37)
class NoteArray
{
private:
class NoteArrayPrivate;
NoteArrayPrivate *d;
struct noteCmd {
/**
* ms from beginning of song
*/
ulong ms;
/**
* The channel
*/
int chn;
/**
* 0 note off, 1 note on, 2 change patch
*/
int cmd;
/**
* The note.
*
* If cmd==2, then the patch is stored in "note"
*/
int note;
};
noteCmd *data;
ulong totalAllocated;
ulong last;
noteCmd *lastAdded;
/**
* @internal
* The iterator
*/
noteCmd *it;
noteCmd *pointerTo(ulong pos);
public:
/**
* Constructor. Initializes internal variables.
*/
NoteArray(void);
/**
* Destructor.
*/
~NoteArray();
/**
* Adds (or modifies) an event in the given position .
*
* Note that this has nothing to do with what is being played, this just
* modifies an internal array.
*/
void at(ulong pos, ulong ms,int chn,int cmd,int note);
/**
* A convenience function, which differs from the above in the parameters
* it accepts.
*/
void at(ulong pos, noteCmd s);
/**
* Returns the note event at a given position.
*/
noteCmd at(int pos);
/**
* Adds a note/patch event at a given millisecond.
*
* Note: This method always appends at the end of the list.
*/
void add(ulong ms,int chn,int cmd,int note);
/**
* Initializes the iterator.
*
* @see #get()
* @see #next()
*/
void iteratorBegin(void) { it=data; };
/**
* Get the command currently pointed to by the iterator.
*/
noteCmd *get(void) { return it; };
/**
* Advances the iterator to the next position.
*/
void next(void);
/**
* Calls @ref #next() until the next event is over ms milliseconds
* and puts in @p pgm[16] the instruments used at this moment.
*/
void moveIteratorTo(ulong ms,int *pgm=NULL);
};
kdelibs'NoteArray::NoteArray() (./kdelibs/libkmid/notearray.cc:30)
NoteArray::NoteArray(void)
{
totalAllocated=50;
data=new noteCmd[totalAllocated];
lastAdded=NULL;
}
kdelibs'NoteArray::~NoteArray() (./kdelibs/libkmid/notearray.cc:37)
NoteArray::~NoteArray()
{
delete data;
totalAllocated=0;
}
NoteArray::noteCmd *NoteArray::pointerTo(ulong pos)
{
if (pos<totalAllocated) return &data[pos];
while (pos>=totalAllocated)
{
noteCmd *tmp=new noteCmd[totalAllocated*2];
memcpy(tmp,data,sizeof(noteCmd)*totalAllocated);
delete data;
data=tmp;
totalAllocated*=2;
}
return &data[pos];
}
kdelibs'NoteArray::at() (./kdelibs/libkmid/notearray.cc:57)
void NoteArray::at(ulong pos, ulong ms,int chn,int cmd,int note)
{
noteCmd *tmp=pointerTo(pos);
tmp->ms=ms;
tmp->chn=chn;
tmp->cmd=cmd;
tmp->note=note;
}
kdelibs'NoteArray::at() (./kdelibs/libkmid/notearray.cc:66)
void NoteArray::at(ulong pos, noteCmd s)
{
noteCmd *tmp=pointerTo(pos);
tmp->ms=s.ms;
tmp->chn=s.chn;
tmp->cmd=s.cmd;
tmp->note=s.note;
}
NoteArray::noteCmd NoteArray::at(int pos)
{
return *pointerTo(pos);
}
kdelibs'NoteArray::add() (./kdelibs/libkmid/notearray.cc:80)
void NoteArray::add(ulong ms,int chn,int cmd,int note)
{
if (lastAdded==NULL)
{
lastAdded=data;
last=0;
}
else
{
last++;
if (last==totalAllocated) lastAdded=pointerTo(totalAllocated);
else lastAdded++;
}
lastAdded->ms=ms;
lastAdded->chn=chn;
lastAdded->cmd=cmd;
lastAdded->note=note;
}
kdelibs'NoteArray::next() (./kdelibs/libkmid/notearray.cc:99)
void NoteArray::next(void)
{
if (it==lastAdded) {it=NULL;return;};
it++;
}
kdelibs'NoteArray::moveIteratorTo() (./kdelibs/libkmid/notearray.cc:105)
void NoteArray::moveIteratorTo(ulong ms,int *pgm)
{
noteCmd *ncmd;
iteratorBegin();
ncmd=get();
int pgm2[16];
for (int j=0;j<16;j++) pgm2[j]=0;
while ((ncmd!=NULL)&&(ncmd->ms<ms))
{
if (ncmd->cmd==2) pgm2[ncmd->chn]=ncmd->note;
next();
ncmd=get();
}
if (pgm!=NULL)
{
for (int i=0;i<16;i++) pgm[i]=pgm2[i];
}
}