Wednesday 15 February 2012

c - Whats wrong with my function or main? -


All my code wants to work differently from my "play" function. I am trying to read the .txt files created by the "record" function and return the notes to the program. Unfortunately, when the user presses his notes to play back, it keeps popping up with only one menu and does not move further in the next phase of the program. Any help is highly appreciated, it can be a little bit, but I am working on it all day and now I am struggling to solve problems.

Include # "aservelibs / aservelib.h" # Include & lt; Stdio.h & gt; # Include & lt; Math.h> #include & lt; String.h & gt; Float MTOf (int note, float frequency); File play (zero); File record (zero); File record 2 (zero); Int main () {FILE * textFilePointer; FILE * textFilePointer2; Int counter = 0; Four users; Doing {printf ("Press A Melody (A), B2 Melody Record (B) \ nP to play a record tune (p):"); Scanf ("% c", and Users); If (user == 'a' || user == 'a') {textFilePointer = fopen ("/ user / Luke / desktop / midnight, .1.txt", "w"); * TextFilePointer = record (); Counter = 0; } And if (user == 'b' || user == 'b') {textFilePointer2 = FOPAN ("/ user / Luke / desktop / MidnightOS 2.", "W"); * TextFilePointer2 = Record 2 (); Counter = 0; } And if (user == 'P' || user == 'P') {textFilePointer = fopen ("/ user / Luke / desktop / midnight, .1.txt", "R"); TextFilePointer2 = FOPAN ("/ User / Luke / Desktop / MidnightTs 02.txt", "R"); Counter = 0; }} While (counter <16); } Float MTOF (int note, float frequency) {frequency = 440.0 * POW (2, (note-69) / 12.0); Printf ("% d \ n", note); Return frequency; } FILE play (zero) {FILE * file; File = fopen ("/ user / Luke / desktop / MidnightTot 1.txt", "r"); File = fopen ("/ user / Luke / desktop / MidnightTot 1.txt", "r"); Do {int note = aserveGetNote (); Int velocity = escaragate velcity (); Fscanf (file, "% d,% d \ n", & amp; notes, and velocity); Int frequency = mtoff (note, frequency); AserveOscillator (0, frequency, 1.0, 0); AserveSleep (500); } While (FIFF) == 0); Fclose (file); Return * file; } FILE record (zero) {int counter; File * file; File = fopen ("/ user / Luke / desktop / midnightTs.1.txt", "w"); Do {int note = aserveGetNote (); Int velocity = escaragate velcity (); If (velocity> 0) {fprintf (file, "% d,% d \ n", note, velocity); Counter ++; }} While (counter <16); Fclose (file); Return * file; } FILE record 2 (zero) {int counter; File * file; File = FOPAN ("/ user / Luke / desktop / midnightotes 02.txt", "w"); Do {int note = aserveGetNote (); Int velocity = escaragate velcity (); If (velocity> 0) {fprintf (file, "% d,% d \ n", note, velocity); Counter ++; }} While (counter <16); Fclose (file); Return * file; }

  fclose (file); Return * file;  

If you turn it off, you can not use it. Do not close the file if you expect it to be used later (what you do).


No comments:

Post a Comment