swap_bytes_inplace   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/libs/core/audiobuffer.xtm

Implementation

(bind-func swap_bytes_inplace
  ;; super dangerous - use only if you know what you're doing
  (lambda (buf:i8* nbytes)
    (let ((tmp 0)
          (i 0))
      (dotimes (i (/ nbytes 2))
        (set! tmp (pref buf i))
        (pset! buf i (pref buf (- nbytes 1 i)))
        (pset! buf (- nbytes 1 i) tmp)))))


Back to Index

Similar Entries