1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-03-18 12:16:40 +01:00
Files
audacity/src/Resample.cpp
Emily Mabrey 2f316d5bc4 Rename project in many places; Replace Most Project Logos; Refactor About Tenacity... Dialog (#276)
Add `locale/en.po` file.
Add English to `locale/LINGUAS` list.
Partially duplicate `msgid`s to `msgstr`s in English locale enable eventual key `msgid` changes
Replace former project name with Tenacity in English locale.
Replace former project website with Tenacity compatible usages in English locale.
Modify `AboutDialog.h` by renaming variables.
Modify `AboutDialog.cpp` by replacing usage of pre-fork name in Strings.
Modify AddBuildInfoRow methods to be static in About dialog.
Make License text const in About dialog.
Make pre-fork credits different in About dialog.
Begin adding Tenacity specific credits
Macros starting with `__` are reserved, so I removed the `__` on the About Dialog guard macro.
Remove `AboutDialog::` from usage of `Role` in `AboutDialog.h`
Refactor overly long generator method into separate methods in `AboutDialog.(h|cpp)`
Begin adding Tenacity developer information
Cleanup layout of `AboutDialog.h` and `AboutDialog.cpp`
Add `safedelete` macro to compliment odd `safenew` macro
Add `enum` to `ShuttleGui.cpp` to make it more clear what `Prop` method is doing.
Remove a ton of pointless and/or redunant `#ifdef` usage
Remove pointless singleton in AboutDialog
Make AboutDialog modal on MacOS
Fix reference type use of `auto` in `AudacityApp` b/c it makes unintentional copy.
Update XPM and PNG images using Tenacity assets
Update ICO images using Tenacity assets.
Fix Windows resource script that improperly used `winuser.h` import.
Add `*.aps` to gitignore to prevent IDE RC pre-load file from being committed.
Add default values for pre-processor constants in `tenacity.rc`.
Make changes needed for `Tenacity.exe` binary
Add 8x8 PNG to Windows ICO files
Replace project name in various CMake and CPack file.
Replace project name in various directory structures.
Replace project name in various OS-specific build files.
Replace project name in various documentation files.
Update the PO and POT files using the script.
Fix places where a `.desktop` file was used on Linux.
Replace title of project windows.
Make splash screen click through to `tenacityaudio.org`.
Remove ® from `AboutDialog.cpp`
Modify copyright message in `AboutDialog.cpp`

Signed-off-by: Emily Mabrey <emilymabrey93@gmail.com>
2021-07-20 19:46:29 -04:00

121 lines
3.2 KiB
C++

/**********************************************************************
Tenacity
Audacity(R) is copyright (c) 1999-2012 Audacity Team.
License: GPL v2. See License.txt.
Resample.cpp
Dominic Mazzoni, Rob Sykes, Vaughan Johnson
******************************************************************//**
\class Resample
\brief Interface to libsoxr.
This class abstracts the interface to different resampling libraries:
libsoxr, written by Rob Sykes. LGPL.
Since Audacity always does resampling on mono streams that are
contiguous in memory, this class doesn't support multiple channels
or some of the other optional features of some of these resamplers.
*//*******************************************************************/
#include "Resample.h"
#include "Prefs.h"
#include "Internat.h"
#include "../include/tenacity/ComponentInterface.h"
#include <soxr.h>
Resample::Resample(const bool useBestMethod, const double dMinFactor, const double dMaxFactor)
{
this->SetMethod(useBestMethod);
soxr_quality_spec_t q_spec;
if (dMinFactor == dMaxFactor)
{
mbWantConstRateResampling = true; // constant rate resampling
q_spec = soxr_quality_spec("\0\1\4\6"[mMethod], 0);
}
else
{
mbWantConstRateResampling = false; // variable rate resampling
q_spec = soxr_quality_spec(SOXR_HQ, SOXR_VR);
}
mHandle.reset(soxr_create(1, dMinFactor, 1, 0, 0, &q_spec, 0));
}
Resample::~Resample()
{
}
//////////
static const std::initializer_list<EnumValueSymbol> methodNames{
{ wxT("LowQuality"), XO("Low Quality (Fastest)") },
{ wxT("MediumQuality"), XO("Medium Quality") },
{ wxT("HighQuality"), XO("High Quality") },
{ wxT("BestQuality"), XO("Best Quality (Slowest)") }
};
static auto intChoicesMethod = {
0, 1, 2, 3
};
EnumSetting< int > Resample::FastMethodSetting{
wxT("/Quality/LibsoxrSampleRateConverterChoice"),
methodNames,
1, // Medium Quality
// for migrating old preferences:
intChoicesMethod,
wxT("/Quality/LibsoxrSampleRateConverter")
};
EnumSetting< int > Resample::BestMethodSetting
{
wxT("/Quality/LibsoxrHQSampleRateConverterChoice"),
methodNames,
3, // Best Quality,
// for migrating old preferences:
intChoicesMethod,
wxT("/Quality/LibsoxrHQSampleRateConverter")
};
//////////
std::pair<size_t, size_t>
Resample::Process(double factor,
float *inBuffer,
size_t inBufferLen,
bool lastFlag,
float *outBuffer,
size_t outBufferLen)
{
size_t idone, odone;
if (mbWantConstRateResampling)
{
soxr_process(mHandle.get(),
inBuffer , (lastFlag? ~inBufferLen : inBufferLen), &idone,
outBuffer, outBufferLen, &odone);
}
else
{
soxr_set_io_ratio(mHandle.get(), 1/factor, 0);
inBufferLen = lastFlag? ~inBufferLen : inBufferLen;
soxr_process(mHandle.get(),
inBuffer , inBufferLen , &idone,
outBuffer, outBufferLen, &odone);
}
return { idone, odone };
}
void Resample::SetMethod(const bool useBestMethod)
{
if (useBestMethod)
mMethod = BestMethodSetting.ReadEnum();
else
mMethod = FastMethodSetting.ReadEnum();
}