1

This code is supposed to repeatedly check the state of the D9 slider on an Axiom keyboard and use its value to control the pitch of a frequency.

int main()
{
    int note;
    int modwheel;
    float frequency;


    while (modwheel != 0)

    {
        note = aserveGetControl(74);
        modwheel = aserveGetControl(01);

        frequency = 440 * pow(2, (note-69) /12.0);
        aserveOscillator(1,frequency,1.0,0);
        aserveSleep(100);
    }



    return 0;
}
Neo
  • 203
  • 1
  • 11

1 Answers1

3

You never initialize modwheel, so when the while loop starts, its value is "random", i.e. it can be zero, which causes the loop to end immediately.

Use a do/while loop to ensure it has at least one iteration, or use an infinite while (true) loop with an if inside to avoid actually handling 0 as valid input.

unwind
  • 378,987
  • 63
  • 458
  • 590