示例#1
0
        static void Main(string[] args)
        {
            // Setup OpenTK audio stuff
            AudioContext ac = new AudioContext();
            XRamExtension xram = new XRamExtension();

            // Load the .ogg files
            string guitarFile = "GuitarSample.ogg";
            AudioClip guitarClip = new AudioClip(guitarFile);

            string boingFile = "BoingSample.ogg";
            AudioClip boingClip = new AudioClip(boingFile);

            // Play it.  The first time a clip is played, a background thread is
            // launched to handle all audio.  Playing the clip again or playing
            // a new clip will use the already existing thread.  To avoid
            // threading, construct your own AudioManager.
            guitarClip.Play();

            // Play the "boing" clip every 2 seconds during the guitar clip
            boingClip.Play();
            Thread.Sleep(2000);

            boingClip.Play();
            Thread.Sleep(2000);

            boingClip.Play();
            Thread.Sleep(2000);

            // Finally play some overlapping sounds to demonstrate a sound can
            // have more than one instance played at a time.
            boingClip.Play();
            Thread.Sleep(200);

            boingClip.Play();
            Thread.Sleep(200);

            boingClip.Play();
            Thread.Sleep(200);

            boingClip.Play();
            Thread.Sleep(200);

            // Give the last "boing" time to finish
            Thread.Sleep(800);
        }