24#include <vorbis/vorbisenc.h>
81 S.StartHorizontalLay(wxEXPAND);
83 S.SetSizerProportion(1);
84 S.StartMultiColumn(2, wxCENTER);
121#define SAMPLES_PER_RUN 8192u
133 std::unique_ptr<BasicUI::ProgressDialog> &pDialog,
140 const Tags *metadata = NULL,
141 int subformat = 0)
override;
160 std::unique_ptr<BasicUI::ProgressDialog> &pDialog,
161 unsigned numChannels,
167 const Tags *metadata,
168 int WXUNUSED(subformat))
172 double quality = (
gPrefs->Read(
wxT(
"/FileFormats/OggExportQuality"), 50)/(float)100.0);
186 ogg_stream_state stream;
191 vorbis_comment comment;
192 vorbis_dsp_state dsp;
196 auto cleanup1 =
finally( [&] {
197 vorbis_info_clear(&info);
205 vorbis_info_init(&info);
206 if (vorbis_encode_init_vbr(&info, numChannels, (
int)(rate + 0.5), quality)) {
212 auto cleanup2 =
finally( [&] {
213 ogg_stream_clear(&stream);
215 vorbis_block_clear(&block);
216 vorbis_dsp_clear(&dsp);
217 vorbis_comment_clear(&comment);
227 if (vorbis_analysis_init(&dsp, &info) ||
228 vorbis_block_init(&dsp, &block)) {
237 if (ogg_stream_init(&stream, rand())) {
250 ogg_packet bitstream_header;
251 ogg_packet comment_header;
252 ogg_packet codebook_header;
254 if(vorbis_analysis_headerout(&dsp, &comment, &bitstream_header, &comment_header,
257 ogg_stream_packetin(&stream, &bitstream_header) ||
258 ogg_stream_packetin(&stream, &comment_header) ||
259 ogg_stream_packetin(&stream, &codebook_header)) {
266 while (ogg_stream_flush(&stream, &page)) {
267 if ( outFile.
Write(page.header, page.header_len).GetLastError() ||
268 outFile.
Write(page.body, page.body_len).GetLastError()) {
282 ?
XO(
"Exporting the selected audio as Ogg Vorbis")
283 :
XO(
"Exporting the audio as Ogg Vorbis") );
284 auto &progress = *pDialog;
288 auto samplesThisRun = mixer->Process();
290 if (samplesThisRun == 0) {
292 err = vorbis_analysis_wrote(&dsp, 0);
296 for (
size_t i = 0; i < numChannels; i++) {
297 float *temp = (
float *)mixer->GetBuffer(i);
302 err = vorbis_analysis_wrote(&dsp, samplesThisRun);
311 while (!err && vorbis_analysis_blockout(&dsp, &block) == 1) {
314 err = vorbis_analysis(&block, NULL);
316 err = vorbis_bitrate_addblock(&block);
318 while (!err && vorbis_bitrate_flushpacket(&dsp, &packet)) {
321 err = ogg_stream_packetin(&stream, &packet);
327 while (!err && !eos) {
328 int result = ogg_stream_pageout(&stream, &page);
333 if ( outFile.
Write(page.header, page.header_len).GetLastError() ||
334 outFile.
Write(page.body, page.body_len).GetLastError()) {
340 if (ogg_page_eos(&page)) {
354 updateResult = progress.Poll(mixer->MixGetCurrentTime() - t0, t1 - t0);
358 if ( !outFile.
Close() ) {
375 if (metadata == NULL)
378 vorbis_comment_init(comment);
381 for (
const auto &pair : metadata->
GetRange()) {
383 const auto &v = pair.second;
387 vorbis_comment_add_tag(comment,
388 (
char *) (
const char *) n.mb_str(wxConvUTF8),
389 (
char *) (
const char *) v.mb_str(wxConvUTF8));
396 []{
return std::make_unique< ExportOGG >(); }
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
void ShowExportErrorDialog(wxString ErrorCode, TranslatableString message, const TranslatableString &caption, bool allowReporting)
void ShowDiskFullExportErrorDialog(const wxFileNameWrapper &fileName)
static Exporter::RegisteredExportPlugin sRegisteredPlugin
XXO("&Cut/Copy/Paste Toolbar")
an object holding per-project preferred sample rate
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...
void OptionsCreate(ShuttleGui &S, int format) override
ProgressResult Export(AudacityProject *project, std::unique_ptr< BasicUI::ProgressDialog > &pDialog, unsigned channels, const wxFileNameWrapper &fName, bool selectedOnly, double t0, double t1, MixerSpec *mixerSpec=NULL, const Tags *metadata=NULL, int subformat=0) override
called to export audio into a file.
bool FillComment(AudacityProject *project, vorbis_comment *comment, const Tags *metadata)
ExportOGGOptions(wxWindow *parent, int format)
virtual ~ExportOGGOptions()
bool TransferDataToWindow() override
void PopulateOrExchange(ShuttleGui &S)
bool TransferDataFromWindow() override
void AddExtension(const FileExtension &extension, int index)
int AddFormat()
Add a NEW entry to the list of formats this plug-in can export.
static void InitProgress(std::unique_ptr< BasicUI::ProgressDialog > &pDialog, const TranslatableString &title, const TranslatableString &message)
void SetFormat(const wxString &format, int index)
std::unique_ptr< Mixer > CreateMixer(const TrackList &tracks, bool selectionOnly, double startTime, double stopTime, unsigned numOutChannels, size_t outBufferSize, bool outInterleaved, double outRate, sampleFormat outFormat, MixerSpec *mixerSpec)
void SetDescription(const TranslatableString &description, int index)
void SetCanMetaData(bool canmetadata, int index)
void SetMaxChannels(unsigned maxchannels, unsigned index)
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
wxOutputStream & Write(const void *buffer, size_t size)
A matrix of booleans, one row per input channel, column per output.
static ProjectRate & Get(AudacityProject &project)
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
static TrackList & Get(AudacityProject &project)