| 683 | } |
| 684 | |
| 685 | void ExportAudioDialog::UpdateLabelExportSettings(const ExportPlugin& plugin, int formatIndex, bool byName, bool addNumber, const wxString& prefix) |
| 686 | { |
| 687 | const auto& tracks = TrackList::Get(mProject); |
| 688 | const auto& labels = (*tracks.Any<const LabelTrack>().begin()); |
| 689 | const auto numLabels = labels->GetNumLabels(); |
| 690 | |
| 691 | auto numFiles = numLabels; |
| 692 | auto fileIndex = 0; // counter for files done |
| 693 | std::vector<ExportSetting> exportSettings; // dynamic array for settings. |
| 694 | exportSettings.reserve(numFiles); // Allocate some guessed space to use. |
| 695 | |
| 696 | // Account for exporting before first label |
| 697 | if( mIncludeAudioBeforeFirstLabel->GetValue() ) { |
| 698 | fileIndex = -1; |
| 699 | numFiles++; |
| 700 | } |
| 701 | |
| 702 | const auto formatInfo = plugin.GetFormatInfo(formatIndex); |
| 703 | |
| 704 | FilePaths otherNames; // keep track of file names we will use, so we |
| 705 | // don't duplicate them |
| 706 | ExportSetting setting; // the current batch of settings |
| 707 | setting.filename.SetPath(mExportOptionsPanel->GetPath()); |
| 708 | setting.channels = mExportOptionsPanel->GetChannels(); |
| 709 | setting.filename.SetFullName(mExportOptionsPanel->GetFullName()); |
| 710 | |
| 711 | wxString name; // used to hold file name whilst we mess with it |
| 712 | wxString title; // un-messed-with title of file for tagging with |
| 713 | |
| 714 | const LabelStruct *info = NULL; |
| 715 | /* Examine all labels a first time, sort out all data but don't do any |
| 716 | * exporting yet (so this run is quick but interactive) */ |
| 717 | while( fileIndex < numLabels ) { |
| 718 | |
| 719 | // Get file name and starting time |
| 720 | if( fileIndex < 0 ) { |
| 721 | // create wxFileName for output file |
| 722 | name = setting.filename.GetName(); |
| 723 | setting.t0 = 0.0; |
| 724 | } else { |
| 725 | info = labels->GetLabel(fileIndex); |
| 726 | name = (info->title); |
| 727 | setting.t0 = info->selectedRegion.t0(); |
| 728 | } |
| 729 | |
| 730 | // Figure out the ending time |
| 731 | if( info && !info->selectedRegion.isPoint() ) { |
| 732 | setting.t1 = info->selectedRegion.t1(); |
| 733 | } else if( fileIndex < numLabels - 1 ) { |
| 734 | // Use start of next label as end |
| 735 | const LabelStruct *info1 = labels->GetLabel(fileIndex+1); |
| 736 | setting.t1 = info1->selectedRegion.t0(); |
| 737 | } else { |
| 738 | setting.t1 = tracks.GetEndTime(); |
| 739 | } |
| 740 | |
| 741 | if( name.empty() ) |
| 742 | name = _("untitled"); |
nothing calls this directly
no test coverage detected