2 # -*- coding: utf-8 -*-
3 # Plays a 440.0 Hz test tone for 3 seconds to alsa_pcm:playback_1.
5 # Copyright 2003, Andrew W. Schmeder
6 # This source code is released under the terms of the GNU Public License.
7 # See LICENSE for the full text of these terms.
12 jack
.attach("testtone")
13 jack
.register_port("in_1", jack
.IsInput
)
14 jack
.register_port("out_1", jack
.IsOutput
)
16 jack
.connect("testtone:out_1", "alsa_pcm:playback_1")
18 N
= jack
.get_buffer_size()
19 Sr
= float(jack
.get_sample_rate())
20 print "Buffer Size:", N
, "Sample Rate:", Sr
23 input = numpy
.zeros((1,N
), 'f')
24 output
= numpy
.reshape(
26 2*numpy
.pi
*440.0 * (numpy
.arange(0, sec
, 1.0/(Sr
), 'f')[0:int(Sr
*sec
)])
27 ), (1, Sr
*sec
)).astype('f')
30 while i
< output
.shape
[1] - N
:
32 jack
.process(output
[:,i
:i
+N
], input)
34 except jack
.InputSyncError
:
36 except jack
.OutputSyncError
: