Lisp结合OpenAL

电脑技术 电脑技术 1017 人阅读 | 0 人回复 | 2022-04-15

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

x
;;;
;;; http://www.devmaster.net/articles/openal/
;;;
(in-package #:cl-openal-examples)

(export 'getting-started)

(defun getting-started ()
  (let ((data nil))
    (alut:with-init
      ;; Init alut so LOAD-MEMORY-HELLO-WORLD works.
      ;; But leave alut so we can grab the device using
      ;; WITH-DEVICE.
      ;; (setf data (alut:load-memory-from-file "bleep.wav")
      ;; is a fun alternative!
      (setf data (alut:load-memory-hello-world)))
    (alc:with-device (device)
      ;; Here it is appropriate to check so
      ;; device is actually opened. GET-ERROR
      ;; for example.
      (alc:with-context (context device)
        (alc:make-context-current context)
        ;; Again: GET-ERROR.
        (al:with-buffer (buffer)
          (al:with-source (source)
            (al:buffer-data buffer #x1101 data 16356 11025)
            ;; How do I know format, size, freq?
            ;; LOAD-MEMORY-HELLO-WORLD told me.
            ;; The appropirate thing to do if you don't
            ;; know these values is m-v-b.
            ;; Link source to buffer, and place
            ;; source at (1 1 1).
            (al:source source :buffer buffer)
            (al:source source :position #(1 1 1))
            (al:source source :velocity #(0 0 0))
            ;; Place listener at (1 1 1), and have it
            ;; face (0 0 0).
            (al:listener :position #(1 1 1))
            (al:listener rientation #(0 0 0
                                        0 0 0))
            ;; Let the music play...
            (al:source source :looping :true)
            (al:source-play source)
            (sleep 10)
            (al:source-stop source)))))))
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

热门推荐