1/*
2 * Copyright (c) 1999-2000, Eric Moon.
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
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 *    notice, this list of conditions, and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions, and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 *
16 * 3. The name of the author may not be used to endorse or promote products
17 *    derived from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
27 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31
32// AudioAdapterOp.cpp
33
34#include "AudioAdapterOp.h"
35#include "IAudioOp.h"
36
37#include "AudioAdapterParams.h"
38
39#include "audio_buffer_tools.h"
40
41#include <Debug.h>
42#include <ParameterWeb.h>
43
44
45//// empty parameter-set implementation
46//// +++++ move to IParameterSet.h!
47//
48//class _EmptyParameterSet :
49//	public	IParameterSet {
50//public:
51//	status_t store(
52//		int32										parameterID,
53//		void*										data,
54//		size_t									size) { return B_ERROR; }
55//
56//	status_t retrieve(
57//		int32										parameterID,
58//		void*										data,
59//		size_t*									ioSize) { return B_ERROR; }
60//
61//	void populateGroup(
62//		BParameterGroup* 				group) {}
63//};
64
65// -------------------------------------------------------- //
66// _AudioAdapterOp_base
67// -------------------------------------------------------- //
68
69class _AudioAdapterOp_base :
70	public	IAudioOp {
71public:
72	_AudioAdapterOp_base(
73		IAudioOpHost*						_host) :
74		IAudioOp(_host) {}
75
76	void replace(
77		IAudioOp*								oldOp) {
78		delete oldOp;
79	}
80};
81
82// -------------------------------------------------------- //
83// _AudioAdapterOp implementations
84// -------------------------------------------------------- //
85
86// direct conversion:
87// - source and destination channel_count must be identical
88// - source and destination must be host-endian
89
90template <class in_t, class out_t>
91class _AudioAdapterOp_direct :
92	public	_AudioAdapterOp_base {
93
94public:
95	_AudioAdapterOp_direct(
96		IAudioOpHost*						_host) :
97		_AudioAdapterOp_base(_host) {
98
99		PRINT(("### _AudioAdapterOp_direct()\n"));
100	}
101
102	uint32 process(
103		const AudioBuffer&			source,
104		AudioBuffer&						destination,
105		double&									sourceFrame,
106		uint32&									destinationFrame,
107		uint32									framesRequired,
108		bigtime_t								performanceTime) {
109
110		int32 inChannels = source.format().channel_count;
111		ASSERT(inChannels <= 2);
112		int32 outChannels = destination.format().channel_count;
113		ASSERT(outChannels == inChannels);
114
115		bool stereo = (inChannels == 2);
116
117		in_t* inBuffer =
118			((in_t*)source.data()) + (uint32)sourceFrame*inChannels;
119
120		out_t* outBuffer =
121			((out_t*)destination.data()) + destinationFrame*outChannels;
122
123		uint32 frame = framesRequired;
124		while(frame--) {
125
126			float val;
127			convert_sample(
128				*inBuffer,
129				val);
130			convert_sample(
131				val,
132				*outBuffer);
133
134			++inBuffer;
135			++outBuffer;
136
137			if(stereo) {
138				convert_sample(
139					*inBuffer,
140					val);
141				convert_sample(
142					val,
143					*outBuffer);
144				++inBuffer;
145				++outBuffer;
146			}
147
148			sourceFrame += 1.0;
149			destinationFrame++;
150		}
151
152		return framesRequired;
153	}
154};
155
156// direct conversion + incoming data byteswapped
157// - source and destination channel_count must be identical
158// - destination must be host-endian
159
160template <class in_t, class out_t>
161class _AudioAdapterOp_swap_direct :
162	public	_AudioAdapterOp_base {
163
164public:
165	_AudioAdapterOp_swap_direct(
166		IAudioOpHost*						_host) :
167		_AudioAdapterOp_base(_host) {
168
169		PRINT(("### _AudioAdapterOp_swap_direct()\n"));
170	}
171
172	uint32 process(
173		const AudioBuffer&			source,
174		AudioBuffer&						destination,
175		double&									sourceFrame,
176		uint32&									destinationFrame,
177		uint32									framesRequired,
178		bigtime_t								performanceTime) {
179
180		int32 inChannels = source.format().channel_count;
181		ASSERT(inChannels <= 2);
182		int32 outChannels = destination.format().channel_count;
183		ASSERT(outChannels == inChannels);
184
185		bool stereo = (inChannels == 2);
186
187		in_t* inBuffer =
188			((in_t*)source.data()) + (uint32)sourceFrame*inChannels;
189
190		out_t* outBuffer =
191			((out_t*)destination.data()) + destinationFrame*outChannels;
192
193		uint32 frame = framesRequired;
194		while(frame--) {
195
196			float val;
197			swap_convert_sample(
198				*inBuffer,
199				val);
200			convert_sample(
201				val,
202				*outBuffer);
203
204			++inBuffer;
205			++outBuffer;
206
207			if(stereo) {
208				swap_convert_sample(
209					*inBuffer,
210					val);
211				convert_sample(
212					val,
213					*outBuffer);
214				++inBuffer;
215				++outBuffer;
216			}
217
218			sourceFrame += 1.0;
219			destinationFrame++;
220		}
221
222		return framesRequired;
223	}
224};
225
226template <class in_t, class out_t>
227class _AudioAdapterOp_split :
228	public	_AudioAdapterOp_base {
229public:
230	_AudioAdapterOp_split(
231		IAudioOpHost*						_host) :
232		_AudioAdapterOp_base(_host) {
233
234		PRINT(("### _AudioAdapterOp_split()\n"));
235	}
236
237	uint32 process(
238		const AudioBuffer&			source,
239		AudioBuffer&						destination,
240		double&									sourceFrame,
241		uint32&									destinationFrame,
242		uint32									framesRequired,
243		bigtime_t								performanceTime) {
244
245		int32 inChannels = source.format().channel_count;
246		ASSERT(inChannels == 1);
247		int32 outChannels = destination.format().channel_count;
248		ASSERT(outChannels == 2);
249
250		in_t* inBuffer =
251			((in_t*)source.data()) + (uint32)sourceFrame*inChannels;
252
253		out_t* outBuffer =
254			((out_t*)destination.data()) + destinationFrame*outChannels;
255
256		uint32 frame = framesRequired;
257		while(frame--) {
258
259			float val;
260			convert_sample(
261				*inBuffer,
262				val);
263			// write channel 0
264			convert_sample(
265				val,
266				*outBuffer);
267
268			// write channel 1
269			++outBuffer;
270			convert_sample(
271				val,
272				*outBuffer);
273
274			++inBuffer;
275			++outBuffer;
276
277			sourceFrame += 1.0;
278			destinationFrame++;
279		}
280
281		return framesRequired;
282	}
283};
284
285template <class in_t, class out_t>
286class _AudioAdapterOp_swap_split :
287	public	_AudioAdapterOp_base {
288public:
289	_AudioAdapterOp_swap_split(
290		IAudioOpHost*						_host) :
291		_AudioAdapterOp_base(_host) {
292
293		PRINT(("### _AudioAdapterOp_swap_split()\n"));
294	}
295
296	uint32 process(
297		const AudioBuffer&			source,
298		AudioBuffer&						destination,
299		double&									sourceFrame,
300		uint32&									destinationFrame,
301		uint32									framesRequired,
302		bigtime_t								performanceTime) {
303
304		int32 inChannels = source.format().channel_count;
305		ASSERT(inChannels == 1);
306		int32 outChannels = destination.format().channel_count;
307		ASSERT(outChannels == 2);
308
309		in_t* inBuffer =
310			((in_t*)source.data()) + (uint32)sourceFrame*inChannels;
311
312		out_t* outBuffer =
313			((out_t*)destination.data()) + destinationFrame*outChannels;
314
315		uint32 frame = framesRequired;
316		while(frame--) {
317
318			float val;
319			swap_convert_sample(
320				*inBuffer,
321				val);
322			// write channel 0
323			convert_sample(
324				val,
325				*outBuffer);
326
327			// write channel 1
328			++outBuffer;
329			convert_sample(
330				val,
331				*outBuffer);
332
333			++inBuffer;
334			++outBuffer;
335
336			sourceFrame += 1.0;
337			destinationFrame++;
338		}
339
340		return framesRequired;
341	}
342};
343
344
345template <class in_t, class out_t>
346class _AudioAdapterOp_mix :
347	public	_AudioAdapterOp_base {
348public:
349	_AudioAdapterOp_mix(
350		IAudioOpHost*						_host) :
351		_AudioAdapterOp_base(_host) {
352
353		PRINT(("### _AudioAdapterOp_mix()\n"));
354	}
355
356	uint32 process(
357		const AudioBuffer&			source,
358		AudioBuffer&						destination,
359		double&									sourceFrame,
360		uint32&									destinationFrame,
361		uint32									framesRequired,
362		bigtime_t								performanceTime) {
363
364		int32 inChannels = source.format().channel_count;
365		ASSERT(inChannels == 2);
366		int32 outChannels = destination.format().channel_count;
367		ASSERT(outChannels == 1);
368
369		in_t* inBuffer =
370			((in_t*)source.data()) + (uint32)sourceFrame*inChannels;
371
372		out_t* outBuffer =
373			((out_t*)destination.data()) + destinationFrame*outChannels;
374
375		uint32 frame = framesRequired;
376		while(frame--) {
377
378			float out, in;
379			convert_sample(
380				*inBuffer,
381				in);
382
383			out = in * 0.5;
384			++inBuffer;
385
386			convert_sample(
387				*inBuffer,
388				in);
389
390			out += (in * 0.5);
391
392			// write channel 0
393			convert_sample(
394				out,
395				*outBuffer);
396
397			++inBuffer;
398			++outBuffer;
399
400			sourceFrame += 1.0;
401			destinationFrame++;
402		}
403
404		return framesRequired;
405	}
406};
407
408template <class in_t, class out_t>
409class _AudioAdapterOp_swap_mix :
410	public	_AudioAdapterOp_base {
411public:
412	_AudioAdapterOp_swap_mix(
413		IAudioOpHost*						_host) :
414		_AudioAdapterOp_base(_host) {
415
416		PRINT(("### _AudioAdapterOp_swap_mix()\n"));
417	}
418
419	uint32 process(
420		const AudioBuffer&			source,
421		AudioBuffer&						destination,
422		double&									sourceFrame,
423		uint32&									destinationFrame,
424		uint32									framesRequired,
425		bigtime_t								performanceTime) {
426
427		int32 inChannels = source.format().channel_count;
428		ASSERT(inChannels == 2);
429		int32 outChannels = destination.format().channel_count;
430		ASSERT(outChannels == 1);
431
432		in_t* inBuffer =
433			((in_t*)source.data()) + (uint32)sourceFrame*inChannels;
434
435		out_t* outBuffer =
436			((out_t*)destination.data()) + destinationFrame*outChannels;
437
438		uint32 frame = framesRequired;
439		while(frame--) {
440
441			float out, in;
442			swap_convert_sample(
443				*inBuffer,
444				in);
445
446			out = in * 0.5;
447			++inBuffer;
448
449			swap_convert_sample(
450				*inBuffer,
451				in);
452
453			out += (in * 0.5);
454
455			// write channel 0
456			convert_sample(
457				out,
458				*outBuffer);
459
460			++inBuffer;
461			++outBuffer;
462
463			sourceFrame += 1.0;
464			destinationFrame++;
465		}
466
467		return framesRequired;
468	}
469};
470
471// -------------------------------------------------------- //
472// AudioAdapterOpFactory impl.
473// -------------------------------------------------------- //
474
475// [8sep99]  yeeechk!
476// [16sep99] now handles pre-conversion byteswapping
477
478IAudioOp* AudioAdapterOpFactory::createOp(
479	IAudioOpHost*										host,
480	const media_raw_audio_format&		inputFormat,
481	const media_raw_audio_format&		outputFormat) {
482
483	// [16sep99] ensure fully-specified input & output formats
484	ASSERT(
485		inputFormat.frame_rate &&
486		inputFormat.byte_order &&
487		inputFormat.channel_count &&
488		inputFormat.format &&
489		inputFormat.buffer_size);
490	ASSERT(
491		outputFormat.frame_rate &&
492		outputFormat.byte_order &&
493		outputFormat.channel_count &&
494		outputFormat.format &&
495		outputFormat.buffer_size);
496
497	int32 inChannels = inputFormat.channel_count;
498	int32 outChannels = outputFormat.channel_count;
499
500//	char fmt_buffer[256];
501//	media_format f;
502//	f.type = B_MEDIA_RAW_AUDIO;
503//	f.u.raw_audio = inputFormat;
504//	string_for_format(f, fmt_buffer, 255);
505
506	bool swapBefore = (inputFormat.byte_order !=
507		((B_HOST_IS_BENDIAN) ? B_MEDIA_BIG_ENDIAN : B_MEDIA_LITTLE_ENDIAN));
508
509//	PRINT(("### swapBefore: '%s'\n", fmt_buffer));
510
511	bool split = outChannels > inChannels;
512	bool mix = outChannels < inChannels;
513
514	switch(inputFormat.format) {
515		case media_raw_audio_format::B_AUDIO_UCHAR:
516			switch(outputFormat.format) {
517				case media_raw_audio_format::B_AUDIO_UCHAR:
518					return
519						split ? (IAudioOp*)new _AudioAdapterOp_split     < uint8, uint8>(host) :
520							mix ? (IAudioOp*)new _AudioAdapterOp_mix       < uint8, uint8>(host) :
521								(IAudioOp*)new _AudioAdapterOp_direct        < uint8, uint8>(host);
522					break;
523				case media_raw_audio_format::B_AUDIO_SHORT:
524					if(swapBefore) return
525						split ? (IAudioOp*)new _AudioAdapterOp_swap_split< uint8, short>(host) :
526							mix ? (IAudioOp*)new _AudioAdapterOp_swap_mix  < uint8, short>(host) :
527								(IAudioOp*)new _AudioAdapterOp_swap_direct   < uint8, short>(host);
528					else return
529						split ? (IAudioOp*)new _AudioAdapterOp_split     < uint8, short>(host) :
530							mix ? (IAudioOp*)new _AudioAdapterOp_mix       < uint8, short>(host) :
531								(IAudioOp*)new _AudioAdapterOp_direct        < uint8, short>(host);
532					break;
533				case media_raw_audio_format::B_AUDIO_FLOAT:
534					if(swapBefore) return
535						split ? (IAudioOp*)new _AudioAdapterOp_swap_split< uint8, float>(host) :
536							mix ? (IAudioOp*)new _AudioAdapterOp_swap_mix  < uint8, float>(host) :
537								(IAudioOp*)new _AudioAdapterOp_swap_direct   < uint8, float>(host);
538					else return
539						split ? (IAudioOp*)new _AudioAdapterOp_split     < uint8, float>(host) :
540							mix ? (IAudioOp*)new _AudioAdapterOp_mix       < uint8, float>(host) :
541								(IAudioOp*)new _AudioAdapterOp_direct        < uint8, float>(host);
542					break;
543				case media_raw_audio_format::B_AUDIO_INT:
544					if(swapBefore) return
545						split ? (IAudioOp*)new _AudioAdapterOp_swap_split< uint8, int32>(host) :
546							mix ? (IAudioOp*)new _AudioAdapterOp_swap_mix  < uint8, int32>(host) :
547								(IAudioOp*)new _AudioAdapterOp_swap_direct   < uint8, int32>(host);
548					else return
549						split ? (IAudioOp*)new _AudioAdapterOp_split     < uint8, int32>(host) :
550							mix ? (IAudioOp*)new _AudioAdapterOp_mix       < uint8, int32>(host) :
551								(IAudioOp*)new _AudioAdapterOp_direct        < uint8, int32>(host);
552					break;
553			}
554			break;
555
556		case media_raw_audio_format::B_AUDIO_SHORT:
557			switch(outputFormat.format) {
558				case media_raw_audio_format::B_AUDIO_UCHAR:
559					if(swapBefore) return
560						split ? (IAudioOp*)new _AudioAdapterOp_swap_split< short, uint8>(host) :
561							mix ? (IAudioOp*)new _AudioAdapterOp_swap_mix  < short, uint8>(host) :
562								(IAudioOp*)new _AudioAdapterOp_swap_direct   < short, uint8>(host);
563					else return
564						split ? (IAudioOp*)new _AudioAdapterOp_split     < short, uint8>(host) :
565							mix ? (IAudioOp*)new _AudioAdapterOp_mix       < short, uint8>(host) :
566								(IAudioOp*)new _AudioAdapterOp_direct        < short, uint8>(host);
567					break;
568				case media_raw_audio_format::B_AUDIO_SHORT:
569					if(swapBefore) return
570						split ? (IAudioOp*)new _AudioAdapterOp_swap_split< short, short>(host) :
571							mix ? (IAudioOp*)new _AudioAdapterOp_swap_mix  < short, short>(host) :
572								(IAudioOp*)new _AudioAdapterOp_swap_direct   < short, short>(host);
573					else return
574						split ? (IAudioOp*)new _AudioAdapterOp_split     < short, short>(host) :
575							mix ? (IAudioOp*)new _AudioAdapterOp_mix       < short, short>(host) :
576								(IAudioOp*)new _AudioAdapterOp_direct        < short, short>(host);
577					break;
578				case media_raw_audio_format::B_AUDIO_FLOAT:
579					if(swapBefore) return
580						split ? (IAudioOp*)new _AudioAdapterOp_swap_split< short, float>(host) :
581							mix ? (IAudioOp*)new _AudioAdapterOp_swap_mix  < short, float>(host) :
582								(IAudioOp*)new _AudioAdapterOp_swap_direct   < short, float>(host);
583					else return
584						split ? (IAudioOp*)new _AudioAdapterOp_split     < short, float>(host) :
585							mix ? (IAudioOp*)new _AudioAdapterOp_mix       < short, float>(host) :
586								(IAudioOp*)new _AudioAdapterOp_direct        < short, float>(host);
587					break;
588				case media_raw_audio_format::B_AUDIO_INT:
589					if(swapBefore) return
590						split ? (IAudioOp*)new _AudioAdapterOp_swap_split< short, int32>(host) :
591							mix ? (IAudioOp*)new _AudioAdapterOp_swap_mix  < short, int32>(host) :
592								(IAudioOp*)new _AudioAdapterOp_swap_direct   < short, int32>(host);
593					else return
594						split ? (IAudioOp*)new _AudioAdapterOp_split     < short, int32>(host) :
595							mix ? (IAudioOp*)new _AudioAdapterOp_mix       < short, int32>(host) :
596								(IAudioOp*)new _AudioAdapterOp_direct        < short, int32>(host);
597					break;
598			}
599			break;
600
601		case media_raw_audio_format::B_AUDIO_FLOAT:
602			switch(outputFormat.format) {
603				case media_raw_audio_format::B_AUDIO_UCHAR:
604					if(swapBefore) return
605						split ? (IAudioOp*)new _AudioAdapterOp_swap_split< float, uint8>(host) :
606							mix ? (IAudioOp*)new _AudioAdapterOp_swap_mix  < float, uint8>(host) :
607								(IAudioOp*)new _AudioAdapterOp_swap_direct   < float, uint8>(host);
608					else return
609						split ? (IAudioOp*)new _AudioAdapterOp_split     < float, uint8>(host) :
610							mix ? (IAudioOp*)new _AudioAdapterOp_mix       < float, uint8>(host) :
611								(IAudioOp*)new _AudioAdapterOp_direct        < float, uint8>(host);
612					break;
613				case media_raw_audio_format::B_AUDIO_SHORT:
614					if(swapBefore) return
615						split ? (IAudioOp*)new _AudioAdapterOp_swap_split< float, short>(host) :
616							mix ? (IAudioOp*)new _AudioAdapterOp_swap_mix  < float, short>(host) :
617								(IAudioOp*)new _AudioAdapterOp_swap_direct   < float, short>(host);
618					else return
619						split ? (IAudioOp*)new _AudioAdapterOp_split     < float, short>(host) :
620							mix ? (IAudioOp*)new _AudioAdapterOp_mix       < float, short>(host) :
621								(IAudioOp*)new _AudioAdapterOp_direct        < float, short>(host);
622					break;
623				case media_raw_audio_format::B_AUDIO_FLOAT:
624					if(swapBefore) return
625						split ? (IAudioOp*)new _AudioAdapterOp_swap_split< float, float>(host) :
626							mix ? (IAudioOp*)new _AudioAdapterOp_swap_mix  < float, float>(host) :
627								(IAudioOp*)new _AudioAdapterOp_swap_direct   < float, float>(host);
628					else return
629						split ? (IAudioOp*)new _AudioAdapterOp_split     < float, float>(host) :
630							mix ? (IAudioOp*)new _AudioAdapterOp_mix       < float, float>(host) :
631								(IAudioOp*)new _AudioAdapterOp_direct        < float, float>(host);
632					break;
633				case media_raw_audio_format::B_AUDIO_INT:
634					if(swapBefore) return
635						split ? (IAudioOp*)new _AudioAdapterOp_swap_split< float, int32>(host) :
636							mix ? (IAudioOp*)new _AudioAdapterOp_swap_mix  < float, int32>(host) :
637								(IAudioOp*)new _AudioAdapterOp_swap_direct   < float, int32>(host);
638					else return
639						split ? (IAudioOp*)new _AudioAdapterOp_split     < float, int32>(host) :
640							mix ? (IAudioOp*)new _AudioAdapterOp_mix       < float, int32>(host) :
641								(IAudioOp*)new _AudioAdapterOp_direct        < float, int32>(host);
642					break;
643			}
644			break;
645
646		case media_raw_audio_format::B_AUDIO_INT:
647			switch(outputFormat.format) {
648				case media_raw_audio_format::B_AUDIO_UCHAR:
649					if(swapBefore) return
650						split ? (IAudioOp*)new _AudioAdapterOp_swap_split< int32, uint8>(host) :
651							mix ? (IAudioOp*)new _AudioAdapterOp_swap_mix  < int32, uint8>(host) :
652								(IAudioOp*)new _AudioAdapterOp_swap_direct   < int32, uint8>(host);
653					else return
654						split ? (IAudioOp*)new _AudioAdapterOp_split     < int32, uint8>(host) :
655							mix ? (IAudioOp*)new _AudioAdapterOp_mix       < int32, uint8>(host) :
656								(IAudioOp*)new _AudioAdapterOp_direct        < int32, uint8>(host);
657					break;
658				case media_raw_audio_format::B_AUDIO_SHORT:
659					if(swapBefore) return
660						split ? (IAudioOp*)new _AudioAdapterOp_swap_split< int32, short>(host) :
661							mix ? (IAudioOp*)new _AudioAdapterOp_swap_mix  < int32, short>(host) :
662								(IAudioOp*)new _AudioAdapterOp_swap_direct   < int32, short>(host);
663					else return
664						split ? (IAudioOp*)new _AudioAdapterOp_split     < int32, short>(host) :
665							mix ? (IAudioOp*)new _AudioAdapterOp_mix       < int32, short>(host) :
666								(IAudioOp*)new _AudioAdapterOp_direct        < int32, short>(host);
667					break;
668				case media_raw_audio_format::B_AUDIO_FLOAT:
669					if(swapBefore) return
670						split ? (IAudioOp*)new _AudioAdapterOp_swap_split< int32, float>(host) :
671							mix ? (IAudioOp*)new _AudioAdapterOp_swap_mix  < int32, float>(host) :
672								(IAudioOp*)new _AudioAdapterOp_swap_direct   < int32, float>(host);
673					else return
674						split ? (IAudioOp*)new _AudioAdapterOp_split     < int32, float>(host) :
675							mix ? (IAudioOp*)new _AudioAdapterOp_mix       < int32, float>(host) :
676								(IAudioOp*)new _AudioAdapterOp_direct        < int32, float>(host);
677					break;
678				case media_raw_audio_format::B_AUDIO_INT:
679					if(swapBefore) return
680						split ? (IAudioOp*)new _AudioAdapterOp_swap_split< int32, int32>(host) :
681							mix ? (IAudioOp*)new _AudioAdapterOp_swap_mix  < int32, int32>(host) :
682								(IAudioOp*)new _AudioAdapterOp_swap_direct   < int32, int32>(host);
683					else return
684						split ? (IAudioOp*)new _AudioAdapterOp_split     < int32, int32>(host) :
685							mix ? (IAudioOp*)new _AudioAdapterOp_mix       < int32, int32>(host) :
686								(IAudioOp*)new _AudioAdapterOp_direct        < int32, int32>(host);
687					break;
688			}
689			break;
690	}
691
692	return 0;
693}
694
695IParameterSet* AudioAdapterOpFactory::createParameterSet() {
696	return new _AudioAdapterParams();
697}
698
699
700// END -- AudioAdapterOp.cpp --
701