3 * This software is released under the provisions of the GPL version 2.
4 * see file "COPYING". If that file is not available, the full statement
5 * of the license can be found at
7 * http://www.fsf.org/licensing/licenses/gpl.txt
9 * Copyright (c) Paul Cifarelli 2005
10 * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved.
11 * PCM time-domain equalizer:
12 * (c) 2002 Felipe Rivera <liebremx at users sourceforge net>
13 * (c) 2004 Mark Kretschmann <markey@web.de>
16 #ifndef _HSPHOOK_H_INCLUDED_
17 #define _HSPHOOK_H_INCLUDED_
21 #define FADE_MIN_dB -120
23 class HSPPreMixAudioHook
: public IHXAudioHook
26 HSPPreMixAudioHook(HelixSimplePlayer
*player
, int playerIndex
, IHXAudioStream
*pAudioStream
,
27 bool fadein
= false, unsigned long fadelength
= 0);
28 virtual ~HSPPreMixAudioHook();
32 STDMETHOD(QueryInterface
) (THIS_
35 STDMETHOD_(ULONG32
,AddRef
) (THIS
);
36 STDMETHOD_(ULONG32
,Release
) (THIS
);
38 * IHXAudioHook methods
40 STDMETHOD(OnBuffer
) (THIS_
41 HXAudioData
*pAudioInData
,
42 HXAudioData
*pAudioOutData
);
43 STDMETHOD(OnInit
) (THIS_
44 HXAudioFormat
*pFormat
);
46 void setFadeout(bool fadeout
);
47 void setFadelength(unsigned long fadelength
) { m_fadelength
= fadelength
; }
52 HelixSimplePlayer
*m_Player
;
55 IHXAudioStream
*m_stream
;
56 HXAudioFormat m_format
;
59 GAIN_STATE
*m_gaintool
;
63 unsigned long m_fadelength
;
65 int volumeize(unsigned char *data
, unsigned char *outbuf
, size_t len
);
71 #define EQ_MAX_BANDS 10
72 #define EQ_CHANNELS 2 // Helix DNA currently only supports stereo
82 /* Coefficient history for the IIR filter */
85 float x
[3]; /* x[n], x[n-1], x[n-2] */
86 float y
[3]; /* y[n], y[n-1], y[n-2] */
92 class HSPPostProcessor
: public IHXAudioHook
95 HSPPostProcessor(HelixSimplePlayer
*player
, int playerIndex
);
96 virtual ~HSPPostProcessor();
100 STDMETHOD(QueryInterface
) (THIS_
103 STDMETHOD_(ULONG32
,AddRef
) (THIS
);
104 STDMETHOD_(ULONG32
,Release
) (THIS
);
106 * IHXAudioHook methods
108 STDMETHOD(OnBuffer
) (THIS_
109 HXAudioData
*pAudioInData
,
110 HXAudioData
*pAudioOutData
);
111 STDMETHOD(OnInit
) (THIS_
112 HXAudioFormat
*pFormat
);
114 void updateEQgains(int preamp
, vector
<int> &equalizerGains
);
116 void scopeify(unsigned long time
, unsigned char *data
, size_t len
);
118 #ifndef HELIX_SW_VOLUME_INTERFACE
119 void setGain(int volume
);
122 void setIndex(int playerIndex
) { m_index
= playerIndex
; }
127 void equalize(unsigned char *datain
, unsigned char *dataout
, size_t len
);
128 #ifndef HELIX_SW_VOLUME_INTERFACE
129 int volumeize(unsigned char *data
, size_t len
);
130 int volumeize(unsigned char *data
, unsigned char *outbuf
, size_t len
);
131 // returns samples (not bytes)
132 int unpack(unsigned char *data
, size_t len
, /*out*/ INT32
*signal
);
133 // returns bytes (siglen is in samples)
134 int pack(INT32
*signal
, size_t siglen
, /*out*/ unsigned char *data
);
137 HelixSimplePlayer
*m_Player
;
140 HXAudioFormat m_format
;
144 struct DelayQueue
*m_item
;
146 unsigned long m_prevtime
;
150 // Gain for each band
151 // values should be between -0.2 and 1.0
152 float gain
[EQ_MAX_BANDS
][EQ_CHANNELS
] __attribute__((aligned
));
154 // values should be between 0.0 and 1.0
155 float preamp
[EQ_CHANNELS
] __attribute__((aligned
));
157 sIIRCoefficients
* iir_cf
;
158 sXYData data_history
[EQ_MAX_BANDS
][EQ_CHANNELS
] __attribute__((aligned
));
164 #ifndef HELIX_SW_VOLUME_INTERFACE
166 GAIN_STATE
*m_gaintool
;
172 class HSPPostMixAudioHook
: public IHXAudioHook
175 HSPPostMixAudioHook(HelixSimplePlayer
*player
, int playerIndex
);
176 virtual ~HSPPostMixAudioHook();
180 STDMETHOD(QueryInterface
) (THIS_
183 STDMETHOD_(ULONG32
,AddRef
) (THIS
);
184 STDMETHOD_(ULONG32
,Release
) (THIS
);
186 * IHXAudioHook methods
188 STDMETHOD(OnBuffer
) (THIS_
189 HXAudioData
*pAudioInData
,
190 HXAudioData
*pAudioOutData
);
191 STDMETHOD(OnInit
) (THIS_
192 HXAudioFormat
*pFormat
);
194 void updateEQgains(int preamp
, vector
<int> &equalizerGains
);
196 #ifndef HELIX_SW_VOLUME_INTERFACE
197 void setGain(int volume
);
201 HSPPostMixAudioHook();
203 HelixSimplePlayer
*m_Player
;
207 HSPPostProcessor
*m_processor
;
211 class HSPFinalAudioHook
: public IHXAudioHook
214 HSPFinalAudioHook(HelixSimplePlayer
*player
);
215 virtual ~HSPFinalAudioHook();
219 STDMETHOD(QueryInterface
) (THIS_
222 STDMETHOD_(ULONG32
,AddRef
) (THIS
);
223 STDMETHOD_(ULONG32
,Release
) (THIS
);
225 * IHXAudioHook methods
227 STDMETHOD(OnBuffer
) (THIS_
228 HXAudioData
*pAudioInData
,
229 HXAudioData
*pAudioOutData
);
230 STDMETHOD(OnInit
) (THIS_
231 HXAudioFormat
*pFormat
);
234 void updateEQgains(int preamp
, vector
<int> &equalizerGains
);
236 #ifndef HELIX_SW_VOLUME_INTERFACE
237 void setGain(int volume
);
243 HelixSimplePlayer
*m_Player
;
246 HSPPostProcessor
*m_processor
;