1 /*
2  * Copyright (c) 2009, The MilkyTracker Team.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * - Redistributions of source code must retain the above copyright notice,
9  *   this list of conditions and the following disclaimer.
10  * - Redistributions in binary form must reproduce the above copyright
11  *   notice, this list of conditions and the following disclaimer in the
12  *   documentation and/or other materials provided with the distribution.
13  * - Neither the name of the <ORGANIZATION> nor the names of its contributors
14  *   may be used to endorse or promote products derived from this software
15  *   without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 /*
31  *  Resampler.cpp
32  *  MilkyPlay
33  *
34  *  Created by Peter Barth on 08.11.07.
35  *
36  */
37 
38 #include "ResamplerFactory.h"
39 #include "ResamplerCubic.h"
40 #include "ResamplerFast.h"
41 #include "ResamplerSinc.h"
42 #include "ResamplerAmiga.h"
43 
createResampler(ResamplerTypes type)44 ChannelMixer::ResamplerBase* ResamplerFactory::createResampler(ResamplerTypes type)
45 {
46 	switch (type)
47 	{
48 		case MIXER_NORMAL:
49 			return new ResamplerSimple();
50 
51 		case MIXER_NORMAL_RAMPING:
52 			return new ResamplerSimpleRamp();
53 
54 		case MIXER_LERPING:
55 			return new ResamplerLerp();
56 
57 		case MIXER_LERPING_RAMPING:
58 			return new ResamplerLerpRampFilter();
59 
60 		case MIXER_LAGRANGE:
61 			return new ResamplerLagrange<false, CubicResamplerLagrange>();
62 
63 		case MIXER_LAGRANGE_RAMPING:
64 			return new ResamplerLagrange<true, CubicResamplerLagrange>();
65 
66 		case MIXER_SPLINE:
67 			return new ResamplerLagrange<false, CubicResamplerSpline>();
68 
69 		case MIXER_SPLINE_RAMPING:
70 			return new ResamplerLagrange<true, CubicResamplerSpline>();
71 
72 		case MIXER_SINCTABLE:
73 			return new ResamplerSincTable<false, 16>();
74 
75 		case MIXER_SINCTABLE_RAMPING:
76 			return new ResamplerSincTable<true, 16>();
77 
78 		case MIXER_SINC:
79 			return new ResamplerSinc<false, 128>();
80 
81 		case MIXER_SINC_RAMPING:
82 			return new ResamplerSinc<true, 128>();
83 
84 		case MIXER_AMIGA500:
85 			return new ResamplerAmiga<0>();
86 
87 		case MIXER_AMIGA500_RAMPING:
88 			return new ResamplerAmiga<0>();
89 
90 		case MIXER_AMIGA500LED:
91 			return new ResamplerAmiga<1>();
92 
93 		case MIXER_AMIGA500LED_RAMPING:
94 			return new ResamplerAmiga<1>();
95 
96 		case MIXER_AMIGA1200:
97 			return new ResamplerAmiga<2>();
98 
99 		case MIXER_AMIGA1200_RAMPING:
100 			return new ResamplerAmiga<2>();
101 
102 		case MIXER_AMIGA1200LED:
103 			return new ResamplerAmiga<3>();
104 
105 		case MIXER_AMIGA1200LED_RAMPING:
106 			return new ResamplerAmiga<3>();
107 
108 		/*	There is also ResamplerAmiga<5> which is a generic 22khz LP filter, it still
109 			emulates Paula's pulse chain but does not emulate any of the Amiga's internal
110 			filter circuitry. Already we have many options here so it's probably not worth
111 			including. */
112 
113 		case MIXER_DUMMY:
114 			return new ResamplerDummy();
115 
116 		default:
117 			return NULL;
118 	}
119 }
120