dsp:DSP   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/examples/external/audio_player.xtm

Implementation

(bind-func dsp:DSP
  (let ((audio_file_path "assets/samples/xmas_carol.wav")
        ;; get number of channels/frames in file
        (nchan (convert (sf_channels_from_file audio_file_path)))
        (nframes (sf_frames_from_file audio_file_path))
        (nsamp (* nchan nframes))
        ;; allocate memory buffer for audio samples
        (audio_data:SAMPLE* (zalloc nsamp))
        ;; read audio samples into buffer
        (samples_read (sf_read_file_into_buffer audio_file_path audio_data 0 nframes #t))
        ;; markers for keeping track of playback position
        (playhead 0)
        (i 0))
    (if (< samples_read 0)
        (printf "Error reading audio file.\n"))
    (lambda (in time chan dat)
      ;; increment playhead (this is the most basic playback possible
      ;; - it's not channel aware, it just steps through the buffer
      ;; one sample at a time)
      (set! playhead (modulo (+ playhead 1) nsamp))
      ;; play audio
      (* 1.0 (pref audio_data playhead)))))


Back to Index

Similar Entries

  • _dsp:set!    scheme
  • dsp    xtlang
  • dsp    xtlang
  • dsp    xtlang
  • dsp    xtlang
  • dsp    xtlang
  • dsp    xtlang
  • dsp    xtlang
  • dsp    xtlang
  • dsp1:DSP    xtlang
  • dsp1:DSP    xtlang
  • dsp1:DSP    xtlang
  • dsp2:DSP    xtlang
  • dsp2:DSP    xtlang
  • dsp3:DSP    xtlang
  • dsp3:DSP    xtlang
  • dsp4:DSP    xtlang
  • dsp5:DSP    xtlang
  • dsp:DSP    xtlang
  • dsp:DSP    xtlang
  • dsp:DSP    xtlang
  • dsp:DSP    xtlang
  • dsp:DSP    xtlang
  • dsp:DSP    xtlang
  • dsp:DSP    xtlang
  • dsp:DSP    xtlang
  • dsp:DSP    xtlang
  • dsp:DSP    xtlang
  • dsp:DSP    xtlang
  • dsp:DSP    xtlang
  • dsp:DSP    xtlang
  • dsp:DSP    xtlang
  • dsp:DSP    xtlang
  • dsp:DSP    xtlang
  • dsp:DSP    xtlang
  • dsp:DSP    xtlang
  • dsp:VDSP    xtlang
  • dsp:set!    macro
  • dsp_load    xtlang
  • dsp_randn    xtlang
  • dsp_randn    xtlang
  • dspmt:DSPMT    xtlang
  • dspmt:DSPMT    xtlang
  • dspsum:DSPMT    xtlang
  • pure_dsp    xtlang