Small utility library for MIDI functions.
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

40 satır
1.1 KiB

  1. #include <stdio.h>
  2. #include <assert.h>
  3. #include "midi-utils.h"
  4. void check_note_value(char* read_note_name, unsigned char read_note_value) {
  5. unsigned int actual_note_value = MIDI_GetNoteFromName(read_note_name);
  6. printf("MIDI_GetNoteFromName(\"%s\")...", read_note_name);
  7. printf("(%d == %d) ", read_note_value, actual_note_value);
  8. assert(read_note_value == actual_note_value);
  9. printf("OK!\n");
  10. }
  11. void check_note_name(char* read_note_name, unsigned char read_note_value) {
  12. printf("MIDI_GetNoteName(%d)...", read_note_value);
  13. char* actual_note_name = MIDI_GetNoteName(read_note_value);
  14. printf("(%s == %s) ", read_note_name, actual_note_name);
  15. assert(!strcmp(read_note_name, actual_note_name));
  16. printf("OK!\n");
  17. }
  18. int main(void) {
  19. FILE* f = fopen("cases.txt", "r");
  20. if (!f) {
  21. return -1;
  22. }
  23. char read_note_name[255] = "";
  24. unsigned int read_note_value;
  25. while (!feof(f)) {
  26. fscanf(f, "%s %d\n", read_note_name, &read_note_value);
  27. check_note_value(read_note_name, read_note_value);
  28. if (read_note_value != 255u || !strcmp(read_note_name, "D#21")) {
  29. check_note_name(read_note_name, read_note_value);
  30. }
  31. }
  32. fclose(f);
  33. return 0;
  34. }