| 786 | } |
| 787 | |
| 788 | void ExportAudioDialog::UpdateTrackExportSettings(const ExportPlugin& plugin, int formatIndex, bool byName, bool addNumber, |
| 789 | const wxString& prefix) |
| 790 | { |
| 791 | auto& tracks = TrackList::Get(mProject); |
| 792 | |
| 793 | bool anySolo = !(( tracks.Any<const WaveTrack>() + &WaveTrack::GetSolo ).empty()); |
| 794 | |
| 795 | auto waveTracks = tracks.Any<WaveTrack>() - |
| 796 | (anySolo ? &WaveTrack::GetNotSolo : &WaveTrack::GetMute); |
| 797 | |
| 798 | const auto numWaveTracks = waveTracks.size(); |
| 799 | |
| 800 | auto fileIndex = 0; // track counter |
| 801 | FilePaths otherNames; |
| 802 | auto formatInfo = plugin.GetFormatInfo(formatIndex); |
| 803 | std::vector<ExportSetting> exportSettings; // dynamic array we will use to store the |
| 804 | // settings needed to do the exports with in |
| 805 | exportSettings.reserve(numWaveTracks); // Allocate some guessed space to use. |
| 806 | ExportSetting setting; // the current batch of settings |
| 807 | setting.filename.SetPath(mExportOptionsPanel->GetPath()); |
| 808 | setting.filename.SetExt(wxFileName{mExportOptionsPanel->GetFullName()}.GetExt()); |
| 809 | |
| 810 | wxString name; // used to hold file name whilst we mess with it |
| 811 | wxString title; // un-messed-with title of file for tagging with |
| 812 | |
| 813 | const auto skipSilenceAtBeginning = mSkipSilenceAtBeginning->GetValue(); |
| 814 | |
| 815 | /* Examine all tracks in turn, collecting export information */ |
| 816 | for (auto tr : waveTracks) { |
| 817 | |
| 818 | // Get the times for the track |
| 819 | setting.t0 = skipSilenceAtBeginning ? tr->GetStartTime() : 0; |
| 820 | setting.t1 = tr->GetEndTime(); |
| 821 | |
| 822 | setting.channels = mExportOptionsPanel->GetChannels(); |
| 823 | // Get name and title |
| 824 | title = tr->GetName(); |
| 825 | if( title.empty() ) |
| 826 | title = _("untitled"); |
| 827 | |
| 828 | if (byName) { |
| 829 | name = title; |
| 830 | if (addNumber) { |
| 831 | name.Prepend( |
| 832 | wxString::Format(wxT("%02d-"), fileIndex+1)); |
| 833 | } |
| 834 | } |
| 835 | else { |
| 836 | name = (wxString::Format(wxT("%s-%02d"), prefix, fileIndex+1)); |
| 837 | } |
| 838 | |
| 839 | Internat::SanitiseFilename(name, wxT("_")); |
| 840 | // store sanitised and user checked name in object |
| 841 | setting.filename.SetName(name); |
| 842 | |
| 843 | // FIXME: TRAP_ERR User could have given an illegal track name. |
| 844 | // in that case we should tell them, not fail silently. |
| 845 | wxASSERT(setting.filename.IsOk()); // burp if file name is broke |
nothing calls this directly
no test coverage detected