AudioBuffer_from_aiff   xtlang


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

Implementation

(bind-func AudioBuffer_from_aiff
  (lambda (filepath)
    (let ((filedata (sys_slurp_file filepath)))
      (if (null? filedata)
          (begin (println "aiff file error: could not open file")
                 null)
          (let ((common (iffchunk_find_dumb filedata "COMM"))
                (sounddata (iffchunk_find_dumb filedata "SSND")))
            ;; pull the data out of the common chunk
            (let ((nchan (i16toi64 (swapi16 (pref (cast (pref-ptr common IFF_CHUNK_HEADER_SIZE) i16*) 0))))
                  (nframes (i32toi64 (swapi32 (pref (cast (pref-ptr common (+ IFF_CHUNK_HEADER_SIZE 2)) i32*) 0))))
                  (bitdepth (i16toi64 (swapi16 (pref (cast (pref-ptr common (+ IFF_CHUNK_HEADER_SIZE 6)) i16*) 0))))
                  (samplerate (begin
                                (swap_bytes_inplace (pref-ptr common (+ IFF_CHUNK_HEADER_SIZE 8)) 10)
                                (fp80ptrtod (pref-ptr common (+ IFF_CHUNK_HEADER_SIZE 8)))))
                  (ab (AudioBuffer nframes nchan samplerate))
                  (abres (AudioBuffer_set_filepath ab (Str filepath)))
                  (res (audiofile_copy_samples (pref-ptr sounddata (+ IFF_CHUNK_HEADER_SIZE 8))
                                               (AudioBuffer_data ab)
                                               (* nchan nframes)
                                               bitdepth
                                               WAVE_FORMAT_PCM ;; AIFF is always PCM
                                               #f)))
              (free filedata) ;; why does this cause a crash?
              (if res ab null)))))))


Back to Index

Similar Entries

  • -clock:metro-from-host-    scheme
  • -clock:metro-from-host-    scheme
  • AudioBuffer    xtlang
  • AudioBuffer    xtlang
  • AudioBuffer    xtlang
  • AudioBuffer    xtlang
  • AudioBuffer    xtlang
  • AudioBuffer_concat    xtlang
  • AudioBuffer_cstring    xtlang
  • AudioBuffer_data_b64    xtlang
  • AudioBuffer_data_b64_cstring    xtlang
  • AudioBuffer_from_wave    xtlang
  • AudioBuffer_malloc    xtlang
  • AudioBuffer_read    xtlang
  • AudioBuffer_read    xtlang
  • AudioBuffer_read_interp    xtlang
  • AudioBuffer_read_interp_mix    xtlang
  • AudioBuffer_read_interp_pw    xtlang
  • AudioBuffer_read_looped    xtlang
  • AudioBuffer_read_looped    xtlang
  • AudioBuffer_set_data_b64    xtlang
  • AudioBuffer_shared_data    xtlang
  • ai_load_ogl_texture_from_buffer    xtlang
  • aiff_validate    xtlang
  • audiofile_aiff_read_samples    xtlang
  • bitmap_from_window    xtlang
  • cerberus_frq_from_val    xtlang
  • cerberus_octave_from_val    xtlang
  • clock:offset-from-server    scheme
  • comb_fb_from_rtsixty    xtlang
  • filename-from-path    scheme
  • frq_from_val    xtlang
  • frq_from_val    xtlang
  • glew-name-from-gl-name    scheme
  • impc:ir:compiler:closure-from-getter    scheme
  • impc:ir:convert-from-pretty-types    scheme
  • impc:ir:get-arity-from-pretty-closure    scheme
  • impc:ir:get-array-type-from-str    scheme
  • impc:ir:get-closure-type-from-str    scheme
  • impc:ir:get-function-type-from-str    scheme
  • impc:ir:get-tuple-type-from-str    scheme
  • impc:ir:get-type-from-pretty-array    scheme
  • impc:ir:get-type-from-pretty-closure    scheme
  • impc:ir:get-type-from-pretty-str    scheme
  • impc:ir:get-type-from-pretty-str-rec    scheme
  • impc:ir:get-type-from-pretty-tuple    scheme
  • impc:ir:get-type-from-pretty-vector    scheme
  • impc:ir:get-type-from-str    scheme
  • impc:ir:get-vector-type-from-str    scheme
  • impc:ti:reverse-set-bangs-from-reified    scheme
  • impc:ti:tuple-list-from-pretty-tuple-str    scheme
  • load_blep_tables_from_blob    unknown
  • octave_from_val    xtlang
  • pc:from-intervals    scheme
  • pc:from-steps    scheme
  • pc:scale-from-chord    scheme
  • pc:scale-from-pc    scheme
  • set_sampler_audiobuffer    xtlang
  • sf_channels_from_file    xtlang
  • sf_frames_from_file    xtlang
  • sf_samples_from_file    xtlang
  • string_list_from_file    xtlang
  • string_list_from_string    xtlang
  • sys:compile-init-ll-from-str    scheme
  • sys:compile-ll-from-str    scheme
  • with-input-from-file    scheme
  • with-input-output-from-to-files    scheme
  • xtmdoc-get-args-from-form    scheme