audiofile_wave_read_samples   xtlang


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

Implementation

(bind-func audiofile_wave_read_samples
  (lambda (filepath dest:SAMPLE*)
    (let ((filedata (sys_slurp_file filepath)))
      (if (null? filedata)
          (begin (println "wavefile error: could not open file")
                 (free filedata)
                 #f)
          (cond ((not (wave_validate filedata))
                 (println "wavefile error: there was a problem with the chunk IDs...\nis the file corrupt?")
                 (free filedata)
                 #f)
                (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 (i32toi64 (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))))
                       ;; read data into memory
                       (res (audiofile_copy_samples (pref-ptr data IFF_CHUNK_HEADER_SIZE)
                                                    dest
                                                    (* nchan nframes)
                                                    bitdepth
                                                    type
                                                    #t)))
                   (free filedata)
                   res)))))))


Back to Index

Similar Entries

  • AudioBuffer_from_wave    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
  • astra_readX    xtlang
  • astra_reader    xtlang
  • audiofile_16bitPCM_to_sample_be    xtlang
  • audiofile_16bitPCM_to_sample_le    xtlang
  • audiofile_24bitPCM_to_sample_be    xtlang
  • audiofile_24bitPCM_to_sample_le    xtlang
  • audiofile_aiff_read_samples    xtlang
  • audiofile_copy_samples    xtlang
  • audiofile_float_to_sample_be    xtlang
  • audiofile_float_to_sample_le    xtlang
  • audiofile_read_samples    xtlang
  • cerberus_get_lfo_waveform    xtlang
  • cerberus_get_waveform    xtlang
  • clock->samples    scheme
  • get_lfo_waveform    xtlang
  • get_waveform    xtlang
  • impc:compiler:print-already-bound-error    scheme
  • midi_read_loop    xtlang
  • midi_read_msg    xtlang
  • nonblocking_read_loop    xtlang
  • nonblocking_read_loop    xtlang
  • nonblocking_read_loop    xtlang
  • nonblocking_read_loop    xtlang
  • ocv_imread    xtlang
  • ocv_imread    xtlang
  • ocv_imread    scheme
  • ocv_imread1    xtlang
  • ocv_imread2    xtlang
  • ocv_read    xtlang
  • ocv_read    xtlang
  • ocv_read    scheme
  • ocv_read1    xtlang
  • ocv_read2    xtlang
  • read_and_write_frame    xtlang
  • samples->clock    scheme
  • sf_read_file_into_buffer    xtlang
  • sf_samples_from_file    xtlang
  • svm_read_line    xtlang
  • svm_read_problem    xtlang
  • sys_file_read    xtlang
  • thread_native_call    xtlang
  • thread_native_call_with_zone    xtlang
  • tri-wave    macro
  • wave_validate    xtlang
  • xhid_read    xtlang