Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update #6

Merged
merged 7 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ copyright = 'Copyright (C) 2001-2023 Audacious developers and others'

have_darwin = host_machine.system() == 'darwin'
have_windows = host_machine.system() == 'windows'
have_cygwin = host_machine.system() == 'cygwin'


cc = meson.get_compiler('c')
Expand Down Expand Up @@ -120,7 +121,7 @@ endif


# XXX - investigate to see if we can do better
if have_windows
if have_windows or have_cygwin
conf.set_quoted('PLUGIN_SUFFIX', '.dll')
elif have_darwin
conf.set_quoted('PLUGIN_SUFFIX', '.dylib')
Expand Down Expand Up @@ -265,7 +266,7 @@ if meson.version().version_compare('>= 0.53')
'PulseAudio': get_variable('have_pulse', false),
'Simple DirectMedia Layer': get_variable('have_sdlout', false),
'Sndio': get_variable('have_sndio', false),
'Win32 waveOut': have_windows,
'Win32 waveOut': have_windows or have_cygwin,
'FileWriter': get_option('filewriter'),
' -> MP3 encoding': conf.has('FILEWRITER_MP3'),
' -> Vorbis encoding': conf.has('FILEWRITER_VORBIS'),
Expand Down
2 changes: 1 addition & 1 deletion po/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -1865,7 +1865,7 @@ msgstr "_Lecture"

#: src/gtkui/menus.cc:201 src/qtui/menus.cc:280
msgid "P_laylist"
msgstr "L_iste de lecture"
msgstr "Lis_te de lecture"

#: src/gtkui/menus.cc:202 src/gtkui/menus.cc:220 src/qtui/menus.cc:281
#: src/qtui/menus.cc:310
Expand Down
37 changes: 33 additions & 4 deletions src/crossfade/crossfade.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* the use of this software.
*/

#include <math.h>
#include <libaudcore/i18n.h>
#include <libaudcore/plugin.h>
#include <libaudcore/preferences.h>
Expand All @@ -36,6 +37,9 @@ static const char * const crossfade_defaults[] = {
"length", "5",
"manual", "TRUE",
"manual_length", "0.2",
"no_fade_in", "FALSE",
"use_sigmoid", "FALSE",
"sigmoid_steepness", "6",
nullptr
};

Expand All @@ -57,6 +61,14 @@ static const PreferencesWidget crossfade_widgets[] = {
WidgetFloat ("crossfade", "manual_length"),
{0.1, 3.0, 0.1, N_("seconds")},
WIDGET_CHILD),
WidgetCheck (N_("No fade in"),
WidgetBool ("crossfade", "no_fade_in")),
WidgetCheck (N_("Use S-curve fade"),
WidgetBool ("crossfade", "use_sigmoid")),
WidgetSpin (N_("S-curve steepness:"),
WidgetFloat ("crossfade", "sigmoid_steepness"),
{2.0, 16.0, 0.5, N_("(higher is steeper)")},
WIDGET_CHILD),
WidgetLabel (N_("<b>Tip</b>")),
WidgetLabel (N_("For better crossfading, enable\n"
"the Silence Removal effect."))
Expand Down Expand Up @@ -107,15 +119,30 @@ void Crossfade::cleanup ()
output.clear ();
}

static void do_ramp (float * data, int length, float a, float b)
static void do_linear_ramp (float * data, int length, float a, float b)
{
for (int i = 0; i < length; i ++)
(* data ++) *= (a * (length - i) + b * i) / length;
}

static void do_sigmoid_ramp (float * data, int length, float a, float b)
{
float steepness = aud_get_double ("crossfade", "sigmoid_steepness");
for (int i = 0; i < length; i ++)
{
* data = (* data) * (a * (length - i) + b * i) / length;
data ++;
float linear = (a * (length - i) + b * i) / length;
(* data ++) *= 0.5f + 0.5f * tanhf (steepness * (linear - 0.5f));
}
}

static void do_ramp (float * data, int length, float a, float b)
{
if (aud_get_bool ("crossfade", "use_sigmoid"))
do_sigmoid_ramp (data, length, a, b);
else
do_linear_ramp (data, length, a, b);
}

static void mix (float * data, float * add, int length)
{
while (length --)
Expand Down Expand Up @@ -211,7 +238,9 @@ static void run_fadein (Index<float> & data)
float a = (float) fadein_point / length;
float b = (float) (fadein_point + copy) / length;

do_ramp (data.begin (), copy, a, b);
if (! aud_get_bool ("crossfade", "no_fade_in"))
do_ramp (data.begin (), copy, a, b);

mix (& buffer[fadein_point], data.begin (), copy);
data.remove (0, copy);

Expand Down
1 change: 1 addition & 0 deletions src/ffaudio/ffaudio-core.cc
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ static const struct {
{Tuple::String, Tuple::Composer, {"composer", nullptr}},
{Tuple::Int, Tuple::Year, {"year", "WM/Year", "date", nullptr}},
{Tuple::Int, Tuple::Track, {"track", "WM/TrackNumber", nullptr}},
{Tuple::Int, Tuple::Disc, {"disc", "WM/PartOfSet", nullptr}},
};

static void read_metadata_dict (Tuple & tuple, AVDictionary * dict)
Expand Down
1 change: 1 addition & 0 deletions src/filewriter/flac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ static bool flac_open (VFSFile & file, const format_info & info, const Tuple & t
insert_vorbis_comment (flac_metadata, "DATE", tuple, Tuple::Date);
insert_vorbis_comment (flac_metadata, "YEAR", tuple, Tuple::Year);
insert_vorbis_comment (flac_metadata, "TRACKNUMBER", tuple, Tuple::Track);
insert_vorbis_comment (flac_metadata, "DISCNUMBER", tuple, Tuple::Disc);

FLAC__stream_encoder_set_metadata(flac_encoder, &flac_metadata, 1);

Expand Down
3 changes: 3 additions & 0 deletions src/filewriter/vorbis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ static bool vorbis_open (VFSFile & file, const format_info & info, const Tuple &
if ((scrint = tuple.get_int (Tuple::Year)) > 0)
vorbis_comment_add_tag(&vc, "year", int_to_str (scrint));

if ((scrint = tuple.get_int (Tuple::Disc)) > 0)
vorbis_comment_add_tag(&vc, "discnumber", int_to_str (scrint));

if (vorbis_encode_init_vbr(& vi, info.channels, info.frequency, GET_DOUBLE("base_quality")))
{
vorbis_info_clear(&vi);
Expand Down
3 changes: 3 additions & 0 deletions src/flac/metadata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ bool FLACng::write_tuple(const char *filename, VFSFile &file, const Tuple &tuple

insert_int_tuple_to_vc(vc_block, tuple, Tuple::Year, "DATE");
insert_int_tuple_to_vc(vc_block, tuple, Tuple::Track, "TRACKNUMBER");
insert_int_tuple_to_vc(vc_block, tuple, Tuple::Disc, "DISCNUMBER");

insert_str_tuple_to_vc(vc_block, tuple, Tuple::Publisher, "publisher");
insert_str_tuple_to_vc(vc_block, tuple, Tuple::CatalogNum, "CATALOGNUMBER");
Expand Down Expand Up @@ -265,6 +266,8 @@ static void parse_comment (Tuple & tuple, const char * key, const char * value)

if (!strcmp_nocase(key, "TRACKNUMBER"))
tuple.set_int(Tuple::Track, atoi(value));
else if (!strcmp_nocase(key, "DISCNUMBER"))
tuple.set_int(Tuple::Disc, atoi(value));
else if (!strcmp_nocase(key, "DATE"))
tuple.set_int(Tuple::Year, atoi(value));
else if (!strcmp_nocase(key, "REPLAYGAIN_TRACK_GAIN"))
Expand Down
9 changes: 6 additions & 3 deletions src/gtkui/columns.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ const char * const pw_col_names[PW_COLS] = {
N_("Bitrate"),
N_("Comment"),
N_("Publisher"),
N_("Catalog Number")
N_("Catalog Number"),
N_("Disc")
};

int pw_num_cols;
Expand All @@ -73,7 +74,8 @@ static const char * const pw_col_keys[PW_COLS] = {
"bitrate",
"comment",
"publisher",
"catalog-number"
"catalog-number",
"disc"
};

static const int pw_default_widths[PW_COLS] = {
Expand All @@ -93,7 +95,8 @@ static const int pw_default_widths[PW_COLS] = {
10, // bitrate
275, // comment
175, // publisher
75 // catalog number
75, // catalog number
10 // disc
};

void pw_col_init ()
Expand Down
2 changes: 2 additions & 0 deletions src/gtkui/menus.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ static const AudguiMenuItem sort_items[] = {
MenuCommand (N_("By _File Path"), nullptr, NONE, sort_path),
MenuCommand (N_("By _Custom Title"), nullptr, NONE, sort_custom_title),
MenuCommand (N_("By C_omment"), nullptr, NONE, sort_comment),
MenuCommand (N_("By D_isc Number"), nullptr, NONE, sort_disc),
MenuSep (),
MenuCommand (N_("R_everse Order"), "view-sort-descending", NONE, sort_reverse),
MenuCommand (N_("_Random Order"), nullptr, NONE, sort_random)
Expand All @@ -147,6 +148,7 @@ static const AudguiMenuItem sort_sel_items[] = {
MenuCommand (N_("By _File Path"), nullptr, NONE, sort_sel_path),
MenuCommand (N_("By _Custom Title"), nullptr, NONE, sort_sel_custom_title),
MenuCommand (N_("By C_omment"), nullptr, NONE, sort_sel_comment),
MenuCommand (N_("By D_isc Number"), nullptr, NONE, sort_sel_disc),
MenuSep (),
MenuCommand (N_("R_everse Order"), "view-sort-descending", NONE, sort_sel_reverse),
MenuCommand (N_("_Random Order"), nullptr, NONE, sort_sel_random)
Expand Down
44 changes: 38 additions & 6 deletions src/gtkui/ui_gtk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -377,14 +377,46 @@ static gboolean ui_volume_value_changed_cb (GtkButton *, double volume)
return true;
}

static void ui_volume_pressed_cb (GtkButton *)
static gboolean ui_volume_button_press_cb (GtkWidget *, GdkEvent * event)
{
volume_slider_is_moving = true;
static int old_volume = 0;
GdkEventButton * button_event = (GdkEventButton *) event;

/* ignore double and triple clicks */
if (button_event->type != GDK_BUTTON_PRESS)
return false;

/* handle left mouse button */
if (button_event->button == 1)
{
volume_slider_is_moving = true;
return false;
}

/* (un)mute with middle mouse button */
if (button_event->button == 2)
{
int current_volume = aud_drct_get_volume_main ();
if (current_volume)
{
old_volume = current_volume;
aud_drct_set_volume_main (0);
}
else
aud_drct_set_volume_main (old_volume);
}

return false;
}

static void ui_volume_released_cb (GtkButton *)
static gboolean ui_volume_button_release_cb (GtkWidget *, GdkEvent * event)
{
volume_slider_is_moving = false;
GdkEventButton * button_event = (GdkEventButton *) event;

if (button_event->button == 1)
volume_slider_is_moving = false;

return false;
}

static void ui_volume_slider_update (void * button)
Expand Down Expand Up @@ -927,8 +959,8 @@ bool GtkUI::init ()
g_signal_connect (slider, "button-release-event", (GCallback) ui_slider_button_release_cb, nullptr);

volume_change_handler_id = g_signal_connect (volume, "value-changed", (GCallback) ui_volume_value_changed_cb, nullptr);
g_signal_connect (volume, "pressed", (GCallback) ui_volume_pressed_cb, nullptr);
g_signal_connect (volume, "released", (GCallback) ui_volume_released_cb, nullptr);
g_signal_connect (volume, "button-press-event", (GCallback) ui_volume_button_press_cb, nullptr);
g_signal_connect (volume, "button-release-event", (GCallback) ui_volume_button_release_cb, nullptr);

timer_add (TimerRate::Hz4, ui_volume_slider_update, volume);

Expand Down
15 changes: 11 additions & 4 deletions src/gtkui/ui_playlist_widget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ static const GType pw_col_types[PW_COLS] =
G_TYPE_STRING, // bitrate
G_TYPE_STRING, // comment
G_TYPE_STRING, // publisher
G_TYPE_STRING // catalog number
G_TYPE_STRING, // catalog number
G_TYPE_STRING // disc
};

static const int pw_col_min_widths[PW_COLS] = {
Expand All @@ -72,7 +73,8 @@ static const int pw_col_min_widths[PW_COLS] = {
3, // bitrate
10, // comment,
10, // publisher
3 // catalog number
3, // catalog number
2 // disc
};

static const bool pw_col_label[PW_COLS] = {
Expand All @@ -92,7 +94,8 @@ static const bool pw_col_label[PW_COLS] = {
false, // bitrate
true, // comment
true, // publisher
false // catalog number
false, // catalog number
false // disc
};

static const Playlist::SortType pw_col_sort_types[PW_COLS] = {
Expand All @@ -112,7 +115,8 @@ static const Playlist::SortType pw_col_sort_types[PW_COLS] = {
Playlist::n_sort_types, // bitrate
Playlist::Comment, // comment
Playlist::Publisher, // publisher
Playlist::CatalogNum // catalog number
Playlist::CatalogNum, // catalog number
Playlist::Disc // disc
};

struct PlaylistWidgetData
Expand Down Expand Up @@ -223,6 +227,9 @@ static void get_value (void * user, int row, int column, GValue * value)
case PW_COL_CATALOG_NUM:
set_string_from_tuple (value, tuple, Tuple::CatalogNum);
break;
case PW_COL_DISC:
set_int_from_tuple (value, tuple, Tuple::Disc);
break;
}
}

Expand Down
1 change: 1 addition & 0 deletions src/gtkui/ui_playlist_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ enum {
PW_COL_COMMENT,
PW_COL_PUBLISHER,
PW_COL_CATALOG_NUM,
PW_COL_DISC,
PW_COLS
};

Expand Down
2 changes: 1 addition & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ if get_option('sndio')
subdir('sndio')
endif

if have_windows
if have_windows or have_cygwin
subdir('waveout')
endif

Expand Down
12 changes: 7 additions & 5 deletions src/moonstone/playlist_header.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
namespace Moonstone {

static const char * const s_col_keys[] = {
"playing", "number", "title", "artist", "year", "album",
"album-artist", "track", "genre", "queued", "length", "path",
"filename", "custom", "bitrate", "comment"};
"playing", "number", "title", "artist", "year", "album",
"album-artist", "track", "genre", "queued", "length", "path",
"filename", "custom", "bitrate", "comment", "disc"};

static const int s_default_widths[] = {
25, // now playing
Expand All @@ -56,7 +56,8 @@ static const int s_default_widths[] = {
275, // filename
275, // custom title
75, // bitrate
275 // comment
275, // comment
75 // disc
};

static const Playlist::SortType s_sort_types[] = {
Expand All @@ -75,7 +76,8 @@ static const Playlist::SortType s_sort_types[] = {
Playlist::Filename, // file name
Playlist::FormattedTitle, // custom title
Playlist::n_sort_types, // bitrate
Playlist::Comment // comment
Playlist::Comment, // comment
Playlist::Disc // disc
};

static_assert(aud::n_elems(s_col_keys) == PlaylistModel::n_cols,
Expand Down
5 changes: 3 additions & 2 deletions src/moonstone/playlist_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ const char * const PlaylistModel::labels[] = {
N_("Album Artist"), N_("Track"), N_("Genre"),
N_("Queue Position"), N_("Length"), N_("File Path"),
N_("File Name"), N_("Custom Title"), N_("Bitrate"),
N_("Comment")};
N_("Comment"), N_("Disc")};

static const Tuple::Field s_fields[] = {
Tuple::Invalid, Tuple::Invalid, Tuple::Title, Tuple::Artist,
Tuple::Year, Tuple::Album, Tuple::AlbumArtist, Tuple::Track,
Tuple::Genre, Tuple::Invalid, Tuple::Length, Tuple::Path,
Tuple::Basename, Tuple::FormattedTitle, Tuple::Bitrate, Tuple::Comment};
Tuple::Basename, Tuple::FormattedTitle, Tuple::Bitrate, Tuple::Comment,
Tuple::Disc};

static_assert(aud::n_elems(PlaylistModel::labels) == PlaylistModel::n_cols,
"update PlaylistModel::labels");
Expand Down
1 change: 1 addition & 0 deletions src/moonstone/playlist_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class PlaylistModel : public QAbstractListModel
CustomTitle,
Bitrate,
Comment,
Disc,
n_cols
};

Expand Down
Loading