-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTGVoice.cpp
More file actions
51 lines (45 loc) · 1.12 KB
/
TGVoice.cpp
File metadata and controls
51 lines (45 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "TGVoice.h"
#include "TGDuration.h"
#include <algorithm>
TGVoice:: ~TGVoice()
{
#ifndef AUTOMATIC_DELETE
delete duration;
duration = NULL;
#endif
}
void TGVoice::addNote(TGNote* note){
note->setVoice(this);
notes.push_back(note);
setEmpty(false);
}
void TGVoice::moveNote(int index,TGNote *aNote)
{
TGNoteList::iterator i = std::find(notes.begin(), notes.end(), aNote);
if (i != notes.end())
{
notes.erase(i);
}
notes.insert(notes.begin() + index, aNote);
}
void TGVoice::removeNote(TGNote *aNote){
TGNoteList::iterator i = std::find(notes.begin(), notes.end(), aNote);
if (i != notes.end())
{
notes.erase(i);
#ifndef AUTOMATIC_DELETE
delete (*i);
#endif
}
}
TGVoice* TGVoice::clone(TGFactory *factory){
TGVoice *voice = factory->newVoice(getIndex());
voice->setEmpty(isEmpty());
voice->setDirection( getDirection() );
getDuration()->copy(voice->getDuration());
for(TGNoteList::iterator i=notes.begin(); i!=notes.end(); ++i) {
TGNote *note = (*i);
voice->addNote(note->clone(factory));
}
return voice;
}