annotate src/sndstretch/sndstretch.h @ 2023:27239c2e3b47

iabervon: We appreciate the plugin you wrote for the VFS system, but, it's now deprecated. We look forward to consider other plugins of yours in the future. (curl plugin dropped from distribution, in favour of neon).
author William Pitcock <nenolod@atheme.org>
date Thu, 11 Oct 2007 15:40:36 -0500
parents 6bb0e52df3d6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
881
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
1 // sndstretch.h
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
2 //
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
3 // sndstretch - algorithm for adjusting pitch and speed of s16le data
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
4 // Copyright (C) 2000 Florian Berger
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
5 // Email: florian.berger@jk.uni-linz.ac.at
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
6 //
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
7 // This program is free software; you can redistribute it and/or modify
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
8 // it under the terms of the GNU General Public License Version 2 as
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
9 // published by the Free Software Foundation;
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
10 //
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
11 // This program is distributed in the hope that it will be useful,
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
14 // GNU General Public License for more details.
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
15 //
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
16 // You should have received a copy of the GNU General Public License
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
17 // along with this program; if not, write to the Free Software
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
18 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
19 //
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
20 //
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
21
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
22 #ifndef SNDSTRETCH_H
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
23 #define SNDSTRETCH_H
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
24
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
25
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
26 #ifdef __cplusplus
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
27 extern "C" {
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
28 #endif
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
29
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
30
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
31 typedef short int s16;
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
32
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
33
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
34 typedef struct{
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
35 int is_initialized; // init me = 0
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
36 int snr_o_prod;
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
37 int snr_i_act;
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
38 int snr_o_act;
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
39 int pos_act;
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
40 int dsnr;
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
41 double snr_rest; // init me = 0.0
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
42
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
43 int _RESMAX_div_max, _RESMAX_mod_max;
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
44 int fade_in_i, fade_out_i, fade_rest_i;
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
45 } StretchJob;
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
46
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
47 typedef struct{
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
48 s16 last_samp[10]; /* 10 channels maximum ;) */
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
49 int pos_rest;
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
50
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
51 int snr;
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
52 int pos1, pos2;
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
53 int ch;
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
54 int ratio1_i;
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
55 int ds_li, ds_li_c, ds_rest;
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
56 int snr_proc_m_chnr;
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
57 } ScaleJob;
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
58
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
59 typedef struct{
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
60 s16 * ring_buff; // init me = (s16*)0
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
61 s16 * ring_buff_old; // init me = (s16*)0
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
62 s16 * buff_help; // init me = (s16*)0
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
63 int ring_size; // init me = 1
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
64 int ring_size_old; // init me = 0
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
65 int ring_pos_w; // init me = 0
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
66 int ring_pos_r; // init me = 0
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
67 int snr_scale_i;
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
68 int snr_scale_o;
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
69 int snr_stretch_i;
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
70 int snr_stretch_o;
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
71 int snr_proc_scale;
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
72 int snr_proc_stretch;
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
73 int is_init; // init me = 0
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
74 int dsnr;
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
75 double speed_act; // init me = 0
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
76 double pitch_act; // init me = 0
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
77 int fade_shift_act;
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
78 StretchJob stretch_job;
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
79 ScaleJob scale_job;
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
80 } PitchSpeedJob;
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
81
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
82
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
83
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
84 int sndstretch(
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
85 // stretches the sound (not changing pitch !!!)
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
86 // returns number of output samples produced
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
87 s16 * buffer, int buff_size, // ring buffer
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
88 int pos_init, // only initial pos in ringbuffer
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
89 int snr_i, int snr_o, // enlarge - spec
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
90 int chnr, /* # of channels */
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
91 s16 * outbuff, // output
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
92 int * out_prod, // # of output-samples produced
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
93 int snr_proc, // # of in-samples to process
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
94 int initialize // bool
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
95 );
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
96
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
97
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
98 int sndscale(
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
99 // rescales the sound (including pitch)
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
100 // returns number of output samples produced
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
101 s16 * buffer, // ring buffer
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
102 int snr_i, int snr_o, // enlarge - specification
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
103 // (snr_o may not exceed 2^16 for
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
104 // integer optimized version)
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
105 int chnr, // # of channels
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
106 s16 * outbuff, // output
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
107 int * out_prod, // # of output-samples produced
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
108 int snr_proc, // # of in-samples to process
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
109 int initialize // bool
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
110 );
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
111
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
112
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
113 int snd_pitch_speed(
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
114 /* input */
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
115 s16 *buff_i, int channels, int snr_proc,
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
116 /* algorihm parameters */
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
117 int initialize, double pitch, double speed, int fade_shift,
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
118 /* output */
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
119 s16 * buff_o, int * snr_produced
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
120 );
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
121
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
122
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
123 int snd_stretch_scale(s16 *buff_i, s16 * buff_o,
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
124 double pitch, double speed, int channels,
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
125 int snr_proc, int * snr_produced, int initialize );
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
126
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
127
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
128 void InitPitchSpeedJob( PitchSpeedJob * job );
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
129
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
130 int snd_pitch_speed_job(
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
131 /* input */
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
132 s16 *buff_i, int channels, int snr_proc,
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
133 /* algorihm parameters */
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
134 int initialize, double pitch, double speed, int fade_shift,
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
135 /* output */
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
136 s16 * buff_o, int * snr_produced, PitchSpeedJob * job,
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
137 int vol_corr
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
138 );
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
139
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
140 int snd_stretch_scale_job(s16 *buff_i, s16 * buff_o,
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
141 double pitch, double speed, int channels,
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
142 int snr_proc, int * snr_produced, int initialize,
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
143 PitchSpeedJob * job, int init_job);
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
144
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
145 void CleanupPitchSpeedJob( PitchSpeedJob * job );
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
146 /* cleaning up the allocated mess would be a good idea */
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
147
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
148 #ifdef __cplusplus
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
149 }
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
150 #endif
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
151
6bb0e52df3d6 [svn] - Made port of XMMS plugin SndStretch
mf0102
parents:
diff changeset
152 #endif // SNDSTRETCH_H