Ardour  9.0-pre0-582-g084a23a80d
audio_utils.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Tim Mayberry <mojofunk@gmail.com>
3  * Copyright (C) 2017 Paul Davis <paul@linuxaudiosystems.com>
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 2 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 along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef AUDIO_UTILS_H
21 #define AUDIO_UTILS_H
22 
23 #include <stdint.h>
24 
25 inline
26 void
27 deinterleave_audio_data(const float* interleaved_input,
28  float* output,
29  uint32_t sample_count,
30  uint32_t channel,
31  uint32_t channel_count)
32 {
33  const float* ptr = interleaved_input + channel;
34  while (sample_count-- > 0) {
35  *output++ = *ptr;
36  ptr += channel_count;
37  }
38 }
39 
40 inline
41 void
42 interleave_audio_data(float* input,
43  float* interleaved_output,
44  uint32_t sample_count,
45  uint32_t channel,
46  uint32_t channel_count)
47 {
48  float* ptr = interleaved_output + channel;
49  while (sample_count-- > 0) {
50  *ptr = *input++;
51  ptr += channel_count;
52  }
53 }
54 
55 #endif // AUDIO_UTILS_H
void deinterleave_audio_data(const float *interleaved_input, float *output, uint32_t sample_count, uint32_t channel, uint32_t channel_count)
Definition: audio_utils.h:27
void interleave_audio_data(float *input, float *interleaved_output, uint32_t sample_count, uint32_t channel, uint32_t channel_count)
Definition: audio_utils.h:42