dlogue_note   xtlang


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

Implementation

(bind-func dlogue_note
  (lambda ()
    (let ((MILLISEC (* .001 SRs))
          (KIT_CONFIGS:|12,DLOGUE_PART|* (alloc)))
      (default_drum (aref-ptr KIT_CONFIGS 0) 70.0) ;; kick
      (default_drum (aref-ptr KIT_CONFIGS 1) 70.0) ;; kick
      (default_snare (aref-ptr KIT_CONFIGS 2) 130.0) ;; snare
      (default_cym (aref-ptr KIT_CONFIGS 3) 300.0) ;; closed
      (default_cym (aref-ptr KIT_CONFIGS 4) 800.0) ;; open
      (default_drum (aref-ptr KIT_CONFIGS 5) 120.0) ;; low tom
      (default_drum (aref-ptr KIT_CONFIGS 6) 170.0) ;; mid tom
      (default_drum (aref-ptr KIT_CONFIGS 7) 210.0) ;; high tom
      (lambda (data:NoteData* nargs:i64 dargs:SAMPLE*)
        (let ((starttime:i64 (note_starttime data))
              (midifrq:SAMPLE (frq2midi (note_frequency data)))
              (partnum:i64 (ftoi64 (/ midifrq 12.0)))
              (config:DLOGUE_PART* (aref-ptr KIT_CONFIGS partnum))
              (notetime:i64 starttime)
              (frequency:SAMPLE (+ (dl_base_frq config)
                                   (* (dl_base_frq config)
                                      (dl_base_frq_scale config) (/ (% midifrq 12.0) 12.0))))
              ;; (llllll (begin (println 'part: partnum 'frq: frequency 'amp: (dl_part_amp config)) 1:i64))
              (amplitude:SAMPLE (note_amplitude data))
              (gate:SAMPLE (note_gate data))
              (target_amp:SAMPLE amplitude)
              (newampinc:SAMPLE 0.0)
              (duration:i64 (note_duration data))
              (new_note_timer:i64 0)
              (FM_H:SAMPLE (dl_fm_h config))
              (FM_I:SAMPLE (dl_fm_idx config))
              (FM:i1 (if (or (> FM_H 0.0) (> FM_I 0.0)) #t #f))
              ;;;;;;;;;;;;;;
              (amp_env:|4,SAMPLE| (array 0.0:f (+ (dl_amp_decay config) (* (dl_amp_decay_dur config) MILLISEC (i64tof duration))) 0.0 0.0))
              ;; (filter_env:|4,SAMPLE| (array 0.0:f 0.0 1.0 0.0))
              (pitch_env:|2,SAMPLE| (array 0.0:f (dl_pitch_decay config)))
              (pitch_env_amt:SAMPLE (dl_pitch_amt config))
              (oldfreq 440.0:f) ;; ??
              (tune1:SAMPLE (dl_osc1_pitch config))
              (tune2:SAMPLE (dl_osc2_pitch config))
              (pw1:SAMPLE (dl_osc1_pw config))
              (pw2:SAMPLE (dl_osc2_pw config))
              (osc1_wave:enum (if (> pw1 0.0) PARAM_PULSE PARAM_SINE))
              (osc2_wave:enum (if (> pw2 0.0) PARAM_PULSE PARAM_SINE))
              (noise:enum PARAM_WHITE) ;; white
              (noise_amp:SAMPLE (dl_noise_amp config))
              (osc1_amp:SAMPLE 0.5)
              (osc2_amp:SAMPLE 0.5)
              (osc_phase_slop 0.01)
              (osc1_phase:SAMPLE (* osc_phase_slop .1 (random)))
              (osc2_phase:SAMPLE (* osc_phase_slop .1 (random)))
              (filter1_type:i64 (dl_filter1_type config)) ;; NOFILTER(-1), lpf(0), band(1), high(2), notch(3), peak(4) allpass(5)
              (filter2_type:i64 (dl_filter2_type config)) ;; NOFILTER(-1), lpf(0), band(1), high(2), notch(3), peak(4) allpass(5)
              ; (follow_frq 0.0)
              ; (follow_amp 0.0)
              (filter1_frq:SAMPLE (+ (dl_filter1_frq config)
                                     (* (dl_filter1_frq config)
                                        (dl_filter1_frq_scale config) (/ (% midifrq 12.0) 12.0))))
              (filter2_frq:SAMPLE (+ (dl_filter2_frq config)
                                     (* (dl_filter2_frq config)
                                        (dl_filter2_frq_scale config) (/ (% midifrq 12.0) 12.0))))
              (filter1_res:SAMPLE (dl_filter1_res config))
              (filter2_res:SAMPLE (dl_filter2_res config))
              ;;;;;;;;;;;;;
              (frq 0.0)
              (adsr1 (adsr_c))
              ;; (adsr2 (adsr_c))
              (adsr3 (adsr_c))
              (adsr1_val 0.0)
              ;; (adsr2_val 0.0)
              (adsr3_val 0.0)
              ;; (gate:SAMPLE 1.0)
              (amp:SAMPLE 0.0)
              (cof:SAMPLE 0.0)
              (amp_attack (aref amp_env 0))
              (amp_decay (aref amp_env 1))
              (amp_sustain (aref amp_env 2))
              (amp_release (+ 3.0 (aref amp_env 3))) ;; a 3ms release minimum
              (amp_release_samples (convert (* SRs (/ amp_release 1000.0)) i64))
              (reltime:i64 0)
              (pitch_attack (aref pitch_env 0))
              (pitch_decay (aref pitch_env 1))
              (f1 (svf_c))
              (f2 (svf_c))
              (f_out:|6,SAMPLE|* (alloc))
              (_osc1_phase (+ osc1_phase (* osc_phase_slop .1 (random))))
              (_osc2_phase (+ osc2_phase (* osc_phase_slop .1 (random))))
              (sin1 (osc_c _osc1_phase))
              (sin2 (osc_c _osc2_phase))
              (pulse1 (blpulse_c _osc1_phase #f))
              (pulse2 (blpulse_c _osc2_phase #f))
              (osc1_out:SAMPLE 0.0)
              (osc2_out:SAMPLE 0.0)
              (zero:SAMPLE 0.0)
              (white (white_c))
              (pink (pink_c))
              (noise_out 0.0)
              (main_out 0.0:f))
          (lambda (time:i64 chan:i64)
            (if (= chan 0)
                (begin
                  (set! notetime (tref data 7)) ;; look for voice steeling
                  ;; this for voice steeling
                  (if (and (<> starttime notetime) (>= time notetime))
                    (begin
                        (set! amplitude (note_amplitude data)) ;; reset envelopes
                        (retrigger_adsr adsr1)
                        ;; (retrigger_adsr adsr2)
                        (retrigger_adsr adsr3)
                        (set! starttime (tref data 7)) ;(note_starttime data))
                        (set! reltime 0)
                        (set! gate 1.0) ;(note_gate data))
                        (set! duration (note_duration data))))
                  ;; voice steeling done
                  (if (and (> gate 0.5) (> (- time starttime) duration)) (set! gate 0.0))
                  (set! adsr1_val (adsr1 chan gate amp_attack amp_decay amp_sustain amp_release))
                  ;; (set! adsr2_val (adsr2 chan gate filter_attack filter_decay filter_sustain filter_release))
                  (set! adsr3_val (adsr3 chan gate pitch_attack pitch_decay 0.0 0.0))
                  (set! amp (* amplitude (dl_part_amp config) adsr1_val))
                  (set! frq (+ frequency (* pitch_env_amt frequency adsr3_val) 0.0))
                  (if (< frq 10.0) (set! frq 10.0))
                  ;; if gate is OFF and amp is sufficiently close to 0.0 then stop note!
                  (if (< gate 0.1) (set! reltime (+ reltime 1)))
                  (if (> reltime amp_release_samples)
                      (begin
                        (note_active data #f)))
                  (if (FM)
                      (begin (set! osc2_out 0.0)
                            (set! osc1_out
                                  (sin1 (* (/ 5.0 (log frq)) osc1_amp)
                                      (+ frq
                                        (sin2 (* (* FM_H frq) FM_I)
                                            (* FM_H frq))))))
                      (begin
                        (if (> osc1_amp 0.001)
                            (set! osc1_out (* osc1_amp
                                              (cond ((= osc1_wave PARAM_SINE) (sin1 1.0 (* tune1 frq)))
                                                    ((= osc1_wave PARAM_PULSE) (pulse1 1.0 (* tune1 frq) pw1))
                                                    (else zero))))
                            (set! osc1_out 0.0))
                        (if (> osc2_amp 0.001)
                            (set! osc2_out (* osc2_amp
                                              (cond ((= osc2_wave PARAM_SINE) (sin2 1.0 (* tune2 frq)))
                                                    ((= osc2_wave PARAM_PULSE) (pulse2 1.0 (* tune2 frq) pw1))
                                                    (else zero))))
                            (set! osc2_out 0.0))))
                  (if (> noise_amp 0.001)
                      (if (= noise PARAM_WHITE)
                          (set! noise_out (* noise_amp (white)))
                          (set! noise_out (* noise_amp (pink))))
                      (set! noise_out 0.0))
                  (set! main_out (+ osc1_out osc2_out noise_out))
                  (if (> filter1_type DL_NOFILTER)
                      (begin
                        (f1 main_out filter1_frq filter1_res f_out)
                        (set! main_out (aref f_out filter1_type))))
                  (if (> filter2_type DL_NOFILTER)
                      (begin
                        (f2 main_out filter2_frq filter2_res f_out)
                        (set! main_out (aref f_out filter2_type))))
                  (set! main_out (* amp main_out))))
            main_out))))))


Back to Index

Similar Entries

  • LFO_OPT_NOTEDUR    scheme    /digego/extempore/tree/v0.8.9/examples/sharedsystem/audiosetup.xtm
  • PmEvent_note_off_p    xtlang    /digego/extempore/tree/v0.8.9/libs/external/portmidi.xtm
  • PmEvent_note_on_p    xtlang    /digego/extempore/tree/v0.8.9/libs/external/portmidi.xtm
  • active_notes    xtlang    /digego/extempore/tree/v0.8.9/libs/core/instruments/instrument_params.xtm
  • active_notes    xtlang    /digego/extempore/tree/v0.8.9/examples/sharedsystem/audiosetup.xtm
  • analogueVec_note    xtlang    /digego/extempore/tree/v0.8.9/libs/core/instruments/analogue.xtm
  • analogue_note    xtlang    /digego/extempore/tree/v0.8.9/libs/core/instruments/analogue.xtm
  • basic_note    xtlang    /digego/extempore/tree/v0.8.9/libs/core/instruments/basicsynth.xtm
  • cerberus_note    xtlang    /digego/extempore/tree/v0.8.9/libs/core/instruments/cerberus.xtm
  • cl:notevery    scheme    /digego/extempore/tree/v0.8.9/runtime/scheme.xtm
  • close-note-gate    scheme    /digego/extempore/tree/v0.8.9/libs/core/instruments-scm.xtm
  • dlogue_fx    xtlang    /digego/extempore/tree/v0.8.9/libs/core/instruments/dlogue.xtm
  • fmsynth_note    xtlang    /digego/extempore/tree/v0.8.9/libs/core/instruments/fmsynth.xtm
  • homo-play-midi-note    scheme    /digego/extempore/tree/v0.8.9/libs/contrib/rtmidi-scm.xtm
  • homo-play-midi-note    scheme    /digego/extempore/tree/v0.8.9/libs/external/portmidi.xtm
  • instrument_find_note    xtlang    /digego/extempore/tree/v0.8.9/libs/core/instruments.xtm
  • midi-note-off    scheme    /digego/extempore/tree/v0.8.9/libs/external/midi.xtm
  • midi-note-on    scheme    /digego/extempore/tree/v0.8.9/libs/external/midi.xtm
  • midi_note_off    xtlang    /digego/extempore/tree/v0.8.9/libs/external/midi.xtm
  • midi_note_off    xtlang    /digego/extempore/tree/v0.8.9/examples/core/midi_synth.xtm
  • midi_note_off    xtlang    /digego/extempore/tree/v0.8.9/examples/sharedsystem/midisetup.xtm
  • midi_note_on    xtlang    /digego/extempore/tree/v0.8.9/libs/external/midi.xtm
  • midi_note_on    xtlang    /digego/extempore/tree/v0.8.9/examples/core/midi_synth.xtm
  • midi_note_on    xtlang    /digego/extempore/tree/v0.8.9/examples/sharedsystem/midisetup.xtm
  • note-active    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/kinect_fire.xtm
  • note-activity    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/kinect_fire.xtm
  • note-grad    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/kinect_fire.xtm
  • note-pitch    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/kinect_fire.xtm
  • play-midi-note    scheme    /digego/extempore/tree/v0.8.9/libs/contrib/rtmidi-scm.xtm
  • play-midi-note    scheme    /digego/extempore/tree/v0.8.9/libs/external/portmidi.xtm
  • play-note    scheme    /digego/extempore/tree/v0.8.9/libs/core/instruments-scm.xtm
  • sampler-parse-midinote-filename    scheme    /digego/extempore/tree/v0.8.9/libs/external/instruments_ext-scm.xtm
  • sampler_note    xtlang    /digego/extempore/tree/v0.8.9/libs/external/instruments_ext.xtm
  • sampler_note_linear    xtlang    /digego/extempore/tree/v0.8.9/libs/external/instruments_ext.xtm
  • saw_synth_note_c    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/polysynth.xtm
  • saw_synth_note_c    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/polysynth.xtm
  • start-note    scheme    /digego/extempore/tree/v0.8.9/libs/core/instruments-scm.xtm
  • stop-note    scheme    /digego/extempore/tree/v0.8.9/libs/core/instruments-scm.xtm
  • xtm_notequal    xtlang    /digego/extempore/tree/v0.8.9/libs/core/rational.xtm
  • xtm_notequal    xtlang    /digego/extempore/tree/v0.8.9/libs/core/rational.xtm
  • xtm_notequal    xtlang    /digego/extempore/tree/v0.8.9/libs/core/rational.xtm
  • xtm_notequal    xtlang    /digego/extempore/tree/v0.8.9/libs/core/rational.xtm
  • xtm_notequal    xtlang    /digego/extempore/tree/v0.8.9/libs/core/rational.xtm
  • xtm_notequal    xtlang    /digego/extempore/tree/v0.8.9/libs/core/rational.xtm
  • xtm_notequal    xtlang    /digego/extempore/tree/v0.8.9/libs/core/rational.xtm
  • xtm_notequal    xtlang    /digego/extempore/tree/v0.8.9/libs/core/rational.xtm
  • xtm_notequal    xtlang    /digego/extempore/tree/v0.8.9/libs/core/rational.xtm
  • xtm_play_note    xtlang    /digego/extempore/tree/v0.8.9/libs/core/instruments.xtm
  • xtm_release_note    xtlang    /digego/extempore/tree/v0.8.9/libs/core/instruments.xtm
  • xtm_start_note    xtlang    /digego/extempore/tree/v0.8.9/libs/core/instruments.xtm
  • xtm_stop_note    xtlang    /digego/extempore/tree/v0.8.9/libs/core/instruments.xtm