summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/rbcodec/dsp/dsp_misc.c83
-rw-r--r--lib/rbcodec/dsp/dsp_misc.h16
-rw-r--r--lib/rbcodec/test/warble.c2
3 files changed, 57 insertions, 44 deletions
diff --git a/lib/rbcodec/dsp/dsp_misc.c b/lib/rbcodec/dsp/dsp_misc.c
index a8c9423cfb..672212b267 100644
--- a/lib/rbcodec/dsp/dsp_misc.c
+++ b/lib/rbcodec/dsp/dsp_misc.c
@@ -35,38 +35,6 @@
35#endif 35#endif
36#include <string.h> 36#include <string.h>
37 37
38/** Firmware callback interface **/
39
40/* Hook back from firmware/ part of audio, which can't/shouldn't call apps/
41 * code directly. */
42int dsp_callback(int msg, intptr_t param)
43{
44 switch (msg)
45 {
46#ifdef HAVE_SW_TONE_CONTROLS
47 case DSP_CALLBACK_SET_PRESCALE:
48 tone_set_prescale(param);
49 break;
50 case DSP_CALLBACK_SET_BASS:
51 tone_set_bass(param);
52 break;
53 case DSP_CALLBACK_SET_TREBLE:
54 tone_set_treble(param);
55 break;
56#endif /* HAVE_SW_TONE_CONTROLS */
57 case DSP_CALLBACK_SET_CHANNEL_CONFIG:
58 channel_mode_set_config(param);
59 break;
60 case DSP_CALLBACK_SET_STEREO_WIDTH:
61 channel_mode_custom_set_width(param);
62 break;
63 default:
64 break;
65 }
66
67 return 0;
68}
69
70/** Replaygain settings **/ 38/** Replaygain settings **/
71static struct replaygain_settings current_settings; 39static struct replaygain_settings current_settings;
72static struct dsp_replay_gains current_gains; 40static struct dsp_replay_gains current_gains;
@@ -153,12 +121,7 @@ static void dsp_pitch_update(struct dsp_config *dsp)
153 (int64_t)pitch_ratio * data->format.codec_frequency / PITCH_SPEED_100; 121 (int64_t)pitch_ratio * data->format.codec_frequency / PITCH_SPEED_100;
154} 122}
155 123
156int32_t sound_get_pitch(void) 124static void dsp_set_pitch(int32_t percent)
157{
158 return pitch_ratio;
159}
160
161void sound_set_pitch(int32_t percent)
162{ 125{
163 pitch_ratio = percent > 0 ? percent : PITCH_SPEED_100; 126 pitch_ratio = percent > 0 ? percent : PITCH_SPEED_100;
164 struct dsp_config *dsp = dsp_get_config(CODEC_IDX_AUDIO); 127 struct dsp_config *dsp = dsp_get_config(CODEC_IDX_AUDIO);
@@ -167,6 +130,50 @@ void sound_set_pitch(int32_t percent)
167} 130}
168#endif /* HAVE_PITCHCONTROL */ 131#endif /* HAVE_PITCHCONTROL */
169 132
133
134/** Firmware callback interface **/
135
136/* Hook back from firmware/ part of audio, which can't/shouldn't call apps/
137 * code directly. */
138int dsp_callback(int msg, intptr_t param)
139{
140 int retval = 0;
141
142 switch (msg)
143 {
144#ifdef HAVE_SW_TONE_CONTROLS
145 case DSP_CALLBACK_SET_PRESCALE:
146 tone_set_prescale(param);
147 break;
148 case DSP_CALLBACK_SET_BASS:
149 tone_set_bass(param);
150 break;
151 case DSP_CALLBACK_SET_TREBLE:
152 tone_set_treble(param);
153 break;
154#endif /* HAVE_SW_TONE_CONTROLS */
155 case DSP_CALLBACK_SET_CHANNEL_CONFIG:
156 channel_mode_set_config(param);
157 break;
158 case DSP_CALLBACK_SET_STEREO_WIDTH:
159 channel_mode_custom_set_width(param);
160 break;
161#ifdef HAVE_PITCHCONTROL
162 case DSP_CALLBACK_SET_PITCH:
163 dsp_set_pitch(param);
164 break;
165 case DSP_CALLBACK_GET_PITCH:
166 retval = pitch_ratio;
167 break;
168#endif /* HAVE_PITCHCONTROL */
169 default:
170 break;
171 }
172
173 return retval;
174}
175
176
170/* This is a null-processing stage that monitors as an enabled stage but never 177/* This is a null-processing stage that monitors as an enabled stage but never
171 * becomes active in processing samples. It only hooks messages. */ 178 * becomes active in processing samples. It only hooks messages. */
172 179
diff --git a/lib/rbcodec/dsp/dsp_misc.h b/lib/rbcodec/dsp/dsp_misc.h
index d658374eaf..2583f495c3 100644
--- a/lib/rbcodec/dsp/dsp_misc.h
+++ b/lib/rbcodec/dsp/dsp_misc.h
@@ -54,12 +54,18 @@ struct dsp_replay_gains
54 54
55void dsp_replaygain_set_settings(const struct replaygain_settings *settings); 55void dsp_replaygain_set_settings(const struct replaygain_settings *settings);
56 56
57#ifdef HAVE_PITCHCONTROL
58void sound_set_pitch(int32_t ratio);
59int32_t sound_get_pitch(void);
60#endif /* HAVE_PITCHCONTROL */
61
62/* Callback for firmware layers to interface */ 57/* Callback for firmware layers to interface */
58enum
59{
60 DSP_CALLBACK_SET_PRESCALE = 0,
61 DSP_CALLBACK_SET_BASS,
62 DSP_CALLBACK_SET_TREBLE,
63 DSP_CALLBACK_SET_CHANNEL_CONFIG,
64 DSP_CALLBACK_SET_STEREO_WIDTH,
65 DSP_CALLBACK_SET_PITCH,
66 DSP_CALLBACK_GET_PITCH,
67};
68
63int dsp_callback(int msg, intptr_t param); 69int dsp_callback(int msg, intptr_t param);
64 70
65#endif /* DSP_MISC_H */ 71#endif /* DSP_MISC_H */
diff --git a/lib/rbcodec/test/warble.c b/lib/rbcodec/test/warble.c
index d5bc1c5aea..cd73a75542 100644
--- a/lib/rbcodec/test/warble.c
+++ b/lib/rbcodec/test/warble.c
@@ -354,7 +354,7 @@ static void perform_config(void)
354 } else if (!strncmp(name, "offset=", 7)) { 354 } else if (!strncmp(name, "offset=", 7)) {
355 ci.id3->offset = atoi(val); 355 ci.id3->offset = atoi(val);
356 } else if (!strncmp(name, "rate=", 5)) { 356 } else if (!strncmp(name, "rate=", 5)) {
357 sound_set_pitch(atof(val) * PITCH_SPEED_100); 357 dsp_callback(DSP_CALLBACK_SET_PITCH, atof(val) * PITCH_SPEED_100);
358 } else if (!strncmp(name, "seek=", 5)) { 358 } else if (!strncmp(name, "seek=", 5)) {
359 codec_action = CODEC_ACTION_SEEK_TIME; 359 codec_action = CODEC_ACTION_SEEK_TIME;
360 codec_action_param = atoi(val); 360 codec_action_param = atoi(val);