summaryrefslogtreecommitdiffstats
path: root/test/uscxml/test-spatial-audio.scxml
blob: 66d06f424d8e8cbf8734290abd59dfc4cc089774 (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
<scxml datamodel="ecmascript" name="spatial.audio.test">
	<datamodel>
		<!-- Alternative to the JSON notation
			<data id="spatialAudio" expr="{}" />
			<data id="spatialAudio.id2" expr="{}" />
			<data id="spatialAudio.id2.degree" expr="90" />
		-->
		<data id="spatialAudio">
			{
				'id2': {
					'degree': 90
				}
			}
		</data>
	</datamodel>
	<state id="click.continuously">
		<initial>
			<transition target="ready" />
		</initial>
		<invoke type="openal" id="spatial-audio.id1">
			<!-- 
				Explicitly set the start position of an audio source.
				Keep in mind that the coordinate system is the same as in OpenGL:
          y
          |
          |___x
         /
        z
			-->
			<param name="x" expr="-1.0" /> <!-- leftmost -->
			<param name="y" expr="0" />
			<param name="z" expr="0" />
		</invoke>
		<invoke type="openal" id="spatial-audio.id2">
			<!-- 
				Set position on a circle.
				Unit for circle is "deg" in clockwise order with 0 being directly in front,
				or "rad" in counter-clockwise with zero being the rightmost position.
				"right", "height" and "front" are aliases for x, y and z respectively.
			-->
			<param name="circle" expr="spatialAudio.id2.degree + 'deg'" /> <!-- rightmost -->
			<param name="height" expr="0.0" />
		</invoke>
		<state id="ready">
			<onentry>
				<!-- trigger transition in 1 second -->
				<send event="spatial-audio.play" delay="1s">
					<param name="src" expr="'audio/click.wav'" />
				</send>
				<log expr="'Ready'" />
			</onentry>
			<transition target="click" event="spatial-audio.play" />
			<transition target="final" event="quit" />
		</state>
		<state id="click">
			<onentry>
				<send target="#_spatial-audio.id1" event="play">
					<param name="src" expr="'audio/click.wav'" />
				</send>
				<!-- 
					move position of audio 2 in a circle 
				-->
				<send target="#_spatial-audio.id2" event="play" delay="200ms">
					<param name="src" expr="'audio/click.wav'" />
					<param name="circle" expr="spatialAudio.id2.degree + 'deg'" />
				</send>
				<log expr="'Clicking'" />
				<script>spatialAudio.id2.degree += 90;</script>
			</onentry>
			<transition target="ready" />
		</state>
	</state>
	
	<final id="final" />
</scxml>