-odac
-m0
/*
Debugger - Unfixed Bugs : BUG #5
http://git.1bpm.net/csd-unfixedbugs1/about/
By Richard Knight 2022, 2023
http://1bpm.net
q@1bpm.net
*/
sr = 44100
ksmps = 64
nchnls = 2
0dbfs = 1.1
seed 0
#define NOFILEIO ## ; file IO with readfi not supported on all platforms: disables bid_loadfile
;#define CPUSAVER ## ; improve CPU performance by degrading aesthetic performance
gkmastergain init 1 ; master gain
gkpump = 0 ; kick ducking control
gksection init -1
#include "wavetables.udo" ; general waveforms
#include "bussing.udo" ; global audio bussing
#include "bid.udo" ; Bug Infested Directive tools and parsing
#include "instruments.udo" ; sound generators
#include "txt_tools.udo" ; text tools
instr global_delay1
aL, aR bus_read "delay1"
aL *= abs(oscil(1, 1))
aR *= abs(oscil(1, 1))
aLdlr delayr 0.8
kdeltime = abs(oscil(0.02, 0.04)) + (gibid_beattime* 0.5)
aLdel deltapi kdeltime + 0.002
delayw aL + (aLdel * 0.7)
aRdlr delayr 0.8
aRdel deltapi kdeltime + 0.001
delayw aR + (aRdel * 0.7)
;aLdel *= 1-gkpump
;aRdel *= 1-gkpump
bus_mix("master", aLdel, aRdel)
endin
/*
Global send effects: reverb
*/
instr global_reverb
#ifndef CPUSAVER
aL, aR bus_read "reverb"
aL, aR freeverb aL, aR, 0.6, 0.3
bus_mix("master", aL, aR)
#endif
endin
/*
Master audio output
*/
instr global_master
igain = 1
aL, aR bus_read "master"
itime6 = tab_i(5, gibid_sectionlengths)*gibid_beattime
itime8 = tab_i(7, gibid_sectionlengths)*gibid_beattime
itime10 = tab_i(9, gibid_sectionlengths)*gibid_beattime
if (gksection == 6) then
khpf linseg 5, itime6*0.5, 10, itime6*0.3, 100, itime6*0.2, 500
klpf linseg 22050, itime6*0.5, 22050, itime6*0.3, 10000, itime6*0.2, 1000
aL butterhp butterlp(aL, klpf), khpf
aR butterhp butterlp(aR, klpf), khpf
elseif (gksection == 8) then
khpf linseg 5, itime6*0.5, 5, itime6*0.2, 100, itime6*0.2, 500, itime6*0.2, 2000
aL butterhp aL, khpf
aR butterhp aL, khpf
elseif (gksection == 10) then
ksnarevol linseg 0, itime10*0.5, 0.2, itime10*0.5, 1
chnset ksnarevol, "snarevol"
endif
aL limit aL*0.5, -1, 1
aR limit aR*0.5, -1, 1
outs aL*gkmastergain*igain, aR*gkmastergain*igain
endin
/*
Parse BID file and run the sequencer
*/
instr parseandrun
tt_notify("Parsing events")
#include "bid_source.udo"
bid_loadtext(SBID)
tt_notify("Running sequencer")
event_i "i", "sequencer", 0, 3600
turnoff
endin
instr endfade
exitnow
endin
instr sequencer
isection = 1
event_i "i", "bid_setcurrentchord", 0, 1, isection, 0
event_i "i", "global_delay1", 0, p3
event_i "i", "global_reverb", 0, p3
event_i "i", "global_master", 0, p3
kmetro metro (gibid_tempo / 60) * 4
kpos init 0
kposabs init 0
ksection init isection
kposchord init 0
gksection = ksection
if (kmetro == 1) then
if (ksection > gibid_maxsection) then
event "i", "endfade", 0, gibid_beattime*8
turnoff
endif
bid_seq "kick", kpos, ksection
bid_seq "hat1", kpos, ksection
bid_seq "hat2", kpos, ksection
bid_seq "snare", kpos, ksection
bid_seq "mel1", kpos, ksection
bid_seq "stringchord", kpos, ksection
bid_seq "chord1", kpos, ksection
bid_seq "bass", kpos, ksection
bid_seq "clap", kpos, ksection
bid_seq "303", kpos, ksection
bid_seq "303b", kpos, ksection
kpos = (kpos < 31) ? kpos + 1 : 0
ksection16ths = bid_getsectionlength(ksection) * 4
if (kposabs+1 < ksection16ths) then
kposabs += 1
else
ksection += 1
kposchord = 0
kpos = 0
kposabs = 0
event "i", "bid_setcurrentchord", 0, 1, ksection, 1
endif
if (kposchord+1 < gkbid_chordlength*4) then
kposchord += 1
else
kposchord = 0
event "i", "bid_setcurrentchord", 0, 1, ksection, 1
endif
endif
endin
i"parseandrun" 0 1