1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-02 16:49:41 +02:00

Use wxFprintf not fprintf and you don't need c_str

This commit is contained in:
Paul Licameli 2017-10-09 00:29:10 -04:00
parent 2dacaa56a9
commit cd06c04fa0
5 changed files with 74 additions and 73 deletions

View File

@ -72,7 +72,7 @@ static bool IsPowerOfTwo(size_t x)
static size_t NumberOfBitsNeeded(size_t PowerOfTwo)
{
if (PowerOfTwo < 2) {
fprintf(stderr, "Error: FFT called with size %ld\n", PowerOfTwo);
wxFprintf(stderr, "Error: FFT called with size %ld\n", PowerOfTwo);
exit(1);
}
@ -136,7 +136,7 @@ void FFT(size_t NumSamples,
double tr, ti; /* temp real, temp imaginary */
if (!IsPowerOfTwo(NumSamples)) {
fprintf(stderr, "%ld is not a power of two\n", NumSamples);
wxFprintf(stderr, "%ld is not a power of two\n", NumSamples);
exit(1);
}
@ -367,7 +367,7 @@ void NewWindowFunc(int whichFunction, size_t NumSamples, bool extraSample, float
switch (whichFunction) {
default:
fprintf(stderr, "FFT::WindowFunc - Invalid window function: %d\n", whichFunction);
wxFprintf(stderr, "FFT::WindowFunc - Invalid window function: %d\n", whichFunction);
break;
case eWinFuncRectangular:
// Multiply all by 1.0f -- do nothing
@ -682,6 +682,6 @@ void DerivativeOfWindowFunc(int whichFunction, size_t NumSamples, bool extraSamp
}
break;
default:
fprintf(stderr, "FFT::DerivativeOfWindowFunc - Invalid window function: %d\n", whichFunction);
wxFprintf(stderr, "FFT::DerivativeOfWindowFunc - Invalid window function: %d\n", whichFunction);
}
}

View File

@ -7672,8 +7672,8 @@ class ASAProgress final : public SAProgress {
#ifdef COLLECT_TIMING_DATA
long ms = 0;
wxDateTime now = wxDateTime::UNow();
fprintf(mTimeFile, "Phase %d begins at %s\n",
i, now.FormatTime().c_str());
wxFprintf(mTimeFile, "Phase %d begins at %s\n",
i, now.FormatTime());
if (i != 0)
ms = now.Subtract(mStartTime).GetMilliseconds().ToLong();
mStartTime = now;
@ -7700,25 +7700,25 @@ class ASAProgress final : public SAProgress {
mTotalWork += work3;
}
#ifdef COLLECT_TIMING_DATA
fprintf(mTimeFile, " mTotalWork (an estimate) = %g\n", mTotalWork);
fprintf(mTimeFile, " work0 = %g, frames %g, is_audio %d\n",
wxFprintf(mTimeFile, " mTotalWork (an estimate) = %g\n", mTotalWork);
wxFprintf(mTimeFile, " work0 = %g, frames %g, is_audio %d\n",
work[0], mFrames[0], is_audio[0]);
fprintf(mTimeFile, " work1 = %g, frames %g, is_audio %d\n",
wxFprintf(mTimeFile, " work1 = %g, frames %g, is_audio %d\n",
work[1], mFrames[1], is_audio[1]);
fprintf(mTimeFile, "work2 = %g, work3 = %g\n", work2, work3);
wxFprintf(mTimeFile, "work2 = %g, work3 = %g\n", work2, work3);
#endif
mProgress.create(_("Synchronize MIDI with Audio"),
_("Synchronizing MIDI and Audio Tracks"));
} else if (i < 3) {
fprintf(mTimeFile,
wxFprintf(mTimeFile,
"Phase %d took %d ms for %g frames, coefficient = %g s/frame\n",
i - 1, ms, mFrames[i - 1], (ms * 0.001) / mFrames[i - 1]);
} else if (i == 3) {
fprintf(mTimeFile,
wxFprintf(mTimeFile,
"Phase 2 took %d ms for %d cells, coefficient = %g s/cell\n",
ms, mCellCount, (ms * 0.001) / mCellCount);
} else if (i == 4) {
fprintf(mTimeFile, "Phase 3 took %d ms for %d iterations on %g frames, coefficient = %g s per frame per iteration\n",
wxFprintf(mTimeFile, "Phase 3 took %d ms for %d iterations on %g frames, coefficient = %g s per frame per iteration\n",
ms, iterations, wxMax(mFrames[0], mFrames[1]),
(ms * 0.001) / (wxMax(mFrames[0], mFrames[1]) * iterations));
}

View File

@ -399,7 +399,7 @@ void NoteTrack::PrintSequence()
FILE *debugOutput;
debugOutput = fopen("debugOutput.txt", "wt");
fprintf(debugOutput, "Importing MIDI...\n");
wxFprintf(debugOutput, "Importing MIDI...\n");
// This is called for debugging purposes. Do not compute mSeq on demand
// with GetSeq()
@ -407,38 +407,38 @@ void NoteTrack::PrintSequence()
int i = 0;
while(i < mSeq->length()) {
fprintf(debugOutput, "--\n");
fprintf(debugOutput, "type: %c\n",
wxFprintf(debugOutput, "--\n");
wxFprintf(debugOutput, "type: %c\n",
((Alg_event_ptr)mSeq->track_list.tracks[i])->get_type());
fprintf(debugOutput, "time: %f\n",
wxFprintf(debugOutput, "time: %f\n",
((Alg_event_ptr)mSeq->track_list.tracks[i])->time);
fprintf(debugOutput, "channel: %li\n",
wxFprintf(debugOutput, "channel: %li\n",
((Alg_event_ptr)mSeq->track_list.tracks[i])->chan);
if(((Alg_event_ptr)mSeq->track_list.tracks[i])->get_type() == wxT('n'))
{
fprintf(debugOutput, "pitch: %f\n",
wxFprintf(debugOutput, "pitch: %f\n",
((Alg_note_ptr)mSeq->track_list.tracks[i])->pitch);
fprintf(debugOutput, "duration: %f\n",
wxFprintf(debugOutput, "duration: %f\n",
((Alg_note_ptr)mSeq->track_list.tracks[i])->dur);
fprintf(debugOutput, "velocity: %f\n",
wxFprintf(debugOutput, "velocity: %f\n",
((Alg_note_ptr)mSeq->track_list.tracks[i])->loud);
}
else if(((Alg_event_ptr)mSeq->track_list.tracks[i])->get_type() == wxT('n'))
{
fprintf(debugOutput, "key: %li\n", ((Alg_update_ptr)mSeq->track_list.tracks[i])->get_identifier());
fprintf(debugOutput, "attribute type: %c\n", ((Alg_update_ptr)mSeq->track_list.tracks[i])->parameter.attr_type());
fprintf(debugOutput, "attribute: %s\n", ((Alg_update_ptr)mSeq->track_list.tracks[i])->parameter.attr_name());
wxFprintf(debugOutput, "key: %li\n", ((Alg_update_ptr)mSeq->track_list.tracks[i])->get_identifier());
wxFprintf(debugOutput, "attribute type: %c\n", ((Alg_update_ptr)mSeq->track_list.tracks[i])->parameter.attr_type());
wxFprintf(debugOutput, "attribute: %s\n", ((Alg_update_ptr)mSeq->track_list.tracks[i])->parameter.attr_name());
if(((Alg_update_ptr)mSeq->track_list.tracks[i])->parameter.attr_type() == wxT('r'))
{
fprintf(debugOutput, "value: %f\n", ((Alg_update_ptr)mSeq->track_list.tracks[i])->parameter.r);
wxFprintf(debugOutput, "value: %f\n", ((Alg_update_ptr)mSeq->track_list.tracks[i])->parameter.r);
}
else if(((Alg_update_ptr)mSeq->track_list.tracks[i])->parameter.attr_type() == wxT('i')) {
fprintf(debugOutput, "value: %li\n", ((Alg_update_ptr)mSeq->track_list.tracks[i])->parameter.i);
wxFprintf(debugOutput, "value: %li\n", ((Alg_update_ptr)mSeq->track_list.tracks[i])->parameter.i);
}
else if(((Alg_update_ptr)mSeq->track_list.tracks[i])->parameter.attr_type() == wxT('s')) {
fprintf(debugOutput, "value: %s\n", ((Alg_update_ptr)mSeq->track_list.tracks[i])->parameter.s);
wxFprintf(debugOutput, "value: %s\n", ((Alg_update_ptr)mSeq->track_list.tracks[i])->parameter.s);
}
else {}
}
@ -447,7 +447,7 @@ void NoteTrack::PrintSequence()
}
}
else {
fprintf(debugOutput, "No sequence defined!\n");
wxFprintf(debugOutput, "No sequence defined!\n");
}
fclose(debugOutput);

View File

@ -24,6 +24,7 @@ but it will probably work fine if you use it on a high level.
#include "Profiler.h"
#include <stdio.h>
#include <string.h>
#include <wx/crt.h>
///write to a profile at the end of the test.
Profiler::~Profiler()
@ -35,24 +36,24 @@ Profiler::~Profiler()
time_t now;
time(&now);
fprintf(log,"Audacity Profiler Run, Ended at ");
fprintf(log,"%s",ctime(&now));
fprintf(log,"****************************************\n");
wxFprintf(log,"Audacity Profiler Run, Ended at ");
wxFprintf(log,"%s",ctime(&now));
wxFprintf(log,"****************************************\n");
//print out the tasks
for(int i=0;i<(int)mTasks.size();i++)
{
if(mTasks[i]->mNumHits>0)
{
fprintf(log,"Task: %s\n(begins at line %d in %s)\n\n",mTasks[i]->mDescription.get(), mTasks[i]->mLine, mTasks[i]->mFileName.get());
fprintf(log,"Number of times run: %d\n",mTasks[i]->mNumHits);
fprintf(log,"Total run time (seconds): %f\n", (double)mTasks[i]->mCumTime/CLOCKS_PER_SEC);
fprintf(log,"Average run time (seconds): %f\n",mTasks[i]->ComputeAverageRunTime());
wxFprintf(log,"Task: %s\n(begins at line %d in %s)\n\n",mTasks[i]->mDescription.get(), mTasks[i]->mLine, mTasks[i]->mFileName.get());
wxFprintf(log,"Number of times run: %d\n",mTasks[i]->mNumHits);
wxFprintf(log,"Total run time (seconds): %f\n", (double)mTasks[i]->mCumTime/CLOCKS_PER_SEC);
wxFprintf(log,"Average run time (seconds): %f\n",mTasks[i]->ComputeAverageRunTime());
if(i < ((int)mTasks.size()) -1)
fprintf(log,"----------------------------\n");
wxFprintf(log,"----------------------------\n");
}
}
fprintf(log,"\n****************************************\n\n\n");
wxFprintf(log,"\n****************************************\n\n\n");
fclose(log);
}

View File

@ -304,7 +304,7 @@ static int GuessFloatFormats(unsigned numTests, const ArrayOf<char> rawData[], s
#if RAW_GUESS_DEBUG
FILE *af = g_raw_debug_file;
fprintf(af, "Testing float\n");
wxFprintf(af, "Testing float\n");
#endif
ArrayOf<float> data1{ dataSize + 4 };
@ -336,7 +336,7 @@ static int GuessFloatFormats(unsigned numTests, const ArrayOf<char> rawData[], s
float smoothAvg = 0;
#if RAW_GUESS_DEBUG
fprintf(af, "prec=%d endian=%d offset=%d\n",
wxFprintf(af, "prec=%d endian=%d offset=%d\n",
prec, endian, (int)offset);
#endif
@ -385,7 +385,7 @@ static int GuessFloatFormats(unsigned numTests, const ArrayOf<char> rawData[], s
smoothAvg /= numTests;
#if RAW_GUESS_DEBUG
fprintf(af, "finite: %ud/%ud maxmin: %ud/%ud smooth: %f\n",
wxFprintf(af, "finite: %ud/%ud maxmin: %ud/%ud smooth: %f\n",
finiteVotes, numTests, maxminVotes, numTests,
smoothAvg);
#endif
@ -444,7 +444,7 @@ static int GuessFloatFormats(unsigned numTests, const ArrayOf<char> rawData[], s
}
#if RAW_GUESS_DEBUG
fprintf(af, "stereo: %ud mono: %ud\n", stereoVotes, monoVotes);
wxFprintf(af, "stereo: %ud mono: %ud\n", stereoVotes, monoVotes);
#endif
guessStereo = (stereoVotes > monoVotes);
@ -467,7 +467,7 @@ static int GuessFloatFormats(unsigned numTests, const ArrayOf<char> rawData[], s
redundant = RedundantStereo(data1.get(), len1);
#if RAW_GUESS_DEBUG
fprintf(af, "redundant: %f\n", redundant);
wxFprintf(af, "redundant: %f\n", redundant);
#endif
if (redundant > 0.8)
@ -477,7 +477,7 @@ static int GuessFloatFormats(unsigned numTests, const ArrayOf<char> rawData[], s
}
#if RAW_GUESS_DEBUG
fprintf(af, "rstereo: %ud rmono: %ud\n", rstereoVotes, rmonoVotes);
wxFprintf(af, "rstereo: %ud rmono: %ud\n", rstereoVotes, rmonoVotes);
#endif
guessStereo = (rstereoVotes > rmonoVotes);
@ -486,9 +486,9 @@ static int GuessFloatFormats(unsigned numTests, const ArrayOf<char> rawData[], s
#if RAW_GUESS_DEBUG
if (guessStereo)
fprintf(af, "stereo\n");
wxFprintf(af, "stereo\n");
else
fprintf(af, "mono\n");
wxFprintf(af, "mono\n");
#endif
*out_offset = bestOffset;
@ -527,7 +527,7 @@ static int Guess8Bit(unsigned numTests, const ArrayOf<char> rawData[], size_t da
#if RAW_GUESS_DEBUG
FILE *af = g_raw_debug_file;
fprintf(af, "8-bit\n");
wxFprintf(af, "8-bit\n");
#endif
/*
@ -567,16 +567,16 @@ static int Guess8Bit(unsigned numTests, const ArrayOf<char> rawData[], size_t da
}
#if RAW_GUESS_DEBUG
fprintf(af, "sign: %ud unsign: %ud\n", signvotes, unsignvotes);
wxFprintf(af, "sign: %ud unsign: %ud\n", signvotes, unsignvotes);
#endif
guessSigned = (signvotes > unsignvotes);
#if RAW_GUESS_DEBUG
if (guessSigned)
fprintf(af, "signed\n");
wxFprintf(af, "signed\n");
else
fprintf(af, "unsigned\n");
wxFprintf(af, "unsigned\n");
#endif
/* Finally we test stereo/mono. We use the same JumpStat, and say
@ -604,7 +604,7 @@ static int Guess8Bit(unsigned numTests, const ArrayOf<char> rawData[], size_t da
}
#if RAW_GUESS_DEBUG
fprintf(af, "stereo: %ud mono: %ud\n", stereoVotes, monoVotes);
wxFprintf(af, "stereo: %ud mono: %ud\n", stereoVotes, monoVotes);
#endif
guessStereo = (stereoVotes > monoVotes);
@ -624,7 +624,7 @@ static int Guess8Bit(unsigned numTests, const ArrayOf<char> rawData[], size_t da
redundant = RedundantStereo(data1.get(), len1);
#if RAW_GUESS_DEBUG
fprintf(af, "redundant: %f\n", redundant);
wxFprintf(af, "redundant: %f\n", redundant);
#endif
if (redundant > 0.8)
@ -634,7 +634,7 @@ static int Guess8Bit(unsigned numTests, const ArrayOf<char> rawData[], size_t da
}
#if RAW_GUESS_DEBUG
fprintf(af, "rstereo: %ud rmono: %ud\n", rstereoVotes, rmonoVotes);
wxFprintf(af, "rstereo: %ud rmono: %ud\n", rstereoVotes, rmonoVotes);
#endif
guessStereo = (rstereoVotes > rmonoVotes);
@ -643,9 +643,9 @@ static int Guess8Bit(unsigned numTests, const ArrayOf<char> rawData[], size_t da
#if RAW_GUESS_DEBUG
if (guessStereo)
fprintf(af, "stereo\n");
wxFprintf(af, "stereo\n");
else
fprintf(af, "mono\n");
wxFprintf(af, "mono\n");
#endif
if (guessStereo)
@ -682,7 +682,7 @@ static int Guess16Bit(unsigned numTests, const ArrayOf<char> rawData[],
#if RAW_GUESS_DEBUG
FILE *af = g_raw_debug_file;
fprintf(af, "16-bit\n");
wxFprintf(af, "16-bit\n");
#endif
/*
@ -721,16 +721,16 @@ static int Guess16Bit(unsigned numTests, const ArrayOf<char> rawData[],
}
#if RAW_GUESS_DEBUG
fprintf(af, "sign: %ud unsign: %ud\n", signvotes, unsignvotes);
wxFprintf(af, "sign: %ud unsign: %ud\n", signvotes, unsignvotes);
#endif
guessSigned = (signvotes > unsignvotes);
#if RAW_GUESS_DEBUG
if (guessSigned)
fprintf(af, "signed\n");
wxFprintf(af, "signed\n");
else
fprintf(af, "unsigned\n");
wxFprintf(af, "unsigned\n");
#endif
/*
@ -761,7 +761,7 @@ static int Guess16Bit(unsigned numTests, const ArrayOf<char> rawData[],
}
#if RAW_GUESS_DEBUG
fprintf(af, "stereoVotes: %ud monoVotes: %ud\n", stereoVotes, monoVotes);
wxFprintf(af, "stereoVotes: %ud monoVotes: %ud\n", stereoVotes, monoVotes);
#endif
guessStereo = (stereoVotes > monoVotes);
@ -794,7 +794,7 @@ static int Guess16Bit(unsigned numTests, const ArrayOf<char> rawData[],
}
#if RAW_GUESS_DEBUG
fprintf(af, "rstereoVotes: %ud rmonoVotes: %ud\n",
wxFprintf(af, "rstereoVotes: %ud rmonoVotes: %ud\n",
rstereoVotes, rmonoVotes);
#endif
@ -804,9 +804,9 @@ static int Guess16Bit(unsigned numTests, const ArrayOf<char> rawData[],
#if RAW_GUESS_DEBUG
if (guessStereo)
fprintf(af, "stereo\n");
wxFprintf(af, "stereo\n");
else
fprintf(af, "mono\n");
wxFprintf(af, "mono\n");
#endif
/*
@ -820,7 +820,7 @@ static int Guess16Bit(unsigned numTests, const ArrayOf<char> rawData[],
guessOffset = 0;
#if RAW_GUESS_DEBUG
fprintf(af, "evenMSB: %d BE: %d\n", evenMSB, guessBigEndian);
wxFprintf(af, "evenMSB: %d BE: %d\n", evenMSB, guessBigEndian);
#endif
for (unsigned test = 0; test < numTests; test++) {
@ -870,7 +870,7 @@ static int Guess16Bit(unsigned numTests, const ArrayOf<char> rawData[],
}
#if RAW_GUESS_DEBUG
fprintf(af, "former: %f latter: %f\n", former, latter);
wxFprintf(af, "former: %f latter: %f\n", former, latter);
#endif
if (former <= latter)
@ -880,7 +880,7 @@ static int Guess16Bit(unsigned numTests, const ArrayOf<char> rawData[],
}
#if RAW_GUESS_DEBUG
fprintf(af, "former (BE/LE): %ud latter (LE+/BE+): %ud\n",
wxFprintf(af, "former (BE/LE): %ud latter (LE+/BE+): %ud\n",
formerVotes, latterVotes);
#endif
@ -892,16 +892,16 @@ static int Guess16Bit(unsigned numTests, const ArrayOf<char> rawData[],
#if RAW_GUESS_DEBUG
if (guessBigEndian)
fprintf(af, "big endian\n");
wxFprintf(af, "big endian\n");
else
fprintf(af, "little endian\n");
wxFprintf(af, "little endian\n");
#endif
#if RAW_GUESS_DEBUG
if (guessOffset)
fprintf(af, "offset 1 byte\n");
wxFprintf(af, "offset 1 byte\n");
else
fprintf(af, "no byte offset\n");
wxFprintf(af, "no byte offset\n");
#endif
format = SF_FORMAT_RAW | SF_FORMAT_PCM_16;
@ -966,7 +966,7 @@ static int GuessIntFormats(unsigned numTests, const ArrayOf<char> rawData[], siz
odd = AmpStat(data2.get(), len2);
if ((even > 0.15) && (odd > 0.15)) {
#if RAW_GUESS_DEBUG
fprintf(af, "Both appear random: %.2f, %.2f.\n", even, odd);
wxFprintf(af, "Both appear random: %.2f, %.2f.\n", even, odd);
#endif
}
else if ((even > 0.15) || (odd > 0.15))
@ -984,9 +984,9 @@ static int GuessIntFormats(unsigned numTests, const ArrayOf<char> rawData[], siz
evenMSB = (evenMSBVotes > oddMSBVotes);
#if RAW_GUESS_DEBUG
fprintf(af, "evenMSBVote: %ud oddMSBVote: %ud\n",
wxFprintf(af, "evenMSBVote: %ud oddMSBVote: %ud\n",
evenMSBVotes, oddMSBVotes);
fprintf(af, "vote8: %ud vote16: %ud\n", vote8, vote16);
wxFprintf(af, "vote8: %ud vote16: %ud\n", vote8, vote16);
#endif
guess16bit = (vote8 <= vote16);
@ -1015,7 +1015,7 @@ int RawAudioGuess(const wxString &in_fname,
#if RAW_GUESS_DEBUG
FILE *af = fopen("raw.txt", "a");
g_raw_debug_file = af;
fprintf(af, "File: %s\n", in_fname);
wxFprintf(af, "File: %s\n", in_fname);
#endif
*out_offset = 0;