0
我的字符讀取功能不工作,它打印我想要打印的內容,但它阻止程序進入下一步,並閱讀用戶輸入的數字,它在它是一個函數之前很好地工作,但我需要它有一定的作用,因爲這是一個賦值我的功能有什麼問題?
#include "aservelibs/aservelib.h"
#include <stdio.h>
#include <math.h>
int length();
float mtof(int note);
float octave(int notes);
char read(char print);
int main()
{
//do while the user hasnt pressed exit key (whatever)
int control[8] = {74, 71, 91, 93, 73, 72, 5, 84};
int index;
int mod;
float frequency;
int notes[8];
int response;
float octave;
char print;
mod = aserveGetControl(1);
//ask backwards, forwards, exit
//SCALING
//(getControl(75)/((127 - 0)/(1000 - 100))) + 100;
while(true)
{
read(print);
mod = 0;
if(response == 1)
{
while(mod==0)
{
for(index = 0; index < 8; index++)
{
notes[index] = aserveGetControl(control[index]);
frequency = mtof(notes[index]);
aserveOscillator(0, frequency, 1.0, 0);
aserveSleep(length());
printf("Slider Value:%5d\n", notes[index]);
printf("frequency: %f\n", frequency);
mod = aserveGetControl(1);
octave = aserveGetControl(7);
}
}
}
else if(response == 2)
{
while(mod==0)
{
for(index = 7; index > 0; index--)
{
notes[index] = aserveGetControl(control[index]);
frequency = mtof(notes[index]);
aserveOscillator(0, frequency, 1.0, 0);
aserveSleep(length());
printf("Slider Value:%5d\n", notes[index]);
printf("%f", frequency);
mod = aserveGetControl(1);
}
}
}
else if(response == 0)
{
return 0;
}
}
}
int length()
{
return (aserveGetControl(75)/((127.0 - 0)/(1000 - 100))) + 100;
}
float mtof(int note)
{
return 440 * pow(2, (note-69)/12.0);
}
float octave(int note)
{
float slider = aserveGetControl(7)/16383.0;
slider *=24;
return 440 * pow(2, ((note+slider)-69)/12.0);
}
char read(char print)
{
char response;
printf("Run Loop Forwards (1), Backwards (2), Exit (0)\nMove modwheel to return to menu\n");
scanf("%c", &response);
}