mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-26 09:28:07 +02:00
... Doing the widening as needed to match Quality preference. Fewer direct dependencies on QualityPrefs.h. FLAC and OGG may import as float where before it was 24 bits; only 16 bits or float. This makes them behave consistently with Raw and PCM.
56 lines
1.4 KiB
C++
56 lines
1.4 KiB
C++
/**********************************************************************
|
|
|
|
Audacity: A Digital Audio Editor
|
|
|
|
ImportPlugin.cpp
|
|
|
|
Paul Licameli split from Import.cpp
|
|
|
|
**********************************************************************/
|
|
|
|
#include "ImportPlugin.h"
|
|
|
|
#include <wx/filename.h>
|
|
#include "../WaveTrack.h"
|
|
#include "../widgets/ProgressDialog.h"
|
|
#include "../prefs/QualityPrefs.h"
|
|
|
|
ImportFileHandle::ImportFileHandle(const FilePath & filename)
|
|
: mFilename(filename)
|
|
{
|
|
}
|
|
|
|
ImportFileHandle::~ImportFileHandle()
|
|
{
|
|
}
|
|
|
|
void ImportFileHandle::CreateProgress()
|
|
{
|
|
wxFileName ff( mFilename );
|
|
|
|
auto title = XO("Importing %s").Format( GetFileDescription() );
|
|
mProgress = std::make_unique< ProgressDialog >(
|
|
title, Verbatim( ff.GetFullName() ) );
|
|
}
|
|
|
|
sampleFormat ImportFileHandle::ChooseFormat(sampleFormat effectiveFormat)
|
|
{
|
|
// Consult user preference
|
|
auto defaultFormat = QualityPrefs::SampleFormatChoice();
|
|
|
|
// Don't choose format narrower than effective or default
|
|
auto format = std::max(effectiveFormat, defaultFormat);
|
|
|
|
// But also always promote 24 bits to float
|
|
if (format > int16Sample)
|
|
format = floatSample;
|
|
|
|
return format;
|
|
}
|
|
|
|
std::shared_ptr<WaveTrack> ImportFileHandle::NewWaveTrack(
|
|
WaveTrackFactory &trackFactory, sampleFormat effectiveFormat, double rate)
|
|
{
|
|
return trackFactory.NewWaveTrack(ChooseFormat(effectiveFormat), rate);
|
|
}
|