-
Notifications
You must be signed in to change notification settings - Fork 11
/
streams.c
119 lines (102 loc) · 3.54 KB
/
streams.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
* Copyright (c) 2013-2014 Adrian Knoth (Google Inc.)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <stdio.h>
#include <inttypes.h>
#define kHDSPe_MADI_FX 1
#define kMADIface_XT 2
#define NUM_OUTPUTS_S_HMFX (64*3+4)
#define NUM_OUTPUTS_D_HMFX (32*3+4)
#define NUM_OUTPUTS_Q_HMFX (16*3+4)
#define NUM_INPUTS_S_HMFX (64*3+2)
#define NUM_INPUTS_D_HMFX (32*3+2)
#define NUM_INPUTS_Q_HMFX (16*3+2)
#define NUM_OUTPUTS_S_MFXT (64*3+6)
#define NUM_OUTPUTS_D_MFXT (32*3+6)
#define NUM_OUTPUTS_Q_MFXT (16*3+6)
#define NUM_INPUTS_S_MFXT (64*3+4)
#define NUM_INPUTS_D_MFXT (32*3+4)
#define NUM_INPUTS_Q_MFXT (16*3+4)
#define NUM_INPUT_STREAMS_HMFX 25
#define NUM_OUTPUT_STREAMS_HMFX 26
#define NUM_INPUT_STREAMS_MFXT 26
#define NUM_OUTPUT_STREAMS_MFXT 27
#define BYTES_PER_SAMPLE 4
#define INITIAL_SAMPLE_RATE 44100
#define NUM_SAMPLE_FRAMES 8192
#define SAMPLE_FRAMES_PER_BUFFER 8192 //4096
#define BIT_DEPTH 32
#define MIN_RATE 30000
#define MAX_RATE 200000
int main(void) {
int card_type = kHDSPe_MADI_FX;
int i;
int numInputStreams = card_type == kHDSPe_MADI_FX ? NUM_INPUT_STREAMS_HMFX : NUM_INPUT_STREAMS_MFXT;
int numOutputStreams = card_type == kHDSPe_MADI_FX ? NUM_OUTPUT_STREAMS_HMFX : NUM_OUTPUT_STREAMS_MFXT;
for (i = 0; i < numInputStreams; i++)
{
int n;
int32_t *buf = 0;
if (card_type == kHDSPe_MADI_FX) {
n = (i == 0) ? 2 : 8;
if (i > 0) {
buf += ((i-1)*8+2) * NUM_SAMPLE_FRAMES;
}
} else { // MADIface XT
n = (i < 2) ? 2 : 8;
if (i == 1) {
buf += 2 * NUM_SAMPLE_FRAMES;
} else if (i > 1) {
buf += ((i-2)*8+4) * NUM_SAMPLE_FRAMES;
}
}
printf ("Inputstream %i with %i channels at byte offset %i\n", i, n, buf);
}
for (i = 0; i < numOutputStreams; i++)
{
int n;
int32_t *buf = 0;
if (card_type == kHDSPe_MADI_FX) {
n = (i == 0 || i == NUM_OUTPUT_STREAMS_HMFX-1) ? 2 : 8;
if (i == NUM_OUTPUT_STREAMS_HMFX-1) {
buf += 2 * NUM_SAMPLE_FRAMES; // HW channel 2..3
} else if (i > 0) {
buf += ((i-1)*8+4) * NUM_SAMPLE_FRAMES; // HW channel 4..195
}
} else {
n = (i < 2 || i == NUM_OUTPUT_STREAMS_MFXT-1) ? 2 : 8;
if (i == NUM_OUTPUT_STREAMS_MFXT-1) {
buf += 4 * NUM_SAMPLE_FRAMES; // Phones, HW channel 4..5
} else if (i == 1) {
buf += 2 * NUM_SAMPLE_FRAMES; // AES, HW channel 2..3
} else if (i > 1) {
buf += ((i-2)*8+6) * NUM_SAMPLE_FRAMES; // HW channel 6..197
} // else Analog, HW channel 0..1
}
printf ("Outputstream %i with %i channels at byte offset %i\n", i, n, buf);
}
for (i = 0; i < 194; i++) {
printf ("Linux input ch %i offset %i\n", i , (i < 2) ? 0 : 65536 + 8 * 4 * 8192 * (((i-2)/8)));
}
for (i = 0; i < 196; i++) {
printf ("Linux sample offset ch %i offset %i\n", i ,
(i < 2 || i > 193) ?
32 * (i % 194) : 32 * ((i-2) % 8));
}
return 0;
}