Example #1
0
//------------------------------------------------------------------------------
// nextBar() - steps through the bar count, until we reach our number of bars
// limit.
//------------------------------------------------------------------------------
void ScanGimbal::nextBar()
{
    unsigned int nbars = getNumBars();
    unsigned int bn = getBarNumber();

    if(isOddNumberOfBars()) {
        if (nbars == 1) {
            setReverseScan( !isReverseScan() );
        }
        else if (bn >= nbars) {
            setReverseScan(true);
            setBarNumber(nbars-1);
        }
        else if (isReverseScan() && bn > 1) {
            setBarNumber(getBarNumber()-1);
        }
        else {
            unsigned int newBar = bn;
            if (newBar < 1) {
                newBar = 1;
            }
            setBarNumber(newBar+1);
            setReverseScan(false);
        }
    }
    else {
        setReverseScan(false);
        unsigned int newBar = bn + 1;
        if (newBar > nbars) newBar = 1;
        setBarNumber(newBar);
    }
}
void WiimotePipeServerWrapper::openLoggingFile(WiimoteData *remote1,WiimoteData *remote2)
{
	if(m_WiimoteCppFileLoggingOn)
	{
		TCHAR * wiimoteLogfileName = getWiimoteLogfileName();
		fp = _wfopen(wiimoteLogfileName,_T("w"));
		logWiimoteFileHeader(remote1,remote2,getBeatsPerMinute(),getBeatsPerBar(),getNumBars(),getLeadIn());
	}

}
Example #3
0
//------------------------------------------------------------------------------
// computeNewBarPos() - computes the beginning or end point of the bar to be scanned
//------------------------------------------------------------------------------
void ScanGimbal::computeNewBarPos(const int bar, const Side side)
{
    // Lookup tables
    // 1 bar scan
    static double table1[2][2] = { { -1, 0 },
        { 1, 0 }
    };
    // 2 bar scan
    static double table2[2][2][2] = {
        { {-1, 0.5f}, {1, 0.5f} },
        { {1, -0.5f}, {-1, -0.5f} }
    };

    // 3 bar scan
    static double table3[3][2][2] = {
        { { -1, 1 }, {  1, 1 } },
        { { 1, 0 },  { -1, 0 } },
        { { -1, -1 }, { 1 , -1 } }
    };

    // 4 bar scan
    static double table4[4][2][2] = {
        { { -1,  1.5f},   {  1,  1.5f} },
        { {  1,  0.5f},   { -1,  0.5f} },
        { { -1, -0.5f},   {  1, -0.5f} },
        { {  1, -1.5f},   { -1, -1.5f} }
    };

    // Now we determine which table to use, depending on the number of bars
    double x = 0.0;
    double y = 0.0;

    // now we draw the Unitless numbers from the tables
    unsigned int nb = getNumBars();
    if (nb == 1) {
        x = table1[side][0];
        y = table1[side][1];
    }
    else if (nb == 2) {
        x = table2[bar-1][side][0];
        y = table2[bar-1][side][1];
    }
    else if (nb == 3) {
        x = table3[bar-1][side][0];
        y = table3[bar-1][side][1];
    }
    else if (nb == 4) {
        x = table4[bar-1][side][0];
        y = table4[bar-1][side][1];
    }

    // swap x values if we are scanning right to left
    if (!isLeftToRightScan()) x = -x;

    // if we have an odd number of bars and are in the reverse scan sequence swap
    // x values on even bar numbers or on bar if only a 1 bar scan
    if (nb == 1 && isReverseScan()) {
        x = -x;
    }

    // now turn our Unitless numbers in something we can use
    double x1 = x * (0.5 * getScanWidth());
    double y1 = y * (getBarSpacing());

    // We need to find which mode we are in before computing the start position
    if (getScanMode() == HORIZONTAL_BAR_SCAN) {
        setScanPos(x1, y1);
    }
    else {
        setScanPos(y1, x1);
    }
}
void MidiGrid::notifyListenersOfTimeSignatureChange ()
{
    if (listener && listener->timeSignatureChanged (getNumBars(), divDenominator))
    {
    }
}