NS BASIC Tech Note                                March 7, 1997

37. How to use the Sound Registry
-----------------------------------------------------------------


Newton 2.0 has a sound registry that contains all the sounds that are  
stored in the Newton. In addition, you can get packages of sounds as  
shareware to add to the built in sounds. Check the AMUG web site for some.

The list of built in sounds is kept in getglobals().soundRegistry._proto.  
Additional sounds are kept in getglobals().soundRegistry.

The following program puts up a picker of all the available sounds and 
plays them.

1400 playsounds: REM
1410  LET pickitems=[]
1420  LET s=elements(getglobals().soundregistry)
1430  gosub addElements //
1440  LET s=elements(getglobals().soundregistry._proto)
1450  gosub addElements //
1460  LET wspec={pickitems: pickItems, GOTO: 'pickChosen}
1470  window w,wspec,"picker"
1480  show w
1490  stop
1500 pickChosen: REM
1510  LET i=wspec.viewValue
1520  playSound(getGlobals().soundRegistry.(intern(pickItems[i])))
1590  GOTO 0100
2000 addElements: REM
2010  for i=0 to length(s)-1
2020    if s[i]<>"_proto" then addArraySlot(pickItems,s[i])
2030  next i
2040  return