Browse Source

add AIFF, AU, CAF, W64 audio export

translate
Alexandros Theodotou 2 months ago
parent
commit
3ca9c0aa67
Signed by: alex
GPG Key ID: 022EAE42313D70F3
  1. 11
      inc/audio/exporter.h
  2. 23
      inc/gui/widgets/dialogs/export_dialog.h
  3. 18
      inc/settings/settings.h
  4. 1
      resources/ui/export_dialog.ui
  5. 2
      scripts/gen-schema.scm.in
  6. 23
      src/audio/exporter.c
  7. 23
      src/gui/widgets/dialogs/export_dialog.c
  8. 47
      src/settings/settings.c

11
inc/audio/exporter.h

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: © 2018-2021 Alexandros Theodotou <alex@zrythm.org>
// SPDX-FileCopyrightText: © 2018-2022 Alexandros Theodotou <alex@zrythm.org>
// SPDX-License-Identifier: LicenseRef-ZrythmLicense
#ifndef __AUDIO_EXPORT_H__
@ -18,15 +18,20 @@ @@ -18,15 +18,20 @@
*/
typedef enum ExportFormat
{
EXPORT_FORMAT_AIFF,
EXPORT_FORMAT_AU,
EXPORT_FORMAT_CAF,
EXPORT_FORMAT_FLAC,
EXPORT_FORMAT_MP3,
EXPORT_FORMAT_OGG_VORBIS,
EXPORT_FORMAT_OGG_OPUS,
EXPORT_FORMAT_WAV,
EXPORT_FORMAT_MP3,
/** Raw audio data. */
EXPORT_FORMAT_RAW,
EXPORT_FORMAT_WAV,
EXPORT_FORMAT_W64,
/** MIDI type 0. */
EXPORT_FORMAT_MIDI0,

23
inc/gui/widgets/dialogs/export_dialog.h

@ -45,17 +45,18 @@ typedef struct _ExportDialogWidget @@ -45,17 +45,18 @@ typedef struct _ExportDialogWidget
AdwViewStack * stack;
/* audio */
AdwEntryRow * audio_title;
AdwEntryRow * audio_artist;
AdwEntryRow * audio_genre;
AdwComboRow * audio_format;
AdwComboRow * audio_bit_depth;
GtkSwitch * audio_dither_switch;
AdwComboRow * audio_filename_pattern;
AdwComboRow * audio_mixdown_or_stems;
GtkDropDown * audio_time_range_drop_down;
GtkTreeView * audio_tracks_treeview;
GtkLabel * audio_output_label;
AdwEntryRow * audio_title;
AdwEntryRow * audio_artist;
AdwEntryRow * audio_genre;
AdwComboRow * audio_format;
AdwComboRow * audio_bit_depth;
AdwActionRow * audio_dither;
GtkSwitch * audio_dither_switch;
AdwComboRow * audio_filename_pattern;
AdwComboRow * audio_mixdown_or_stems;
GtkDropDown * audio_time_range_drop_down;
GtkTreeView * audio_tracks_treeview;
GtkLabel * audio_output_label;
/* MIDI */
AdwEntryRow * midi_title;

18
inc/settings/settings.h

@ -211,6 +211,24 @@ settings_get_default_value_double ( @@ -211,6 +211,24 @@ settings_get_default_value_double (
const char * schema,
const char * key);
/**
* Returns the localized summary as a newly
* allocated string.
*/
char *
settings_get_summary (
GSettings * settings,
const char * key);
/**
* Returns the localized description as a newly
* allocated string.
*/
char *
settings_get_description (
GSettings * settings,
const char * key);
/**
* Frees settings.
*/

1
resources/ui/export_dialog.ui

@ -70,7 +70,6 @@ @@ -70,7 +70,6 @@
<child>
<object class="AdwActionRow" id="audio_dither">
<property name="title" translatable="yes">Dither</property>
<property name="subtitle" translatable="yes">Add low level noise to reduce errors on lower bit depths.</property>
<property name="activatable_widget">audio_dither_switch</property>
<child>
<object class="GtkSwitch" id="audio_dither_switch">

2
scripts/gen-schema.scm.in

@ -931,7 +931,7 @@ Args: @@ -931,7 +931,7 @@ Args:
(make-schema-key
"dither" "b" "false"
"Dither"
"Add dither while exporting, if applicable.")
"Add low level noise to reduce errors on lower bit depths.")
(make-schema-key
"export-stems" "b" "false"
"Export stems"

23
src/audio/exporter.c

@ -40,14 +40,15 @@ @@ -40,14 +40,15 @@
#define AMPLITUDE (1.0 * 0x7F000000)
static const char * pretty_formats[] = {
"FLAC", "OGG (Vorbis)", "OGG (OPUS)",
"WAV", "MP3", "RAW",
"MIDI Type 0", "MIDI Type 1",
"AIFF", "AU", "CAF",
"FLAC", "MP3", "OGG (Vorbis)",
"OGG (OPUS)", "RAW", "WAV",
"W64", "MIDI Type 0", "MIDI Type 1",
};
static const char * format_exts[] = {
"FLAC", "ogg", "ogg", "wav",
"mp3", "raw", "mid", "mid",
"aiff", "au", "caf", "FLAC", "mp3", "ogg",
"ogg", "raw", "wav", "w64", "mid", "mid",
};
/**
@ -92,6 +93,15 @@ export_audio (ExportSettings * info) @@ -92,6 +93,15 @@ export_audio (ExportSettings * info)
switch (info->format)
{
case EXPORT_FORMAT_AIFF:
sfinfo.format = SF_FORMAT_AIFF;
break;
case EXPORT_FORMAT_AU:
sfinfo.format = SF_FORMAT_AU;
break;
case EXPORT_FORMAT_CAF:
sfinfo.format = SF_FORMAT_CAF;
break;
case EXPORT_FORMAT_FLAC:
sfinfo.format = SF_FORMAT_FLAC;
break;
@ -101,6 +111,9 @@ export_audio (ExportSettings * info) @@ -101,6 +111,9 @@ export_audio (ExportSettings * info)
case EXPORT_FORMAT_WAV:
sfinfo.format = SF_FORMAT_WAV;
break;
case EXPORT_FORMAT_W64:
sfinfo.format = SF_FORMAT_W64;
break;
case EXPORT_FORMAT_OGG_VORBIS:
#ifdef HAVE_OPUS
case EXPORT_FORMAT_OGG_OPUS:

23
src/gui/widgets/dialogs/export_dialog.c

@ -1427,6 +1427,22 @@ setup_time_range_drop_down ( @@ -1427,6 +1427,22 @@ setup_time_range_drop_down (
"time-range"));
}
static void
setup_dither (
AdwActionRow * dither_row,
GtkSwitch * dither_switch)
{
gtk_switch_set_active (
dither_switch,
g_settings_get_boolean (
S_EXPORT_AUDIO, "dither"));
char * descr = settings_get_description (
S_EXPORT_AUDIO, "dither");
adw_action_row_set_subtitle (dither_row, descr);
g_free (descr);
}
/**
* Creates a new export dialog.
*/
@ -1461,6 +1477,7 @@ export_dialog_widget_class_init ( @@ -1461,6 +1477,7 @@ export_dialog_widget_class_init (
BIND_CHILD (audio_genre);
BIND_CHILD (audio_format);
BIND_CHILD (audio_bit_depth);
BIND_CHILD (audio_dither);
BIND_CHILD (audio_dither_switch);
BIND_CHILD (audio_filename_pattern);
BIND_CHILD (audio_mixdown_or_stems);
@ -1512,10 +1529,8 @@ export_dialog_widget_init ( @@ -1512,10 +1529,8 @@ export_dialog_widget_init (
/* options */
setup_audio_formats_dropdown (self->audio_format);
gtk_switch_set_active (
self->audio_dither_switch,
g_settings_get_boolean (
S_EXPORT_AUDIO, "dither"));
setup_dither (
self->audio_dither, self->audio_dither_switch);
setup_bit_depth_drop_down (self->audio_bit_depth);
setup_filename_pattern_combo_row (
self, self->audio_filename_pattern, true);

47
src/settings/settings.c

@ -450,6 +450,53 @@ settings_get_range_double ( @@ -450,6 +450,53 @@ settings_get_range_double (
g_variant_unref (upper_var);
}
/**
* Returns the localized summary as a newly
* allocated string.
*/
char *
settings_get_summary (
GSettings * settings,
const char * key)
{
GSettingsSchema * settings_schema;
g_object_get (
settings, "settings-schema", &settings_schema,
NULL);
GSettingsSchemaKey * schema_key =
g_settings_schema_get_key (settings_schema, key);
char * descr = g_strdup (
g_settings_schema_key_get_summary (schema_key));
g_settings_schema_key_unref (schema_key);
g_settings_schema_unref (settings_schema);
return descr;
}
/**
* Returns the localized description as a newly
* allocated string.
*/
char *
settings_get_description (
GSettings * settings,
const char * key)
{
GSettingsSchema * settings_schema;
g_object_get (
settings, "settings-schema", &settings_schema,
NULL);
GSettingsSchemaKey * schema_key =
g_settings_schema_get_key (settings_schema, key);
char * descr = g_strdup (
g_settings_schema_key_get_description (
schema_key));
g_settings_schema_key_unref (schema_key);
g_settings_schema_unref (settings_schema);
return descr;
}
/**
* Returns whether the "as" key contains the given
* string.

Loading…
Cancel
Save