コード例 #1
0
def core(request):
    retv = aserver.Core()
    retv.set_processor()  # NO_OPERATION
    retv.set_output()  # MEMORY

    def fin():
        retv.shutdown()

    request.addfinalizer(fin)
    return retv
コード例 #2
0
def test_add_source():
    core = aserver.Core()
    #    core.set_output(aserver.OutputType.MEMORY)
    #    core.set_processor()
    sid = core.add_source()
    assert sid == -1

    core.set_processor()

    for i in np.arange(20):
        sid = core.add_source()
        assert sid == i

    core.shutdown()
コード例 #3
0
import sys
import time
import socket

sys.path.append("..")
import bindings as aserver
import numpy as np

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind(("0.0.0.0", 10101))
sock.setblocking(0)

period = 132  # 1.4 ms @ 44100 Hz

core = aserver.Core()
core.set_period(period)
core.set_processor()
core.alsa_output(dump_config=True, blocking=False)

gid = core.add_generator(aserver.GeneratorType.WAVE)
cfg = core.new_config("wave")
cfg.config.flags = aserver.WaveFlags("WAVE_INDEX PLAYBACK_COMMAND").value
# cfg.waveIndex = core.get_wave_index(filename)
cfg.waveIndex = core.add_wave(
    441, 1, (3.2e4 * np.cos(np.linspace(0, np.pi * 10, 441))).astype(np.int16))
cfg.command = aserver.PlaybackCommand.PLAY
core.add_source()

core.start_render_loop()
コード例 #4
0
def core(request):
    return aserver.Core()