summaryrefslogtreecommitdiff
path: root/pyecasound/test2_stresstest.py
blob: a864aba67cdfce50971bba8e0187eaca111f27bd (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
#!/usr/bin/env python

# -----------------------------------------------------------------------
# A second stress test for the pyeca interface
#
# Copyright (C) 2003 Kai Vehmanen (kai.vehmanen@wakkanet.fi)
# Licensed under GPL. See the file 'COPYING' for more information.
# -----------------------------------------------------------------------

import time
import sys
import os

# ---
# select pyeca implementation to use

# test the default implementation
from pyeca import *

# test the native Python implementation
# from ecacontrol import *

# test the C implementation
# from pyecasound import *

# ---
# configuration variables

# run for how many seconds
runlen = 5
# debug level (0, 1, 2, ...)
debuglevel = 0

if os.path.isfile("../ecasound/ecasound_debug"):
    os.environ["ECASOUND"] = "../ecasound/ecasound_debug"

if os.path.isfile("../ecasound/ecasound"):
    os.environ["ECASOUND"] = "../ecasound/ecasound"

# if above tests fail, the default ecasound binary
# will be used

# main program
e = ECA_CONTROL_INTERFACE(debuglevel)
result = 0

e.command("cs-add play_chainsetup")
e.command("c-add 1st_chain")
e.command("ai-add rtnull")
e.command("ao-add null")
e.command("cop-add -ezx:1,0.0")
e.command("ctrl-add -kos:2,-1,1,300,0")
e.command("cop-add -efl:300")
e.command("cop-add -evp")
e.command("cop-select 3")
e.command("copp-select 1")
e.command("cs-connect")
e.command("start")

total_cmds = 0

while 1 and e.last_type() != "e":
    e.command("get-position")
    curpos = e.last_float()
    if curpos > runlen or e.last_type() == "e":
        break

    if debuglevel > 0:
        sys.stderr.write(".")

    # some commands that return a lot
    # of return data
    e.command("cop-register")
    e.command("aio-register")
    e.command("int-cmd-list")

    total_cmds = total_cmds + 4

if e.last_type() == "e":
    print("Ended to error:", e.last_error())
    result = -1
else:
    e.command("stop")
    e.command("cs-disconnect")

if debuglevel == 2:
    sys.stderr.write(
        "\nprocessing speed: " + str(total_cmds / runlen) + " cmds/second.\n"
    )

if debuglevel > 0:
    sys.stderr.write("\n")

sys.exit(result)