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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 738 - (hide 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 schoenebeck 320 /***************************************************************************
2     * *
3     * LinuxSampler - modular, streaming capable sampler *
4     * *
5     * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 schoenebeck 738 * Copyright (C) 2005 Christian Schoenebeck *
7 schoenebeck 320 * *
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 senkov 325 #include "Profiler.h"
30 schoenebeck 320
31 schoenebeck 738 #define SYNTHESIZE(IMPL,CHAN,LOOP,FILTER,INTERPOLATE) \
32     Synthesizer<IMPL,CHAN,LOOP,FILTER,INTERPOLATE>::SynthesizeSubFragment( \
33 schoenebeck 320 voice, samples, pSrc, skip)
34 senkov 325 #define SYNTHESIZEP(IMPL,CHAN,FILTER,INTERPOLATE,LOOP,CONSTPITCH) \
35 schoenebeck 328 RTMath::time_stamp_t start = Profiler::Stamp(); \
36 senkov 325 Synthesizer<IMPL,CHAN,FILTER,INTERPOLATE,LOOP,CONSTPITCH>::SynthesizeFragment( \
37     voice, samples, pSrc, skip); \
38     Profiler::Record(start, samples, skip)
39 schoenebeck 320
40     namespace LinuxSampler { namespace gig {
41    
42 schoenebeck 738 void SynthesizeFragment_mode00(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
43     SYNTHESIZE(CPP,MONO,0,0,0);
44     }
45    
46 senkov 325 void SynthesizeFragment_mode01(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
47 schoenebeck 738 SYNTHESIZE(CPP,MONO,0,0,1);
48 schoenebeck 320 }
49    
50 senkov 325 void SynthesizeFragment_mode02(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
51 schoenebeck 738 SYNTHESIZE(CPP,MONO,0,1,0);
52 schoenebeck 320 }
53    
54 senkov 325 void SynthesizeFragment_mode03(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
55 schoenebeck 738 SYNTHESIZE(CPP,MONO,0,1,1);
56 schoenebeck 320 }
57    
58 senkov 325 void SynthesizeFragment_mode04(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
59 schoenebeck 738 SYNTHESIZE(CPP,MONO,1,0,0);
60 schoenebeck 320 }
61    
62 senkov 325 void SynthesizeFragment_mode05(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
63 schoenebeck 738 SYNTHESIZE(CPP,MONO,1,0,1);
64 schoenebeck 320 }
65    
66 senkov 325 void SynthesizeFragment_mode06(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
67 schoenebeck 738 SYNTHESIZE(CPP,MONO,1,1,0);
68 schoenebeck 320 }
69    
70 senkov 325 void SynthesizeFragment_mode07(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
71 schoenebeck 738 SYNTHESIZE(CPP,MONO,1,1,1);
72 schoenebeck 320 }
73    
74 senkov 325 void SynthesizeFragment_mode08(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
75 schoenebeck 738 SYNTHESIZE(CPP,STEREO,0,0,0);
76 schoenebeck 320 }
77    
78 senkov 325 void SynthesizeFragment_mode09(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
79 schoenebeck 738 SYNTHESIZE(CPP,STEREO,0,0,1);
80 schoenebeck 320 }
81    
82 senkov 325 void SynthesizeFragment_mode0a(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
83 schoenebeck 738 SYNTHESIZE(CPP,STEREO,0,1,0);
84 schoenebeck 320 }
85    
86 senkov 325 void SynthesizeFragment_mode0b(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
87 schoenebeck 738 SYNTHESIZE(CPP,STEREO,0,1,1);
88 schoenebeck 320 }
89    
90 senkov 325 void SynthesizeFragment_mode0c(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
91 schoenebeck 738 SYNTHESIZE(CPP,STEREO,1,0,0);
92 schoenebeck 320 }
93    
94 senkov 325 void SynthesizeFragment_mode0d(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
95 schoenebeck 738 SYNTHESIZE(CPP,STEREO,1,0,1);
96 schoenebeck 320 }
97    
98 senkov 325 void SynthesizeFragment_mode0e(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
99 schoenebeck 738 SYNTHESIZE(CPP,STEREO,1,1,0);
100 schoenebeck 320 }
101    
102 senkov 325 void SynthesizeFragment_mode0f(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
103 schoenebeck 738 SYNTHESIZE(CPP,STEREO,1,1,1);
104 schoenebeck 320 }
105    
106 schoenebeck 738 #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 senkov 325 void SynthesizeFragment_mode11(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
113 schoenebeck 738 SYNTHESIZE(ASM_X86_MMX_SSE,MONO,0,0,1);
114 schoenebeck 320 }
115    
116 schoenebeck 738 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 senkov 325 void SynthesizeFragment_mode13(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
121 schoenebeck 738 SYNTHESIZE(ASM_X86_MMX_SSE,MONO,0,1,1);
122 schoenebeck 320 }
123    
124 senkov 325 void SynthesizeFragment_mode14(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
125 schoenebeck 738 SYNTHESIZE(ASM_X86_MMX_SSE,MONO,1,0,0);
126 schoenebeck 320 }
127    
128 senkov 325 void SynthesizeFragment_mode15(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
129 schoenebeck 738 SYNTHESIZE(ASM_X86_MMX_SSE,MONO,1,0,1);
130 schoenebeck 320 }
131    
132 senkov 325 void SynthesizeFragment_mode16(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
133 schoenebeck 738 SYNTHESIZE(ASM_X86_MMX_SSE,MONO,1,1,0);
134 schoenebeck 320 }
135    
136 senkov 325 void SynthesizeFragment_mode17(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
137 schoenebeck 738 SYNTHESIZE(ASM_X86_MMX_SSE,MONO,1,1,1);
138 schoenebeck 320 }
139    
140 schoenebeck 738 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 senkov 325 void SynthesizeFragment_mode19(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
145 schoenebeck 738 SYNTHESIZE(ASM_X86_MMX_SSE,STEREO,0,0,1);
146 schoenebeck 320 }
147    
148 schoenebeck 738 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 senkov 325 void SynthesizeFragment_mode1b(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
153 schoenebeck 738 SYNTHESIZE(ASM_X86_MMX_SSE,STEREO,0,1,1);
154 schoenebeck 320 }
155    
156 senkov 325 void SynthesizeFragment_mode1c(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
157 schoenebeck 738 SYNTHESIZE(ASM_X86_MMX_SSE,STEREO,1,0,0);
158 schoenebeck 320 }
159    
160 senkov 325 void SynthesizeFragment_mode1d(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
161 schoenebeck 738 SYNTHESIZE(ASM_X86_MMX_SSE,STEREO,1,0,1);
162 schoenebeck 320 }
163    
164 senkov 325 void SynthesizeFragment_mode1e(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
165 schoenebeck 738 SYNTHESIZE(ASM_X86_MMX_SSE,STEREO,1,1,0);
166 schoenebeck 320 }
167    
168 senkov 325 void SynthesizeFragment_mode1f(VOICE &voice, uint samples, sample_t* pSrc, uint skip) {
169 schoenebeck 738 SYNTHESIZE(ASM_X86_MMX_SSE,STEREO,1,1,1);
170 schoenebeck 320 }
171    
172 schoenebeck 738 #endif // CONFIG_ASM && ARCH_X86
173 schoenebeck 328
174 schoenebeck 738 void* GetSynthesisFunction(int SynthesisMode) {
175     // Mode Bits: IMPL,CHAN,LOOP,FILT,INTERP
176     SynthesisMode &= 0x1f;
177 schoenebeck 320 switch (SynthesisMode) {
178 schoenebeck 738 case 0x00: return (void*) SynthesizeFragment_mode00;
179 senkov 325 case 0x01: return (void*) SynthesizeFragment_mode01;
180 schoenebeck 738 case 0x02: return (void*) SynthesizeFragment_mode02;
181 senkov 325 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 schoenebeck 738 case 0x08: return (void*) SynthesizeFragment_mode08;
187 senkov 325 case 0x09: return (void*) SynthesizeFragment_mode09;
188 schoenebeck 738 case 0x0a: return (void*) SynthesizeFragment_mode0a;
189 senkov 325 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 schoenebeck 738 #if CONFIG_ASM && ARCH_X86
195     case 0x10: return (void*) SynthesizeFragment_mode10;
196 senkov 325 case 0x11: return (void*) SynthesizeFragment_mode11;
197 schoenebeck 738 case 0x12: return (void*) SynthesizeFragment_mode12;
198 senkov 325 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 schoenebeck 738 case 0x18: return (void*) SynthesizeFragment_mode18;
204 senkov 325 case 0x19: return (void*) SynthesizeFragment_mode19;
205 schoenebeck 738 case 0x1a: return (void*) SynthesizeFragment_mode1a;
206 senkov 325 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 schoenebeck 738 #endif // CONFIG_ASM && ARCH_X86
212 schoenebeck 320 default: {
213     printf("gig::Synthesizer: Invalid Synthesis Mode: %d\n", SynthesisMode);
214     exit(-1);
215     }
216     }
217     }
218    
219 senkov 325 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 schoenebeck 328
225 schoenebeck 320 }} // namespace LinuxSampler::gig

  ViewVC Help
Powered by ViewVC