History

Hook in skeleton FIR/IIR/Polynomial converter.

Erik de Castro Lopo committed 22 years ago

Commit c38dc851 parent b4eb5ce5 files · +176 −2Browse files

Unified · Split

5 files
  1. src/Makefile.am +2 −1
  2. src/common.h +6 −0
  3. src/samplerate.c +9 −0
  4. src/samplerate.h +4 −1
  5. src/src_fir_iir_poly.c +155 −0
src/Makefile.am+2−1
@@ -11,7 +11,8 @@ COEFF_HDRS = high_qual_coeffs.h mid_qual_coeffs.h fastest_coeffs.h · 10 unmodified lines
11 11
12noinst_HEADERS = common.h float_cast.h $(COEFF_HDRS)12noinst_HEADERS = common.h float_cast.h $(COEFF_HDRS)
13 13
14SRC_SOURCES = samplerate.c src_sinc.c $(COEFF_HDRS) src_zoh.c src_linear.c14SRC_SOURCES = samplerate.c src_sinc.c $(COEFF_HDRS) src_zoh.c src_linear.c \
15 src_fir_iir_poly.c
15 16
16# MinGW requires -no-undefined if a DLL is to be built.17# MinGW requires -no-undefined if a DLL is to be built.
17libsamplerate_la_LDFLAGS = -no-undefined version-info @SHARED_VERSION_INFO@ @SHLIB_VERSION_ARG@18libsamplerate_la_LDFLAGS = -no-undefined version-info @SHARED_VERSION_INFO@ @SHLIB_VERSION_ARG@
src/common.h+6−0
@@ -114,6 +114,12 @@ const char* zoh_get_description (int src_enum) ; · 113 unmodified lines
114 114
115int zoh_set_converter (SRC_PRIVATE *psrc, int src_enum) ;115int zoh_set_converter (SRC_PRIVATE *psrc, int src_enum) ;
116 116
117/* In src_fir_iir_poly.c */
118const char* fip_get_name (int src_enum) ;
119const char* fip_get_description (int src_enum) ;
120
121int fip_set_converter (SRC_PRIVATE *psrc, int src_enum) ;
122
117#endif /* COMMON_H_INCLUDED */123#endif /* COMMON_H_INCLUDED */
118 124
119/*125/*
src/samplerate.c+9−0
@@ -313,6 +313,9 @@ src_get_name (int converter_type) · 312 unmodified lines
313 if ((desc = linear_get_name (converter_type)) != NULL)313 if ((desc = linear_get_name (converter_type)) != NULL)
314 return desc ;314 return desc ;
315 315
316 if ((desc = fip_get_name (converter_type)) != NULL)
317 return desc ;
318
316 return NULL ;319 return NULL ;
317} /* src_get_name */320} /* src_get_name */
318 321
@@ -329,6 +332,9 @@ src_get_description (int converter_type) · 10 unmodified lines
329 if ((desc = linear_get_description (converter_type)) != NULL)332 if ((desc = linear_get_description (converter_type)) != NULL)
330 return desc ;333 return desc ;
331 334
335 if ((desc = fip_get_description (converter_type)) != NULL)
336 return desc ;
337
332 return NULL ;338 return NULL ;
333} /* src_get_description */339} /* src_get_description */
334 340
@@ -482,6 +488,9 @@ psrc_set_converter (SRC_PRIVATE *psrc, int converter_type) · 147 unmodified lines
482 if (linear_set_converter (psrc, converter_type) == SRC_ERR_NO_ERROR)488 if (linear_set_converter (psrc, converter_type) == SRC_ERR_NO_ERROR)
483 return SRC_ERR_NO_ERROR ;489 return SRC_ERR_NO_ERROR ;
484 490
491 if (fip_set_converter (psrc, converter_type) == SRC_ERR_NO_ERROR)
492 return SRC_ERR_NO_ERROR ;
493
485 return SRC_ERR_BAD_CONVERTER ;494 return SRC_ERR_BAD_CONVERTER ;
486} /* psrc_set_converter */495} /* psrc_set_converter */
487 496
src/samplerate.h+4−1
@@ -168,7 +168,10 @@ enum · 167 unmodified lines
168 SRC_SINC_MEDIUM_QUALITY = 1,168 SRC_SINC_MEDIUM_QUALITY = 1,
169 SRC_SINC_FASTEST = 2,169 SRC_SINC_FASTEST = 2,
170 SRC_ZERO_ORDER_HOLD = 3,170 SRC_ZERO_ORDER_HOLD = 3,
171 SRC_LINEAR = 4171 SRC_LINEAR = 4,
172 SRC_FIR_IIR_POLY_BEST = 5,
173 SRC_FIR_IIR_POLY_MEDIUM = 6,
174 SRC_FIR_IIR_POLY_FASTEST = 7
172} ;175} ;
173 176
174/*177/*
src/src_fir_iir_poly.c+155−0
@@ -0,0 +1,155 @@
1/*
2** Copyright (C) 2002-2004 Erik de Castro Lopo <erikd@mega-nerd.com>
3**
4** This program is free software; you can redistribute it and/or modify
5** it under the terms of the GNU General Public License as published by
6** the Free Software Foundation; either version 2 of the License, or
7** (at your option) any later version.
8**
9** This program is distributed in the hope that it will be useful,
10** but WITHOUT ANY WARRANTY; without even the implied warranty of
11** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12** GNU General Public License for more details.
13**
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.
17*/
18
19#include <stdio.h>
20#include <stdlib.h>
21#include <string.h>
22
23#include "config.h"
24#include "float_cast.h"
25#include "common.h"
26
27#define FIP_MAGIC_MARKER MAKE_MAGIC ('f', 'i', 'r', 'p', 'l', 'y')
28
29typedef struct
30{ int fip_magic_marker ;
31
32 int channels ;
33 long in_count, in_used ;
34 long out_count, out_gen ;
35
36 double src_ratio, input_index ;
37
38 float *input_buffer ;
39 int in_buf_len ;
40
41 float *fir_out ;
42 int fir_out_len ;
43
44 float *iir_out ;
45 int iir_out_len ;
46
47 float buffer [1] ;
48} FIR_IIR_POLY ;
49
50static void fip_reset (SRC_PRIVATE *psrc) ;
51static int fip_process (SRC_PRIVATE *psrc, SRC_DATA *data) ;
52
53const char*
54fip_get_name (int src_enum)
55{
56 switch (src_enum)
57 { case SRC_FIR_IIR_POLY_BEST :
58 return "Best FIR/IIR/Polynomial Interpolator" ;
59
60 case SRC_FIR_IIR_POLY_MEDIUM :
61 return "Medium FIR/IIR/Polynomial Interpolator" ;
62
63 case SRC_FIR_IIR_POLY_FASTEST :
64 return "Fastest FIR/IIR/Polynomial Interpolator" ;
65 } ;
66
67 return NULL ;
68} /* fip_get_descrition */
69
70const char*
71fip_get_description (int src_enum)
72{
73 switch (src_enum)
74 { case SRC_FIR_IIR_POLY_BEST :
75 return "Three stage FIR/IIR/Polynomial Interpolator, best quality, XXdb SNR, XX% BW." ;
76
77 case SRC_FIR_IIR_POLY_MEDIUM :
78 return "Three stage FIR/IIR/Polynomial Interpolator, medium quality, XXdb SNR, XX% BW." ;
79
80 case SRC_FIR_IIR_POLY_FASTEST :
81 return "Three stage FIR/IIR/Polynomial Interpolator, fastest, XXdb SNR, XX% BW." ;
82 } ;
83
84 return NULL ;
85} /* fip_get_descrition */
86
87int
88fip_set_converter (SRC_PRIVATE *psrc, int src_enum)
89{ FIR_IIR_POLY *fip ;
90
91 fip = (FIR_IIR_POLY *) psrc->private_data ;
92
93 switch (src_enum)
94 { case SRC_FIR_IIR_POLY_BEST :
95 break ;
96
97 case SRC_FIR_IIR_POLY_MEDIUM :
98 break ;
99
100 case SRC_FIR_IIR_POLY_FASTEST :
101 break ;
102
103 default :
104 return SRC_ERR_BAD_CONVERTER ;
105 } ;
106
107 psrc->reset = fip_reset ;
108 psrc->process = fip_process ;
109
110 return SRC_ERR_NO_ERROR ;
111} /* fip_set_converter */
112
113static void
114fip_reset (SRC_PRIVATE *psrc)
115{ FIR_IIR_POLY *fip ;
116
117 fip = (FIR_IIR_POLY *) psrc->private_data ;
118
119} /* fip_reset */
120
121/*========================================================================================
122** Beware all ye who dare pass this point. There be dragons here.
123*/
124
125static int
126fip_process (SRC_PRIVATE *psrc, SRC_DATA *data)
127{ FIR_IIR_POLY *fip ;
128
129 if (psrc->private_data == NULL)
130 return SRC_ERR_NO_PRIVATE ;
131
132 fip = (FIR_IIR_POLY*) psrc->private_data ;
133
134 /* If there is not a problem, this will be optimised out. */
135 if (sizeof (fip->buffer [0]) != sizeof (data->data_in [0]))
136 return SRC_ERR_SIZE_INCOMPATIBILITY ;
137
138
139 return SRC_ERR_NO_ERROR ;
140} /* fip_process */
141
142/*----------------------------------------------------------------------------------------
143*/
144
145
146
147
148/*
149** Do not edit or modify anything in this comment block.
150** The arch-tag line is a file identity tag for the GNU Arch
151** revision control system.
152**
153** arch-tag: a6c8bad4-740c-4e4f-99f1-e274174ab540
154*/
155

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t