Drum Transient Processor Jacob Joaquin June 21, 2010 jacobjoaquin@gmail.com csoundblog.com Instructions To run, you need to download the BT sample packet which contains the sample "110 Kool Skool II.wav." (see below) This sample is licensed under Creative Commons, and part of the OLPC Sample Library. Run this csd in the same folder as the sample. BT sample pack http://www.archive.org/download/BT/BT44.zip BT (aka Brian Transeau) http://www.btmusic.com/ One Laptop Per Child music library http://wiki.laptop.org/go/Sound_samples Creative Commons Attribution 3.0 Unported http://creativecommons.org/licenses/by/3.0/ sr = 44100 kr = 44100 ksmps = 1 nchnls = 1 0dbfs = 1 # define TransLooper # 1 # # define PrintTrigger # 2 # opcode Transient, k, ak asig, \ ; Audio signal to process kthresh \ ; RMS difference threshold xin klast init 1 krms rms asig k1 divz krms, klast, 1 / (2 ^ 31) if k1 >= kthresh then kout = 1 else kout = 0 endif klast = krms xout kout endop instr TransLooper idur = p3 ; Duration iamp = p4 ; Amplitude imix = p5 ; Mix unaltered sound with transient attack (0..1) itrans_amp = p6 ; Amplitude scaling of transient S_sample = p7 ; Audio file. Mono only. ipitch = p8 ; Change pitch of sample ithresh = p9 ; RMS difference threshold idecay = p10 ; Envelope decay time in seconds ienv_init = p11 ; Initial value of envelope it_min = p12 ; Minimum time between triggers kdt init 0 ; Time since last trigger kenv init ienv_init ; Initial value of envelope a1 diskin2 S_sample, ipitch, 0, 1 ; Sample input ; Triggering mechanism ktrigger Transient a1, ithresh if (ktrigger == 1 && kdt > it_min) then kenv = 1 ; Reset envelope kdt = 0 ; Reset delta time event "i", $PrintTrigger, 0, 1 ; Print "Trigger" to console else kenv = kenv - (1 / kr) * (1 / idecay) ; Decay envelope kenv limit kenv, 0, 1 ; Limit range of envelope kdt = kdt + (1 / kr) ; Update delta time endif ; Create separate transient signal atrans = a1 * kenv * itrans_amp ; Mix, scale and output out (a1 * sqrt(1 - imix) + atrans * sqrt(imix)) * iamp endin instr $PrintTrigger prints "Trigger" turnoff endin # define TEMPO_MOD # 1.5 # t 0 [110 * $TEMPO_MOD] i 1 0 16 1 0 0 "110 Kool Skool II.wav" $TEMPO_MOD 2 1 1 1 i 1 + . 1 1 1 "110 Kool Skool II.wav" $TEMPO_MOD 1.015 0.06 1 0.0625 i 1 + . 1 0.5 1 "110 Kool Skool II.wav" $TEMPO_MOD 1.015 0.06 1 0.0625 i 1 + . 1 0.9 1 "110 Kool Skool II.wav" $TEMPO_MOD 1.015 0.06 1 0.0625 i 1 + . 1 1 1 "110 Kool Skool II.wav" $TEMPO_MOD 1.027 0.1 1 0.18 i 1 + . 1 0.9 1 "110 Kool Skool II.wav" $TEMPO_MOD 1.027 0.1 1 0.18 i 1 + . 1 0.5 -1 "110 Kool Skool II.wav" $TEMPO_MOD 1.015 0.06 1 0.0625 i 1 + . 1 0.5 -0.5 "110 Kool Skool II.wav" $TEMPO_MOD 1.015 0.1 1 0.0625