test5.c
5.38 KB
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
/*====================================================================
* test5.c
*
* Synopsis:
*
* Random sound player tester.
*
* Copyright 1993, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
* Inc.; the contents of this file may not be disclosed to third
* parties, copied or duplicated in any form, in whole or in part,
* without the prior written permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS
* 252.227-7013, and/or in similar or successor clauses in the FAR,
* DOD or NASA FAR Supplement. Unpublished - rights reserved under the
* Copyright Laws of the United States.
*====================================================================*/
#include <libaudio.h>
#include "audio.h"
#include "audiotest.h"
#define REV_INST_SND 15
#define TEST5_STOPPED 0
#define TEST5_RUNNING 1
#define TEST5_STOPPING 2
#define TEST5_DONE 3
static void startTest5();
static void stopTest5();
static void doRetrace();
static void ButtProc5(u16 oldButton,u16 newButton);
test_cntrl Test5 = {
&startTest5,
&stopTest5,
&ButtProc5, /* button proc */
&doRetrace,
NULL, /* void *retraceData */
1 /* u32 numSubTests */
};
extern u32 gTestDone;
extern ALHeap gHeapRec;
extern u8 gHeapBuf[AUDIO_HEAP_SIZE];
static ALSndPlayer *sndp;
static ALInstrument *sfxInst;
static u32 test5State;
static ALSndId sfxID;
static f32 engPitch;
static ALPan engPan;
static u8 engFXMix;
static s16 engVol;
/***********************************************************************
* Test interface routines
***********************************************************************/
static void startTest5()
{
ALSynConfig c;
u32 bankLen;
ALBankFile *bankPtr;
ALBank *bank;
amConfig amc;
ALSndpConfig SPConfig;
alHeapInit(&gHeapRec, gHeapBuf, sizeof(gHeapBuf));
/**** Load the bank file from ROM ****/
bankLen = _sfxbankSegmentRomEnd - _sfxbankSegmentRomStart;
bankPtr = alHeapAlloc(&gHeapRec, 1, bankLen);
romCopy(_sfxbankSegmentRomStart, (char *)bankPtr, bankLen);
alBnkfNew(bankPtr, (u8 *) _sfxtableSegmentRomStart);
bank = bankPtr->bankArray[0];
sfxInst = bank->instArray[0];
/**** Create the Audio Manager ****/
c.maxVVoices = MAX_SYNTH_VVOICES;
c.maxPVoices = MAX_SYNTH_PVOICES;
c.maxUpdates = MAX_SYNTH_UPDATES;
c.dmaproc = 0; /* audio mgr will fill this in */
c.fxType = AL_FX_SMALLROOM;
c.heap = &gHeapRec;
amc.outputRate = 44100;
amc.framesPerField = NUM_FIELDS;
amc.maxACMDSize = MAX_RSP_CMDS;
amCreateAudioMgr(&c, AUDIO_PRIORITY, &amc);
/*** Initialize the soundplayer ****/
sndp = alHeapAlloc(&gHeapRec, 1, sizeof(ALSndPlayer));
SPConfig.maxSounds = MAX_SNDP_VOICES;
SPConfig.maxEvents = MAX_SNDP_EVENTS;
SPConfig.heap = &gHeapRec;
alSndpNew(sndp, &SPConfig);
test5State = TEST5_STOPPED;
engPitch = 0.5f;
engPan = 64;
engFXMix = 0;
engVol = 0x3FFF;
}
static void stopTest5()
{
int i;
PRINTF("Stopped test5\n");
alSndpDelete(sndp);
amDestroyAM();
}
static void doRetrace()
{
switch(test5State)
{
case TEST5_STOPPED:
sfxID = alSndpAllocate(sndp,sfxInst->soundArray[REV_INST_SND]);
alSndpSetSound(sndp,sfxID);
alSndpSetPitch(sndp,engPitch);
alSndpSetPan(sndp,engPan);
alSndpSetVol(sndp,engVol);
alSndpSetFXMix(sndp,engFXMix);
alSndpPlay(sndp);
test5State = TEST5_RUNNING;
PRINTF("Engine Rev Test.\n");
PRINTF("Use the joypad to control volume and pitch\n");
PRINTF("Use the L & R buttons to control pan\n");
PRINTF("Press the start button to stop and go to next test\n");
break;
case TEST5_RUNNING:
break;
case TEST5_STOPPING:
if(alSndpGetState(sndp) == AL_STOPPED)
{
alSndpDeallocate(sndp,sfxID);
test5State = TEST5_DONE;
}
break;
case TEST5_DONE:
gTestDone = TRUE;
break;
}
}
static void ButtProc5(u16 oldButton,u16 newButton)
{
if(test5State == TEST5_RUNNING)
{
if(newButton & CONT_START)
{
test5State = TEST5_STOPPING;
alSndpStop(sndp);
return;
}
if (newButton & CONT_UP)
{
if((engPitch+0.01f) < 2.0f)
engPitch += 0.01f;
else
engPitch = 2.0f;
alSndpSetPitch(sndp,engPitch);
}
if (newButton & CONT_DOWN)
{
if((engPitch-0.01f) > 0.0f)
engPitch -= 0.01f;
else
engPitch = 0.01f;
alSndpSetPitch(sndp,engPitch);
}
if(newButton & CONT_LEFT)
{
if((engVol - 0x40) > 0)
engVol -= 0x40;
else
engVol = 0;
alSndpSetVol(sndp,engVol);
}
if(newButton & CONT_RIGHT)
{
if((u16)(engVol + 0x40) < 0x7FFF)
engVol += 0x40;
else
engVol = 0x7FFF;
alSndpSetVol(sndp,engVol);
}
if(newButton & CONT_L)
{
if((engPan - 1) > 0)
engPan -= 1;
else
engPan = 0;
alSndpSetPan(sndp,engPan);
}
if(newButton & CONT_R)
{
if((engPan + 1) < 127)
engPan += 1;
else
engPan = 127;
alSndpSetPan(sndp,engPan);
}
}
}