[go: up one dir, main page]

Menu

[r19]: / trunk / SongState.h  Maximize  Restore  History

Download this file

117 lines (97 with data), 3.4 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
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// Copyleft 2014 Chris Korda
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 of the License, or any later version.
/*
chris korda
revision history:
rev date comments
00 07may14 initial version
01 23jul14 add InsertSection
02 09sep14 use default memberwise copy
03 18sep14 add Transpose and ChangeLength
04 15jun15 add TranslateChordTypes
song editing container
*/
#ifndef CSONGSTATE_INCLUDED
#define CSONGSTATE_INCLUDED
#include "Song.h"
class CSongState : public WCopyable {
public:
// Construction
CSongState();
// Attributes
int GetChordCount() const;
int GetSectionCount() const;
bool IsValidChordIndex(int ChordIdx) const;
bool IsValidSectionIndex(int SectionIdx) const;
const CSong::CChord& GetChord(int ChordIdx) const;
void GetChords(CSong::CChordArray& Chord) const;
void GetChords(CIntRange BeatRange, CSong::CChordArray& Chord) const;
void SetChord(CIntRange BeatRange, const CSong::CChord& Chord);
int GetStartBeat(int ChordIdx) const;
// Operations
int FindChord(int Beat, int& Offset) const;
CIntRange FindChordRange(CIntRange BeatRange, CIntRange& Offset) const;
void InsertChords(int Beat, const CSong::CChordArray& Chord);
void RemoveChords(CIntRange BeatRange);
int MoveChords(CIntRange BeatRange, int Beat);
void CreateSection(CIntRange BeatRange);
bool InsertSection(CSong::CSection& Section, CString Name);
bool DeleteSection(int Beat);
void AssignToSection(CIntRange BeatRange, int SectionIdx);
bool EditSectionProperties(int Beat);
void RemoveSectionMap();
void Transpose(CIntRange BeatRange, int Steps);
bool ChangeLength(CIntRange& BeatRange, double Scale);
bool TranslateChordTypes(const CIntArrayEx& TranTbl, int& UndefTypeIdx);
protected:
// Member data
CSong::CChordArray m_Chord; // array of song chords
CSong::CSectionArray m_Section; // array of song sections
CStringArrayEx m_SectionName; // array of song section names
CIntArrayEx m_SectionMap; // array of section indices, one per chord
// Helpers
int GetSection(int ChordIdx);
void InsertAt(int ChordIdx, CSong::CChord Chord);
void InsertAt(int ChordIdx, const CSong::CChordArray& Chord);
void RemoveAt(int ChordIdx, int Count = 1);
void MakeSectionMap();
void MakeSections();
void MergeDuplicateChords();
void OnChordCountChange();
void MergeImplicitSections();
friend class CSong;
};
inline CSongState::CSongState()
{
}
inline int CSongState::GetChordCount() const
{
return(m_Chord.GetSize());
}
inline int CSongState::GetSectionCount() const
{
return(m_Section.GetSize());
}
inline bool CSongState::IsValidChordIndex(int ChordIdx) const
{
return(ChordIdx >= 0 && ChordIdx < GetChordCount());
}
inline bool CSongState::IsValidSectionIndex(int SectionIdx) const
{
return(SectionIdx >= 0 && SectionIdx < GetSectionCount());
}
inline const CSong::CChord& CSongState::GetChord(int ChordIdx) const
{
return(m_Chord[ChordIdx]);
}
inline void CSongState::GetChords(CSong::CChordArray& Chord) const
{
Chord = m_Chord;
}
inline bool CSongState::TranslateChordTypes(const CIntArrayEx& TranTbl, int& UndefTypeIdx)
{
return(m_Chord.TranslateChordTypes(TranTbl, UndefTypeIdx));
}
#endif