Audacity  2.2.2
Classes | Macros | Functions
ImportPCM.cpp File Reference
#include "../Audacity.h"
#include "ImportPCM.h"
#include "../Internat.h"
#include "../Tags.h"
#include <wx/wx.h>
#include <wx/string.h>
#include <wx/utils.h>
#include <wx/intl.h>
#include <wx/ffile.h>
#include <wx/sizer.h>
#include <wx/checkbox.h>
#include <wx/button.h>
#include <wx/stattext.h>
#include "sndfile.h"
#include "../ondemand/ODManager.h"
#include "../ondemand/ODComputeSummaryTask.h"
#include "../prefs/QualityPrefs.h"
#include "../FileFormats.h"
#include "../Prefs.h"
#include "../WaveTrack.h"
#include "ImportPlugin.h"
#include <algorithm>

Go to the source code of this file.

Classes

class  PCMImportPlugin
 An ImportPlugin for PCM data. More...
 
class  PCMImportFileHandle
 An ImportFileHandle for PCM data. More...
 

Macros

#define kMinimumODFileSampleSize   44100*30
 
#define DESC   _("WAV, AIFF, and other uncompressed types")
 

Functions

void GetPCMImportPlugin (ImportPluginList &importPluginList, UnusableImportPluginList &WXUNUSED(unusableImportPluginList))
 
static wxString AskCopyOrEdit ()
 

Macro Definition Documentation

#define DESC   _("WAV, AIFF, and other uncompressed types")

Definition at line 70 of file ImportPCM.cpp.

Referenced by PCMImportPlugin::GetPluginFormatDescription().

#define kMinimumODFileSampleSize   44100*30

Definition at line 45 of file ImportPCM.cpp.

Referenced by PCMImportFileHandle::Import().

Function Documentation

static wxString AskCopyOrEdit ( )
static

Definition at line 227 of file ImportPCM.cpp.

References _(), gPrefs, and safenew.

Referenced by PCMImportFileHandle::Import().

228 {
229  wxString oldCopyPref = gPrefs->Read(wxT("/FileFormats/CopyOrEditUncompressedData"), wxT("copy"));
230  bool firstTimeAsk = gPrefs->Read(wxT("/Warnings/CopyOrEditUncompressedDataFirstAsk"), true)?true:false;
231  bool oldAskPref = gPrefs->Read(wxT("/Warnings/CopyOrEditUncompressedDataAsk"), true)?true:false;
232 
233  // The first time the user is asked we force it to 'copy'.
234  // This effectively does a one-time change to the preferences.
235  if (firstTimeAsk) {
236  if (oldCopyPref != wxT("copy")) {
237  gPrefs->Write(wxT("/FileFormats/CopyOrEditUncompressedData"), wxT("copy"));
238  oldCopyPref = wxT("copy");
239  }
240  gPrefs->Write(wxT("/Warnings/CopyOrEditUncompressedDataFirstAsk"), (long) false);
241  gPrefs->Flush();
242  }
243 
244  // check the current preferences for whether or not we should ask the user about this.
245  if (oldAskPref) {
246  wxString newCopyPref = wxT("copy");
247  wxDialogWrapper dialog(nullptr, -1, wxString(_("Warning")));
248  dialog.SetName(dialog.GetTitle());
249 
250  wxBoxSizer *vbox;
251  dialog.SetSizer(vbox = safenew wxBoxSizer(wxVERTICAL));
252 
253  wxString clause1 = _(
254 "When importing uncompressed audio files you can either copy them into the project,"
255 " or read them directly from their current location (without copying).\n\n"
256  );
257 
258  wxString clause2 = oldCopyPref == wxT("copy")
259  ? _("Your current preference is set to copy in.\n\n")
260  : _("Your current preference is set to read directly.\n\n")
261  ;
262 
263  wxString clause3 = _(
264 "Reading the files directly allows you to play or edit them almost immediately. "
265 "This is less safe than copying in, because you must retain the files with their "
266 "original names in their original locations.\n"
267 "Help > Diagnostics > Check Dependencies will show the original names and locations of any files "
268 "that you are reading directly.\n\n"
269 "How do you want to import the current file(s)?"
270  );
271 
272  wxStaticText *message =
273  safenew wxStaticText(&dialog, -1, clause1 + clause2 + clause3);
274 
275  message->Wrap(500);
276  message->SetName(message->GetLabel());
277 
278  vbox->Add(message, 1, wxALL | wxEXPAND, 10);
279 
280  wxStaticBox *box = safenew wxStaticBox(&dialog, -1, _("Choose an import method"));
281  box->SetName(box->GetLabel());
282 
283  wxRadioButton *aliasRadio;
284  wxRadioButton *copyRadio;
285  wxCheckBox *dontAskNextTimeBox;
286 
287  {
288  auto boxsizer = std::make_unique<wxStaticBoxSizer>(box, wxVERTICAL);
289 
290  copyRadio = safenew wxRadioButton(&dialog, -1, _("Make a &copy of the files before editing (safer)"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
291  boxsizer->Add(copyRadio, 0, wxALL);
292  copyRadio->SetName(wxStripMenuCodes(copyRadio->GetLabel()));
293 
294  aliasRadio = safenew wxRadioButton(&dialog, -1, _("Read the files &directly from the original (faster)"));
295  boxsizer->Add(aliasRadio, 0, wxALL);
296  aliasRadio->SetName(wxStripMenuCodes(aliasRadio->GetLabel()));
297 
298  dontAskNextTimeBox = safenew wxCheckBox(&dialog, -1, _("Don't &warn again and always use my choice above"));
299  boxsizer->Add(dontAskNextTimeBox, 0, wxALL);
300  vbox->Add(boxsizer.release(), 0, wxALL, 10);
301  }
302 
303  dontAskNextTimeBox->SetName(wxStripMenuCodes(dontAskNextTimeBox->GetLabel()));
304 
305 
306  wxRadioButton *prefsRadio = oldCopyPref == wxT("copy") ? copyRadio : aliasRadio;
307  prefsRadio->SetValue(true);
308 
309  wxSizer *buttonSizer = dialog.CreateButtonSizer(wxOK | wxCANCEL);
310  vbox->Add(buttonSizer, 0, wxALL | wxEXPAND, 10);
311 
312  dialog.SetSize(dialog.GetBestSize());
313  dialog.Layout();
314  dialog.Center();
315 
316  if (dialog.ShowModal() == wxID_OK) {
317  if (aliasRadio->GetValue()) {
318  newCopyPref = wxT("edit");
319  }
320  if (dontAskNextTimeBox->IsChecked()) {
321  gPrefs->Write(wxT("/Warnings/CopyOrEditUncompressedDataAsk"), (long) false);
322  gPrefs->Flush();
323  }
324  } else {
325  return wxT("cancel");
326  }
327 
328  // if the preference changed, save it.
329  if (newCopyPref != oldCopyPref) {
330  gPrefs->Write(wxT("/FileFormats/CopyOrEditUncompressedData"), newCopyPref);
331  gPrefs->Flush();
332  }
333  oldCopyPref = newCopyPref;
334  }
335  return oldCopyPref;
336 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
#define safenew
Definition: Audacity.h:230
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
void GetPCMImportPlugin ( ImportPluginList importPluginList,
UnusableImportPluginList WXUNUSEDunusableImportPluginList 
)

Definition at line 117 of file ImportPCM.cpp.

Referenced by Importer::Initialize().

119 {
120  importPluginList.push_back( std::make_unique<PCMImportPlugin>() );
121 }