Skip to content

Commit

Permalink
Change ENC enum keywords to reflect CFFI types where possible.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinmera committed Aug 24, 2016
1 parent 04565ee commit 51dad52
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -26,7 +26,7 @@ Now that we have a stable connection to the sound system, we can query it for po

Finally once we have figured out a proper format to use, or again are fine with the default, we can start playback to the device:

(cl-out123:start *out* :rate 44100 :channels 2 :encoding :signed-16)
(cl-out123:start *out* :rate 44100 :channels 2 :encoding :int16)

Now buffered audio data that conforms to the format we picked can be sent to be played back using `play` or `play-directly`:

Expand Down
37 changes: 18 additions & 19 deletions low-level.lisp
Expand Up @@ -26,28 +26,27 @@

;;; fmt123.h
(defcenum enc
(:error 0)
(:8 #x000F)
(:16 #x0040)
(:24 #x4000)
(:32 #x0100)
(:signed #x0080)
(:float #x0E00)
(:signed-16 #x00D0) ; 16 | signed | 0x10
(:unsigned-16 #x0060) ; 16 | 0x20
(:unsigned-8 #x0001)
(:signed-8 #x0082) ; signed | 0x02
(:ulaw-8 #x0004)
(:alaw-8 #x0008)
(:signed-32 #x1180) ; 32 | signed | 0x1000
(:unsigned-32 #x2100) ; 32 | 0x2000
(:signed-24 #x5080) ; 24 | signed | 0x1000
(:unsigned-24 #x6000) ; 24 | 0x2000
(:float-32 #x0200)
(:float-64 #x0400)
(:any #x77FF)) ; signed-16 | unsigned-16 | unsigned-8 | signed-8
;| ulaw-8 | alaw-8 | signed-32 | unsigned-32
;| signed-24 | unsigned-24 | float-32 | float-64
(:float-type #x0E00)
(:int16 #x00D0) ; 16 | signed | 0x10
(:uint16 #x0060) ; 16 | 0x20
(:uint8 #x0001)
(:int8 #x0082) ; signed | 0x02
(:ulaw8 #x0004)
(:alaw8 #x0008)
(:int32 #x1180) ; 32 | signed | 0x1000
(:uint32 #x2100) ; 32 | 0x2000
(:int24 #x5080) ; 24 | signed | 0x1000
(:uint24 #x6000) ; 24 | 0x2000
(:float #x0200)
(:double #x0400)
(:any #x77FF)) ; int16 | uint16 | uint8 | int8
;| ulaw-8 | alaw-8 | int32 | uint32
;| int24 | uint24 | float | double

(declaim (inline samplesize))
(defun samplesize (enc)
Expand All @@ -58,9 +57,9 @@
((/= 0 (logand enc (foreign-enum-value 'enc :24)))
3)
((or (/= 0 (logand enc (foreign-enum-value 'enc :32)))
(= enc (foreign-enum-value 'enc :float-32)))
(= enc (foreign-enum-value 'enc :float)))
4)
((= enc (foreign-enum-value 'enc :float-64))
((= enc (foreign-enum-value 'enc :double))
8)
(T
0)))
Expand Down
6 changes: 2 additions & 4 deletions wrapper.lisp
Expand Up @@ -35,7 +35,7 @@
:device NIL
:rate 44100
:channels 2
:encoding :signed-16
:encoding :int16
:output-to ()
:preload T
:gain NIL
Expand Down Expand Up @@ -107,9 +107,7 @@
(error 'not-connected :output output)))

(defun decode-encodings (encs)
(loop for enc in '(:signed-32 :signed-24 :signed-16 :signed-8
:unsigned-32 :unsigned-24 :unsigned-16 :unsigned-8
:ulaw-8 :alaw-8 :float-32 :float-64)
(loop for enc in '(:int32 :int24 :int16 :int8 :uint32 :uint24 :uint16 :uint8 :ulaw8 :alaw8 :float :double)
when (/= 0 (logand (foreign-enum-value 'cl-out123-cffi:enc enc) encs))
collect (list enc (cl-out123-cffi:encsize enc))))

Expand Down

0 comments on commit 51dad52

Please sign in to comment.