~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to kmid/player/notearray.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  notearray.h  - NoteArray class, which holds an array of notes
 
2
    Copyright (C) 1998  Antonio Larrosa Jimenez
 
3
 
 
4
    This program is free software; you can redistribute it and/or modify
 
5
    it under the terms of the GNU General Public License as published by
 
6
    the Free Software Foundation; either version 2 of the License, or
 
7
    (at your option) any later version.
 
8
 
 
9
    This program is distributed in the hope that it will be useful,
 
10
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
    GNU General Public License for more details.
 
13
 
 
14
    You should have received a copy of the GNU General Public License
 
15
    along with this program; if not, write to the Free Software
 
16
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
17
 
 
18
    Send comments and bug fixes to antlarr@arrakis.es
 
19
    or to Antonio Larrosa, Rio Arnoya, 10 5B, 29006 Malaga, Spain
 
20
 
 
21
***************************************************************************/
 
22
 
 
23
#ifndef NOTEARRAY_H
 
24
#define NOTEARRAY_H
 
25
 
 
26
// This class holds a resizeable array of noteon/off events, it can increase it size, but
 
27
// it doesn't decreases it until destruction :-)
 
28
#include "dattypes.h"
 
29
 
 
30
struct noteCmd {
 
31
    ulong ms; // ms from beginning of song
 
32
    int chn;
 
33
    int cmd; // 0 note off, 1 note on, 2 change patch
 
34
    int note; // if cmd==2 then the patch is stored in "note"
 
35
};
 
36
 
 
37
class NoteArray
 
38
{
 
39
    noteCmd *data;
 
40
    ulong totalAllocated;
 
41
 
 
42
    ulong last;
 
43
    noteCmd *lastAdded;
 
44
 
 
45
    noteCmd *it; // the iterator
 
46
    
 
47
    noteCmd *pointerTo(ulong pos);
 
48
    
 
49
public:
 
50
    NoteArray(void);
 
51
    ~NoteArray();
 
52
 
 
53
    void at(ulong pos, ulong ms,int chn,int cmd,int note);
 
54
    void at(ulong pos, noteCmd s);
 
55
    noteCmd at(int pos);
 
56
 
 
57
    void add(ulong ms,int chn,int cmd,int note);
 
58
 
 
59
    void iteratorBegin(void) { it=data; };
 
60
    noteCmd *get(void)       { return it; };
 
61
    void next(void);
 
62
    void moveIteratorTo(ulong ms,int *pgm=NULL);
 
63
    // call next() until the next event is over ms milliseconds
 
64
    // and puts in pgm[16] the instruments used at this moment
 
65
 
 
66
};
 
67
 
 
68
#endif