Time for hitsounds.
Sample code fragment:
Sample code fragment:
SPOILER
#include <fstream>
using namespace std;
// Object types and properties
#define OBJECT_CIRCLE 1
#define OBJECT_SLIDER 2
#define OBJECT_SPINNER 12
#define OBJECT_NEW_COMBO 4
// Hitsounds
#define HITSOUND_HIT 0
#define HITSOUND_WHISTLE 2
#define HITSOUND_FINISH 4
#define HITSOUND_CLAP 8
// Combo and hitsound pattern
const int comboLength = 16;
const int patternLength = 16;
const int hitsoundPattern[] =
{
HITSOUND_FINISH,
HITSOUND_CLAP,
HITSOUND_HIT,
HITSOUND_CLAP,
HITSOUND_HIT,
HITSOUND_CLAP,
HITSOUND_HIT,
HITSOUND_CLAP,
HITSOUND_HIT,
HITSOUND_CLAP,
HITSOUND_HIT,
HITSOUND_CLAP,
HITSOUND_HIT,
HITSOUND_CLAP,
HITSOUND_HIT,
HITSOUND_CLAP,
};
// Calculates note position and time. Implementation is omitted here.
int GetPosX(char digit);
int GetPosY(char digit);
int GetTime(int ticksFromBeginning);
// Outputs [HitObjects] section to file
void WriteHitObjects(ofstream& osuFile, const char* piDigits)
{
osuFile << "[HitObjects]\n";
for (int i = 0; i < 10240; i++)
{
osuFile << GetPosX(piDigits[i]) << ',';
osuFile << GetPosY(piDigits[i]) << ',';
osuFile << GetTime(i) << ',';
if (i % comboLength == 0)
{
osuFile << (OBJECT_CIRCLE | OBJECT_NEW_COMBO) << ',';
}
else
{
osuFile << OBJECT_CIRCLE << ',';
}
osuFile << hitsoundPattern[i % patternLength] << '\n';
}
}