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    /digego/extempore/tree/v0.8.9/runtime/scheme.xtm
  • dsp    xtlang    /digego/extempore/tree/v0.8.9/examples/core/audio_101.xtm
  • dsp    xtlang    /digego/extempore/tree/v0.8.9/examples/core/audio_101.xtm
  • dsp    xtlang    /digego/extempore/tree/v0.8.9/examples/core/audio_101.xtm
  • dsp    xtlang    /digego/extempore/tree/v0.8.9/examples/core/audio_101.xtm
  • dsp    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/lv2.xtm
  • dsp    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/polysynth.xtm
  • dsp    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/polysynth.xtm
  • dsp    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/TSM_example.xtm
  • dsp1:DSP    xtlang    /digego/extempore/tree/v0.8.9/examples/core/mtaudio.xtm
  • dsp1:DSP    xtlang    /digego/extempore/tree/v0.8.9/examples/sharedsystem/audiosetup.xtm
  • dsp1:DSP    xtlang    /digego/extempore/tree/v0.8.9/examples/external/convolution_reverb.xtm
  • dsp2:DSP    xtlang    /digego/extempore/tree/v0.8.9/examples/core/mtaudio.xtm
  • dsp2:DSP    xtlang    /digego/extempore/tree/v0.8.9/examples/sharedsystem/audiosetup.xtm
  • dsp3:DSP    xtlang    /digego/extempore/tree/v0.8.9/examples/core/mtaudio.xtm
  • dsp3:DSP    xtlang    /digego/extempore/tree/v0.8.9/examples/sharedsystem/audiosetup.xtm
  • dsp4:DSP    xtlang    /digego/extempore/tree/v0.8.9/examples/sharedsystem/audiosetup.xtm
  • dsp5:DSP    xtlang    /digego/extempore/tree/v0.8.9/examples/sharedsystem/audiosetup.xtm
  • dsp:DSP    xtlang    /digego/extempore/tree/v0.8.9/examples/core/topclock_metro.xtm
  • dsp:DSP    xtlang    /digego/extempore/tree/v0.8.9/examples/core/covers.xtm
  • dsp:DSP    xtlang    /digego/extempore/tree/v0.8.9/examples/core/audio_streams.xtm
  • dsp:DSP    xtlang    /digego/extempore/tree/v0.8.9/examples/core/audio_101.xtm
  • dsp:DSP    xtlang    /digego/extempore/tree/v0.8.9/examples/core/midi_synth.xtm
  • dsp:DSP    xtlang    /digego/extempore/tree/v0.8.9/examples/core/scheduler.xtm
  • dsp:DSP    xtlang    /digego/extempore/tree/v0.8.9/examples/core/synth.xtm
  • dsp:DSP    xtlang    /digego/extempore/tree/v0.8.9/examples/core/fmsynth.xtm
  • dsp:DSP    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/rtmidi.xtm
  • dsp:DSP    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/portaudio.xtm
  • dsp:DSP    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/convolution.xtm
  • dsp:DSP    xtlang    /digego/extempore/tree/v0.8.9/examples/external/going-native.xtm
  • dsp:DSP    xtlang    /digego/extempore/tree/v0.8.9/examples/external/spectrogram.xtm
  • dsp:DSP    xtlang    /digego/extempore/tree/v0.8.9/examples/external/sampler.xtm
  • dsp:DSP    xtlang    /digego/extempore/tree/v0.8.9/examples/external/sing_a_song.xtm
  • dsp:DSP    xtlang    /digego/extempore/tree/v0.8.9/examples/external/electrofunk.xtm
  • dsp:DSP    xtlang    /digego/extempore/tree/v0.8.9/examples/external/granulator.xtm
  • dsp:DSP    xtlang    /digego/extempore/tree/v0.8.9/examples/external/audio_player.xtm
  • dsp:VDSP    xtlang    /digego/extempore/tree/v0.8.9/libs/core/vaudio_dsp.xtm
  • dsp:set!    macro    /digego/extempore/tree/v0.8.9/runtime/scheme.xtm
  • dsp_load    xtlang    /digego/extempore/tree/v0.8.9/examples/sharedsystem/audiosetup.xtm
  • dsp_randn    xtlang    /digego/extempore/tree/v0.8.9/libs/core/audio_dsp.xtm
  • dsp_randn    xtlang    /digego/extempore/tree/v0.8.9/libs/core/vaudio_dsp.xtm
  • dspmt:DSPMT    xtlang    /digego/extempore/tree/v0.8.9/examples/core/mtaudio.xtm
  • dspmt:DSPMT    xtlang    /digego/extempore/tree/v0.8.9/examples/sharedsystem/audiosetup.xtm
  • dspsum:DSPMT    xtlang    /digego/extempore/tree/v0.8.9/examples/external/convolution_reverb.xtm
  • pure_dsp    xtlang    /digego/extempore/tree/v0.8.9/examples/core/audio_streams.xtm