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    /digego/extempore/tree/v0.8.9/runtime/scheme.xtm
  • -clock:metro-from-host-    scheme    /digego/extempore/tree/v0.8.9/runtime/scheme.xtm
  • AudioBuffer    xtlang    /digego/extempore/tree/v0.8.9/libs/core/audiobuffer.xtm
  • AudioBuffer    xtlang    /digego/extempore/tree/v0.8.9/libs/core/audiobuffer.xtm
  • AudioBuffer    xtlang    /digego/extempore/tree/v0.8.9/libs/core/audiobuffer.xtm
  • AudioBuffer    xtlang    /digego/extempore/tree/v0.8.9/libs/core/audiobuffer.xtm
  • AudioBuffer    xtlang    /digego/extempore/tree/v0.8.9/libs/core/audiobuffer.xtm
  • AudioBuffer_concat    xtlang    /digego/extempore/tree/v0.8.9/libs/core/audiobuffer.xtm
  • AudioBuffer_cstring    xtlang    /digego/extempore/tree/v0.8.9/libs/core/audiobuffer.xtm
  • AudioBuffer_data_b64    xtlang    /digego/extempore/tree/v0.8.9/libs/core/audiobuffer.xtm
  • AudioBuffer_data_b64_cstring    xtlang    /digego/extempore/tree/v0.8.9/libs/core/audiobuffer.xtm
  • AudioBuffer_from_wave    xtlang    /digego/extempore/tree/v0.8.9/libs/core/audiobuffer.xtm
  • AudioBuffer_malloc    xtlang    /digego/extempore/tree/v0.8.9/libs/core/audiobuffer.xtm
  • AudioBuffer_read    xtlang    /digego/extempore/tree/v0.8.9/libs/core/audiobuffer.xtm
  • AudioBuffer_read    xtlang    /digego/extempore/tree/v0.8.9/libs/core/audiobuffer.xtm
  • AudioBuffer_read_interp    xtlang    /digego/extempore/tree/v0.8.9/libs/core/audiobuffer.xtm
  • AudioBuffer_read_interp_mix    xtlang    /digego/extempore/tree/v0.8.9/libs/core/audiobuffer.xtm
  • AudioBuffer_read_interp_pw    xtlang    /digego/extempore/tree/v0.8.9/libs/core/audiobuffer.xtm
  • AudioBuffer_read_looped    xtlang    /digego/extempore/tree/v0.8.9/libs/core/audiobuffer.xtm
  • AudioBuffer_read_looped    xtlang    /digego/extempore/tree/v0.8.9/libs/core/audiobuffer.xtm
  • AudioBuffer_set_data_b64    xtlang    /digego/extempore/tree/v0.8.9/libs/core/audiobuffer.xtm
  • AudioBuffer_shared_data    xtlang    /digego/extempore/tree/v0.8.9/libs/core/audiobuffer.xtm
  • ai_load_ogl_texture_from_buffer    xtlang    /digego/extempore/tree/v0.8.9/libs/external/assimp.xtm
  • aiff_validate    xtlang    /digego/extempore/tree/v0.8.9/libs/core/audiobuffer.xtm
  • audiofile_aiff_read_samples    xtlang    /digego/extempore/tree/v0.8.9/libs/core/audiobuffer.xtm
  • bitmap_from_window    xtlang    /digego/extempore/tree/v0.8.9/libs/contrib/win32.xtm
  • cerberus_frq_from_val    xtlang    /digego/extempore/tree/v0.8.9/libs/core/instruments/cerberus_midi.xtm
  • cerberus_octave_from_val    xtlang    /digego/extempore/tree/v0.8.9/libs/core/instruments/cerberus_midi.xtm
  • clock:offset-from-server    scheme    /digego/extempore/tree/v0.8.9/runtime/scheme.xtm
  • comb_fb_from_rtsixty    xtlang    /digego/extempore/tree/v0.8.9/libs/core/audio_dsp.xtm
  • filename-from-path    scheme    /digego/extempore/tree/v0.8.9/runtime/scheme.xtm
  • frq_from_val    xtlang    /digego/extempore/tree/v0.8.9/libs/core/instruments/analogue_midi.xtm
  • frq_from_val    xtlang    /digego/extempore/tree/v0.8.9/libs/core/instruments/channel_strip.xtm
  • glew-name-from-gl-name    scheme    /digego/extempore/tree/v0.8.9/libs/external/gl/glcore-glew.xtm
  • impc:ir:compiler:closure-from-getter    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmir.xtm
  • impc:ir:convert-from-pretty-types    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmir.xtm
  • impc:ir:get-arity-from-pretty-closure    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmir.xtm
  • impc:ir:get-array-type-from-str    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmir.xtm
  • impc:ir:get-closure-type-from-str    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmir.xtm
  • impc:ir:get-function-type-from-str    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmir.xtm
  • impc:ir:get-tuple-type-from-str    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmir.xtm
  • impc:ir:get-type-from-pretty-array    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmir.xtm
  • impc:ir:get-type-from-pretty-closure    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmir.xtm
  • impc:ir:get-type-from-pretty-str    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmir.xtm
  • impc:ir:get-type-from-pretty-str-rec    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmir.xtm
  • impc:ir:get-type-from-pretty-tuple    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmir.xtm
  • impc:ir:get-type-from-pretty-vector    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmir.xtm
  • impc:ir:get-type-from-str    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmir.xtm
  • impc:ir:get-vector-type-from-str    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmir.xtm
  • impc:ti:reverse-set-bangs-from-reified    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmti.xtm
  • impc:ti:tuple-list-from-pretty-tuple-str    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmti.xtm
  • load_blep_tables_from_blob    unknown    /digego/extempore/tree/v0.8.9/libs/core/audio_dsp.xtm
  • octave_from_val    xtlang    /digego/extempore/tree/v0.8.9/libs/core/instruments/analogue_midi.xtm
  • pc:from-intervals    scheme    /digego/extempore/tree/v0.8.9/libs/core/pc_ivl.xtm
  • pc:from-steps    scheme    /digego/extempore/tree/v0.8.9/libs/core/pc_ivl.xtm
  • pc:scale-from-chord    scheme    /digego/extempore/tree/v0.8.9/libs/core/pc_ivl.xtm
  • pc:scale-from-pc    scheme    /digego/extempore/tree/v0.8.9/libs/core/pc_ivl.xtm
  • set_sampler_audiobuffer    xtlang    /digego/extempore/tree/v0.8.9/libs/external/instruments_ext.xtm
  • sf_channels_from_file    xtlang    /digego/extempore/tree/v0.8.9/libs/external/sndfile.xtm
  • sf_frames_from_file    xtlang    /digego/extempore/tree/v0.8.9/libs/external/sndfile.xtm
  • sf_samples_from_file    xtlang    /digego/extempore/tree/v0.8.9/libs/external/sndfile.xtm
  • string_list_from_file    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/word_count.xtm
  • string_list_from_string    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/word_count.xtm
  • sys:compile-init-ll-from-str    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmir.xtm
  • sys:compile-ll-from-str    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmir.xtm
  • with-input-from-file    scheme    /digego/extempore/tree/v0.8.9/runtime/init.xtm
  • with-input-output-from-to-files    scheme    /digego/extempore/tree/v0.8.9/runtime/init.xtm
  • xtmdoc-get-args-from-form    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmti.xtm