Thank you all so much for the suggestions. It seems that I wasn't too clear exactly what I wanted to do... but, I've figured it out and here's the answer to my own question:
Code:
if(Pm_Poll(stream))//status will only change if it re-Polls
{
length = Pm_Read(stream, event, sizeof(long));
for(i = 0; i < length; i++)//if(Pm_Read(data->stream, data->event, sizeof(long)) > 0)
{
status = Pm_MessageStatus(event[i].message);
data1 = Pm_MessageData1(event[i].message);
data2 = Pm_MessageData2(event[i].message);
printf("Status: %d, Data1: %d, Data2: %d\n", status, data1, data2);
}
int time, temp, loop = 0, counter = 0;
while(status==144)//Enters this while loop if status==144, or noteon
{
if(Pm_Read(stream, event, sizeof(long)) > 0)//Events must be detected within the loop as well. Otherwise there's no way out of this while loop
{
status = Pm_MessageStatus(event[i].message);
data1 = Pm_MessageData1(event[i].message);
data2 = Pm_MessageData2(event[i].message);
}
time = Pt_Time(NULL);
while (Pt_Time(NULL) - time < 1);// set to 1ms because 100ms is too long for Pm_Poll to notice anything has happened
counter++;//Every 1ms counter is incremented
if(counter % 100 == 0)//when it has counted 100ms, (or whatever you set it to)
{
loop++; // it increments loop
printf("\n%d\ntest\n", loop);
}
}
}
This code does exactly what I wanted it to do. It increments "loop" every 100ms when it receives a noteon message (status 144) and terminates when it receives a noteoff(status 128).