[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Low Level Interfacing -- HELP!!



I am trying to do some sound processing.  I have a sound handle (snd_h)
and get the offset to the sound header using the following trap:

(deftrap _GetSoundHeaderOffset ((sndhdl :handle) 
		                (offset (:pointer :signed-long)))
   (:stack :signed-integer)
   (:stack-trap #xA800 :d0 (+ (ash 260 16) 36) sndhdl offset))


Then I want to access the contents of the soundheader, but I am getting
something messed up here.  I need to get my hands on either the record,
or a pointer or handle to it, and I can't seem to get it right.

The definition of the soundheader is given below:

(def-mactype :soundheaderptr (find-mactype :pointer))
(defrecord SoundHeader 
   (samplePtr :pointer)         ;  if NIL then samples are in sampleArea 
   (length :signed-long)        ;  length of sound in bytes 
   (sampleRate :signed-long)    ;  sample rate for this sound 
   (loopStart :signed-long)     ;  start of looping portion 
   (loopEnd :signed-long)       ;  end of looping portion 
   (encode :unsigned-byte)      ;  header encoding 
   (baseFrequency :unsigned-byte);  baseFrequency value 
   (sampleArea (:array :unsigned-byte 1))
   )


      (rlet ((n (:pointer :signed-long)))
	(#_GetSoundHeaderOffset snd_h n)
	(format t "offset: ~a~%" (%get-signed-long n))
	;;; OK, so now I have a pointer to the signed-long offset, in n
	;;; and I try to get my hands on a pointer to the soundheader
	;;; by getting a pointer from the appropriate offset from snd_h
	;;; only what's there is the actual soundheader, and not a pointer
        ;;; to it, or something, like that. but rref doesn't work either,
        ;;; so what I'm storing in header seems to be neither the record
        ;;; nor a pointer to it.
	(let ((header (%hget-ptr snd_h (%get-signed-long n))))
	  (format t "Pointer to SoundHeader?: ~a~%" header)
	  (format t "sample rate is ~a~%" 
		  (pref header soundheader.samplerate))
	  (format t "length is ~a~%" (pref header soundheader.length)))
	)


Can anyone help me?  What is it that is located at offset (%get-signed-long n)
from my sound handle (snd_h) and how can I use it?

Thanks very very much in advance for any help you can give me.  I am stuck!

--Robyn