4
4
#include "../config.h"
11
typedef struct _SScore {
19
#define TYPE_NOTE_FREESTYLE 0
20
#define TYPE_NOTE_NORMAL 1
21
#define TYPE_NOTE_GOLDEN 2
22
#define TYPE_NOTE_SLEEP 3
24
typedef struct _SNote {
5
#include <boost/noncopyable.hpp>
6
#include <boost/ptr_container/ptr_set.hpp>
7
#include <boost/scoped_ptr.hpp>
14
static const int m_baseId = 33;
16
MusicalScale(double baseFreq = 440.0): m_baseFreq(baseFreq) {}
17
std::string getNoteStr(double freq) const;
18
unsigned int getNoteNum(int id) const;
19
bool isSharp(int id) const;
20
double getNoteFreq(int id) const;
21
int getNoteId(double freq) const;
22
double getNote(double freq) const;
23
double getNoteOffset(double freq) const;
28
enum Type { FREESTYLE = 'F', NORMAL = ':', GOLDEN = '*', SLEEP = '-'} type;
37
void parseFile( void );
42
std::vector <char *> category;
50
SDL_Surface * coverSurf;
53
SDL_Surface * backgroundSurf;
60
std::vector <TBpm> bpm;
65
std::vector <TNote *> notes;
77
CSong * getSong( unsigned int i );
78
int nbSongs( void ) {return songs.size();};
79
bool parseFile( CSong * tmp );
80
void sortByEdition( void );
81
void sortByGenre( void );
82
void sortByTitle( void );
83
void sortByArtist( void );
84
int getOrder( void ) {return order;};
86
std::vector <CSong*> songs;
90
SDL_Surface * surface_nocover;
31
double diff(double n) const;
32
double maxScore() const;
33
double score(double freq, double b, double e) const;
35
double scoreMultiplier(double error) const;
40
class Song: boost::noncopyable {
42
friend class SongParser;
43
Song(std::string const& path, std::string const& filename);
48
// Temporary score calculation system
50
void update(double time, double freq);
51
int getScore() const { return 10000 * m_score; }
52
bool parseField(std::string const& line);
53
std::string str() const { return title + " by " + artist; }
54
SDL_Surface* getCover() { loadCover(); return m_coverSurf; }
55
SDL_Surface* getBackground() { loadBackground(); return m_backgroundSurf; }
56
void loadBackground();
58
void unloadBackground();
60
typedef std::vector<Note> notes_t;
65
std::vector<std::string> category;
74
std::string background;
80
SDL_Surface* m_coverSurf;
81
SDL_Surface* m_backgroundSurf;
82
double m_scoreFactor; // Normalization factor for the scoring system
83
// Temporary score calculation system
86
notes_t::const_iterator m_scoreIt;
89
bool operator<(Song const& l, Song const& r);
92
std::set<std::string> m_songdirs;
94
Songs(std::set<std::string> const& songdirs);
97
Song& operator[](std::vector<Song*>::size_type pos) { return *m_filtered[pos]; }
98
int size() const { return m_filtered.size(); };
99
int empty() const { return m_filtered.empty(); };
100
void advance(int diff) {
101
m_current = (m_current + diff) % int(m_filtered.size());
102
if (m_current < 0) m_current += m_filtered.size();
104
int currentId() const { return m_current; }
105
Song& current() { return *m_filtered[m_current]; }
106
Song const& current() const { return *m_filtered[m_current]; }
107
void setFilter(std::string const& regex);
108
std::string sortDesc() const;
110
void sortChange(int diff);
111
void parseFile(Song& tmp);
112
SDL_Surface* getEmptyCover() { return surface_nocover; }
115
typedef boost::ptr_set<Song> songlist_t;
117
typedef std::vector<Song*> filtered_t;
118
filtered_t m_filtered;
121
SDL_Surface* surface_nocover;
122
void sort_internal();