| 997 | } |
| 998 | |
| 999 | void FrequencyPlotDialog::OnExport(wxCommandEvent & WXUNUSED(event)) |
| 1000 | { |
| 1001 | wxString fName = _("spectrum.txt"); |
| 1002 | |
| 1003 | fName = SelectFile(FileNames::Operation::Export, |
| 1004 | XO("Export Spectral Data As:"), |
| 1005 | wxEmptyString, |
| 1006 | fName, |
| 1007 | wxT("txt"), |
| 1008 | { FileNames::TextFiles, FileNames::AllFiles }, |
| 1009 | wxFD_SAVE | wxRESIZE_BORDER, |
| 1010 | this); |
| 1011 | |
| 1012 | if (fName.empty()) |
| 1013 | return; |
| 1014 | |
| 1015 | wxFFileOutputStream ffStream{ fName }; |
| 1016 | if (!ffStream.IsOk()) { |
| 1017 | AudacityMessageBox( XO("Couldn't write to file: %s").Format( fName ) ); |
| 1018 | return; |
| 1019 | } |
| 1020 | |
| 1021 | wxTextOutputStream ss(ffStream); |
| 1022 | |
| 1023 | const int processedSize = mAnalyst->GetProcessedSize(); |
| 1024 | const float *const processed = mAnalyst->GetProcessed(); |
| 1025 | if (mAlgChoice->GetSelection() == 0) { |
| 1026 | ss |
| 1027 | << XO("Frequency (Hz)\tLevel (dB)") << '\n'; |
| 1028 | for (int i = 1; i < processedSize; i++) |
| 1029 | ss |
| 1030 | << wxString::Format(wxT("%f\t%f\n"), |
| 1031 | i * mRate / mWindowSize, processed[i] ); |
| 1032 | } |
| 1033 | else { |
| 1034 | ss |
| 1035 | << XO("Lag (seconds)\tFrequency (Hz)\tLevel") << '\n'; |
| 1036 | for (int i = 1; i < processedSize; i++) |
| 1037 | ss |
| 1038 | << wxString::Format(wxT("%f\t%f\t%f\n"), |
| 1039 | i / mRate, mRate / i, processed[i] ); |
| 1040 | } |
| 1041 | } |
| 1042 | |
| 1043 | void FrequencyPlotDialog::OnReplot(wxCommandEvent & WXUNUSED(event)) |
| 1044 | { |
nothing calls this directly
no test coverage detected