2 * Copyright (C) 2003-2009 The Music Player Daemon Project
3 * http://www.musicpd.org
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef MPD_CROSSFADE_H
21 #define MPD_CROSSFADE_H
27 * Calculate how many music pipe chunks should be used for crossfading.
29 * @param duration the requested crossfade duration
30 * @param total_time total_time the duration of the new song
31 * @param af the audio format of the new song
32 * @param old_format the audio format of the current song
33 * @param max_chunks the maximum number of chunks
34 * @return the number of chunks for crossfading, or 0 if cross fading
35 * should be disabled for this song change
37 unsigned cross_fade_calc(float duration
, float total_time
,
38 const struct audio_format
*af
,
39 const struct audio_format
*old_format
,
43 * Applies cross fading to two chunks, i.e. mixes these chunks.
44 * Internally, this calls pcm_mix().
46 * @param a the chunk in the current song (and the destination chunk)
47 * @param b the according chunk in the new song
48 * @param format the audio format of both chunks (must be the same)
49 * @param current_chunk the relative index of the current chunk
50 * @param num_chunks the number of chunks used for cross fading
52 void cross_fade_apply(struct music_chunk
*a
, const struct music_chunk
*b
,
53 const struct audio_format
*format
,
54 unsigned int current_chunk
, unsigned int num_chunks
);