revert between 56095 -> 55830 in arch
[AROS.git] / rom / usb / classes / audio / numtostr.c
blob2ec7428062123f059736cd3b9a7732b3f8dbcf8b
2 #include "numtostr.h"
4 #include <proto/poseidon.h>
6 #define ps nch->nch_Base
8 /* /// "Terminal Types" */
9 const struct AudioIDMap audioterminaltypes[] =
11 { UAUTT_UNDEFINED , "USB Undefined" },
12 { UAUTT_STREAMING , "USB Stream" },
13 { UAUTT_VENDOR , "USB vendor specific" },
14 { UAITT_UNDEFINED , "Input Undefined" },
15 { UAITT_MIC , "Microphone" },
16 { UAITT_DESKTOP_MIC , "Desktop microphone" },
17 { UAITT_PERSONAL_MIC , "Personal microphone" },
18 { UAITT_OMNI_DIR_MIC , "Omni-directional microphone" },
19 { UAITT_MIC_ARRAY , "Microphone array" },
20 { UAITT_PROC_MIC_ARRAY , "Processing microphone array" },
21 { UAOTT_UNDEFINED , "Output Undefined" },
22 { UAOTT_SPEAKER , "Speaker" },
23 { UAOTT_HEADPHONES , "Headphones" },
24 { UAOTT_DISPLAY , "Head Mounted Display Audio" },
25 { UAOTT_DESKTOP_SPEAKER , "Desktop speaker" },
26 { UAOTT_ROOM_SPEAKER , "Room speaker" },
27 { UAOTT_COMM_SPEAKER , "Communication speaker" },
28 { UAOTT_LOFI_SPEAKER , "Low frequency effects speaker" },
29 { UABTT_UNDEFINED , "Bi-directional Undefined" },
30 { UABTT_HANDSET , "Handset" },
31 { UABTT_HEADSET , "Headset" },
32 { UABTT_SPEAKERPHONE_NER, "Speakerphone, no echo reduction" },
33 { UABTT_SPEAKERPHONE_ES , "Echo-suppressing speakerphone" },
34 { UABTT_SPEAKERPHONE_EC , "Echo-canceling speakerphone" },
35 { UATTT_UNDEFINED , "Telephony Undefined" },
36 { UATTT_PHONE_LINE , "Phone line" },
37 { UATTT_TELEPHONE , "Telephone" },
38 { UATTT_DOWN_LINE_PHONE , "Down Line Phone" },
39 { UAETT_UNDEFINED , "External Undefined" },
40 { UAETT_ANALOG , "Analog connector" },
41 { UAETT_DIGITAL , "Digital audio interface" },
42 { UAETT_LINE , "Line connector" },
43 { UAETT_LEGACY , "Legacy audio connector" },
44 { UAETT_SPDIF , "S/PDIF interface" },
45 { UAETT_1394DA , "1394 DA stream" },
46 { UAETT_1394DV , "1394 DV stream soundtrack" },
47 { UAFTT_UNDEFINED , "Embedded Undefined" },
48 { UAFTT_CALIB_NOISE , "Level Calibration Noise Source" },
49 { UAFTT_EQ_NOISE , "Equalization Noise" },
50 { UAFTT_CD , "CD player" },
51 { UAFTT_DAT , "DAT" },
52 { UAFTT_DCC , "DCC" },
53 { UAFTT_MINIDISK , "MiniDisk" },
54 { UAFTT_TAPE , "Analog Tape" },
55 { UAFTT_PHONO , "Phonograph" },
56 { UAFTT_VCR , "VCR Audio" },
57 { UAFTT_VIDEODISC , "Video Disc Audio" },
58 { UAFTT_DVD , "DVD Audio" },
59 { UAFTT_TV_TUNER , "TV Tuner Audio" },
60 { UAFTT_SAT_RX , "Satellite Receiver Audio" },
61 { UAFTT_CABLE_TUNER , "Cable Tuner Audio" },
62 { UAFTT_DSS , "DSS Audio" },
63 { UAFTT_RADIO_RX , "Radio Receiver" },
64 { UAFTT_RADIO_TX , "Radio Transmitter" },
65 { UAFTT_MULTITRACK , "Multi-track Recorder" },
66 { UAFTT_SYNTHESIZER , "Synthesizer" },
67 { 0x0000, NULL }
69 /* \\\ */
71 /* /// "Audio Format types" */
72 const struct AudioIDMap audioformattypes[] =
74 { UAADF_TYPE_I_UNDEFINED , "Undefined Type I" },
75 { UAADF_PCM , "signed PCM" },
76 { UAADF_PCM8 , "8 bit unsigned PCM" },
77 { UAADF_IEEE_FLOAT , "IEEE Floating Point" },
78 { UAADF_ALAW , "aLaw" },
79 { UAADF_MULAW , "µLaw" },
81 { UAADF_TYPE_II_UNDEFINED , "Undefined Type II" },
82 { UAADF_MPEG , "MPEG" },
83 { UAADF_AC3 , "AC3" },
85 { UAADF_TYPE_III_UNDEFINED , "Undefined Type III" },
86 { UAADF_IEC1937_AC3 , "IEC1937 AC3" },
87 { UAADF_IEC1937_MPEG1_L1 , "IEC1937 MPEG1 Layer 1" },
88 { UAADF_IEC1937_MPEG1_L2_3 , "IEC1937 MPEG1 Layer 2/3" },
89 { UAADF_IEC1937_MPEG2_NOEXT , "IEC1937 MPEG2 NoExt." },
90 { UAADF_IEC1937_MPEG2_EXT , "IEC1937 MPEG2 Ext." },
91 { UAADF_IEC1937_MPEG2_L1_LS , "IEC1937 MPEG2 Layer 1 LS" },
92 { UAADF_IEC1937_MPEG2_L2_3_LS, "IEC1937 MPEG2 Layer 2/3 LS" },
93 { 0x0000, NULL }
95 /* \\\ */
97 /* /// "Spatial Location Bits" */
98 const struct AudioIDMap audiospatiallocation[] =
100 { 0, "Left Front (L)", },
101 { 1, "Right Front (R)", },
102 { 2, "Center Front (C)", },
103 { 3, "Subwoofer (SW)", },
104 { 4, "Left Surround (LS)", },
105 { 5, "Right Surround (RS)", },
106 { 6, "Left of Center (LC)", },
107 { 7, "Right of Center (RC)", },
108 { 8, "Surround (S)", },
109 { 9, "Side Left (SL)", },
110 { 10, "Side Right (SR)", },
111 { 11, "Top (T)", },
112 { 0, NULL }
114 /* \\\ */
116 /* /// "Spatial Location Bits (Bitmasks)" */
117 const struct AudioIDMap audiospatiallocationbits[] =
119 { 0x03f, "5.1" },
120 { 0x003, "Stereo" },
121 { 1<< 0, "Left", },
122 { 1<< 1, "Right", },
123 { 1<< 2, "Center", },
124 { 1<< 3, "Subwoofer", },
125 { 1<< 4, "LSurr.", },
126 { 1<< 5, "RSurr.", },
127 { 1<< 6, "LCent.", },
128 { 1<< 7, "RCent.", },
129 { 1<< 8, "Surr.", },
130 { 1<< 9, "SideL", },
131 { 1<<10, "SideR", },
132 { 1<<11, "Top", },
133 { 0, NULL }
135 /* \\\ */
137 /* /// "Feature Unit Control Selectors" */
138 const struct AudioIDMap audiofeature[] =
140 { UAFUCS_MUTE , "Mute", },
141 { UAFUCS_VOLUME , "Volume", },
142 { UAFUCS_BASS , "Bass", },
143 { UAFUCS_MID , "Mid", },
144 { UAFUCS_TREBLE , "Treble", },
145 { UAFUCS_EQUALIZER , "Graphic Equalizer", },
146 { UAFUCS_AUTOMATIC_GAIN, "Automatic Gain", },
147 { UAFUCS_DELAY , "Delay", },
148 { UAFUCS_BASS_BOOST , "Bass Boost", },
149 { UAFUCS_LOUDNESS , "Loudness", },
150 { 0, NULL }
152 /* \\\ */
154 /* /// "Feature Unit Control Bits" */
155 const struct AudioIDMap audiofeaturebits[] =
157 { UAFUF_MUTE , "Mute", },
158 { UAFUF_VOLUME , "Volume", },
159 { UAFUF_BASS , "Bass", },
160 { UAFUF_MID , "Mid", },
161 { UAFUF_TREBLE , "Treble", },
162 { UAFUF_EQUALIZER , "Graphic Equalizer", },
163 { UAFUF_AUTOMATIC_GAIN, "Automatic Gain", },
164 { UAFUF_DELAY , "Delay", },
165 { UAFUF_BASS_BOOST , "Bass Boost", },
166 { UAFUF_LOUDNESS , "Loudness", },
167 { 0, NULL }
169 /* \\\ */
171 /* /// "Unit Types" */
172 const struct AudioIDMap audiounittype[] =
174 { UDST_AUDIO_CTRL_INPUT_TERMINAL , "Input" },
175 { UDST_AUDIO_CTRL_OUTPUT_TERMINAL, "Output" },
176 { UDST_AUDIO_CTRL_MIXER_UNIT , "Mixer" },
177 { UDST_AUDIO_CTRL_SELECTOR_UNIT , "Selector" },
178 { UDST_AUDIO_CTRL_FEATURE_UNIT , "Feature" },
179 { UDST_AUDIO_CTRL_PROCESSING_UNIT, "Processing" },
180 { UDST_AUDIO_CTRL_EXTENSION_UNIT , "Extension" },
181 { 0, NULL }
183 /* \\\ */
185 /* /// "nNumToStr()" */
186 STRPTR nNumToStr(struct NepClassAudio *nch, UWORD type, ULONG id, STRPTR defstr)
188 const struct AudioIDMap *aim = NULL;
190 switch(type)
192 case NTS_TERMINALTYPE:
193 aim = audioterminaltypes;
194 break;
196 case NTS_AUDIOFORMAT:
197 aim = audioformattypes;
198 break;
200 case NTS_SPATIALLOCATION:
201 aim = audiospatiallocation;
202 break;
204 case NTS_FEATURE:
205 aim = audiofeature;
206 break;
208 case NTS_UNITTYPE:
209 aim = audiounittype;
210 break;
212 if(aim)
214 while(aim->aim_String)
216 if(aim->aim_ID == id)
218 return(aim->aim_String);
220 aim++;
223 return(defstr);
225 /* \\\ */
227 /* /// "nConcatBitsStr()" */
228 STRPTR nConcatBitsStr(struct NepClassAudio *nch, UWORD type, ULONG bits)
230 const struct AudioIDMap *iteraim = NULL;
231 const struct AudioIDMap *aim = NULL;
232 ULONG len = 0;
233 STRPTR strptr;
234 STRPTR locstr;
235 STRPTR tarptr;
236 ULONG iterbits;
238 switch(type)
240 case NTS_SPATIALLOCATION:
241 if(bits == 1)
243 return(psdCopyStr("Mono")); // avoid left
245 aim = audiospatiallocationbits;
246 break;
248 case NTS_FEATURE:
249 aim = audiofeaturebits;
250 break;
252 if(!aim)
254 return(NULL);
257 iteraim = aim;
258 iterbits = bits;
259 while((strptr = iteraim->aim_String) && iterbits)
261 if((iterbits & iteraim->aim_ID) == iteraim->aim_ID)
263 iterbits ^= iteraim->aim_ID;
264 if(len)
266 len += 2;
268 while(*strptr++)
270 len++;
273 iteraim++;
275 locstr = tarptr = psdAllocVec(len + 1);
276 if(!locstr)
278 return(NULL);
280 iteraim = aim;
281 iterbits = bits;
282 while((strptr = iteraim->aim_String) && iterbits)
284 if((iterbits & iteraim->aim_ID) == iteraim->aim_ID)
286 iterbits ^= iteraim->aim_ID;
287 if(locstr != tarptr)
289 *tarptr++ = ',';
290 *tarptr++ = ' ';
292 while((*tarptr++ = *strptr++));
293 tarptr--;
295 iteraim++;
297 return locstr;
299 /* \\\ */