Audacity  2.2.2
Public Member Functions | Public Attributes | Private Attributes | List of all members
ImportRawDialog Class Referencefinal

ImportRawDialog prompts you with options such as endianness and sample size to help you importing data of an unknown format. More...

Inheritance diagram for ImportRawDialog:
wxDialogWrapper wxTabTraversalWrapper< wxDialog >

Public Member Functions

 ImportRawDialog (wxWindow *parent, int encoding, unsigned channels, int offset, double rate)
 
 ~ImportRawDialog ()
 
void OnOK (wxCommandEvent &event)
 
void OnCancel (wxCommandEvent &event)
 
void OnPlay (wxCommandEvent &event)
 
void OnChoice (wxCommandEvent &event)
 
- Public Member Functions inherited from wxDialogWrapper
 wxDialogWrapper ()
 
 wxDialogWrapper (wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const wxString &name=_("Dialog"))
 
bool Create (wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const wxString &name=_("Dialog"))
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxDialog >
 wxTabTraversalWrapper (Args &&...args)
 

Public Attributes

int mEncoding
 
unsigned mChannels
 
int mOffset
 
double mRate
 
double mPercent
 

Private Attributes

wxButton * mOK
 
wxChoice * mEncodingChoice
 
wxChoice * mEndianChoice
 
wxChoice * mChannelChoice
 
wxTextCtrl * mOffsetText
 
wxTextCtrl * mPercentText
 
wxTextCtrl * mRateText
 
int mNumEncodings
 
ArrayOf< int > mEncodingSubtype
 

Detailed Description

ImportRawDialog prompts you with options such as endianness and sample size to help you importing data of an unknown format.

Definition at line 62 of file ImportRaw.cpp.

Constructor & Destructor Documentation

ImportRawDialog::ImportRawDialog ( wxWindow *  parent,
int  encoding,
unsigned  channels,
int  offset,
double  rate 
)

Definition at line 319 of file ImportRaw.cpp.

References _(), ShuttleGuiBase::AddChoice(), ShuttleGui::AddStandardButtons(), ShuttleGuiBase::AddTextBox(), ShuttleGuiBase::AddUnits(), eIsCreating, ShuttleGuiBase::EndMultiColumn(), ShuttleGuiBase::EndTwoColumn(), ShuttleGuiBase::EndVerticalLay(), ShuttleGui::Id(), ShuttleGuiBase::SetBorder(), sf_encoding_index_name(), sf_encoding_index_to_subtype(), sf_num_encodings(), ShuttleGuiBase::StartMultiColumn(), ShuttleGuiBase::StartTwoColumn(), and ShuttleGuiBase::StartVerticalLay().

322 : wxDialogWrapper(parent, wxID_ANY, _("Import Raw Data"),
323  wxDefaultPosition, wxDefaultSize,
324  wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER),
325  mEncoding(encoding),
326  mChannels(channels),
327  mOffset(offset),
328  mRate(rate)
329 {
330  wxASSERT(channels >= 1);
331 
332  SetName(GetTitle());
333 
334  ShuttleGui S(this, eIsCreating);
335  wxArrayString encodings;
336  wxArrayString endians;
337  wxArrayString chans;
338  int num;
339  int selection;
340  int endian;
341  int i;
342 
343  num = sf_num_encodings();
344  mNumEncodings = 0;
345  mEncodingSubtype.reinit(static_cast<size_t>(num));
346 
347  selection = 0;
348  for (i=0; i<num; i++) {
349  SF_INFO info;
350 
351  memset(&info, 0, sizeof(SF_INFO));
352 
353  int subtype = sf_encoding_index_to_subtype(i);
354  info.format = SF_FORMAT_RAW + SF_ENDIAN_LITTLE + subtype;
355  info.channels = 1;
356  info.samplerate = 44100;
357 
358  if (sf_format_check(&info)) {
359  mEncodingSubtype[mNumEncodings] = subtype;
360  encodings.Add(sf_encoding_index_name(i));
361 
362  if ((mEncoding & SF_FORMAT_SUBMASK) == subtype)
363  selection = mNumEncodings;
364 
365  mNumEncodings++;
366  }
367  }
368 
369  /* i18n-hint: Refers to byte-order. Don't translate "endianness" if you don't
370  know the correct technical word. */
371  endians.Add(_("No endianness"));
372  /* i18n-hint: Refers to byte-order. Don't translate this if you don't
373  know the correct technical word. */
374  endians.Add(_("Little-endian"));
375  /* i18n-hint: Refers to byte-order. Don't translate this if you don't
376  know the correct technical word. */
377  endians.Add(_("Big-endian"));
378  /* i18n-hint: Refers to byte-order. Don't translate "endianness" if you don't
379  know the correct technical word. */
380  endians.Add(_("Default endianness"));
381 
382  switch (mEncoding & (SF_FORMAT_ENDMASK))
383  {
384  default:
385  case SF_ENDIAN_FILE:
386  endian = 0;
387  break;
388  case SF_ENDIAN_LITTLE:
389  endian = 1;
390  break;
391  case SF_ENDIAN_BIG:
392  endian = 2;
393  break;
394  case SF_ENDIAN_CPU:
395  endian = 3;
396  break;
397  }
398 
399  chans.Add(_("1 Channel (Mono)"));
400  chans.Add(_("2 Channels (Stereo)"));
401  for (i=2; i<16; i++) {
402  chans.Add(wxString::Format(_("%d Channels"), i + 1));
403  }
404 
405  S.StartVerticalLay(false);
406  {
407  S.SetBorder(5);
408  S.StartTwoColumn();
409  {
410  mEncodingChoice = S.Id(ChoiceID).AddChoice(_("Encoding:"),
411  encodings[selection],
412  &encodings);
413  mEndianChoice = S.Id(ChoiceID).AddChoice(_("Byte order:"),
414  endians[endian],
415  &endians);
416  mChannelChoice = S.Id(ChoiceID).AddChoice(_("Channels:"),
417  chans[mChannels-1],
418  &chans);
419  }
420  S.EndTwoColumn();
421 
422  S.SetBorder(5);
423  S.StartMultiColumn(3);
424  {
425  // Offset text
426  /* i18n-hint: (noun)*/
427  mOffsetText = S.AddTextBox(_("Start offset:"),
428  wxString::Format(wxT("%d"), mOffset),
429  12);
430  S.AddUnits(_("bytes"));
431 
432  // Percent text
433  mPercentText = S.AddTextBox(_("Amount to import:"),
434  wxT("100"),
435  12);
436  S.AddUnits(_("%"));
437 
438  // Rate text
439  /* i18n-hint: (noun)*/
440  mRateText = S.AddTextBox(_("Sample rate:"),
441  wxString::Format(wxT("%d"), (int)mRate),
442  12);
443  /* i18n-hint: This is the abbreviation for "Hertz", or
444  cycles per second. */
445  S.AddUnits(_("Hz"));
446  }
447  S.EndMultiColumn();
448 
449  //
450  // Preview Pane goes here
451  //
452 
453  S.AddStandardButtons();
454  // Find the OK button, and change its text to 'Import'.
455  // We MUST set mOK because it is used later.
456  mOK = (wxButton *)wxWindow::FindWindowById(wxID_OK, this);
457  mOK->SetLabel(_("&Import"));
458  }
459  S.EndVerticalLay();
460 
461  Fit();
462  SetSizeHints(GetSize());
463 
464  Centre(wxBOTH);
465 }
wxString sf_encoding_index_name(int i)
Get the string name of the data encoding of the requested format.
Definition: FileFormats.cpp:84
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:409
wxChoice * mEndianChoice
Definition: ImportRaw.cpp:86
wxTextCtrl * mRateText
Definition: ImportRaw.cpp:90
void reinit(Integral count, bool initialize=false)
Definition: MemoryX.h:117
wxButton * mOK
Definition: ImportRaw.cpp:84
ArrayOf< int > mEncodingSubtype
Definition: ImportRaw.cpp:93
unsigned mChannels
Definition: ImportRaw.cpp:77
wxTextCtrl * mOffsetText
Definition: ImportRaw.cpp:88
int sf_num_encodings()
Get the number of data encodings libsndfile supports (in any container or none.
Definition: FileFormats.cpp:75
wxChoice * mEncodingChoice
Definition: ImportRaw.cpp:85
unsigned int sf_encoding_index_to_subtype(int i)
Definition: FileFormats.cpp:95
wxChoice * mChannelChoice
Definition: ImportRaw.cpp:87
_("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
wxTextCtrl * mPercentText
Definition: ImportRaw.cpp:89
ImportRawDialog::~ImportRawDialog ( )

Definition at line 467 of file ImportRaw.cpp.

468 {
469 }

Member Function Documentation

void ImportRawDialog::OnCancel ( wxCommandEvent &  event)

Definition at line 500 of file ImportRaw.cpp.

501 {
502  EndModal(false);
503 }
void ImportRawDialog::OnChoice ( wxCommandEvent &  event)

Definition at line 509 of file ImportRaw.cpp.

References mChannelChoice, mEncoding, mEncodingChoice, mEncodingSubtype, mEndianChoice, and mOK.

510 {
511  SF_INFO info;
512 
513  memset(&info, 0, sizeof(SF_INFO));
514 
515  mEncoding = mEncodingSubtype[mEncodingChoice->GetSelection()];
516  mEncoding += (mEndianChoice->GetSelection() * 0x10000000);
517 
518  info.format = mEncoding | SF_FORMAT_RAW;
519  info.channels = mChannelChoice->GetSelection() + 1;
520  info.samplerate = 44100;
521 
522  //mOK = (wxButton *)wxWindow::FindWindowById(wxID_OK, this);
523  if (sf_format_check(&info)) {
524  mOK->Enable(true);
525  return;
526  }
527 
528  // Try it with 1-channel
529  info.channels = 1;
530  if (sf_format_check(&info)) {
531  mChannelChoice->SetSelection(0);
532  mOK->Enable(true);
533  return;
534  }
535 
536  // Otherwise, this is an unsupported format
537  mOK->Enable(false);
538 }
wxChoice * mEndianChoice
Definition: ImportRaw.cpp:86
wxButton * mOK
Definition: ImportRaw.cpp:84
ArrayOf< int > mEncodingSubtype
Definition: ImportRaw.cpp:93
wxChoice * mEncodingChoice
Definition: ImportRaw.cpp:85
wxChoice * mChannelChoice
Definition: ImportRaw.cpp:87
void ImportRawDialog::OnOK ( wxCommandEvent &  event)

Definition at line 471 of file ImportRaw.cpp.

References mChannelChoice, mChannels, mEncoding, mEncodingChoice, mEncodingSubtype, mEndianChoice, mOffset, mOffsetText, mPercent, mPercentText, mRate, and mRateText.

472 {
473  long l;
474 
475  mEncoding = mEncodingSubtype[mEncodingChoice->GetSelection()];
476  mEncoding += (mEndianChoice->GetSelection() * 0x10000000);
477  mChannels = mChannelChoice->GetSelection() + 1;
478  mOffsetText->GetValue().ToLong(&l);
479  mOffset = l;
480  mPercentText->GetValue().ToDouble(&mPercent);
481  mRateText->GetValue().ToDouble(&mRate);
482 
483  if (mChannels < 1 || mChannels > 16)
484  mChannels = 1;
485  if (mOffset < 0)
486  mOffset = 0;
487  if (mPercent < 0.0)
488  mPercent = 0.0;
489  if (mPercent > 100.0)
490  mPercent = 100.0;
491  if (mRate < 100.0)
492  mRate = 100.0;
493  // Highest preset sample rate supported in Audacity 2.3.0 is 384 kHz
494  if (mRate > 384000.0)
495  mRate = 384000.0;
496 
497  EndModal(true);
498 }
wxChoice * mEndianChoice
Definition: ImportRaw.cpp:86
wxTextCtrl * mRateText
Definition: ImportRaw.cpp:90
ArrayOf< int > mEncodingSubtype
Definition: ImportRaw.cpp:93
unsigned mChannels
Definition: ImportRaw.cpp:77
wxTextCtrl * mOffsetText
Definition: ImportRaw.cpp:88
wxChoice * mEncodingChoice
Definition: ImportRaw.cpp:85
wxChoice * mChannelChoice
Definition: ImportRaw.cpp:87
wxTextCtrl * mPercentText
Definition: ImportRaw.cpp:89
void ImportRawDialog::OnPlay ( wxCommandEvent &  event)

Definition at line 505 of file ImportRaw.cpp.

506 {
507 }

Member Data Documentation

wxChoice* ImportRawDialog::mChannelChoice
private

Definition at line 87 of file ImportRaw.cpp.

Referenced by OnChoice(), and OnOK().

unsigned ImportRawDialog::mChannels

Definition at line 77 of file ImportRaw.cpp.

Referenced by ImportRaw(), and OnOK().

int ImportRawDialog::mEncoding

Definition at line 76 of file ImportRaw.cpp.

Referenced by ImportRaw(), OnChoice(), and OnOK().

wxChoice* ImportRawDialog::mEncodingChoice
private

Definition at line 85 of file ImportRaw.cpp.

Referenced by OnChoice(), and OnOK().

ArrayOf<int> ImportRawDialog::mEncodingSubtype
private

Definition at line 93 of file ImportRaw.cpp.

Referenced by OnChoice(), and OnOK().

wxChoice* ImportRawDialog::mEndianChoice
private

Definition at line 86 of file ImportRaw.cpp.

Referenced by OnChoice(), and OnOK().

int ImportRawDialog::mNumEncodings
private

Definition at line 92 of file ImportRaw.cpp.

int ImportRawDialog::mOffset

Definition at line 78 of file ImportRaw.cpp.

Referenced by ImportRaw(), and OnOK().

wxTextCtrl* ImportRawDialog::mOffsetText
private

Definition at line 88 of file ImportRaw.cpp.

Referenced by OnOK().

wxButton* ImportRawDialog::mOK
private

Definition at line 84 of file ImportRaw.cpp.

Referenced by OnChoice().

double ImportRawDialog::mPercent

Definition at line 80 of file ImportRaw.cpp.

Referenced by ImportRaw(), and OnOK().

wxTextCtrl* ImportRawDialog::mPercentText
private

Definition at line 89 of file ImportRaw.cpp.

Referenced by OnOK().

double ImportRawDialog::mRate

Definition at line 79 of file ImportRaw.cpp.

Referenced by ImportRaw(), and OnOK().

wxTextCtrl* ImportRawDialog::mRateText
private

Definition at line 90 of file ImportRaw.cpp.

Referenced by OnOK().


The documentation for this class was generated from the following file: