I have to write out to a text file using a for loop. The file is being created, but there is no data in the file when I open it. Here's what I've got (assuming f1=10, f2=10, and samperiod = .025)
using namespace std;
void GenerateTone (double f1, double f2, double dur, double samperiod)
for (dur = 0; dur >= .5; dur = dur + samperiod)
tone = (sin(2*M_PI*f1*dur))+(sin(2*M_PI*f2*dur));
outfile << dur << " " << tone << endl;
I'm not sure what the problem is, maybe something with the sin()?
It's your loop. You initialise dur to zero then tell the loop to run while dur is greater or equal to 0.5. Therefore, the loop never runs.