using System;
using System.Collections.Generic;
using System.Text;
namespace SalsaModel.Tests {
class ManualTiming : ITiming {
double _beat;
///
/// Constructs a timing object representing the beat, supplied as a float in [0.0, 8).
///
///
public ManualTiming(double beat) {
_beat = beat;
}
public int Beat() {
return (((int)_beat) % 8) + 1;
}
public int GlobalBeat() {
return (int)_beat + 1;
}
public double Percent() {
return _beat - (int)_beat;
}
const bool c_onOne = true;
// XXX this probably means that StepNumber shouldn't be part of timing?
public int StepNumber()
{
int beat = Beat();
if (c_onOne)
{
switch (beat)
{
case 1:
case 2:
case 3:
return beat - 1;
case 5:
case 6:
case 7:
return beat - 2;
case 4:
case 8:
return -1;
default:
throw new InvalidOperationException("bad beat");
}
}
else
{
switch (beat)
{
// case 5: return 0;
case 6: return 0;
case 7: return 1;
case 1: return 2;
case 2: return 3;
case 3: return 4;
case 5: return 5;
case 8:
case 4:
return -1;
default: throw new InvalidOperationException("bad beat");
}
}
}
}
}