1
/**************************************************************************
3
notearray.cc - NoteArray class, which holds an array of notes
4
Copyright (C) 1998 Antonio Larrosa Jimenez
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
Send comments and bug fixes to antlarr@arrakis.es
21
or to Antonio Larrosa, Rio Arnoya, 10 5B, 29006 Malaga, Spain
23
***************************************************************************/
25
#include "notearray.h"
28
NoteArray::NoteArray(void)
31
data=new noteCmd[totalAllocated];
35
NoteArray::~NoteArray()
41
noteCmd *NoteArray::pointerTo(ulong pos)
43
if (pos<totalAllocated) return &data[pos];
44
while (pos>=totalAllocated)
46
noteCmd *tmp=new noteCmd[totalAllocated*2];
47
memcpy(tmp,data,sizeof(noteCmd)*totalAllocated);
55
void NoteArray::at(ulong pos, ulong ms,int chn,int cmd,int note)
57
noteCmd *tmp=pointerTo(pos);
64
void NoteArray::at(ulong pos, noteCmd s)
66
noteCmd *tmp=pointerTo(pos);
73
noteCmd NoteArray::at(int pos)
75
return *pointerTo(pos);
78
void NoteArray::add(ulong ms,int chn,int cmd,int note)
88
if (last==totalAllocated) lastAdded=pointerTo(totalAllocated);
97
void NoteArray::next(void)
99
if (it==lastAdded) {it=NULL;return;};
103
void NoteArray::moveIteratorTo(ulong ms,int *pgm)
109
for (int j=0;j<16;j++) pgm2[j]=0;
110
while ((ncmd!=NULL)&&(ncmd->ms<ms))
112
if (ncmd->cmd==2) pgm2[ncmd->chn]=ncmd->note;
118
for (int i=0;i<16;i++) pgm[i]=pgm2[i];