Add RVA2 tag support to MPD
[mpd-mk/avuton.git] / src / pcm_utils.h
blob71398c0152acbf806b4df57c06c2d59a25fcdbee
1 /* the Music Player Daemon (MPD)
2 * Copyright (C) 2003-2007 by Warren Dukes (warren.dukes@gmail.com)
3 * This project's homepage is: 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.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef MPD_PCM_UTILS_H
20 #define MPD_PCM_UTILS_H
22 #include "pcm_resample.h"
23 #include "pcm_dither.h"
25 #include <stdint.h>
26 #include <stddef.h>
28 struct audio_format;
30 enum {
31 /** this value means "100% volume" */
32 PCM_VOLUME_1 = 1000,
35 struct pcm_convert_state {
36 struct pcm_resample_state resample;
38 struct pcm_dither_24 dither;
40 /* Strict C99 doesn't allow empty structs */
41 int error;
44 /**
45 * Converts a float value (0.0 = silence, 1.0 = 100% volume) to an
46 * integer volume value (1000 = 100%).
48 static inline int
49 pcm_float_to_volume(float volume)
51 return volume * PCM_VOLUME_1 + 0.5;
54 void pcm_volume(char *buffer, int bufferSize,
55 const struct audio_format *format,
56 int volume);
58 void pcm_mix(char *buffer1, const char *buffer2, size_t size,
59 const struct audio_format *format, float portion1);
61 void pcm_convert_init(struct pcm_convert_state *state);
63 size_t pcm_convert(const struct audio_format *inFormat,
64 const char *inBuffer, size_t inSize,
65 const struct audio_format *outFormat,
66 char *outBuffer,
67 struct pcm_convert_state *convState);
69 size_t pcm_convert_size(const struct audio_format *inFormat, size_t inSize,
70 const struct audio_format *outFormat);
72 #endif