Пример #1
0
int main(void){

  assert(notenum_from_notetext("") < 0);
  assert(notenum_from_notetext("y5") < 0);
  assert(notenum_from_notetext("cd") < 0);

  assert(notenum_from_notetext("cb0") < 0);

  cmp("c0,1",0.01);
  cmp("c0,10",0.1);
  cmp("c#0",1);
  cmp("c#0,99",1.99);
  cmp("ga",127);
  cmp("ga,99",127.99);
  cmp("g-a",127);
  cmp("g-a,99",127.99);

  cmp("C0,1",0.01);
  cmp("C0,10",0.1);
  cmp("C#0",1);
  cmp("C#0,99",1.99);
  cmp("G-A",127);
  cmp("G-A,99",127.99);

  int cents;
  for(cents=0;cents<100;cents++){
    char *a = talloc_format("c9,%d",cents);
    cmp(a,108.0 + (float)cents/100.0f);
  }

  printf("Success, no errors\n");

  return 0;
}
Пример #2
0
static float request_notenum(struct Tracker_Windows *window, const char *title, float old_notenum){
  float notenum = -1;
  
  ReqType reqtype=GFX_OpenReq(window,30,12,"Set Pitch");

  if (old_notenum>0.0f)
    GFX_SetString(reqtype, notetext_from_notenum(old_notenum));

  char temp[1024];
  sprintf(temp, "%s (for example: \"c4\" or \"c#5,50\") >", title);
  
  while(notenum <= 0.0f){
    char *notetext = GFX_GetString(
                                   window,
                                   reqtype,
                                   temp
                                   );
    if(notetext==NULL)
      break;
    
    notenum = notenum_from_notetext(notetext);
  }
  
  GFX_CloseReq(window,reqtype);

  printf("notenum: %f\n",notenum);
  
  return notenum;
}
Пример #3
0
static void cmp(char *text, float value){
  fprintf(stderr,"\n\nComparing \"%s\" against %f\n",text,value);
  
  float from_text = notenum_from_notetext(text);

  char *from_value = notetext_from_notenum(value);
  float from_text_from_value = notenum_from_notetext(from_value);

  fprintf(stderr,"from_text: %f, from_value: \"%s\", from_text_from_value: %f (value: %f)\n",
          from_text,
          from_value,
          from_text_from_value,
          value
          );
  
  assert(fabsf(from_text-value) < 0.001);
  assert(fabsf(from_text_from_value-value) < 0.001);
}
Пример #4
0
float getNoteNameValue(char *notename){
  return notenum_from_notetext(notename);
}