【发布时间】:2015-05-30 01:13:20
【问题描述】:
我的程序从用户那里接受一个数字来确定正在记录的序列的长度。我将如何获取该数字并让它确定执行此循环的次数。 While(true) 显然根本不允许循环结束。
提前致谢
这是从 MIDI 输入合成声音的功能
void midisound (int note)
{
int velocity;
int playingNote = -1;
float frequency;
while(true)
{
note = aserveGetNote();
velocity = aserveGetVelocity();
if(velocity > 0)
{
frequency = 440 * pow(2, (note-69) / 12.0);
aserveOscillator(0, frequency, 1.0, 0);
playingNote = note;
}
else if(note == playingNote)
{
aserveOscillator(0, 0, 0, 0);
}
}
}
---here is where function ^ is called in the program----
if (reclayer == 1)
{
//open first text file for layer 1 to be written to
textFilePointer = fopen("recording1.txt", "w+");
if(textFilePointer == NULL)
{
printf("Error Opening File!");
}
else
{
//function call to write notes and vel data
notetofile(input, seqlen, reclayer);
printf("Would you like to record a second layer or re-record? (y or n)\n");
scanf(" %c", &choice2);
}
}
【问题讨论】:
-
使用一个变量并将其初始化为零。然后为每个循环增加它。使用它,您可以获得执行循环的次数。