X3D Model Documentation: Keyboard.x3d

  1  <?xml version="1.0" encoding="UTF-8"?>
  2  <!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.3//EN" "https://www.web3d.org/specifications/x3d-3.3.dtd">
  3  <X3D profile='Immersive' version='3.3 xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='https://www.web3d.org/specifications/x3d-3.3.xsd'>
  4       <head>
  5            <meta name='titlecontent='Keyboard.x3d'/>
  6            <meta name='descriptioncontent='Synthesizer keyboard that creates a playable synthesizer keyboard. Each key on the keyboard has a sound and touch sensor associated with it. Touching a key triggers the touch sensor, which triggers the sound.'/>
  7            <meta name='creatorcontent='David R. Nadeau'/>
  8            <meta name='translatorcontent='Don Brutzman'/>
  9            <meta name='createdcontent='1 July 1998'/>
 10            <meta name='translatedcontent='2 February 2014'/>
 11            <meta name='modifiedcontent='20 October 2019'/>
 12            <meta name='referencecontent='originals/keybd.wrl'/>
 13            <meta name='referencecontent='http://www.siggraph.org/s98'/>
 14            <meta name='referencecontent='http://www.siggraph.org/s98/conference/courses/18.html'/>
 15            <meta name='referencecontent='http://www.sdsc.edu/~moreland/courses/Siggraph98/vrml97/slides/mt0345.htm'/>
 16            <meta name='referencecontent='http://www.sdsc.edu/~moreland/courses/Siggraph98/vrml97/vrml97.htm'/>
 17            <meta name='referencecontent='https://www.web3d.org/x3d/content/examples/X3dResources.html'/>
 18            <meta name='identifiercontent='https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/Keyboard.x3d'/>
 19            <meta name='generatorcontent='Vrml97ToX3dNist, http://ovrt.nist.gov/v2_x3d.html'/>
 20            <meta name='generatorcontent='X3D-Edit, https://savage.nps.edu/X3D-Edit'/>
 21            <meta name='licensecontent='../license.html'/>
 22       </head>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->

<!-- to top Index for DEF nodes: A5, As5, B5, BlackKey, C4, C5, Cs4, D4, Ds4, E4, F4, Fs4, G4, Gs4, PitchA5, PitchAs5, PitchB5, PitchC4, PitchC5, PitchCs4, PitchD4, PitchDs4, PitchE4, PitchF4, PitchFs4, PitchG4, PitchGs4, WhiteKey

Index for Viewpoint node: Viewpoint_1
-->
 23       <Scene>
 24            <!-- Things to experiment with... -->
 25            <!-- Use a Script to trigger sounds on **Mouse button down** not up. Huh, you say? Well, a TouchSensor generates a touch time event on mouse down, not up. Since means that sounds triggered by a TouchSensor seem to happen late... they happen when you release the mouse button, not when you press it. But, a TouchSensor sends a TRUE on it's isActive output on mouse down. So, you could route that into a Script node and grab the associated time stamp, then send THAT out as an event to start the sound. This will remove the lag and make sounds more responsive. -->
 26            <WorldInfo info='"Copyright (c) 1997, David R. Nadeau"title='Synthesizer keyboard'/>
 27            <Viewpoint description='Entry vieworientation='1.0 0.0 0.0 -0.785position='0.875 1.5 1.5'/>
 28            <NavigationInfo headlight='false'/>
 29            <DirectionalLight direction='1.0 -2.0 -0.5'/>
 30            <Transform>
 31 
               <!-- Shape WhiteKey is a DEF node that has 7 USE nodes: USE_1, USE_2, USE_3, USE_4, USE_5, USE_6, USE_7 -->
               <Shape DEF='WhiteKey'>
 32                      <Appearance>
 33                           <Material diffuseColor='1.0 1.0 1.0'/>
 34                      </Appearance>
 35                      <Box size='0.23 0.1 1.5'/>
 36                 </Shape>
 37 
               <!-- ROUTE information for C4 node:  [from touchTime to PitchC4.set_startTime ] -->
               <TouchSensor DEF='C4'/>
 38                 <Sound maxBack='100.0maxFront='100.0'>
 39 
                    <!-- ROUTE information for PitchC4 node:  [from C4.touchTime to set_startTime ] -->
                    <AudioClip DEF='PitchC4'   url=' "tone1.wav" "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/tone1.wav" '/>
 40                 </Sound>
 41            </Transform>
 42            <Transform translation='0.125 0.1 -0.375'>
 43 
               <!-- Shape BlackKey is a DEF node that has 4 USE nodes: USE_1, USE_2, USE_3, USE_4 -->
               <Shape DEF='BlackKey'>
 44                      <Appearance>
 45                           <Material diffuseColor='0.4 0.4 0.4'/>
 46                      </Appearance>
 47                      <Box size='0.2 0.1 0.75'/>
 48                 </Shape>
 49 
               <!-- ROUTE information for Cs4 node:  [from touchTime to PitchCs4.set_startTime ] -->
               <TouchSensor DEF='Cs4'/>
 50                 <Sound maxBack='100.0maxFront='100.0'>
 51 
                    <!-- ROUTE information for PitchCs4 node:  [from Cs4.touchTime to set_startTime ] -->
                    <AudioClip DEF='PitchCs4pitch='1.059'   url=' "tone1.wav" "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/tone1.wav" '/>
 52                 </Sound>
 53            </Transform>
 54            <Transform translation='0.25 0.0 0.0'>
 55                 <Shape USE='WhiteKey'/>
 56 
               <!-- ROUTE information for D4 node:  [from touchTime to PitchD4.set_startTime ] -->
               <TouchSensor DEF='D4'/>
 57                 <Sound maxBack='100.0maxFront='100.0'>
 58 
                    <!-- ROUTE information for PitchD4 node:  [from D4.touchTime to set_startTime ] -->
                    <AudioClip DEF='PitchD4pitch='1.122'   url=' "tone1.wav" "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/tone1.wav" '/>
 59                 </Sound>
 60            </Transform>
 61            <Transform translation='0.375 0.1 -0.375'>
 62                 <Shape USE='BlackKey'/>
 63 
               <!-- ROUTE information for Ds4 node:  [from touchTime to PitchDs4.set_startTime ] -->
               <TouchSensor DEF='Ds4'/>
 64                 <Sound maxBack='100.0maxFront='100.0'>
 65 
                    <!-- ROUTE information for PitchDs4 node:  [from Ds4.touchTime to set_startTime ] -->
                    <AudioClip DEF='PitchDs4pitch='1.189'   url=' "tone1.wav" "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/tone1.wav" '/>
 66                 </Sound>
 67            </Transform>
 68            <Transform translation='0.5 0.0 0.0'>
 69                 <Shape USE='WhiteKey'/>
 70 
               <!-- ROUTE information for E4 node:  [from touchTime to PitchE4.set_startTime ] -->
               <TouchSensor DEF='E4'/>
 71                 <Sound maxBack='100.0maxFront='100.0'>
 72 
                    <!-- ROUTE information for PitchE4 node:  [from E4.touchTime to set_startTime ] -->
                    <AudioClip DEF='PitchE4pitch='1.26'   url=' "tone1.wav" "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/tone1.wav" '/>
 73                 </Sound>
 74            </Transform>
 75            <Transform translation='0.75 0.0 0.0'>
 76                 <Shape USE='WhiteKey'/>
 77 
               <!-- ROUTE information for F4 node:  [from touchTime to PitchF4.set_startTime ] -->
               <TouchSensor DEF='F4'/>
 78                 <Sound maxBack='100.0maxFront='100.0'>
 79 
                    <!-- ROUTE information for PitchF4 node:  [from F4.touchTime to set_startTime ] -->
                    <AudioClip DEF='PitchF4pitch='1.335'   url=' "tone1.wav" "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/tone1.wav" '/>
 80                 </Sound>
 81            </Transform>
 82            <Transform translation='0.875 0.1 -0.375'>
 83                 <Shape USE='BlackKey'/>
 84 
               <!-- ROUTE information for Fs4 node:  [from touchTime to PitchFs4.set_startTime ] -->
               <TouchSensor DEF='Fs4'/>
 85                 <Sound maxBack='100.0maxFront='100.0'>
 86 
                    <!-- ROUTE information for PitchFs4 node:  [from Fs4.touchTime to set_startTime ] -->
                    <AudioClip DEF='PitchFs4pitch='1.414'   url=' "tone1.wav" "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/tone1.wav" '/>
 87                 </Sound>
 88            </Transform>
 89            <Transform translation='1.0 0.0 0.0'>
 90                 <Shape USE='WhiteKey'/>
 91 
               <!-- ROUTE information for G4 node:  [from touchTime to PitchG4.set_startTime ] -->
               <TouchSensor DEF='G4'/>
 92                 <Sound maxBack='100.0maxFront='100.0'>
 93 
                    <!-- ROUTE information for PitchG4 node:  [from G4.touchTime to set_startTime ] -->
                    <AudioClip DEF='PitchG4pitch='1.498'   url=' "tone1.wav" "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/tone1.wav" '/>
 94                 </Sound>
 95            </Transform>
 96            <Transform translation='1.125 0.1 -0.375'>
 97                 <Shape USE='BlackKey'/>
 98 
               <!-- ROUTE information for Gs4 node:  [from touchTime to PitchGs4.set_startTime ] -->
               <TouchSensor DEF='Gs4'/>
 99                 <Sound maxBack='100.0maxFront='100.0'>
100 
                    <!-- ROUTE information for PitchGs4 node:  [from Gs4.touchTime to set_startTime ] -->
                    <AudioClip DEF='PitchGs4pitch='1.587'   url=' "tone1.wav" "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/tone1.wav" '/>
101                 </Sound>
102            </Transform>
103            <Transform translation='1.25 0.0 0.0'>
104                 <Shape USE='WhiteKey'/>
105 
               <!-- ROUTE information for A5 node:  [from touchTime to PitchA5.set_startTime ] -->
               <TouchSensor DEF='A5'/>
106                 <Sound maxBack='100.0maxFront='100.0'>
107 
                    <!-- ROUTE information for PitchA5 node:  [from A5.touchTime to set_startTime ] -->
                    <AudioClip DEF='PitchA5pitch='1.682'   url=' "tone1.wav" "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/tone1.wav" '/>
108                 </Sound>
109            </Transform>
110            <Transform translation='1.375 0.1 -0.375'>
111                 <Shape USE='BlackKey'/>
112 
               <!-- ROUTE information for As5 node:  [from touchTime to PitchAs5.set_startTime ] -->
               <TouchSensor DEF='As5'/>
113                 <Sound maxBack='100.0maxFront='100.0'>
114 
                    <!-- ROUTE information for PitchAs5 node:  [from As5.touchTime to set_startTime ] -->
                    <AudioClip DEF='PitchAs5pitch='1.782'   url=' "tone1.wav" "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/tone1.wav" '/>
115                 </Sound>
116            </Transform>
117            <Transform translation='1.5 0.0 0.0'>
118                 <Shape USE='WhiteKey'/>
119 
               <!-- ROUTE information for B5 node:  [from touchTime to PitchB5.set_startTime ] -->
               <TouchSensor DEF='B5'/>
120                 <Sound maxBack='100.0maxFront='100.0'>
121 
                    <!-- ROUTE information for PitchB5 node:  [from B5.touchTime to set_startTime ] -->
                    <AudioClip DEF='PitchB5pitch='1.888'   url=' "tone1.wav" "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/tone1.wav" '/>
122                 </Sound>
123            </Transform>
124            <Transform translation='1.75 0.0 0.0'>
125                 <Shape USE='WhiteKey'/>
126 
               <!-- ROUTE information for C5 node:  [from touchTime to PitchC5.set_startTime ] -->
               <TouchSensor DEF='C5'/>
127                 <Sound maxBack='100.0maxFront='100.0'>
128 
                    <!-- ROUTE information for PitchC5 node:  [from C5.touchTime to set_startTime ] -->
                    <AudioClip DEF='PitchC5pitch='2.0'   url=' "tone1.wav" "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/tone1.wav" '/>
129                 </Sound>
130            </Transform>
131            < ROUTE  fromNode='C4' fromField='touchTime' toNode='PitchC4' toField='set_startTime'/>
132            < ROUTE  fromNode='Cs4' fromField='touchTime' toNode='PitchCs4' toField='set_startTime'/>
133            < ROUTE  fromNode='D4' fromField='touchTime' toNode='PitchD4' toField='set_startTime'/>
134            < ROUTE  fromNode='Ds4' fromField='touchTime' toNode='PitchDs4' toField='set_startTime'/>
135            < ROUTE  fromNode='E4' fromField='touchTime' toNode='PitchE4' toField='set_startTime'/>
136            < ROUTE  fromNode='F4' fromField='touchTime' toNode='PitchF4' toField='set_startTime'/>
137            < ROUTE  fromNode='Fs4' fromField='touchTime' toNode='PitchFs4' toField='set_startTime'/>
138            < ROUTE  fromNode='G4' fromField='touchTime' toNode='PitchG4' toField='set_startTime'/>
139            < ROUTE  fromNode='Gs4' fromField='touchTime' toNode='PitchGs4' toField='set_startTime'/>
140            < ROUTE  fromNode='A5' fromField='touchTime' toNode='PitchA5' toField='set_startTime'/>
141            < ROUTE  fromNode='As5' fromField='touchTime' toNode='PitchAs5' toField='set_startTime'/>
142            < ROUTE  fromNode='B5' fromField='touchTime' toNode='PitchB5' toField='set_startTime'/>
143            < ROUTE  fromNode='C5' fromField='touchTime' toNode='PitchC5' toField='set_startTime'/>
144       </Scene>
145  </X3D>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->

<!-- to top Index for DEF nodes: A5, As5, B5, BlackKey, C4, C5, Cs4, D4, Ds4, E4, F4, Fs4, G4, Gs4, PitchA5, PitchAs5, PitchB5, PitchC4, PitchC5, PitchCs4, PitchD4, PitchDs4, PitchE4, PitchF4, PitchFs4, PitchG4, PitchGs4, WhiteKey

Index for Viewpoint node: Viewpoint_1
-->
X3D Tooltips element index: Appearance, AudioClip, Box, DirectionalLight, head, Material, meta, NavigationInfo, ROUTE, Scene, Shape, Sound, TouchSensor, Transform, Viewpoint, WorldInfo, X3D, accessType and type, XML data types, field types

Event Graph ROUTE Table entries with 13 ROUTE connections total, showing X3D event-model relationships for this scene.

Each row shows an event cascade that may occur during a single timestamp interval between frame renderings, as part of the X3D execution model.

A5
TouchSensor
touchTime
SFTime

ROUTE
event to
(1)
PitchA5
AudioClip
set_startTime
SFTime

As5
TouchSensor
touchTime
SFTime

ROUTE
event to
(1)
PitchAs5
AudioClip
set_startTime
SFTime

B5
TouchSensor
touchTime
SFTime

ROUTE
event to
(1)
PitchB5
AudioClip
set_startTime
SFTime

C4
TouchSensor
touchTime
SFTime

ROUTE
event to
(1)
PitchC4
AudioClip
set_startTime
SFTime

C5
TouchSensor
touchTime
SFTime

ROUTE
event to
(1)
PitchC5
AudioClip
set_startTime
SFTime

Cs4
TouchSensor
touchTime
SFTime

ROUTE
event to
(1)
PitchCs4
AudioClip
set_startTime
SFTime

D4
TouchSensor
touchTime
SFTime

ROUTE
event to
(1)
PitchD4
AudioClip
set_startTime
SFTime

Ds4
TouchSensor
touchTime
SFTime

ROUTE
event to
(1)
PitchDs4
AudioClip
set_startTime
SFTime

E4
TouchSensor
touchTime
SFTime

ROUTE
event to
(1)
PitchE4
AudioClip
set_startTime
SFTime

F4
TouchSensor
touchTime
SFTime

ROUTE
event to
(1)
PitchF4
AudioClip
set_startTime
SFTime

Fs4
TouchSensor
touchTime
SFTime

ROUTE
event to
(1)
PitchFs4
AudioClip
set_startTime
SFTime

G4
TouchSensor
touchTime
SFTime

ROUTE
event to
(1)
PitchG4
AudioClip
set_startTime
SFTime

Gs4
TouchSensor
touchTime
SFTime

ROUTE
event to
(1)
PitchGs4
AudioClip
set_startTime
SFTime

Additional guidance on X3D animation can be found in the 10-Step Animation Design Process and Event Tracing hint sheets. Have fun with X3D! 😀

-->
<!-- Online at
https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/KeyboardIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/Keyboard.x3d -->

<!-- Color legend: X3D terminology <X3dNode DEF='idName' field='value'/> matches XML terminology <XmlElement DEF='idName' attribute='value'/>
(Light-blue background: event-based behavior node or statement) (Grey background inside box: inserted documentation) (Magenta background: X3D Extensibility)
-->

to top <!-- For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints. -->