mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-01 16:19:43 +02:00
Redo format setting choices in Quality preferences
This commit is contained in:
parent
293f22db37
commit
2ea5741e2e
@ -184,12 +184,12 @@ inline size_t limitSampleBufferSize( size_t bufferSize, sampleCount limit )
|
||||
// ----------------------------------------------------------------------------
|
||||
// Supported sample formats
|
||||
// ----------------------------------------------------------------------------
|
||||
typedef enum
|
||||
enum sampleFormat : unsigned
|
||||
{
|
||||
int16Sample = 0x00020001,
|
||||
int24Sample = 0x00040001,
|
||||
floatSample = 0x0004000F
|
||||
} sampleFormat;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Provide the number of bytes a specific sample will take
|
||||
|
@ -447,6 +447,7 @@ TimeTrack and AudioIOListener and whether the playback is looped.
|
||||
#include "WaveTrack.h"
|
||||
#include "AutoRecovery.h"
|
||||
|
||||
#include "prefs/QualityPrefs.h"
|
||||
#include "toolbars/ControlToolBar.h"
|
||||
#include "widgets/Meter.h"
|
||||
#include "widgets/ErrorDialog.h"
|
||||
@ -1825,8 +1826,7 @@ void AudioIO::StartMonitoring(double sampleRate)
|
||||
|
||||
bool success;
|
||||
long captureChannels;
|
||||
sampleFormat captureFormat = (sampleFormat)
|
||||
gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleFormat"), floatSample);
|
||||
auto captureFormat = QualityPrefs::SampleFormatChoice();
|
||||
gPrefs->Read(wxT("/AudioIO/RecordChannels"), &captureChannels, 2L);
|
||||
gPrefs->Read(wxT("/AudioIO/SWPlaythrough"), &mSoftwarePlaythrough, false);
|
||||
int playbackChannels = 0;
|
||||
|
@ -166,6 +166,8 @@ scroll information. It also has some status flags.
|
||||
#include "commands/CommandType.h"
|
||||
#include "commands/CommandContext.h"
|
||||
|
||||
#include "prefs/QualityPrefs.h"
|
||||
|
||||
#include "../images/AudacityLogoAlpha.xpm"
|
||||
|
||||
std::shared_ptr<TrackList> AudacityProject::msClipboard{ TrackList::Create() };
|
||||
@ -917,8 +919,7 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id,
|
||||
mViewInfo(0.0, 1.0, ZoomInfo::GetDefaultZoom()),
|
||||
mbLoadedFromAup( false ),
|
||||
mRate((double) gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleRate"), AudioIO::GetOptimalSupportedSampleRate())),
|
||||
mDefaultFormat((sampleFormat) gPrefs->
|
||||
Read(wxT("/SamplingRate/DefaultProjectSampleFormat"), floatSample)),
|
||||
mDefaultFormat(QualityPrefs::SampleFormatChoice()),
|
||||
mSnapTo(gPrefs->Read(wxT("/SnapTo"), SNAP_OFF)),
|
||||
mSelectionFormat(gPrefs->Read(wxT("/SelectionFormat"), wxT(""))),
|
||||
mFrequencySelectionFormatName(gPrefs->Read(wxT("/FrequencySelectionFormatName"), wxT(""))),
|
||||
@ -1305,7 +1306,7 @@ void AudacityProject::UpdatePrefsVariables()
|
||||
// gPrefs->Read(wxT("/GUI/UpdateSpectrogram"), &mViewInfo.bUpdateSpectrogram, true);
|
||||
|
||||
gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleRate"), &mRate, AudioIO::GetOptimalSupportedSampleRate());
|
||||
mDefaultFormat = (sampleFormat) gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleFormat"), floatSample);
|
||||
mDefaultFormat = QualityPrefs::SampleFormatChoice();
|
||||
|
||||
gPrefs->Read(wxT("/AudioIO/SeekShortPeriod"), &mSeekShort, 1.0);
|
||||
gPrefs->Read(wxT("/AudioIO/SeekLongPeriod"), &mSeekLong, 15.0);
|
||||
@ -5887,8 +5888,7 @@ wxString AudacityProject::GetHoursMinsString(int iMinutes)
|
||||
int AudacityProject::GetEstimatedRecordingMinsLeftOnDisk(long lCaptureChannels) {
|
||||
|
||||
// Obtain the current settings
|
||||
sampleFormat oCaptureFormat = (sampleFormat)
|
||||
gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleFormat"), floatSample);
|
||||
auto oCaptureFormat = QualityPrefs::SampleFormatChoice();
|
||||
if (lCaptureChannels == 0) {
|
||||
gPrefs->Read(wxT("/AudioIO/RecordChannels"), &lCaptureChannels, 2L);
|
||||
}
|
||||
|
@ -1040,7 +1040,7 @@ void Sequence::WriteXML(XMLWriter &xmlFile) const
|
||||
xmlFile.StartTag(wxT("sequence"));
|
||||
|
||||
xmlFile.WriteAttr(wxT("maxsamples"), mMaxSamples);
|
||||
xmlFile.WriteAttr(wxT("sampleformat"), mSampleFormat);
|
||||
xmlFile.WriteAttr(wxT("sampleformat"), (size_t)mSampleFormat);
|
||||
xmlFile.WriteAttr(wxT("numsamples"), mNumSamples.as_long_long() );
|
||||
|
||||
for (b = 0; b < mBlock.size(); b++) {
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "ImportPlugin.h"
|
||||
|
||||
#include "../Tags.h"
|
||||
#include "../prefs/QualityPrefs.h"
|
||||
|
||||
#include "../Experimental.h"
|
||||
|
||||
@ -350,8 +351,7 @@ FLACImportFileHandle::FLACImportFileHandle(const wxString & name)
|
||||
mStreamInfoDone(false),
|
||||
mUpdateResult(ProgressResult::Success)
|
||||
{
|
||||
mFormat = (sampleFormat)
|
||||
gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleFormat"), floatSample);
|
||||
mFormat = QualityPrefs::SampleFormatChoice();
|
||||
mFile = std::make_unique<MyFLACFile>(this);
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "ImportPlugin.h"
|
||||
#include "../Internat.h"
|
||||
#include "../Tags.h"
|
||||
#include "../prefs/QualityPrefs.h"
|
||||
|
||||
#define DESC _("MP3 files")
|
||||
|
||||
@ -498,8 +499,7 @@ enum mad_flow output_cb(void *_data,
|
||||
if(data->channels.empty()) {
|
||||
data->channels.resize(channels);
|
||||
|
||||
sampleFormat format = (sampleFormat) gPrefs->
|
||||
Read(wxT("/SamplingRate/DefaultProjectSampleFormat"), floatSample);
|
||||
auto format = QualityPrefs::SampleFormatChoice();
|
||||
|
||||
for(auto &channel: data->channels) {
|
||||
channel = data->trackFactory->NewWaveTrack(format, samplerate);
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "../Prefs.h"
|
||||
#include "../Internat.h"
|
||||
#include "../Tags.h"
|
||||
#include "../prefs/QualityPrefs.h"
|
||||
|
||||
|
||||
#define DESC _("Ogg Vorbis files")
|
||||
@ -108,8 +109,7 @@ public:
|
||||
mVorbisFile(std::move(vorbisFile))
|
||||
, mStreamUsage{ static_cast<size_t>(mVorbisFile->links) }
|
||||
{
|
||||
mFormat = (sampleFormat)
|
||||
gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleFormat"), floatSample);
|
||||
mFormat = QualityPrefs::SampleFormatChoice();
|
||||
|
||||
for (int i = 0; i < mVorbisFile->links; i++)
|
||||
{
|
||||
|
@ -38,6 +38,7 @@
|
||||
|
||||
#include "../ondemand/ODManager.h"
|
||||
#include "../ondemand/ODComputeSummaryTask.h"
|
||||
#include "../prefs/QualityPrefs.h"
|
||||
|
||||
//If OD is enabled, he minimum number of samples a file has to use it.
|
||||
//Otherwise, we use the older PCMAliasBlockFile method since it should be fast enough.
|
||||
@ -204,8 +205,7 @@ PCMImportFileHandle::PCMImportFileHandle(wxString name,
|
||||
// the quality of the original file.
|
||||
//
|
||||
|
||||
mFormat = (sampleFormat)
|
||||
gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleFormat"), floatSample);
|
||||
mFormat = QualityPrefs::SampleFormatChoice();
|
||||
|
||||
if (mFormat != floatSample &&
|
||||
sf_subtype_more_than_16_bits(mInfo.format))
|
||||
|
@ -34,6 +34,7 @@ and sample size to help you importing data of an unknown format.
|
||||
#include "../ShuttleGui.h"
|
||||
#include "../UserException.h"
|
||||
#include "../WaveTrack.h"
|
||||
#include "../prefs/QualityPrefs.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
@ -193,8 +194,7 @@ void ImportRaw(wxWindow *parent, const wxString &fileName,
|
||||
// the quality of the original file.
|
||||
//
|
||||
|
||||
format = (sampleFormat)
|
||||
gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleFormat"), floatSample);
|
||||
format = QualityPrefs::SampleFormatChoice();
|
||||
|
||||
if (format != floatSample &&
|
||||
sf_subtype_more_than_16_bits(encoding))
|
||||
|
@ -225,8 +225,7 @@ bool ODFlacDecoder::ReadHeader()
|
||||
{
|
||||
mFormat = int16Sample;//start with the smallest and move up in the metadata_callback.
|
||||
//we want to use the native flac type for quick conversion.
|
||||
/* (sampleFormat)
|
||||
gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleFormat"), floatSample);*/
|
||||
/* QualityPrefs::SampleFormatChoice(); */
|
||||
mFile = std::make_unique<ODFLACFile>(this);
|
||||
|
||||
|
||||
|
@ -30,6 +30,33 @@
|
||||
|
||||
#define ID_SAMPLE_RATE_CHOICE 7001
|
||||
|
||||
//////////
|
||||
|
||||
static const IdentInterfaceSymbol choicesFormat[] = {
|
||||
{ wxT("Format16Bit"), XO("16-bit") },
|
||||
{ wxT("Format24Bit"), XO("24-bit") },
|
||||
{ wxT("Format32BitFloat"), XO("32-bit float") }
|
||||
};
|
||||
static const size_t nChoicesFormat = WXSIZEOF( choicesFormat );
|
||||
static const int intChoicesFormat[] = {
|
||||
int16Sample,
|
||||
int24Sample,
|
||||
floatSample
|
||||
};
|
||||
static_assert( nChoicesFormat == WXSIZEOF(intChoicesFormat), "size mismatch" );
|
||||
|
||||
static const size_t defaultChoiceFormat = 2; // floatSample
|
||||
|
||||
static EncodedEnumSetting formatSetting{
|
||||
wxT("/SamplingRate/DefaultProjectSampleFormatChoice"),
|
||||
choicesFormat, nChoicesFormat, defaultChoiceFormat,
|
||||
|
||||
intChoicesFormat,
|
||||
wxT("/SamplingRate/DefaultProjectSampleFormat"),
|
||||
};
|
||||
|
||||
//////////
|
||||
|
||||
BEGIN_EVENT_TABLE(QualityPrefs, PrefsPanel)
|
||||
EVT_CHOICE(ID_SAMPLE_RATE_CHOICE, QualityPrefs::OnSampleRateChoice)
|
||||
END_EVENT_TABLE()
|
||||
@ -102,11 +129,6 @@ void QualityPrefs::GetNamesAndLabels()
|
||||
// The label for the 'Other...' case can be any value at all.
|
||||
mSampleRateLabels.push_back(44100); // If chosen, this value will be overwritten
|
||||
|
||||
//------------- Sample Format Names
|
||||
mSampleFormatNames.Add(wxT("16-bit")); mSampleFormatLabels.push_back(int16Sample);
|
||||
mSampleFormatNames.Add(wxT("24-bit")); mSampleFormatLabels.push_back(int24Sample);
|
||||
mSampleFormatNames.Add(wxT("32-bit float")); mSampleFormatLabels.push_back(floatSample);
|
||||
|
||||
//------------- Converter Names
|
||||
int numConverters = Resample::GetNumMethods();
|
||||
for (int i = 0; i < numConverters; i++) {
|
||||
@ -149,10 +171,7 @@ void QualityPrefs::PopulateOrExchange(ShuttleGui & S)
|
||||
S.EndHorizontalLay();
|
||||
|
||||
S.TieChoice(_("Default Sample &Format:"),
|
||||
wxT("/SamplingRate/DefaultProjectSampleFormat"),
|
||||
floatSample,
|
||||
mSampleFormatNames,
|
||||
mSampleFormatLabels);
|
||||
formatSetting);
|
||||
}
|
||||
S.EndMultiColumn();
|
||||
}
|
||||
@ -239,3 +258,9 @@ PrefsPanel *QualityPrefsFactory::operator () (wxWindow *parent, wxWindowID winid
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew QualityPrefs(parent, winid);
|
||||
}
|
||||
|
||||
sampleFormat QualityPrefs::SampleFormatChoice()
|
||||
{
|
||||
return (sampleFormat)formatSetting.ReadInt();
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "PrefsPanel.h"
|
||||
|
||||
class ShuttleGui;
|
||||
enum sampleFormat : unsigned;
|
||||
|
||||
class QualityPrefs final : public PrefsPanel
|
||||
{
|
||||
@ -33,6 +34,8 @@ class QualityPrefs final : public PrefsPanel
|
||||
wxString HelpPageName() override;
|
||||
void PopulateOrExchange(ShuttleGui & S) override;
|
||||
|
||||
static sampleFormat SampleFormatChoice();
|
||||
|
||||
private:
|
||||
void Populate();
|
||||
void GetNamesAndLabels();
|
||||
@ -42,8 +45,6 @@ class QualityPrefs final : public PrefsPanel
|
||||
std::vector<int> mDitherLabels;
|
||||
wxArrayString mSampleRateNames;
|
||||
std::vector<int> mSampleRateLabels;
|
||||
wxArrayString mSampleFormatNames;
|
||||
std::vector<int> mSampleFormatLabels;
|
||||
wxArrayString mConverterNames;
|
||||
std::vector<int> mConverterLabels;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user