Audacity  2.2.2
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ExportPCMOptions Class Referencefinal
Inheritance diagram for ExportPCMOptions:
wxPanelWrapper wxTabTraversalWrapper< wxPanel >

Public Member Functions

 ExportPCMOptions (wxWindow *parent, int format)
 
virtual ~ExportPCMOptions ()
 
void PopulateOrExchange (ShuttleGui &S)
 
bool TransferDataToWindow () override
 
bool TransferDataFromWindow () override
 
void OnHeaderChoice (wxCommandEvent &evt)
 
- Public Member Functions inherited from wxPanelWrapper
 wxPanelWrapper ()
 
 wxPanelWrapper (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const wxString &name=_("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const wxString &name=_("Panel"))
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&...args)
 

Private Member Functions

bool ValidatePair (int format)
 
int GetFormat ()
 

Private Attributes

wxArrayString mHeaderNames
 
wxArrayString mEncodingNames
 
wxChoice * mHeaderChoice
 
wxChoice * mEncodingChoice
 
int mHeaderFromChoice
 
int mEncodingFromChoice
 
std::vector< int > mEncodingFormats
 

Detailed Description

Definition at line 99 of file ExportPCM.cpp.

Constructor & Destructor Documentation

ExportPCMOptions::ExportPCMOptions ( wxWindow *  parent,
int  format 
)

Definition at line 134 of file ExportPCM.cpp.

References eIsCreatingFromPrefs, format, kFormats, ReadExportFormatPref(), sf_encoding_index_name(), sf_encoding_index_to_subtype(), sf_header_index_name(), sf_header_index_to_type(), sf_num_encodings(), and sf_num_headers().

135 : wxPanelWrapper(parent, wxID_ANY)
136 {
137  int format;
138 
139  if (selformat < 0 || static_cast<unsigned int>(selformat) >= WXSIZEOF(kFormats))
140  {
141  format = ReadExportFormatPref();
142  }
143  else
144  {
145  format = kFormats[selformat].format;
146  }
147 
148  mHeaderFromChoice = 0;
149  for (int i = 0, num = sf_num_headers(); i < num; i++) {
151  if ((format & SF_FORMAT_TYPEMASK) == (int)sf_header_index_to_type(i))
152  mHeaderFromChoice = i;
153  }
154 
156  for (int i = 0, sel = 0, num = sf_num_encodings(); i < num; i++) {
157  int enc = sf_encoding_index_to_subtype(i);
158  int fmt = (format & SF_FORMAT_TYPEMASK) | enc;
159  bool valid = ValidatePair(fmt);
160  if (valid)
161  {
163  mEncodingFormats.push_back(enc);
164  if ((format & SF_FORMAT_SUBMASK) == (int)sf_encoding_index_to_subtype(i))
165  mEncodingFromChoice = sel;
166  else
167  sel++;
168  }
169  }
170 
173 
176 }
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
wxString sf_header_index_name(int format)
Get the name of a container format from libsndfile.
Definition: FileFormats.cpp:47
wxArrayString mEncodingNames
Definition: ExportPCM.cpp:120
bool TransferDataFromWindow() override
Definition: ExportPCM.cpp:219
struct @41 kFormats[]
int format
Definition: ExportPCM.cpp:56
wxArrayString mHeaderNames
Definition: ExportPCM.cpp:119
int sf_num_encodings()
Get the number of data encodings libsndfile supports (in any container or none.
Definition: FileFormats.cpp:75
std::vector< int > mEncodingFormats
Definition: ExportPCM.cpp:125
void PopulateOrExchange(ShuttleGui &S)
Definition: ExportPCM.cpp:183
bool TransferDataToWindow() override
Definition: ExportPCM.cpp:212
unsigned int sf_encoding_index_to_subtype(int i)
Definition: FileFormats.cpp:95
bool ValidatePair(int format)
Definition: ExportPCM.cpp:297
static int ReadExportFormatPref()
Definition: ExportPCM.cpp:75
unsigned int sf_header_index_to_type(int i)
Definition: FileFormats.cpp:59
int sf_num_headers()
Get the number of container formats supported by libsndfile.
Definition: FileFormats.cpp:37
ExportPCMOptions::~ExportPCMOptions ( )
virtual

Definition at line 178 of file ExportPCM.cpp.

References TransferDataFromWindow().

179 {
181 }
bool TransferDataFromWindow() override
Definition: ExportPCM.cpp:219

Member Function Documentation

int ExportPCMOptions::GetFormat ( )
private

Definition at line 285 of file ExportPCM.cpp.

References mEncodingChoice, mEncodingFormats, mHeaderChoice, and sf_header_index_to_type().

Referenced by OnHeaderChoice(), and TransferDataFromWindow().

286 {
287  int hdr = sf_header_index_to_type(mHeaderChoice->GetSelection());
288  int sel = mEncodingChoice->GetSelection();
289  int enc = mEncodingFormats[sel];
290  return hdr | enc;
291 }
wxChoice * mEncodingChoice
Definition: ExportPCM.cpp:122
std::vector< int > mEncodingFormats
Definition: ExportPCM.cpp:125
wxChoice * mHeaderChoice
Definition: ExportPCM.cpp:121
unsigned int sf_header_index_to_type(int i)
Definition: FileFormats.cpp:59
void ExportPCMOptions::OnHeaderChoice ( wxCommandEvent &  evt)

Definition at line 231 of file ExportPCM.cpp.

References format, GetFormat(), mEncodingChoice, mEncodingFormats, mEncodingFromChoice, mEncodingNames, mHeaderChoice, name, sf_encoding_index_name(), sf_encoding_index_to_subtype(), sf_header_index_to_type(), sf_num_encodings(), sf_num_simple_formats(), sf_simple_format(), TransferDataFromWindow(), and ValidatePair().

232 {
233  int format = sf_header_index_to_type(mHeaderChoice->GetSelection());
234  // Fix for Bug 1218 - AIFF with no option should default to 16 bit.
235  if( format == SF_FORMAT_AIFF )
236  format = SF_FORMAT_AIFF | SF_FORMAT_PCM_16;
237 
238  mEncodingNames.Clear();
239  mEncodingChoice->Clear();
240  mEncodingFormats.clear();
241  int sel = wxNOT_FOUND;
242  int i,j;
243 
244  int sfnum = sf_num_simple_formats();
245  std::vector<int> sfs;
246 
247  for (i = 0; i < sfnum; i++)
248  {
249  SF_FORMAT_INFO *fi = sf_simple_format(i);
250  sfs.push_back(fi->format);
251  }
252 
253  int num = sf_num_encodings();
254  for (i = 0; i < num; i++)
255  {
256  int enc = sf_encoding_index_to_subtype(i);
257  int fmt = format | enc;
258  bool valid = ValidatePair(fmt);
259  if (valid)
260  {
261  const auto name = sf_encoding_index_name(i);
262  mEncodingNames.Add(name);
263  mEncodingChoice->Append(name);
264  mEncodingFormats.push_back(enc);
265  for (j = 0; j < sfnum; j++)
266  {
267  int enc = sfs[j];
268  if ((sel == wxNOT_FOUND) && (fmt == enc))
269  {
270  sel = mEncodingFormats.size() - 1;
271  break;
272  }
273  }
274  }
275  }
276 
277  if (sel == wxNOT_FOUND) sel = 0;
278  mEncodingFromChoice = sel;
279  mEncodingChoice->SetSelection(sel);
281 
283 }
wxString sf_encoding_index_name(int i)
Get the string name of the data encoding of the requested format.
Definition: FileFormats.cpp:84
wxChoice * mEncodingChoice
Definition: ExportPCM.cpp:122
wxArrayString mEncodingNames
Definition: ExportPCM.cpp:120
SF_FORMAT_INFO * sf_simple_format(int i)
bool TransferDataFromWindow() override
Definition: ExportPCM.cpp:219
int format
Definition: ExportPCM.cpp:56
int sf_num_encodings()
Get the number of data encodings libsndfile supports (in any container or none.
Definition: FileFormats.cpp:75
std::vector< int > mEncodingFormats
Definition: ExportPCM.cpp:125
unsigned int sf_encoding_index_to_subtype(int i)
Definition: FileFormats.cpp:95
bool ValidatePair(int format)
Definition: ExportPCM.cpp:297
wxChoice * mHeaderChoice
Definition: ExportPCM.cpp:121
unsigned int sf_header_index_to_type(int i)
Definition: FileFormats.cpp:59
int sf_num_simple_formats()
const wxChar * name
Definition: ExportPCM.cpp:57
void ExportPCMOptions::PopulateOrExchange ( ShuttleGui S)

Definition at line 183 of file ExportPCM.cpp.

References _(), ShuttleGuiBase::AddChoice(), ShuttleGuiBase::EndHorizontalLay(), ShuttleGuiBase::EndMultiColumn(), ShuttleGuiBase::EndVerticalLay(), ShuttleGui::Id(), ID_ENCODING_CHOICE, ID_HEADER_CHOICE, mEncodingChoice, mEncodingFromChoice, mEncodingNames, mHeaderChoice, mHeaderFromChoice, mHeaderNames, ShuttleGuiBase::SetStretchyCol(), ShuttleGuiBase::StartHorizontalLay(), ShuttleGuiBase::StartMultiColumn(), and ShuttleGuiBase::StartVerticalLay().

Referenced by TransferDataFromWindow().

184 {
185  S.StartVerticalLay();
186  {
187  S.StartHorizontalLay(wxCENTER);
188  {
189  S.StartMultiColumn(2, wxCENTER);
190  {
191  S.SetStretchyCol(1);
193  .AddChoice(_("Header:"),
195  &mHeaderNames);
197  .AddChoice(_("Encoding:"),
199  &mEncodingNames);
200  }
201  S.EndMultiColumn();
202  }
203  S.EndHorizontalLay();
204  }
205  S.EndVerticalLay();
206 
207  return;
208 }
wxChoice * mEncodingChoice
Definition: ExportPCM.cpp:122
wxArrayString mEncodingNames
Definition: ExportPCM.cpp:120
void EndMultiColumn()
void EndHorizontalLay()
void EndVerticalLay()
wxArrayString mHeaderNames
Definition: ExportPCM.cpp:119
void StartHorizontalLay(int PositionFlags=wxALIGN_CENTRE, int iProp=1)
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
wxChoice * AddChoice(const wxString &Prompt, const wxString &Selected, const wxArrayString *pChoices)
Definition: ShuttleGui.cpp:371
ShuttleGui & Id(int id)
_("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
wxChoice * mHeaderChoice
Definition: ExportPCM.cpp:121
#define ID_HEADER_CHOICE
Definition: ExportPCM.cpp:96
#define ID_ENCODING_CHOICE
Definition: ExportPCM.cpp:97
void SetStretchyCol(int i)
Used to modify an already placed FlexGridSizer to make a column stretchy.
Definition: ShuttleGui.cpp:203
void StartVerticalLay(int iProp=1)
bool ExportPCMOptions::TransferDataFromWindow ( )
override

Definition at line 219 of file ExportPCM.cpp.

References eIsSavingToPrefs, GetFormat(), gPrefs, PopulateOrExchange(), and WriteExportFormatPref().

Referenced by OnHeaderChoice(), and ~ExportPCMOptions().

220 {
221  ShuttleGui S(this, eIsSavingToPrefs);
223 
224  gPrefs->Flush();
225 
227 
228  return true;
229 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
static void WriteExportFormatPref(int format)
Definition: ExportPCM.cpp:86
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:409
void PopulateOrExchange(ShuttleGui &S)
Definition: ExportPCM.cpp:183
bool ExportPCMOptions::TransferDataToWindow ( )
override

Definition at line 212 of file ExportPCM.cpp.

213 {
214  return true;
215 }
bool ExportPCMOptions::ValidatePair ( int  format)
private

Calls a libsndfile library function to determine whether the user's choice of sample encoding (e.g. pcm 16-bit or GSM 6.10 compression) is compatible with their choice of file format (e.g. WAV, AIFF) and enables/disables the OK button accordingly.

Definition at line 297 of file ExportPCM.cpp.

References format.

Referenced by OnHeaderChoice().

298 {
299  SF_INFO info;
300  memset(&info, 0, sizeof(info));
301  info.frames = 0;
302  info.samplerate = 44100;
303  info.channels = 1;
304  info.format = format;
305  info.sections = 1;
306  info.seekable = 0;
307 
308  return sf_format_check(&info) != 0 ? true : false;
309 }
int format
Definition: ExportPCM.cpp:56

Member Data Documentation

wxChoice* ExportPCMOptions::mEncodingChoice
private

Definition at line 122 of file ExportPCM.cpp.

Referenced by GetFormat(), OnHeaderChoice(), and PopulateOrExchange().

std::vector<int> ExportPCMOptions::mEncodingFormats
private

Definition at line 125 of file ExportPCM.cpp.

Referenced by GetFormat(), and OnHeaderChoice().

int ExportPCMOptions::mEncodingFromChoice
private

Definition at line 124 of file ExportPCM.cpp.

Referenced by OnHeaderChoice(), and PopulateOrExchange().

wxArrayString ExportPCMOptions::mEncodingNames
private

Definition at line 120 of file ExportPCM.cpp.

Referenced by OnHeaderChoice(), and PopulateOrExchange().

wxChoice* ExportPCMOptions::mHeaderChoice
private

Definition at line 121 of file ExportPCM.cpp.

Referenced by GetFormat(), OnHeaderChoice(), and PopulateOrExchange().

int ExportPCMOptions::mHeaderFromChoice
private

Definition at line 123 of file ExportPCM.cpp.

Referenced by PopulateOrExchange().

wxArrayString ExportPCMOptions::mHeaderNames
private

Definition at line 119 of file ExportPCM.cpp.

Referenced by PopulateOrExchange().


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