2002-08-13 23:26:46 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
File: NoteTypes.cpp
|
|
|
|
|
|
|
|
|
|
Desc:
|
|
|
|
|
|
|
|
|
|
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
|
|
|
|
Chris Danford
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
#include "NoteTypes.h"
|
|
|
|
|
|
|
|
|
|
|
2002-10-28 05:30:45 +00:00
|
|
|
RageColor NoteTypeToColor( NoteType nt )
|
2002-08-13 23:26:46 +00:00
|
|
|
{
|
|
|
|
|
switch( nt )
|
|
|
|
|
{
|
2002-10-28 05:30:45 +00:00
|
|
|
case NOTE_TYPE_4TH: return RageColor(1,0,0,1); // red
|
|
|
|
|
case NOTE_TYPE_8TH: return RageColor(0,0,1,1); // blue
|
|
|
|
|
case NOTE_TYPE_12TH: return RageColor(1,0,1,1); // purple
|
|
|
|
|
case NOTE_TYPE_16TH: return RageColor(1,1,0,1); // yellow
|
|
|
|
|
case NOTE_TYPE_24TH: return RageColor(0,1,1,1); // light blue
|
2002-09-11 04:49:07 +00:00
|
|
|
default:
|
|
|
|
|
ASSERT(0);
|
2002-09-17 23:02:37 +00:00
|
|
|
case NOTE_TYPE_32ND: // fall through
|
2002-10-28 05:30:45 +00:00
|
|
|
return RageColor(0.5f,0.5f,0.5f,1); // gray
|
2002-08-13 23:26:46 +00:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
float NoteTypeToBeat( NoteType nt )
|
|
|
|
|
{
|
|
|
|
|
switch( nt )
|
|
|
|
|
{
|
2002-08-25 19:00:12 +00:00
|
|
|
case NOTE_TYPE_4TH: return 1.0f; // quarter notes
|
|
|
|
|
case NOTE_TYPE_8TH: return 1.0f/2; // eighth notes
|
2002-08-23 20:18:29 +00:00
|
|
|
case NOTE_TYPE_12TH: return 1.0f/3; // triplets
|
|
|
|
|
case NOTE_TYPE_16TH: return 1.0f/4; // sixteenth notes
|
2002-09-11 04:49:07 +00:00
|
|
|
case NOTE_TYPE_24TH: return 1.0f/6; // twenty-forth notes
|
|
|
|
|
case NOTE_TYPE_32ND: return 1.0f/8; // thirty-second notes
|
2002-08-25 19:00:12 +00:00
|
|
|
default: ASSERT(0); return 0;
|
2002-08-13 23:26:46 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NoteType GetNoteType( int iNoteIndex )
|
|
|
|
|
{
|
2002-08-23 20:18:29 +00:00
|
|
|
if( iNoteIndex % (ROWS_PER_MEASURE/4) == 0) return NOTE_TYPE_4TH;
|
|
|
|
|
else if( iNoteIndex % (ROWS_PER_MEASURE/8) == 0) return NOTE_TYPE_8TH;
|
|
|
|
|
else if( iNoteIndex % (ROWS_PER_MEASURE/12) == 0) return NOTE_TYPE_12TH;
|
|
|
|
|
else if( iNoteIndex % (ROWS_PER_MEASURE/16) == 0) return NOTE_TYPE_16TH;
|
2002-09-11 04:49:07 +00:00
|
|
|
else if( iNoteIndex % (ROWS_PER_MEASURE/24) == 0) return NOTE_TYPE_24TH;
|
|
|
|
|
else if( iNoteIndex % (ROWS_PER_MEASURE/32) == 0) return NOTE_TYPE_32ND;
|
2002-08-25 19:00:12 +00:00
|
|
|
else return NOTE_TYPE_INVALID;
|
2002-08-13 23:26:46 +00:00
|
|
|
};
|
|
|
|
|
|
2003-02-06 07:32:57 +00:00
|
|
|
CString NoteTypeToString( NoteType nt )
|
|
|
|
|
{
|
|
|
|
|
switch( nt )
|
|
|
|
|
{
|
|
|
|
|
case NOTE_TYPE_4TH: return "4th";
|
|
|
|
|
case NOTE_TYPE_8TH: return "8th";
|
|
|
|
|
case NOTE_TYPE_12TH: return "12th";
|
|
|
|
|
case NOTE_TYPE_16TH: return "16th";
|
|
|
|
|
case NOTE_TYPE_24TH: return "24th";
|
|
|
|
|
case NOTE_TYPE_32ND: return "32nd";
|
|
|
|
|
default: ASSERT(0); return "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-02-05 03:53:57 +00:00
|
|
|
NoteType BeatToNoteType( float fBeat )
|
|
|
|
|
{
|
|
|
|
|
return GetNoteType( BeatToNoteRow(fBeat) );
|
2003-02-06 07:32:57 +00:00
|
|
|
}
|
2003-02-05 03:53:57 +00:00
|
|
|
|
2002-08-13 23:26:46 +00:00
|
|
|
bool IsNoteOfType( int iNoteIndex, NoteType t )
|
|
|
|
|
{
|
|
|
|
|
return GetNoteType(iNoteIndex) == t;
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-28 05:30:45 +00:00
|
|
|
RageColor GetNoteColorFromIndex( int iIndex )
|
2002-08-13 23:26:46 +00:00
|
|
|
{
|
2002-09-11 04:49:07 +00:00
|
|
|
return NoteTypeToColor( GetNoteType(iIndex) );
|
2002-08-13 23:26:46 +00:00
|
|
|
}
|
|
|
|
|
|
2002-10-28 05:30:45 +00:00
|
|
|
RageColor GetNoteColorFromBeat( float fBeat )
|
2002-08-13 23:26:46 +00:00
|
|
|
{
|
|
|
|
|
return GetNoteColorFromIndex( BeatToNoteRow(fBeat) );
|
|
|
|
|
}
|
|
|
|
|
|