Chris Cannam wrote:
> Why not just go from one end of the
> composition to the other, filling in notes at all the right times?
fyi, here's a function that will calculate those times. The depth
argument is the level of subdivision (0 = bars only, 3 = bars, beats,
beat divisions, subdivisions -- etc). Doesn't do anything except
print them out, and note that they aren't in order as it's really a
recursive process that's just flattened into a loop.
This is a long way from the fastest way to do it, but it's simple
enough and very generic (works for any time signatures).
void
calculateMetronomeTicks(Rosegarden::Composition &c, int depth)
{
Rosegarden::timeT t = 0;
while (t < c.getEndMarker()) {
Rosegarden::TimeSignature sig = c.getTimeSignatureAt(t);
std::vector<int> divisions;
if (depth > 0) divisions = sig.getDivisions(depth - 1);
int ticks = 1;
for (int i = -1; i < (int)divisions.size(); ++i) {
if (i >= 0) ticks *= divisions[i];
for (int tick = 0; tick < ticks; ++tick) {
if (i >= 0 && (tick % divisions[i] == 0)) continue;
Rosegarden::timeT tickTime =
t + (tick * sig.getBarDuration()) / ticks;
std::cout << "Tick of depth " << i+1
<< " at time " << tickTime << std::endl;
}
}
t = c.getBarEndForTime(t);
}
}
Chris
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
Rosegarden-devel mailing list
[EMAIL PROTECTED] - use the link below to unsubscribe
https://lists.sourceforge.net/lists/listinfo/rosegarden-devel