MCPcopy Create free account
hub / github.com/audacity/audacity / Initialize

Method Initialize

modules/import-export/mod-pcm/ExportPCM.cpp:536–687  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

534
535
536bool PCMExportProcessor::Initialize(AudacityProject& project,
537 const Parameters& parameters,
538 const wxFileNameWrapper& fName,
539 double t0, double t1, bool selectionOnly,
540 double sampleRate, unsigned numChannels,
541 MixerOptions::Downmix* mixerSpec,
542 const Tags* metadata)
543{
544 context.t0 = t0;
545 context.t1 = t1;
546 context.fName = fName;
547
548 // Set a default in case the settings aren't found
549 int& sf_format = context.sf_format;
550
551 switch (context.subformat)
552 {
553#if defined(__WXMAC__)
554 case FMT_AIFF:
555 sf_format = SF_FORMAT_AIFF;
556 break;
557#endif
558
559 case FMT_WAV:
560 sf_format = SF_FORMAT_WAV;
561 break;
562
563 default:
564 // Retrieve the current format.
565 sf_format = ExportPluginHelpers::GetParameterValue(parameters, OptionIDSFType, 0);
566 break;
567 }
568
569 sf_format |= ExportPluginHelpers::GetParameterValue(parameters, sf_format, 0);
570
571 // If subtype is still not specified, supply a default.
572 if (!(sf_format & SF_FORMAT_SUBMASK))
573 {
574 sf_format |= SF_FORMAT_PCM_16;
575 }
576
577 int& fileFormat = context.fileFormat;
578 fileFormat = sf_format & SF_FORMAT_TYPEMASK;
579
580 {
581 wxFile &f = context.f;
582 SNDFILE* &sf = context.sf;
583
584 wxString formatStr;
585 SF_INFO &info = context.info;
586 //int err;
587
588 //This whole operation should not occur while a file is being loaded on OD,
589 //(we are worried about reading from a file being written to,) so we block.
590 //Furthermore, we need to do this because libsndfile is not threadsafe.
591 formatStr = SFCall<wxString>(sf_header_name, fileFormat);
592
593 // Use libsndfile to export file

Callers

nothing calls this directly

Calls 6

GetParameterValueFunction · 0.85
sf_subtype_is_integerFunction · 0.85
GetFunction · 0.85
OpenMethod · 0.45

Tested by

no test coverage detected