Beatmup
processing.h
Go to the documentation of this file.
1 /*
2  Beatmup image and signal processing library
3  Copyright (C) 2020, lnstadrum
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #pragma once
20 #include "sample_arithmetic.h"
21 
22 namespace Beatmup {
23  namespace Audio {
24  /**
25  Contains templates calling elementary audio signal processing routines depending on sample formats of their arguments.
26  An elementary routine is a class template having a public function process() performing a specific processing action.
27  The template arguments of this class are readers of / writers to signal specialized for given sample formats.
28  */
29  namespace Processing {
30 
31  template<template<typename, typename> class Func, typename... Args>
32  inline void pipeline(const AudioSampleFormat inFormat, const AudioSampleFormat outFormat, const sample8* input, sample8* output, Args&&... args) {
33 
34 #define WRITING(IN_T) \
35  switch (outFormat) { \
36  case Int8: \
37  Func<IN_T, sample8>::process((const IN_T*)input, (sample8*)output, args...); \
38  break; \
39  case Int16: \
40  Func<IN_T, sample16>::process((const IN_T*)input, (sample16*)output, args...); \
41  break; \
42  case Int32: \
43  Func<IN_T, sample32>::process((const IN_T*)input, (sample32*)output, args...); \
44  break; \
45  case Float32: \
46  Func<IN_T, sample32f>::process((const IN_T*)input, (sample32f*)output, args...); \
47  break; \
48  }
49 
50  switch (inFormat) {
51  case Int8:
53  break;
54  case Int16:
56  break;
57  case Int32:
59  break;
60  case Float32:
62  break;
63  }
64 #undef WRITING
65  }
66  }
67  }
68 }
#define WRITING(IN_T)
void pipeline(const AudioSampleFormat inFormat, const AudioSampleFormat outFormat, const sample8 *input, sample8 *output, Args &&... args)
Definition: processing.h:32
AudioSampleFormat
Format of audio samples.
@ Int8
signed integer, 8 bit per sample
@ Int32
signed integer, 32 bit per sample
@ Float32
floating point, 32 bit per sample
@ Int16
signed integer, 16 bit per sample