19#include <vorbis/vorbisenc.h>
68 value = mQualityUnscaled;
74 if(
auto num = std::get_if<int>(&value))
76 mQualityUnscaled = *num;
89 mQualityUnscaled = config.
Read(
wxT(
"/FileFormats/OggExportQuality"),50)/10;
94 config.
Write(
wxT(
"/FileFormats/OggExportQuality"), mQualityUnscaled * 10);
100#define SAMPLES_PER_RUN 8192u
132 double t0,
double t1,
bool selectedOnly,
135 const Tags* tags)
override;
152 std::unique_ptr<ExportOptionsEditor>
168 wxT(
"OGG"),
XO(
"Ogg Vorbis Files"), {
wxT(
"ogg") }, 255,
true
175 ogg_stream_clear(&
context.stream);
179 vorbis_comment_clear(&
context.comment);
180 vorbis_block_clear(&
context.block);
181 vorbis_dsp_clear(&
context.dsp);
184 vorbis_info_clear(&
context.info);
191 double t0,
double t1,
bool selectionOnly,
194 const Tags* metadata)
209 vorbis_info_init(&
context.info);
218 if (!
context.outFile->IsOpened()) {
225 if (!
context.analysis_state_ok) {
236 context.stream_ok = ogg_stream_init(&
context.stream, rand()) == 0;
249 ogg_packet bitstream_header;
250 ogg_packet comment_header;
251 ogg_packet codebook_header;
253 if(vorbis_analysis_headerout(&
context.dsp, &
context.comment, &bitstream_header, &comment_header,
256 ogg_stream_packetin(&
context.stream, &bitstream_header) ||
257 ogg_stream_packetin(&
context.stream, &comment_header) ||
258 ogg_stream_packetin(&
context.stream, &codebook_header)) {
276 ?
XO(
"Exporting the selected audio as Ogg Vorbis")
277 :
XO(
"Exporting the audio as Ogg Vorbis");
291 auto samplesThisRun =
context.mixer->Process();
293 if (samplesThisRun == 0) {
295 err = vorbis_analysis_wrote(&
context.dsp, 0);
299 for (
size_t i = 0; i <
context.numChannels; i++) {
300 float *temp = (
float *)
context.mixer->GetBuffer(i);
305 err = vorbis_analysis_wrote(&
context.dsp, samplesThisRun);
314 while (!err && vorbis_analysis_blockout(&
context.dsp, &
context.block) == 1) {
317 err = vorbis_analysis(&
context.block, NULL);
319 err = vorbis_bitrate_addblock(&
context.block);
321 while (!err && vorbis_bitrate_flushpacket(&
context.dsp, &
context.packet)) {
330 while (!err && !eos) {
342 if (ogg_page_eos(&
context.page)) {
358 if ( !
context.outFile->Close() ) {
367std::unique_ptr<ExportOptionsEditor>
370 return std::make_unique<ExportOptionOGGEditor>();
375 return std::make_unique<OGGExportProcessor>();
382 if (metadata == NULL)
388 for (
const auto &pair : metadata->
GetRange()) {
390 const auto &v = pair.second;
394 vorbis_comment_add_tag(
comment,
395 (
char *) (
const char *) n.mb_str(wxConvUTF8),
396 (
char *) (
const char *) v.mb_str(wxConvUTF8));
401 []{
return std::make_unique< ExportOGG >(); }
static ExportPluginRegistry::RegisteredPlugin sRegisteredPlugin
std::variant< bool, int, double, std::string > ExportValue
A type of option values (parameters) used by exporting plugins.
declares abstract base class Track, TrackList, and iterators over TrackList
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
FormatInfo GetFormatInfo(int) const override
Returns FormatInfo structure for given index if it's valid, or a default one. FormatInfo::format isn'...
std::unique_ptr< ExportOptionsEditor > CreateOptionsEditor(int, ExportOptionsEditor::Listener *) const override
Creates format-dependent options editor, that is used to create a valid set of parameters to be used ...
int GetFormatCount() const override
std::unique_ptr< ExportProcessor > CreateProcessor(int format) const override
Listener object that is used to report on option changes.
Editor objects are used to retrieve a set of export options, and configure exporting parameters accor...
std::vector< int > SampleRateList
static T GetParameterValue(const ExportProcessor::Parameters ¶meters, int id, T defaultValue=T())
static ExportResult UpdateProgress(ExportProcessorDelegate &delegate, Mixer &mixer, double t0, double t1)
Sends progress update to delegate and retrieves state update from it. Typically used inside each expo...
static std::unique_ptr< Mixer > CreateMixer(const AudacityProject &project, bool selectionOnly, double startTime, double stopTime, unsigned numOutChannels, size_t outBufferSize, bool outInterleaved, double outRate, sampleFormat outFormat, MixerOptions::Downmix *mixerSpec)
virtual void SetStatusString(const TranslatableString &str)=0
std::vector< std::tuple< ExportOptionID, ExportValue > > Parameters
A matrix of booleans, one row per input channel, column per output.
~OGGExportProcessor() override
struct OGGExportProcessor::@177 context
std::unique_ptr< Mixer > mixer
static void FillComment(AudacityProject *project, vorbis_comment *comment, const Tags *metadata)
ExportResult Process(ExportProcessorDelegate &delegate) override
bool Initialize(AudacityProject &project, const Parameters ¶meters, const wxFileNameWrapper &filename, double t0, double t1, bool selectedOnly, double sampleRate, unsigned channels, MixerOptions::Downmix *mixerSpec, const Tags *tags) override
Called before start processing.
TranslatableString status
std::unique_ptr< FileIO > outFile
Holds a msgid for the translation catalog; may also bind format arguments.
bool GetOption(int, ExportOption &option) const override
bool GetValue(ExportOptionID, ExportValue &value) const override
void Store(audacity::BasicSettings &config) const override
int GetOptionsCount() const override
SampleRateList GetSampleRateList() const override
bool SetValue(ExportOptionID, const ExportValue &value) override
void Load(const audacity::BasicSettings &config) override
Base class for objects that provide facility to store data persistently, and access it with string ke...
virtual bool Write(const wxString &key, bool value)=0
virtual bool Read(const wxString &key, bool *value) const =0
constexpr auto sampleRate
const ExportOption OGGQualityOption
A type that provides a description of an exporting option. Isn't allowed to change except non-type re...
@ TypeRange
Range option. values holds [min, max].
ExportValue defaultValue
Default valid value for the parameter.