dsp:DSP   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/examples/contrib/spectral_meter.xtm

Implementation

;; set up the type alias for our dsp function
(bind-alias DSP [double,double,double,double,double*]*)
;; dsp function - this will play the sound file.  Remember to
;; change the file path to an audio file on your system
(bind-func dsp:DSP 100000000     ; make sure we allocate enough memory
  (let ((audio_length 60)
        (audio:double* (zalloc (* 44100 2 audio_length)))
        (samples_read (read_audio_data "/path/to/audiofile.wav"
                                       audio
                                       0
                                       (* 44100 audio_length)))
        (playhead 0)
        (fft_window_size 1024)
        (time_buffer:cpxd* (zalloc fft_window_size))
        (freq_buffer:cpxd* (zalloc fft_window_size))
        (i:i64 0))
    (lambda (in time chan dat)
      (if (and (= (modulo playhead fft_window_size) 0)
               (= chan 0.0))
          (mag_spectrum (pref-ptr audio playhead) fft_window_size
                        time_buffer freq_buffer))
      ;; increment playhead once per (stereo) pair of samples
      (if (= chan 1.0)
          (set! playhead (modulo (+ playhead 1)
                                 (* audio_length 44100))))
      ;; play audio
      (pref audio (+ (dtoi64 chan) (* 2 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