Hello,

I've just started using mpd and I really like it -- nice job.

However a feature I really miss is a cross-fade when you manually change
songs, and not just at song boundaries.

After some experimentation I managed to get it to do that (the patch against
0.16.6 is attached). I am not a C programmer and the communication between
the threads is still a mystery to me. Consider it more of a proof-of-concept
-- you will probably want to adapt it to your own design model, i.e., do it
right.

Two bugs I've already discovered with it is that if you go from an .mp3 to
an .ogg, or vice versa, it produces a few seconds of distortion. Maybe this
is trivial for you to fix, I don't know.

And, if you fast-forward during the cross-fade, the cross-fade gets
cancelled. (There's really no reason to fast-forward during a cross-fade, of
course, so it could just be disabled while cross-fading.)

Oh, and I have no idea if the cross-fade time is being properly honored;
but, I also don't know if it works properly at song boundaries.

Greetings, Allen


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

diff /usr/local/src/mpd-0.16.6/src/player_control.c ./player_control.c
110a111
>         /*
112a114,118
>                 */
> 
>         if (pc.state != PLAYER_STATE_STOP) {
>             player_command_locked( pc_get_cross_fade() == 0.0 ? 
> PLAYER_COMMAND_STOP : PLAYER_COMMAND_PLAY_IMMEDIATE );
>         }
diff /usr/local/src/mpd-0.16.6/src/player_control.h ./player_control.h
64a65,66
> 
>         PLAYER_COMMAND_PLAY_IMMEDIATE,
diff /usr/local/src/mpd-0.16.6/src/player_thread.c ./player_thread.c
123a124,125
> 
>         bool next_immediately;
147a150
> 
524a528,532
>         case PLAYER_COMMAND_PLAY_IMMEDIATE:
>             player->next_immediately = 1;
>             player_command_finished_locked();
>             break;
> 
831a840,868
> void 
> check_cross_fade(struct player *player, struct decoder_control *dc) {
> 
>                       /* enable cross fading in this song?  if yes,
>                          calculate how many chunks will be required
>                          for it */
>                       player->cross_fade_chunks =
>                               cross_fade_calc(pc.cross_fade_seconds, 
> dc->total_time,
>                                               pc.mixramp_db,
>                                               pc.mixramp_delay_seconds,
>                                               dc->replay_gain_db,
>                                               dc->replay_gain_prev_db,
>                                               dc->mixramp_start,
>                                               dc->mixramp_prev_end,
>                                               &dc->out_audio_format,
>                                               &player->play_audio_format,
>                                               
> music_buffer_size(player_buffer) -
>                                               pc.buffered_before_play);
>                       if (player->cross_fade_chunks > 0) {
>                               player->xfade = XFADE_ENABLED;
>                               player->cross_fading = false;
>                       } else {
>                               /* cross fading is disabled or the
>                                  next song is too short */
>                               player->xfade = XFADE_DISABLED;
>                         }
> }
> 
> 
851a889,890
> 
>                 .next_immediately = false,
932a972,980
>                 if ( player.next_immediately ) {
> 
>                     check_cross_fade(&player, dc);
> 
>                     assert(dc->pipe == NULL || dc->pipe == player.pipe);
>                     if (player.xfade == XFADE_ENABLED) dc->command = 
> DECODE_COMMAND_STOP;
>                     player.next_immediately = 0;
>                 }
> 
946,967c994,995
<                       /* enable cross fading in this song?  if yes,
<                          calculate how many chunks will be required
<                          for it */
<                       player.cross_fade_chunks =
<                               cross_fade_calc(pc.cross_fade_seconds, 
dc->total_time,
<                                               pc.mixramp_db,
<                                               pc.mixramp_delay_seconds,
<                                               dc->replay_gain_db,
<                                               dc->replay_gain_prev_db,
<                                               dc->mixramp_start,
<                                               dc->mixramp_prev_end,
<                                               &dc->out_audio_format,
<                                               &player.play_audio_format,
<                                               
music_buffer_size(player_buffer) -
<                                               pc.buffered_before_play);
<                       if (player.cross_fade_chunks > 0) {
<                               player.xfade = XFADE_ENABLED;
<                               player.cross_fading = false;
<                       } else
<                               /* cross fading is disabled or the
<                                  next song is too short */
<                               player.xfade = XFADE_DISABLED;
---
> 
>                     check_cross_fade(&player, dc);
1064a1093,1094
>                 case PLAYER_COMMAND_PLAY_IMMEDIATE:
>                         
------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
Musicpd-dev-team mailing list
Musicpd-dev-team@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team

Reply via email to