










(**************************************************************************)
(* $Id: sound.ml,v 1.2 1997/04/22 17:41:40 doub Exp $                     *)
(* Creation and manipulation of sound                                     *)
(**************************************************************************)


open Compatibility;;
open Types;;
open Default;;
open Exceptions;;
open Basic_types;;
open Font;;
open Fonts;;
open Colors;;
open Vrml_objects_pre;;
open Calc_3D;;
open Vrml_objects_post;;
open Positionables;;
open Geometrics;;
open Geometric_properties;;
open Map;;
open Complex_geometrics;;
open Map_complex;;
open Lights;;
open Map_light;;

(**************************************************************************)
(* Sound                                                                  *)
(**************************************************************************)

(* new_basic_sound :
   vect3D -> float -> float -> float -> float -> float -> float -> bool
-> string -> float -> clip -> vrml_positionable *)
let new_basic_sound direction intensity max_back max_front min_back
                    min_front priority spatialize description pitch clip =
    Sound
      ({ sound_direction   = direction ;
         sound_intensity   = test_sound_intensity intensity ;
         sound_max_back    = test_sound_min_or_max max_back ;
         sound_max_front   = test_sound_min_or_max max_front ;
         sound_min_back    = test_sound_min_or_max min_back ;
         sound_min_front   = test_sound_min_or_max min_front ;
         sound_priority    = test_sound_priority priority ;
         sound_spatialize  = spatialize ;
         sound_description = description ;
         sound_pitch       = test_pitch pitch ;
         sound_clip        = clip
      })
;;

(* new_complete_sound :
   vect3D -> float -> float -> float -> float -> float -> float -> bool
-> string -> float -> clip -> vrml_object *)
let new_complete_sound direction intensity max_back max_front min_back
                       min_front priority spatialize description pitch
                       clip =
    add_object default_vrml_object    
       (new_basic_sound direction intensity max_back max_front min_back
                        min_front priority spatialize description pitch
                        clip)
;;

(* new_sound : vect3D -> float -> clip -> vrml_object *)
let new_sound direction intensity clip =
    let d = default_sound
    in
       new_complete_sound direction intensity d.sound_max_back
                          d.sound_max_front
                          d.sound_min_back d.sound_min_front
                          d.sound_priority d.sound_spatialize
                          d.sound_description d.sound_pitch clip
;;


(* setf_sound_direction :
   vrml_positionable -> vect3D -> vrml_positionable *)
let setf_sound_direction sound direction =
    match sound with
      Sound s ->
        new_basic_sound direction s.sound_intensity
                        s.sound_max_back s.sound_max_front
                        s.sound_min_back s.sound_min_front
                        s.sound_priority s.sound_spatialize
                        s.sound_description s.sound_pitch 
                        s.sound_clip
    | _ -> raise (Failure "Not a Sound")
;;

(* setf_sound_intensity :
   vrml_positionable -> float -> vrml_positionable *)
let setf_sound_intensity sound intensity =
    match sound with
      Sound s ->
        new_basic_sound s.sound_direction intensity
                        s.sound_max_back s.sound_max_front
                        s.sound_min_back s.sound_min_front
                        s.sound_priority s.sound_spatialize
                        s.sound_description s.sound_pitch 
                        s.sound_clip
    | _ -> raise (Failure "Not a Sound")
;;

(* setf_sound_max_back :
   vrml_positionable -> float -> vrml_positionable *)
let setf_sound_max_back sound max =
    match sound with
      Sound s ->
        new_basic_sound s.sound_direction s.sound_intensity
                        max s.sound_max_front
                        s.sound_min_back s.sound_min_front
                        s.sound_priority s.sound_spatialize
                        s.sound_description s.sound_pitch 
                        s.sound_clip
    | _ -> raise (Failure "Not a Sound")
;;

(* setf_sound_max_front :
   vrml_positionable -> float -> vrml_positionable *)
let setf_sound_max_front sound max =
    match sound with
      Sound s ->
        new_basic_sound s.sound_direction s.sound_intensity
                        s.sound_max_back max
                        s.sound_min_back s.sound_min_front
                        s.sound_priority s.sound_spatialize
                        s.sound_description s.sound_pitch 
                        s.sound_clip
    | _ -> raise (Failure "Not a Sound")
;;

(* setf_sound_min_back :
   vrml_positionable -> float -> vrml_positionable *)
let setf_sound_min_back sound min =
    match sound with
      Sound s ->
        new_basic_sound s.sound_direction s.sound_intensity
                        s.sound_max_back s.sound_max_front
                        min s.sound_min_front
                        s.sound_priority s.sound_spatialize
                        s.sound_description s.sound_pitch 
                        s.sound_clip
    | _ -> raise (Failure "Not a Sound")
;;

(* setf_sound_min_front :
   vrml_positionable -> float -> vrml_positionable *)
let setf_sound_min_front sound min =
    match sound with
      Sound s ->
        new_basic_sound s.sound_direction s.sound_intensity
                        s.sound_max_back s.sound_max_front
                        s.sound_min_back min
                        s.sound_priority s.sound_spatialize
                        s.sound_description s.sound_pitch 
                        s.sound_clip
    | _ -> raise (Failure "Not a Sound")
;;

(* setf_sound_priority :
   vrml_positionable -> float -> vrml_positionable *)
let setf_sound_priority sound priority =
    match sound with
      Sound s ->
        new_basic_sound s.sound_direction s.sound_intensity
                        s.sound_max_back s.sound_max_front
                        s.sound_min_back s.sound_min_front
                        priority s.sound_spatialize
                        s.sound_description s.sound_pitch 
                        s.sound_clip
    | _ -> raise (Failure "Not a Sound")
;;

(* setf_sound_spatialize :
   vrml_positionable -> bool -> vrml_positionable *)
let setf_sound_spatialize sound spatialize =
    match sound with
      Sound s ->
        new_basic_sound s.sound_direction s.sound_intensity
                        s.sound_max_back s.sound_max_front
                        s.sound_min_back s.sound_min_front
                        s.sound_priority spatialize
                        s.sound_description s.sound_pitch 
                        s.sound_clip
    | _ -> raise (Failure "Not a Sound")
;;

(* setf_sound_description :
   vrml_positionable -> string -> vrml_positionable *)
let setf_sound_description sound description =
    match sound with
      Sound s ->
        new_basic_sound s.sound_direction s.sound_intensity
                        s.sound_max_back s.sound_max_front
                        s.sound_min_back s.sound_min_front
                        s.sound_priority s.sound_spatialize
                        description s.sound_pitch 
                        s.sound_clip
    | _ -> raise (Failure "Not a Sound")
;;

(* setf_sound_pitch :
   vrml_positionable -> float -> vrml_positionable *)
let setf_sound_pitch sound pitch =
    match sound with
      Sound s ->
        new_basic_sound s.sound_direction s.sound_intensity
                        s.sound_max_back s.sound_max_front
                        s.sound_min_back s.sound_min_front
                        s.sound_priority s.sound_spatialize
                        s.sound_description pitch 
                        s.sound_clip
    | _ -> raise (Failure "Not a Sound")
;;

(* setf_sound_clip : vrml_positionable -> clip -> vrml_positionable *)
let setf_sound_clip sound clip =
    match sound with
      Sound s ->
        new_basic_sound s.sound_direction s.sound_intensity
                        s.sound_max_back s.sound_max_front
                        s.sound_min_back s.sound_min_front
                        s.sound_priority s.sound_spatialize
                        s.sound_description s.sound_pitch clip
    | _ -> raise (Failure "Not a Sound")
;;

