aboutsummaryrefslogtreecommitdiffstats
path: root/src/snd_motu_register_dsp_parameter.c
blob: 7a0370c774332861bd774a74b990372ab4e2495b (plain)
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
// SPDX-License-Identifier: LGPL-3.0-or-later
#include "internal.h"

/**
 * HinawaSndMotuRegisterDspParameter:
 * A boxed object for container of parameter in register DSP model.
 *
 * A [struct@SndMotuRegisterDspParameter] is a boxed object for container of parameter in register
 * DSP model.
 */
HinawaSndMotuRegisterDspParameter *register_dsp_parameter_copy(const HinawaSndMotuRegisterDspParameter *self)
{
#ifdef g_memdup2
    return g_memdup2(self, sizeof(*self));
#else
    // GLib v2.68 deprecated g_memdup() with concern about overflow by narrow conversion from size_t to
    // unsigned int however it's safe in the local case.
    gpointer ptr = g_malloc(sizeof(*self));
    memcpy(ptr, self, sizeof(*self));
    return ptr;
#endif
}

G_DEFINE_BOXED_TYPE(HinawaSndMotuRegisterDspParameter, hinawa_snd_motu_register_dsp_parameter, register_dsp_parameter_copy, g_free)

/**
 * hinawa_snd_motu_register_dsp_parameter_new:
 *
 * Instantiate [struct@SndMotuRegisterDspParameter] object and return the instance.
 *
 * Returns: an instance of [struct@SndMotuRegisterDspParameter].
 * Since: 2.4
 */
HinawaSndMotuRegisterDspParameter *hinawa_snd_motu_register_dsp_parameter_new(void)
{
    return g_malloc0(sizeof(HinawaSndMotuRegisterDspParameter));
}

/**
 * hinawa_snd_motu_register_dsp_parameter_get_mixer_source_gain:
 * @self: A [struct@SndMotuRegisterDspParameter].
 * @mixer: the numeric index of mixer, up to 4.
 * @gain: (array fixed-size=20)(out)(transfer none): The array with elements for the data of source
 *	  gains.
 *
 * Get the array with elements for the data of source gains in indicated mixer. The data has gain
 * value between 0x00 and 0x80.
 */
void hinawa_snd_motu_register_dsp_parameter_get_mixer_source_gain(
	const HinawaSndMotuRegisterDspParameter *self, gsize mixer, const guint8 *gain[20])
{
	struct snd_firewire_motu_register_dsp_parameter *param;

	g_return_if_fail(self != NULL);
	g_return_if_fail(mixer < SNDRV_FIREWIRE_MOTU_REGISTER_DSP_MIXER_COUNT);
	g_return_if_fail(gain != NULL);

	param = (struct snd_firewire_motu_register_dsp_parameter *)self;
	*gain = param->mixer.source[mixer].gain;
}

/**
 * hinawa_snd_motu_register_dsp_parameter_get_mixer_source_pan:
 * @self: A [struct@SndMotuRegisterDspParameter].
 * @mixer: the numeric index of mixer, up to 4.
 * @pan: (array fixed-size=20)(out)(transfer none): The array with elements for the data of source
 *	 pan.
 *
 * Get the array with elements for the data of source pans in indicated mixer. The data has pan
 * value between 0x00 and 0x80.
 */
void hinawa_snd_motu_register_dsp_parameter_get_mixer_source_pan(
	const HinawaSndMotuRegisterDspParameter *self, gsize mixer, const guint8 *pan[20])
{
	struct snd_firewire_motu_register_dsp_parameter *param;

	g_return_if_fail(self != NULL);
	g_return_if_fail(mixer < SNDRV_FIREWIRE_MOTU_REGISTER_DSP_MIXER_COUNT);
	g_return_if_fail(pan != NULL);

	param = (struct snd_firewire_motu_register_dsp_parameter *)self;
	*pan = param->mixer.source[mixer].pan;
}

/**
 * hinawa_snd_motu_register_dsp_parameter_get_mixer_source_flag:
 * @self: A [struct@SndMotuRegisterDspParameter].
 * @mixer: the numeric index of mixer, up to 4.
 * @flag: (array fixed-size=20)(out)(transfer none): The array with elements for the data of source
 *	  flag.
 *
 * Get the array with elements for the data of source flags in indicated mixer. The data consists of
 * bit flags below:
 *
 *  - 0x01: whether to enable mute function for the source.
 *  - 0x02: whether to enable solo function for the source.
 */
void hinawa_snd_motu_register_dsp_parameter_get_mixer_source_flag(
	const HinawaSndMotuRegisterDspParameter *self, gsize mixer, const guint8 *flag[20])
{
	struct snd_firewire_motu_register_dsp_parameter *param;

	g_return_if_fail(self != NULL);
	g_return_if_fail(mixer < SNDRV_FIREWIRE_MOTU_REGISTER_DSP_MIXER_COUNT);
	g_return_if_fail(flag != NULL);

	param = (struct snd_firewire_motu_register_dsp_parameter *)self;
	*flag = param->mixer.source[mixer].flag;
}

/**
 * hinawa_snd_motu_register_dsp_parameter_get_mixer_source_paired_balance:
 * @self: A [struct@SndMotuRegisterDspParameter].
 * @mixer: the numeric index of mixer, up to 4.
 * @balance: (array fixed-size=20)(out)(transfer none): The array with elements for the data of
 *	     paired source L/R balance.
 *
 * Get the array with elements for the data of paired source L/R balance in indicated mixer. The
 * data has L/R balance value between 0x00 and 0x80.
 */
void hinawa_snd_motu_register_dsp_parameter_get_mixer_source_paired_balance(
	const HinawaSndMotuRegisterDspParameter *self, gsize mixer, const guint8 *balance[20])
{
	struct snd_firewire_motu_register_dsp_parameter *param;

	g_return_if_fail(self != NULL);
	g_return_if_fail(mixer < SNDRV_FIREWIRE_MOTU_REGISTER_DSP_MIXER_COUNT);
	g_return_if_fail(balance != NULL);

	param = (struct snd_firewire_motu_register_dsp_parameter *)self;
	*balance = param->mixer.source[mixer].paired_balance;
}

/**
 * hinawa_snd_motu_register_dsp_parameter_get_mixer_source_paired_width:
 * @self: A [struct@SndMotuRegisterDspParameter].
 * @mixer: the numeric index of mixer, up to 4.
 * @width: (array fixed-size=20)(out)(transfer none): The array with elements for the data of
 *	   paired source width.
 *
 * Get the array with elements for the data of paired source width in indicated mixer. The data
 * has width value between 0x00 and 0x80.
 */
void hinawa_snd_motu_register_dsp_parameter_get_mixer_source_paired_width(
	const HinawaSndMotuRegisterDspParameter *self, gsize mixer, const guint8 *width[20])
{
	struct snd_firewire_motu_register_dsp_parameter *param;

	g_return_if_fail(self != NULL);
	g_return_if_fail(mixer < SNDRV_FIREWIRE_MOTU_REGISTER_DSP_MIXER_COUNT);
	g_return_if_fail(width != NULL);

	param = (struct snd_firewire_motu_register_dsp_parameter *)self;
	*width = param->mixer.source[mixer].paired_width;
}

/**
 * hinawa_snd_motu_register_dsp_parameter_get_mixer_output_paired_volume:
 * @self: A [struct@SndMotuRegisterDspParameter].
 * @volume: (array fixed-size=4)(out)(transfer none): The array with elements for the data of
*	    paired output volume.
 *
 * Get the array with elements for the data of paired output volume in indicated mixer. The data
 * has gain value between 0x00 and 0x80.
 */
void hinawa_snd_motu_register_dsp_parameter_get_mixer_output_paired_volume(
	const HinawaSndMotuRegisterDspParameter *self, const guint8 *volume[4])
{
	struct snd_firewire_motu_register_dsp_parameter *param ;

	g_return_if_fail(self != NULL);
	g_return_if_fail(volume != NULL);

	param = (struct snd_firewire_motu_register_dsp_parameter *)self;
	*volume = param->mixer.output.paired_volume;
}

/**
 * hinawa_snd_motu_register_dsp_parameter_get_mixer_output_paired_flag:
 * @self: A [struct@SndMotuRegisterDspParameter].
 * @flag: (array fixed-size=4)(out)(transfer none): The array with elements for the data of paired
 *	  output flag.
 *
 * Get the array with elements for the data of paired output flags in indicated mixer. The data
 * consists of bit flags and masks below:
 *
 *  - 0x0f: the mask for destination of paired output
 *  - 0x10: whether to enable mute for paired output
 */
void hinawa_snd_motu_register_dsp_parameter_get_mixer_output_paired_flag(
	const HinawaSndMotuRegisterDspParameter *self, const guint8 *flag[4])
{
	struct snd_firewire_motu_register_dsp_parameter *param;

	g_return_if_fail(self != NULL);
	g_return_if_fail(flag != NULL);

	param = (struct snd_firewire_motu_register_dsp_parameter *)self;
	*flag= param->mixer.output.paired_flag;
}

/**
 * hinawa_snd_motu_register_dsp_parameter_get_main_output_paired_volume:
 * @self: A [struct@SndMotuRegisterDspParameter].
 * @volume: (out): The value of paired main output.
 *
 * Get the array with elements for the data of paired main output volume. The data has volume value
 * between 0x00 and 0x80.
 */
void hinawa_snd_motu_register_dsp_parameter_get_main_output_paired_volume(
	const HinawaSndMotuRegisterDspParameter *self, guint8 *volume)
{
	struct snd_firewire_motu_register_dsp_parameter *param;

	g_return_if_fail(self != NULL);
	g_return_if_fail(volume != NULL);

	param = (struct snd_firewire_motu_register_dsp_parameter *)self;
	*volume = param->output.main_paired_volume;
}

/**
 * hinawa_snd_motu_register_dsp_parameter_get_headphone_output_paired_volume:
 * @self: A [struct@SndMotuRegisterDspParameter].
 * @volume: (out): The value of paired headphone output.
 *
 * Get the array with elements for the data of paired headphone output volume. The data has volume
 * value between 0x00 and 0x80.
 */
void hinawa_snd_motu_register_dsp_parameter_get_headphone_output_paired_volume(
	const HinawaSndMotuRegisterDspParameter *self, guint8 *volume)
{
	struct snd_firewire_motu_register_dsp_parameter *param;

	g_return_if_fail(self != NULL);
	g_return_if_fail(volume != NULL);

	param = (struct snd_firewire_motu_register_dsp_parameter *)self;
	*volume = param->output.hp_paired_volume;
}

/**
 * hinawa_snd_motu_register_dsp_parameter_get_headphone_output_paired_assignment:
 * @self: A [struct@SndMotuRegisterDspParameter].
 * @assignment: (out): The value of paired headphone assignment.
 *
 * Get the array with elements for the data of paired headphone output source. The data has index
 * value of source.
 */
void hinawa_snd_motu_register_dsp_parameter_get_headphone_output_paired_assignment(
	const HinawaSndMotuRegisterDspParameter *self, guint8 *assignment)
{
	struct snd_firewire_motu_register_dsp_parameter *param;

	g_return_if_fail(self != NULL);
	g_return_if_fail(assignment != NULL);

	param = (struct snd_firewire_motu_register_dsp_parameter *)self;
	*assignment = param->output.hp_paired_assignment;
}

/**
 * hinawa_snd_motu_register_dsp_parameter_get_line_input_boost_flag:
 * @self: A [struct@SndMotuRegisterDspParameter].
 * @boost_flag: (out): The flag of boost for line input.
 *
 * Get the data for flags of line input boost. The data consists of bit flags for corresponding line
 * input channel. When the flag stands, the input is boosted.
 */
void hinawa_snd_motu_register_dsp_parameter_get_line_input_boost_flag(
	const HinawaSndMotuRegisterDspParameter *self, guint8 *boost_flag)
{
	struct snd_firewire_motu_register_dsp_parameter *param;

	g_return_if_fail(self != NULL);
	g_return_if_fail(boost_flag != NULL);

	param = (struct snd_firewire_motu_register_dsp_parameter *)self;
	*boost_flag = param->line_input.boost_flag;
}

/**
 * hinawa_snd_motu_register_dsp_parameter_get_line_input_nominal_level_flag:
 * @self: A [struct@SndMotuRegisterDspParameter].
 * @nominal_level_flag: (out): The flag of boost for line input.
 *
 * Get the data for flags of line input nominal level. The data consists of bit flags for
 * corresponding line input channel. When the flag stands, the nominal level of input is +4 dBu,
 * else -10 dBV.
 */
void hinawa_snd_motu_register_dsp_parameter_get_line_input_nominal_level_flag(
	const HinawaSndMotuRegisterDspParameter *self, guint8 *nominal_level_flag)
{
	struct snd_firewire_motu_register_dsp_parameter *param;

	g_return_if_fail(self != NULL);
	g_return_if_fail(nominal_level_flag != NULL);

	param = (struct snd_firewire_motu_register_dsp_parameter *)self;
	*nominal_level_flag = param->line_input.nominal_level_flag;
}

/**
 * hinawa_snd_motu_register_dsp_parameter_get_input_gain_and_invert:
 * @self: A [struct@SndMotuRegisterDspParameter].
 * @gain_and_invert: (array fixed-size=10)(out)(transfer none): The array with elements for the data
 *		     of input gain and invert flags.
 *
 * Get the array with elements for input gain and invert flags. The interpretation of data is
 * different in below two groups:
 *
 * - Ultralite
 *     - 0x1f: the gain.
 *     - 0x20: whether to invert phase of the input
 * - Audio Express and 4 pre
 *     - 0x3f: the gain
 *     - 0x40: whether to invert phase of the input
 */
void hinawa_snd_motu_register_dsp_parameter_get_input_gain_and_invert(
	const HinawaSndMotuRegisterDspParameter *self, const guint8 *gain_and_invert[10])
{
	struct snd_firewire_motu_register_dsp_parameter *param;

	g_return_if_fail(self != NULL);
	g_return_if_fail(gain_and_invert != NULL);

	param = (struct snd_firewire_motu_register_dsp_parameter *)self;
	*gain_and_invert = param->input.gain_and_invert;
}

/**
 * hinawa_snd_motu_register_dsp_parameter_get_input_flag:
 * @self: A [struct@SndMotuRegisterDspParameter].
 * @flag: (array fixed-size=10)(out)(transfer none): The array with elements for the data of input
 *	  flags.
 *
 * Get the array with elements for the data of input flags. The data consists of bit flags below:
 *
 * - 0x01: whether to make paired input
 * - 0x02: whether to enable phantom powering
 * - 0x04: whether to enable attenuation pad
 * - 0x08: whether to detect plug insert to jack
 */
void hinawa_snd_motu_register_dsp_parameter_get_input_flag(
	const HinawaSndMotuRegisterDspParameter *self, const guint8 *flag[10])
{
	struct snd_firewire_motu_register_dsp_parameter *param;

	g_return_if_fail(self != NULL);
	g_return_if_fail(flag != NULL);

	param = (struct snd_firewire_motu_register_dsp_parameter *)self;
	*flag = param->input.flag;
}