File: dumpeax.c

package info (click to toggle)
libnjb 1.2-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,952 kB
  • ctags: 643
  • sloc: ansic: 10,718; sh: 7,926; makefile: 220
file content (133 lines) | stat: -rw-r--r-- 3,566 bytes parent folder | download
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
#include <libnjb.h>
#include <getopt.h>

extern int njb_error;

int main(int argc, char **argv)
{
	njb_t njbs[NJB_MAX_DEVICES], *njb;
	extern char *optarg;
	int opt;
	int i, n, debug;
	/* eax_t *eax; - deprecated API */
	njb_eax_t *eax;

	debug = 0;
	while ((opt = getopt(argc, argv, "D:")) != -1) {
		switch (opt) {
		case 'D':
			debug = atoi(optarg);
			break;
		default:
			fprintf(stderr, "usage: dumpeax [ -D debuglvl ]\n");
			return 1;
		}
	}

	if (debug)
		NJB_Set_Debug(debug);

	if (NJB_Discover(njbs, 0, &n) == -1)
		njb_error_dump(stderr);

	if (n == 0) {
		fprintf(stderr, "no NJB devices found\n");
		return 0;
	}

	njb = njbs;

	if (NJB_Open(njb) == -1) {
		njb_error_dump(stderr);
		return 1;
	}

	if (NJB_Capture(njb) == -1) {
		njb_error_dump(stderr);
		return 1;
	}


	NJB_Reset_Get_EAX_Type (njb);
	
	while ((eax = NJB_Get_EAX_Type (njb)) != NULL) {
	  printf("------------------------------------------\n");
	  printf("Effect number: %04X\n", eax->number);
	  printf("Effect name: %s\n", eax->name);
	  printf("Effect group %d\n", eax->group);
	  if (eax->exclusive != 0x00) {
	    printf("Effect is exclusive\n");
	  }
	  if (eax->selectable != 0x00) {
	    printf("Effect has selectable patches:\n");
	    printf("    Current selection: %d\n", eax->current_selectionvalue);
	    for(i = 0; i < eax->max_selectionvalue - eax->min_selectionvalue + 1; i++) {
	      printf("    %d. %s\n", eax->min_selectionvalue+i, eax->selection_names[i]);
	    }
	  }
	  if (eax->scaleable != 0x00) {
	    printf("Effect is scaleable:\n");
	    printf("    Current value: %d\n", eax->current_scalevalue);
	    printf("    Min value: %d\n", eax->min_scalevalue);
	    printf("    Max value %d\n", eax->max_scalevalue);
	  }	  
	  NJB_Destroy_EAX_Type (eax);
	}


	/* Deprecated API */
	/*
	eax = NJB_Get_EAX(njb);
	if (eax != NULL) {
		printf("Volume: %u\n", eax->volume);
		printf("Volume min: %u\n", eax->volumemin);
		printf("Volume max: %u\n", eax->volumemax);
		printf("Muted: %s\n", eax->muted ? "yes" : "no");
		printf("EQ Active: %s\n", eax->eq_status ? "yes" : "no");
		printf("Bass: %d\n", eax->bass);
		printf("Bass min: %d\n", eax->bassmin);
		printf("Bass max: %d\n", eax->bassmax);
		printf("Midrange: %d\n", eax->midrange);
		printf("Midrange min: %d\n", eax->midrangemin);
		printf("Midrange max: %d\n", eax->midrangemax);
		printf("Treble: %d\n", eax->treble);
		printf("Treble min: %d\n", eax->treblemin);
		printf("Treble max: %d\n", eax->treblemax);
		printf("Number of Equalizer midrange frequencies: %u\n",
			eax->nfreq);
		printf("Midrange frequency setting: %u\n", eax->freqset);
		printf("Midrange frequencies:\n");
		for (i = 0; i < eax->nfreq; i++) {
			printf("\t%u. %d\n", i, eax->frequencies[i]);
		}
		printf("Number of effects: %u\n", eax->neffects);
		printf("Active effect: %u\n", eax->acteffect);
		printf("Effects:\n");
		for (i = 0; i < eax->neffects; i++) {
			printf("\t%u. %s (amount: %u)\n", i,
				eax->effects[i], eax->effamts[i]);
		}
		printf("Number of headphone modes: %u\n", eax->nphone);
		printf("Active headphone mode: %u\n", eax->actphone);
		printf("Headphone modes:\n");
		for (i = 0; i < eax->nphone; i++) {
			printf("\t%u. %s\n", i, eax->phonemodes[i]);
		}
		printf("Number of rear modes: %u\n", eax->nrear);
		printf("Active rear mode: %u\n", eax->actrear);
		printf("Rear modes:\n");
		for (i = 0; i < eax->nrear; i++) {
			printf("\t%u. %s\n", i, eax->rears[i]);
		}
		eax_destroy(eax);
	}
	*/

	if (njb_error != EO_EOM)
		njb_error_dump(stderr);

	NJB_Release(njb);

	NJB_Close(njb);
	return 0;
}