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
  • -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_aiff    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
  • audiofile_wave_read_samples    xtlang
  • bitmap_from_window    xtlang
  • cerberus_frq_from_val    xtlang
  • cerberus_get_lfo_waveform    xtlang
  • cerberus_get_waveform    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
  • get_lfo_waveform    xtlang
  • get_waveform    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
  • tri-wave    macro
  • wave_validate    xtlang
  • with-input-from-file    scheme
  • with-input-output-from-to-files    scheme
  • xtmdoc-get-args-from-form    scheme