/[svn]/linuxsampler/trunk/src/engines/gig/Synthesizer.cpp
ViewVC logotype

Contents of /linuxsampler/trunk/src/engines/gig/Synthesizer.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 738 - (show annotations) (download)
Tue Aug 16 17:14:25 2005 UTC (18 years, 8 months ago) by schoenebeck
File size: 9674 byte(s)
* extensive synthesis optimization: reimplementation of EGs and LFO(s),
  removed synthesis parameter prerendering and the synthesis parameter
  matrix in general, splitting each audio fragment into subfragments now
  where each subfragment uses constant synthesis parameters
  (everything's still very buggy ATM)

1 /***************************************************************************
2 * *
3 * LinuxSampler - modular, streaming capable sampler *
4 * *
5 * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 * Copyright (C) 2005 Christian Schoenebeck *
7 * *
8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This program is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
21 * MA 02111-1307 USA *
22 ***************************************************************************/
23
24 #include <unistd.h>
25 #include <stdlib.h>
26 #include <stdio.h>
27
28 #include "Synthesizer.h"
29 #include "Profiler.h"
30
31 #define SYNTHESIZE(IMPL,CHAN,LOOP,FILTER,INTERPOLATE) \
32 Synthesizer<IMPL,CHAN,LOOP,FILTER,INTERPOLATE>::SynthesizeSubFragment( \
33 voice, samples, pSrc, skip)
34 #define SYNTHESIZEP(IMPL,CHAN,FILTER,INTERPOLATE,LOOP,CONSTPITCH) \
35 RTMath::time_stamp_t start = Profiler::Stamp(); \
36 Synthesizer<IMPL,CHAN,FILTER,INTERPOLATE,LOOP,CONSTPITCH>::SynthesizeFragment( \
37 voice, samples, pSrc, skip); \
38 Profiler::Record(start, samples, skip)
39
40 namespace LinuxSampler { namespace gig {
41
42 void SynthesizeFragment_mode00(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
43 SYNTHESIZE(CPP,MONO,0,0,0);
44 }
45
46 void SynthesizeFragment_mode01(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
47 SYNTHESIZE(CPP,MONO,0,0,1);
48 }
49
50 void SynthesizeFragment_mode02(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
51 SYNTHESIZE(CPP,MONO,0,1,0);
52 }
53
54 void SynthesizeFragment_mode03(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
55 SYNTHESIZE(CPP,MONO,0,1,1);
56 }
57
58 void SynthesizeFragment_mode04(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
59 SYNTHESIZE(CPP,MONO,1,0,0);
60 }
61
62 void SynthesizeFragment_mode05(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
63 SYNTHESIZE(CPP,MONO,1,0,1);
64 }
65
66 void SynthesizeFragment_mode06(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
67 SYNTHESIZE(CPP,MONO,1,1,0);
68 }
69
70 void SynthesizeFragment_mode07(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
71 SYNTHESIZE(CPP,MONO,1,1,1);
72 }
73
74 void SynthesizeFragment_mode08(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
75 SYNTHESIZE(CPP,STEREO,0,0,0);
76 }
77
78 void SynthesizeFragment_mode09(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
79 SYNTHESIZE(CPP,STEREO,0,0,1);
80 }
81
82 void SynthesizeFragment_mode0a(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
83 SYNTHESIZE(CPP,STEREO,0,1,0);
84 }
85
86 void SynthesizeFragment_mode0b(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
87 SYNTHESIZE(CPP,STEREO,0,1,1);
88 }
89
90 void SynthesizeFragment_mode0c(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
91 SYNTHESIZE(CPP,STEREO,1,0,0);
92 }
93
94 void SynthesizeFragment_mode0d(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
95 SYNTHESIZE(CPP,STEREO,1,0,1);
96 }
97
98 void SynthesizeFragment_mode0e(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
99 SYNTHESIZE(CPP,STEREO,1,1,0);
100 }
101
102 void SynthesizeFragment_mode0f(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
103 SYNTHESIZE(CPP,STEREO,1,1,1);
104 }
105
106 #if CONFIG_ASM && ARCH_X86
107
108 void SynthesizeFragment_mode10(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
109 SYNTHESIZE(ASM_X86_MMX_SSE,MONO,0,0,0);
110 }
111
112 void SynthesizeFragment_mode11(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
113 SYNTHESIZE(ASM_X86_MMX_SSE,MONO,0,0,1);
114 }
115
116 void SynthesizeFragment_mode12(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
117 SYNTHESIZE(ASM_X86_MMX_SSE,MONO,0,1,0);
118 }
119
120 void SynthesizeFragment_mode13(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
121 SYNTHESIZE(ASM_X86_MMX_SSE,MONO,0,1,1);
122 }
123
124 void SynthesizeFragment_mode14(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
125 SYNTHESIZE(ASM_X86_MMX_SSE,MONO,1,0,0);
126 }
127
128 void SynthesizeFragment_mode15(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
129 SYNTHESIZE(ASM_X86_MMX_SSE,MONO,1,0,1);
130 }
131
132 void SynthesizeFragment_mode16(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
133 SYNTHESIZE(ASM_X86_MMX_SSE,MONO,1,1,0);
134 }
135
136 void SynthesizeFragment_mode17(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
137 SYNTHESIZE(ASM_X86_MMX_SSE,MONO,1,1,1);
138 }
139
140 void SynthesizeFragment_mode18(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
141 SYNTHESIZE(ASM_X86_MMX_SSE,STEREO,0,0,0);
142 }
143
144 void SynthesizeFragment_mode19(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
145 SYNTHESIZE(ASM_X86_MMX_SSE,STEREO,0,0,1);
146 }
147
148 void SynthesizeFragment_mode1a(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
149 SYNTHESIZE(ASM_X86_MMX_SSE,STEREO,0,1,0);
150 }
151
152 void SynthesizeFragment_mode1b(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
153 SYNTHESIZE(ASM_X86_MMX_SSE,STEREO,0,1,1);
154 }
155
156 void SynthesizeFragment_mode1c(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
157 SYNTHESIZE(ASM_X86_MMX_SSE,STEREO,1,0,0);
158 }
159
160 void SynthesizeFragment_mode1d(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
161 SYNTHESIZE(ASM_X86_MMX_SSE,STEREO,1,0,1);
162 }
163
164 void SynthesizeFragment_mode1e(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
165 SYNTHESIZE(ASM_X86_MMX_SSE,STEREO,1,1,0);
166 }
167
168 void SynthesizeFragment_mode1f(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
169 SYNTHESIZE(ASM_X86_MMX_SSE,STEREO,1,1,1);
170 }
171
172 #endif // CONFIG_ASM && ARCH_X86
173
174 void* GetSynthesisFunction(int SynthesisMode) {
175 // Mode Bits: IMPL,CHAN,LOOP,FILT,INTERP
176 SynthesisMode &= 0x1f;
177 switch (SynthesisMode) {
178 case 0x00: return (void*) SynthesizeFragment_mode00;
179 case 0x01: return (void*) SynthesizeFragment_mode01;
180 case 0x02: return (void*) SynthesizeFragment_mode02;
181 case 0x03: return (void*) SynthesizeFragment_mode03;
182 case 0x04: return (void*) SynthesizeFragment_mode04;
183 case 0x05: return (void*) SynthesizeFragment_mode05;
184 case 0x06: return (void*) SynthesizeFragment_mode06;
185 case 0x07: return (void*) SynthesizeFragment_mode07;
186 case 0x08: return (void*) SynthesizeFragment_mode08;
187 case 0x09: return (void*) SynthesizeFragment_mode09;
188 case 0x0a: return (void*) SynthesizeFragment_mode0a;
189 case 0x0b: return (void*) SynthesizeFragment_mode0b;
190 case 0x0c: return (void*) SynthesizeFragment_mode0c;
191 case 0x0d: return (void*) SynthesizeFragment_mode0d;
192 case 0x0e: return (void*) SynthesizeFragment_mode0e;
193 case 0x0f: return (void*) SynthesizeFragment_mode0f;
194 #if CONFIG_ASM && ARCH_X86
195 case 0x10: return (void*) SynthesizeFragment_mode10;
196 case 0x11: return (void*) SynthesizeFragment_mode11;
197 case 0x12: return (void*) SynthesizeFragment_mode12;
198 case 0x13: return (void*) SynthesizeFragment_mode13;
199 case 0x14: return (void*) SynthesizeFragment_mode14;
200 case 0x15: return (void*) SynthesizeFragment_mode15;
201 case 0x16: return (void*) SynthesizeFragment_mode16;
202 case 0x17: return (void*) SynthesizeFragment_mode17;
203 case 0x18: return (void*) SynthesizeFragment_mode18;
204 case 0x19: return (void*) SynthesizeFragment_mode19;
205 case 0x1a: return (void*) SynthesizeFragment_mode1a;
206 case 0x1b: return (void*) SynthesizeFragment_mode1b;
207 case 0x1c: return (void*) SynthesizeFragment_mode1c;
208 case 0x1d: return (void*) SynthesizeFragment_mode1d;
209 case 0x1e: return (void*) SynthesizeFragment_mode1e;
210 case 0x1f: return (void*) SynthesizeFragment_mode1f;
211 #endif // CONFIG_ASM && ARCH_X86
212 default: {
213 printf("gig::Synthesizer: Invalid Synthesis Mode: %d\n", SynthesisMode);
214 exit(-1);
215 }
216 }
217 }
218
219 void RunSynthesisFunction(const int SynthesisMode, VOICE& voice, uint Samples, sample_t* pSrc, uint Skip)
220 {
221 SynthesizeFragment_Fn* f = (SynthesizeFragment_Fn*) GetSynthesisFunction(SynthesisMode);
222 f(voice, Samples, pSrc, Skip);
223 }
224
225 }} // namespace LinuxSampler::gig

  ViewVC Help
Powered by ViewVC