AudioBuffer_from_wave   xtlang


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

Implementation

(bind-func AudioBuffer_from_wave
  (lambda (filepath)
    (let ((filedata (sys_slurp_file filepath)))
      (if (null? filedata)
          (begin (println "wavefile error: could not open file")
                 (free filedata)
                 null)
          (cond ((not (wave_validate filedata))
                 (println "wavefile error: there was a problem with the chunk IDs...\nis the file corrupt?")
                 (free filedata)
                 null)
                (else
                 (let ((fmt (iffchunk_find_dumb filedata "fmt "))
                       (chunksize (i32toi64 (iffchunk_size (cast fmt IffChunkHeader*) #t)))
                       (type (i16toi64 (pref (cast (pref-ptr fmt IFF_CHUNK_HEADER_SIZE) i16*) 0)))
                       (nchan (i16toi64 (pref (cast (pref-ptr fmt (+ IFF_CHUNK_HEADER_SIZE 2)) i16*) 0)))
                       (samplerate (i32tod (pref (cast (pref-ptr fmt (+ IFF_CHUNK_HEADER_SIZE 4)) i32*) 0)))
                       (bitdepth (i16toi64 (pref (cast (pref-ptr fmt (+ IFF_CHUNK_HEADER_SIZE 14)) i16*) 0)))
                       (data (iffchunk_find_dumb filedata "data"))
                       (nframes (/ (i32toi64 (iffchunk_size (cast data IffChunkHeader*) #t))
                                   (* nchan (/ bitdepth 8))))
                       (ab (AudioBuffer nframes nchan samplerate))
                       (abres (AudioBuffer_set_filepath ab (Str filepath)))
                       ;; read data into memory
                       (res (audiofile_copy_samples (pref-ptr data IFF_CHUNK_HEADER_SIZE)
                                                    (AudioBuffer_data ab)
                                                    (* nchan nframes)
                                                    bitdepth
                                                    type
                                                    #t)))
                   (free filedata)
                   (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_aiff    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
  • audiofile_wave_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_get_lfo_waveform    xtlang    /digego/extempore/tree/v0.8.9/libs/core/instruments/cerberus_midi.xtm
  • cerberus_get_waveform    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
  • get_lfo_waveform    xtlang    /digego/extempore/tree/v0.8.9/libs/core/instruments/analogue_midi.xtm
  • get_waveform    xtlang    /digego/extempore/tree/v0.8.9/libs/core/instruments/analogue_midi.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
  • tri-wave    macro    /digego/extempore/tree/v0.8.9/runtime/scheme.xtm
  • wave_validate    xtlang    /digego/extempore/tree/v0.8.9/libs/core/audiobuffer.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