OpenCoD2-Plus
Call of Duty 2 client & server, rebuilt
Loading...
Searching...
No Matches
sound_test Namespace Reference

Classes

class  Run

Functions

 gametype (test)
 read_audio (path)
 rms (samples)
 windows (samples, rate)
 events (win)
 main ()

Variables

 ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
int FPS = 20
int MENU_FRAMES = 500
int TIMEOUT = 150
int BOTS_TIMEOUT = 300
int MIN_RMS = 100
int DOMINANCE = 3
float WINDOW = 0.05
float GAP = 1.0
str LOCAL_ALIAS = 'weap_kar98k_fire_plr'
str WORLD_ALIAS = 'weap_kar98k_fire'
str START
str LOCAL
str LEFT_RIGHT
str NOISE
tuple CASES = ('menu_music', 'local_2d', 'left_right', 'map_change', 'no_device', 'snd_khz_22', 'callback_cost')

Detailed Description

A client plays sound: what it sends to the device, read from SDL's disk driver.

    python3 scripts/sound_test.py /path/to/CoD2 --protocol {115|118} [--binary PATH] [--wine CMD] [--cases a,b] [--keep DIR]

Each case starts a client (cod2_linux) with SDL_AUDIODRIVER=disk, so that its
output lands in a file as the device would get it, and measures that file.
menu_music: the menu's MP3 stream has an RMS over MIN_RMS. local_2d: a
playLocalSound rises above the silence before it. left_right: a script_origin
to the player's left and then to the right, with playSound: the channel on that
side dominates by at least DOMINANCE. map_change: map_restart, vid_restart,
disconnect and quit with sounds playing leave no crash report. no_device:
SDL_AUDIODRIVER=nonexistent reaches the menu with the failure in its log and no
crash. snd_khz_22: the menu's music at 22 kHz. callback_cost: bots fighting on a
local game (scripts/install_bots.py), the worst callback snd_stats prints is
below half the buffer. Exits with 0 when every case passes. --wine runs a
Windows client (cod2_win32.exe, given with --binary) with that command. --keep copies each case's log and
audio to DIR. The client opens a window and needs a CD key in
~/.cod2/preferences; without one the test is skipped (exit 0).

Function Documentation

◆ events()

sound_test.events ( win)
The (left, right) energy of each burst, split by GAP of quiet.

◆ gametype()

sound_test.gametype ( test)
fx_test's gametype, whose player starts test as it spawns.

◆ main()

sound_test.main ( )

◆ read_audio()

sound_test.read_audio ( path)
The interleaved 16 bit samples of a disk driver file, or an empty array.

◆ rms()

sound_test.rms ( samples)

◆ windows()

sound_test.windows ( samples,
rate )
(left RMS, right RMS) of each WINDOW of stereo samples.

Variable Documentation

◆ BOTS_TIMEOUT

int sound_test.BOTS_TIMEOUT = 300

◆ CASES

tuple sound_test.CASES = ('menu_music', 'local_2d', 'left_right', 'map_change', 'no_device', 'snd_khz_22', 'callback_cost')

◆ DOMINANCE

int sound_test.DOMINANCE = 3

◆ FPS

int sound_test.FPS = 20

◆ GAP

float sound_test.GAP = 1.0

◆ LEFT_RIGHT

str sound_test.LEFT_RIGHT
Initial value:
1= '''
2soundTest()
3{
4 ambientStop(0);
5 wait 8;
6 for(side = -1; side <= 1; side += 2)
7 {
8 ent = spawn("script_origin", self getEye() + vectorScale(anglesToRight(self getPlayerAngles()), side * 30));
9 wait 1;
10 ent playSound("%s");
11 wait 5;
12 ent delete();
13 }
14}
15''' % WORLD_ALIAS

◆ LOCAL

str sound_test.LOCAL
Initial value:
1= '''
2soundTest()
3{
4 ambientStop(0);
5 wait 8;
6 for(i = 0; i < 3; i++)
7 {
8 self playLocalSound("%s");
9 wait 3;
10 }
11}
12''' % LOCAL_ALIAS

◆ LOCAL_ALIAS

str sound_test.LOCAL_ALIAS = 'weap_kar98k_fire_plr'

◆ MENU_FRAMES

int sound_test.MENU_FRAMES = 500

◆ MIN_RMS

int sound_test.MIN_RMS = 100

◆ NOISE

str sound_test.NOISE
Initial value:
1= '''
2soundTest()
3{
4 ent = spawn("script_origin", self.origin + (100, 0, 0));
5 for(;;)
6 {
7 self playLocalSound("%s");
8 ent playSound("%s");
9 wait 0.1;
10 }
11}
12''' % (LOCAL_ALIAS, WORLD_ALIAS)

◆ ROOT

sound_test.ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

◆ START

str sound_test.START
Initial value:
1= '''
2 self thread soundTest();
3'''

◆ TIMEOUT

int sound_test.TIMEOUT = 150

◆ WINDOW

float sound_test.WINDOW = 0.05

◆ WORLD_ALIAS

str sound_test.WORLD_ALIAS = 'weap_kar98k_fire'