aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard <q@1bpm.net>2021-11-09 21:10:12 +0000
committerRichard <q@1bpm.net>2021-11-09 21:10:12 +0000
commit69d812698d8b6b4e963d49d0953ebeca05fa6500 (patch)
treee7fcf987afe9cd1ca290cbee3011bd6b3deacb8a
parentdae3d836d099b1abf8b4e6e935d148eccb90f96e (diff)
downloadcsd-unfixedbugs1-69d812698d8b6b4e963d49d0953ebeca05fa6500.tar.gz
csd-unfixedbugs1-69d812698d8b6b4e963d49d0953ebeca05fa6500.tar.bz2
csd-unfixedbugs1-69d812698d8b6b4e963d49d0953ebeca05fa6500.zip
BUG4 finished
-rw-r--r--.gitignore1
-rw-r--r--BID-rework/BUG5.csd154
-rw-r--r--BID-rework/bid.udo431
-rw-r--r--BID-rework/bid_source.udo135
-rw-r--r--BID-rework/bussing.udo62
-rw-r--r--BID-rework/instruments.udo312
-rw-r--r--BID-rework/txt_tools.udo82
-rw-r--r--BID-rework/wavetables.udo16
-rw-r--r--BUG3/BUG3.csd5
-rw-r--r--BUG3/bid.udo6
-rw-r--r--BUG3/instruments.udo10
-rw-r--r--BUG4/BUG4.csd181
-rw-r--r--BUG4/bid.udo425
-rw-r--r--BUG4/bid_source.udo494
-rw-r--r--BUG4/bussing.udo5
-rw-r--r--BUG4/instruments.udo489
-rw-r--r--BUG4/txt_tools.udo82
-rw-r--r--BUG4/wavetables.udo2
-rw-r--r--BUG5/BUG5.csd157
-rw-r--r--BUG5/bid.udo425
-rw-r--r--BUG5/bid_source.udo135
-rw-r--r--BUG5/bussing.udo62
-rw-r--r--BUG5/instruments.udo312
-rw-r--r--BUG5/txt_tools.udo82
-rw-r--r--BUG5/wavetables.udo16
-rw-r--r--BUG6/BUG6.csd245
-rw-r--r--BUG6/bid.udo425
-rw-r--r--BUG6/bid_source.udo169
-rw-r--r--BUG6/bussing.udo62
-rw-r--r--BUG6/instruments.udo491
-rw-r--r--BUG6/txt_tools.udo82
-rw-r--r--BUG6/wavetables.udo16
-rw-r--r--BUG7/BUG7.csd192
-rw-r--r--BUG7/basis.csd62
-rw-r--r--BUG7/bid.udo425
-rw-r--r--BUG7/bid_source.udo103
-rw-r--r--BUG7/bussing.udo62
-rw-r--r--BUG7/instruments.udo272
-rw-r--r--BUG7/txt_tools.udo82
-rw-r--r--BUG7/wavetables.udo16
-rw-r--r--README.md11
-rw-r--r--README.md~43
42 files changed, 6685 insertions, 154 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b25c15b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+*~
diff --git a/BID-rework/BUG5.csd b/BID-rework/BUG5.csd
new file mode 100644
index 0000000..4f05983
--- /dev/null
+++ b/BID-rework/BUG5.csd
@@ -0,0 +1,154 @@
+<CsoundSynthesizer>
+<CsOptions>
+-odac
+</CsOptions>
+<CsInstruments>
+/*
+ Debugger - Unfixed Bugs : BUG #5
+
+ http://git.1bpm.net/csd-unfixedbugs1/about/
+
+ By Richard Knight 2022
+ http://1bpm.net
+ q@1bpm.net
+
+*/
+
+sr = 44100
+ksmps = 10
+nchnls = 2
+0dbfs = 1
+seed 0
+
+#define NOFILEIO ## ; file IO with readfi not supported on all platforms: disables bid_loadfile
+
+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
+ aL, aR bus_read "reverb"
+ aL, aR freeverb aL, aR, 0.6, 0.3
+ bus_mix("master", aL, aR)
+endin
+
+/*
+ Master audio output
+*/
+instr global_master
+ igain = 1
+ aL, aR bus_read "master"
+ 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
+
+
+ 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
+
+</CsInstruments>
+<CsScore>
+i"parseandrun" 0 1
+
+</CsScore>
+</CsoundSynthesizer> \ No newline at end of file
diff --git a/BID-rework/bid.udo b/BID-rework/bid.udo
new file mode 100644
index 0000000..4c0e797
--- /dev/null
+++ b/BID-rework/bid.udo
@@ -0,0 +1,431 @@
+#ifndef UDO_BID
+#define UDO_BID ##
+/*
+ Debugger - Unfixed Bugs : BUG #5
+
+ Bug Infested Directive file parser v1 and tools
+
+ Designed to create a reusable loop based score format in the Unfixed Bugs project and beyond.
+*/
+
+
+#define BID_VERSION #1.1#
+
+#include "txt_tools.udo"
+
+; globals
+gibid_tempo init -1 ; beats per minute
+gibid_beattime init -1 ; time of one beat in second
+gibid_maxsection init -1 ; max number of sections
+gibid_chordfn init -1 ; current chord ftable
+gkbid_chordlength init -1 ; current chord length
+
+; BID internals
+gibid_sectionmax init 64
+gibid_sectionlengths ftgen 0, 0, -gibid_sectionmax, -7, 0 ; section lengths
+gibid_sections ftgen 0, 0, -pow(gibid_sectionmax, 2), -7, 0 ; section pointers to data: dim0=section, dim1=instrument
+gibid_sectiondata ftgen 0, 0, -(99*6), -7, 0 ; section data, ftables contained: dim0=ID, dim1=parameter ftable number
+
+gibid_chordgroups[][] init 16, 12 ; chord groups, pointers to sectionchords by section
+gibid_sectionchords[] init 16 ; ftables of section chords
+
+gibid_currentchordnum = 0 ; current chord number
+gibid_lastchordgroup = -1 ; last chord group
+gibid_lastsection = -1 ; last section
+
+gSbid_sequenced[] init 1 ; internal tracking of sequenced elements
+gibid_sequenceinit init 1 ; internal tracking of sequenced init
+gibid_swingtime init -1 ; swing time calculated from percent
+
+/*
+ Get BID instrument index, creating new reference if specified.
+ Internal use only.
+
+ index _bid_gettextindex Sname, [iaddifnotexists = -1]
+
+ index BID instrument index
+
+ Sname name to look up or create
+ iaddifnotexists 1=create , default=fatal if not exists
+*/
+opcode _bid_gettextindex, i, Sj
+ Sname, iaddifnotexists xin
+ ifinalindex = -1
+ index = 0
+ while (index < lenarray(gSbid_sequenced)) do
+ if (strcmp(gSbid_sequenced[index], Sname) == 0) then
+ ifinalindex = index
+ igoto complete
+ endif
+ index += 1
+ od
+
+ if (iaddifnotexists == 1) then
+ if (gibid_sequenceinit == 1) then
+ gibid_sequenceinit = 0
+ SequencedNew[] fillarray Sname
+ ifinalindex = 0
+ else
+ SequencedNew[] init lenarray(gSbid_sequenced) + 1
+ index = 0
+ while (index < lenarray(gSbid_sequenced)) do
+ SequencedNew[index] = gSbid_sequenced[index]
+ index += 1
+ od
+ SequencedNew[index] = Sname
+ ifinalindex = index
+ endif
+ gSbid_sequenced = SequencedNew
+ igoto complete
+ else
+ tt_notify_fatal(sprintf("Sequenced index for '%s' not found", Sname))
+ endif
+
+complete:
+ xout ifinalindex
+endop
+
+
+
+/*
+ Parse a row of comma-separated numerical values of either patterns or chords.
+ Internal use only.
+
+ inum _bid_parserowitems Sline, ix1, ix2, imode
+
+ inum number of elements found parsed
+
+ Sline input line
+ ix1 array dimension 1 index
+ ix2 array dimension 2 index
+ imode 0=count elements; 1=write patterns; 2=write chords
+*/
+opcode _bid_parserowitems, i, Siii
+ Sline, ix1, ix2, imode xin
+ inum = 0
+ while (strlen(Sline) > 0) do
+ icomma = strindex(Sline, ",")
+ Stemp = strsub(Sline, 0, icomma)
+ icomma = (icomma == -1) ? 0 : icomma
+ Sline = strsub(Sline, icomma + 1)
+ if (imode == 1) then
+ tabw_i strtod(Stemp), inum, gibid_sectiondata[ix1][ix2]
+ elseif (imode == 2) then
+ tabw_i strtod(Stemp), inum, gibid_chordgroups[ix1][ix2]
+ endif
+ inum += 1
+ od
+ xout inum
+endop
+
+
+
+/*
+ Read BID data for specified element and trigger accordingly.
+
+ bid_seq Splayer, kposition, ksection
+
+ Splayer name of BID element
+ kposition position in pattern provided by master sequencer
+ ksection section in composition provided by master sequencer
+
+*/
+opcode bid_seq, 0, Skk
+ Splayer, kpos, ksection xin
+ Sinstrument = sprintf("play_%s", Splayer)
+ instrindex = _bid_gettextindex(Splayer)
+ kdata = tab:k(ksection * gibid_sectionmax + instrindex, gibid_sections)
+
+ if (kdata != -1) then ; null section
+ tab:k(kpos,
+ kon = tablekt:k(kpos, gibid_sectiondata[kdata][0])
+
+ if (kon == 1) then
+ kchance = tablekt:k(kpos, gibid_sectiondata[kdata][3])
+ if (random:k(0, 1) < kchance) then
+ ktime = (kpos % 2 == 0) ? 0 : gibid_swingtime
+ kdur = tablekt:k(kpos, gibid_sectiondata[kdata][1]) * gibid_beattime
+ ;kamp = tablekt:k(kpos, gisectiondata[kdata][2])
+ event "i", Sinstrument, ktime, kdur, kpos, kdata
+ endif
+ endif
+ endif
+endop
+
+
+/*
+ Get a parameter for the specified pattern position.
+ ipos and idataindex are provided as p4 and p5 to instruments scheduled by bid_seq,
+ hence can typically used as bid_getparameter(p4, p5, iparameter)
+
+ idata bid_getparameter ipos, idataindex, iparameter
+
+ idata the resulting value
+
+ ipos position in pattern
+ idataindex section specific data index; pointer to ftable
+ iparameter parameter index as in BID file; defaults include 0=on/off, 1=duration, 2=amp, 3=chance
+
+*/
+opcode bid_getparameter, i, iii
+ ipos, idataindex, iparameter xin
+ ifn = tab_i(idataindex * gibid_sectionmax + iparameter, gibid_sectiondata)
+ xout tab_i(ipos, ifn)
+endop
+
+
+/*
+ Get a section length in beats
+
+ klength bid_getsectionlength ksection
+
+ klength length in beats
+
+ ksection section to look up
+*/
+opcode bid_getsectionlength, k, k
+ ksection xin
+ xout tab:k(ksection, gibid_sectionlengths)
+endop
+
+/*
+ Parse a row of comma-separated values to either section patterns or chord storage.
+ Scans row, assigns ftable of appropriate length and then fills ftable.
+ Internal use only.
+
+ _bid_parserow Sline, ix1, ix2, imode
+
+ Sline line to parse
+ ix1 array dimension 1 index of target storage
+ ix2 array dimension 2 index of target storage
+ imode 1=section patterns, 2=chords
+*/
+opcode _bid_parserow, 0, Siii
+ Sline, ix1, ix2, imode xin
+ isize = _bid_parserowitems(Sline, ix1, ix2, 0)
+ if (imode == 1) then
+ ifn ftgen 0, 0, -isize, -7, 0
+ tabw_i(ifn, ix1 * gibid_sectionmax + ix2, gibid_sectiondata)
+ elseif (imode == 2) then
+ gibid_chordgroups[ix1][ix2] ftgen 0, 0, -isize, -7, 0
+ endif
+ isize = _bid_parserowitems(Sline, ix1, ix2, imode)
+endop
+
+
+
+/*
+ Parse a line from a BID string
+ Internal use only.
+
+ idataout[] _bid_parseline Sline, idatain[]
+
+ idataout[] state data
+
+ Sline line to parse
+ idatain[] state data
+
+*/
+opcode _bid_parseline, i[], Si[]
+ Sline, idata[] xin
+ iparameter = idata[0]
+ isection = idata[1]
+ ichordnum = idata[2]
+ isectiondataindex = idata[3]
+ imode = idata[4]
+
+ if (strlen(Sline) > 0) then
+ Sfirstchar = strsub(Sline, 0, 1)
+
+ ; comment
+ if (strcmp(Sfirstchar, ";") == 0) then
+ ; no action
+
+ ; version check
+ elseif (strcmp(Sfirstchar, "v") == 0) then
+ imode = 0
+ iversion = strtod(strsub(Sline, 2))
+ if (iversion != $BID_VERSION) then
+ tt_notify(sprintf("Incompatible BID file version: got %.2f , expected %.2f", iversion, $BID_VERSION))
+ exitnow
+ endif
+
+ ; section header
+ elseif (strcmp(Sfirstchar, "s") == 0) then
+ imode = 1
+ icomma = strindex(Sline, ",")
+ isectionnum = strtod(strsub(Sline, 2, icomma))
+ Sub = strsub(Sline, icomma+1)
+ icomma = strindex(Sub, ",")
+ isectionlength = strtod(strsub(Sub, 0, icomma))
+ ichordgroup = strtod(strsub(Sub, icomma+1))
+ gibid_sectionchords[isectionnum] = ichordgroup
+ tabw_i isectionlength, isectionnum, gibid_sectionlengths
+
+ ; tempo
+ elseif (strcmp(Sfirstchar, "b") == 0) then
+ imode = -1
+ icomma = strindex(Sline, ",")
+ gibid_tempo = strtod(strsub(Sline, 2, icomma))
+ gibid_beattime = 60 / gibid_tempo
+ iswingpercent = strtod(strsub(Sline, icomma+1))
+ gibid_swingtime = ((gibid_beattime/4)/100) * iswingpercent
+
+ ; chord group header
+ elseif (strcmp(Sfirstchar, "c") == 0) then
+ imode = 3
+ ichordgroup = strtod(strsub(Sline, 2))
+ ichordnum = 0
+
+ ; pattern header
+ elseif (strcmp(Sfirstchar, "i") == 0) then
+ imode = 4
+ iparameter = 0
+
+ icomma = strindex(Sline, ",")
+ instrindex = _bid_gettextindex(strsub(Sline, 2, icomma), 1)
+ Sub = strsub(Sline, icomma+1)
+ icomma2 = strindex(Sub, ",")
+ isection = strtod(strsub(Sub, 0, icomma2))
+ if (isection > gibid_maxsection) then
+ gibid_maxsection = isection
+ endif
+ if (icomma2 != -1) then ; repeat or null section
+ irepeatsection = strtod(strsub(Sub, icomma2+1))
+ if (irepeatsection == -1) then
+ inewsection = -1
+ else
+ inewsection = tab_i(irepeatsection * gibid_sectionmax + instrindex, gibid_sections)
+ endif
+ tabw_i(inewsection, isection * gibid_sectionmax + instrindex, gibid_sections)
+ ;gibid_sections[isection][instrindex] = inewsection
+ else
+ isectiondataindex += 1
+ tabw_i(isectiondataindex, isection * gibid_sectionmax + instrindex, gibid_sections)
+ endif
+
+ ; chord row
+ elseif (imode == 3) then
+ _bid_parserow(Sline, ichordgroup, ichordnum, 2)
+ ichordnum += 1
+
+ ; pattern row
+ elseif (imode == 4) then
+ _bid_parserow(Sline, isectiondataindex, iparameter, 1)
+ iparameter += 1
+ endif
+ endif
+ idata[0] = iparameter
+ idata[1] = isection
+ idata[2] = ichordnum
+ idata[3] = isectiondataindex
+ idata[4] = imode
+ xout idata
+endop
+
+
+/*
+ Parse a Bug Infested Directive Format string to global arrays, ftables and variables.
+ Handles patterns, tempo, chord groups and sections etc accordingly.
+
+ bid_loadtext Sfile, [imode = 0]
+
+ Stext directive data as string to parse
+*/
+opcode bid_loadtext, 0, S
+ Stext xin
+ idata[] fillarray -1, -1, -1, -1, -1
+read:
+ index = strindex(Stext, "\n")
+ if (index != -1) then
+ Sline = strsub(Stext, 0, index)
+ Stext = strsub(Stext, index + 1)
+ idata[] _bid_parseline Sline, idata
+
+ igoto read
+ else
+ igoto complete
+ endif
+
+complete:
+endop
+
+
+/*
+ Parse a Bug Infested Directive Format string to global arrays, ftables and variables.
+ Handles patterns, tempo, chord groups and sections etc accordingly.
+ Requires readfi support which is not available on all platforms. Platforms that do not support that
+ should set NOFILEIO.
+
+ bid_loadfile Sfile
+
+ Sfile directive file to parse
+*/
+opcode bid_loadfile, 0, S
+ Sfile xin
+#ifdef NOFILEIO
+ tt_notify_fatal("Attempting to use parsefile when NOFILEIO is set")
+#else
+ if (filevalid(Sfile) == 0) then
+ tt_notify(sprintf("Directive file cannot be found: '%s'", Sfile))
+ exitnow
+ endif
+ idata[] fillarray -1, -1, -1, -1, -1
+read:
+ Sline, ilinenum readfi Sfile
+ Sline = tt_stripnewline(Sline)
+
+ idata[] _bid_parseline Sline, idata
+
+ if (ilinenum != -1) igoto read
+#endif
+endop
+
+
+
+/*
+ Set the current chord given a section
+ p4 the section number
+ p5 0=start at beginning, 1=increment chord index
+*/
+instr bid_setcurrentchord
+ isection = p4
+ ichordincrement = p5
+ if (isection > gibid_maxsection) then
+ turnoff
+ endif
+
+ ichordgroup = gibid_sectionchords[isection]
+ if (ichordgroup != gibid_lastchordgroup || isection != gibid_lastsection) then
+ gibid_currentchordnum = 0
+ gibid_lastchordgroup = ichordgroup
+ gibid_lastsection = isection
+ elseif (ichordincrement == 1) then
+ if (gibid_currentchordnum + 1 < lenarray(gibid_chordgroups, 2) - 1) then
+ if (gibid_chordgroups[ichordgroup][gibid_currentchordnum + 1] == 0) then
+ gibid_currentchordnum = 0
+ else
+ gibid_currentchordnum += 1
+ endif
+ else
+ gibid_currentchordnum = 0
+ endif
+ else
+ gibid_currentchordnum = 0
+ endif
+
+ ifn = gibid_chordgroups[ichordgroup][gibid_currentchordnum]
+
+ if (ifn > 0) then
+ gkbid_chordlength = tab:k(0, ifn)
+ gibid_chordfn = ifn
+ endif
+
+ if (timeinstk() > 2) then
+ turnoff
+ endif
+endin
+
+
+#end
+
diff --git a/BID-rework/bid_source.udo b/BID-rework/bid_source.udo
new file mode 100644
index 0000000..a64d00a
--- /dev/null
+++ b/BID-rework/bid_source.udo
@@ -0,0 +1,135 @@
+/*
+ Debugger - Unfixed Bugs : BUG #5
+
+ Bug Infested Directives source
+ Provided as a string due to readfi not being available on all platforms.
+ Used with bid_loadtext (whereas a separate file would be used with bid_loadfile and requires readfi support)
+*/
+
+SBID = {{
+; Bug Infested Directives : Debugger - Unfixed Bugs : BUG #5
+v 1.1
+
+; tempo, swing percent
+b 123, 41
+
+; chord groups
+c 1
+ 3.5, 56, 59, 61, 64
+ 4.5, 56, 59, 63
+ 8, 59, 60, 62, 65, 69
+
+c 2
+ 8, 56, 59, 61, 64, 69
+ 8, 56, 59, 65, 71, 73
+;8, 56, 59, 63, 68
+;4.5, 57, 60, 65, 69, 71
+; 4.5, 60, 61, 65, 67, 70 ; 57, 60, 65, 69, 71
+
+
+; sections: section number, length, chordgroup
+s 1, 32, 2
+s 2, 32, 1
+s 3, 32, 1
+
+
+
+; patterns: trig , dur, amp, chance
+i stringchord, 1
+; 1 - - - 2 - - - 3 - - - 4 - - - 5 - - - 6 - - - 7 - - - 8 - - -
+ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4.5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,.6, 1, 1, 1, 1, 1, 1, 1, 1
+ 1,.6, 1,.6, 1, 1, 0, 1, 1, 1, 1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 1, 1, 1, 1, 1, 1, 1,.8, 1,.8, 1, 1, 1, 1, 1, 1
+ 1, 1, 1, 1, 1, 1, 1, 1, 1,.5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,.5, 1,.5, 1, 1, 1, 1, 1, 1
+i bass, 3, 2
+
+
+i kick, 1
+; 1 - - - 2 - - - 3 - - - 4 - - - 5 - - - 6 - - - 7 - - - 8 - - -
+ 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0
+ .9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9
+ 1, 0,.8, 0, 1, 0, 0, 0, 1, 0,.7, 0, 1, 0, 0, 0, 1, 0,.8, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0,.6,.6
+ 1, 1,.1, 1, 1, 1, 1, 1, 1, 1,.5, 1, 1, 1, 1, 1, 1, 1,.1, 1, 1, 1, 1, 1, 1, 1,.5, 1, 1, 1,.6,.2
+i kick, 2, 1
+i kick, 3, 1
+}}
diff --git a/BID-rework/bussing.udo b/BID-rework/bussing.udo
new file mode 100644
index 0000000..78755ce
--- /dev/null
+++ b/BID-rework/bussing.udo
@@ -0,0 +1,62 @@
+#ifndef UDO_BUSSING
+#define UDO_BUSSING ##
+
+
+/*
+ Get the stereo L and R names for a singular bus name
+
+ SnameL, SnameR bus_name Sbus
+
+ SnameL left bus identifier
+ SnameR right bus identifier
+
+ Sbus bus name
+*/
+opcode bus_name, SS, S
+ Sbus xin
+ xout sprintf("%sL", Sbus), sprintf("%sR", Sbus)
+endop
+
+
+/*
+ Mix to a stereo bus
+
+ bus_mix Sbus, aL, aR
+
+ Sbus bus name
+ aL left channel
+ aR right channel
+*/
+opcode bus_mix, 0, Saa
+ Sbus, aL, aR xin
+ SbusL, SbusR bus_name Sbus
+ chnmix aL, SbusL
+ chnmix aR, SbusR
+endop
+
+
+
+/*
+ Read from a stereo bus, and then clear the bus
+
+ aL, aR bus_read Sbus
+
+ aL left channel
+ aR right channel
+
+ Sbus bus name
+*/
+opcode bus_read, aa, S
+ Sbus xin
+ SbusL, SbusR bus_name Sbus
+ aL chnget SbusL
+ aR chnget SbusR
+ chnclear SbusL
+ chnclear SbusR
+ xout aL, aR
+endop
+
+
+
+
+#end
diff --git a/BID-rework/instruments.udo b/BID-rework/instruments.udo
new file mode 100644
index 0000000..834f942
--- /dev/null
+++ b/BID-rework/instruments.udo
@@ -0,0 +1,312 @@
+#ifndef UDO_INSTRUMENTS
+#define UDO_INSTRUMENTS ##
+/*
+ Debugger - Unfixed Bugs : BUG #5
+
+ Sound generators
+ Names should correspond to those used in BID file, prepended with play_
+*/
+
+
+#include "wavetables.udo"
+#include "bussing.udo"
+#include "bid.udo"
+
+
+instr play_hat1
+ iamp = bid_getparameter(p4, p5, 2)
+ idel1 = random(0.01, 0.03)
+ idel2 = random(0.01, 0.03)
+ xtratim(max(idel1, idel2))
+ p3 = 0.22
+ kfreq linseg 1000, p3*0.2, 300, p3*0.8, 500 ; mid as 500 not 300
+ aenv expsega .1, .0005, 1, p3 - .0005, .01
+ asqr1 oscil 1, kfreq, gifnSquare, -1
+ asqr2 oscil 1, kfreq*1.4471, gifnSquare, -1
+ asqr3 oscil 1, kfreq*1.6170, gifnSquare, -1
+ asqr4 oscil 1, kfreq*1.9265, gifnSquare, -1
+ asqr5 oscil 1, kfreq*2.5028, gifnSquare, -1
+ asqr6 oscil 1, kfreq*2.6637, gifnSquare, -1
+ a808 sum asqr1, asqr2, asqr3, asqr4, asqr5, asqr6
+ a808 butterhp a808, 3270
+ a808 butterhp a808, 3270
+ aout = a808 * aenv * iamp
+ aL delay aout, idel1
+ aR delay aout, idel2
+ bus_mix("master", aL, aR)
+endin
+
+
+instr play_hat2
+ iamp = bid_getparameter(p4, p5, 2)
+ idel1 = random(0.005, 0.02)
+ idel2 = random(0.005, 0.02)
+ xtratim(max(idel1, idel2))
+ kfreq init 415.3*0.8
+ aenv expsega .1, .0005, 1, p3 - .0005, .01
+ asqr1 oscil 1, kfreq, gifnSquare, -1
+ asqr2 oscil 1, kfreq*1.4471, gifnSquare, -1
+ asqr3 oscil 1, kfreq*1.6170, gifnSquare, -1
+ asqr4 oscil 1, kfreq*1.9265, gifnSquare, -1
+ asqr5 oscil 1, kfreq*2.5028, gifnSaw, -1
+ asqr6 oscil 1, kfreq*2.6637, gifnSaw, -1
+ a808 sum asqr1, asqr2, asqr3, asqr4, asqr5, asqr6
+ a808 butterhp a808, 3270
+ a808 butterhp a808, 3270
+ aout = a808 * aenv * iamp
+ aL delay aout, idel1
+ aR delay aout, idel2
+ bus_mix("master", aL, aR)
+endin
+
+instr play_bass
+ iamp = bid_getparameter(p4, p5, 2)
+ inote = tab_i(random(1, ftlen(gibid_chordfn) - 3), gibid_chordfn) - 24
+ a1 foscil 0.56, cpsmidinn(inote), 1, 2, random(0, 6), gifnSine
+ a1 pareq a1, 150, 0.24, 0.9
+ a1 pareq a1, 80, 1.3, 0.9
+ kenv linseg 1, p3, 0
+ aout = a1*kenv
+ bus_mix("master", aout, aout)
+endin
+
+
+instr play_kick ; 808 style kick
+ iamp = bid_getparameter(p4, p5, 2)
+
+ idist = 0.35 ;= (i(gksection) == 1) ? 0.55 : 0.35
+ xtratim 0.1
+ krelease release
+ ktune init 0
+ kmul transeg 0.2, p3*0.5, -15, 0.01, p3*0.5, 0, 0
+ kbend transeg 0.5, 1.2, -4, 0, 1, 0, 0
+ asig gbuzz 0.5, 50*octave(ktune)*semitone(kbend), 20, 1, kmul, gifnCosine
+ aenv transeg 1, p3-0.004, -6, 0
+ gkpump = k(aenv)
+ aatt linseg 0, 0.004, 1
+ asig = asig*aenv*aatt
+ aenv linseg 1, 0.07, 0
+ acps expsega 400, 0.07, 0.001, 1, 0.001
+ aimp oscili aenv, acps*octave(ktune*0.25)
+ amix = ((asig*0.7)+(aimp*0.35))*2*iamp
+ gkpump = min(rms(amix) * 7, 1)
+ aout1 distort amix, idist, gifnSine
+
+
+ aout1 *= 1.6
+ bus_mix("master", aout1, aout1)
+endin
+
+
+instr play_snare
+ icps0 = 211
+ iamp = bid_getparameter(p4, p5, 2)
+ ;p3 = random(0.03, 0.5)
+ icps1 = 2.0 * icps0
+ kcps port icps0, 0.007, icps1
+ kcpsx = kcps * 1.5
+
+ kfmd port 0.0, 0.01, 0.7
+ aenv1 expon 1.0, 0.03, 0.5
+ kenv2 port 1.0, 0.008, 0.0
+ aenv2 interp kenv2
+ aenv3 expon 1.0, 0.025, 0.5
+
+ a_ oscili 1.0, kcps
+ a1 oscili 1.0, kcps * (1.0 + a_*kfmd)
+ a_ oscili 1.0, kcpsx
+ a2 oscili 1.0, kcpsx * (1.0 + a_*kfmd)
+
+ a3 unirand 2.0
+ a3 = a3 - 1.0
+ a3 butterbp a3, 3200, 1500
+ a3 = a3 * aenv2
+
+ a0 = a1 + a2*aenv3 + a3*1.0
+ a0 = a0 * aenv1
+ a0 butterhp a0, 210
+ aout = a0*iamp
+ bus_mix("master", aout, aout)
+
+endin
+
+
+/*
+ Convenience opcode for playing current chord on given instrument, passing p4 as note and p5 as amp
+
+ chordinstrument Sinstrument
+
+ Sinstrument the instrument name
+ ipos position in pattern
+ idataindex section specific data index; pointer to ftable
+*/
+opcode chordinstrument, 0, Sii
+ Sinstrument, ipos, idataindex xin
+ iamp = bid_getparameter(ipos, idataindex, 2)
+ index = 1 ; index 0 is chordgroup length
+ while (index < ftlen(gibid_chordfn)) do
+ event_i "i", Sinstrument, 0, p3, tab_i(index, gibid_chordfn), iamp
+ index += 1
+ od
+
+endop
+
+
+
+instr play_clap
+ iamp = bid_getparameter(p4, p5, 2)
+ ;p3 = 0.065
+ aL noise 1, 0.9
+ aR noise 0.5, 0.4
+ aL butterbp aL, 1200, 1100
+ aR butterbp aR, 1200, 1100
+ aL butterhp aL, 400
+ aR butterhp aR, 400
+ kamp1 linseg 1, p3*0.1, 0, p3*0.1, 1, p3*0.2, 0.1, p3*0.3, 0.5, p3*0.2, 0, p3*0.05, 0.4, p3*0.05, 0
+ kamp2 linseg 1, p3*0.15, 0, p3*0.15, 1, p3*0.1, 0.1, p3*0.2, 0.5, p3*0.3, 0, p3*0.05, 0.4, p3*0.05, 0
+
+ aL = aL*kamp1*12*iamp
+ aR = aR*kamp2*12*iamp
+ bus_mix("master", aL, aR)
+ bus_mix("reverb", aL*0.2, aR*0.2)
+endin
+
+instr play_mel1
+ iamp = bid_getparameter(p4, p5, 2)
+ inote = tab_i(1, gibid_chordfn) ;tab_i(random(1, ftlen(gibid_chordfn) - 3), gibid_chordfn) - 12
+ inote2 = tab_i(2, gibid_chordfn) ;tab_i(random(1, ftlen(gibid_chordfn) - 3), gibid_chordfn) - 12
+ aL moog 0.6*iamp, cpsmidinn(inote - 12), 0.1, 0.02, 4, 0.01, gifnSine, gifnSaw, gifnSine
+ aR moog 0.6*iamp, cpsmidinn(inote2 - 12), 0.1, 0.002, 4, 0.01, gifnSine, gifnSaw, gifnSine
+ kenv linseg 1, p3*0.8, 0, p3*0.2, 0
+ aL *= kenv
+ aR *= kenv
+ bus_mix("master", aL, aR)
+endin
+
+instr string
+ if (random(0, 1) > 0.8) then
+ ifqc = cpsmidinn(p4)
+ else
+ ifqc = cpsmidinn(p4+12)
+ endif
+ iamp = p5
+idur = p3
+ ifm1 = ifqc
+ ifm2 = ifqc*3
+ ifm3 = ifqc*4
+ indx1 = 7.5/log(ifqc) ;range from ca 2 to 1
+ indx2 = 15/sqrt(ifqc) ;range from ca 2.6 to .5
+ indx3 = 1.25/sqrt(ifqc) ;range from ca .2 to .038
+
+ irise = 0.1
+ idec = 0.4
+ inoisdur= .1
+ ivibdel = 0.25
+ ivibwth = 0.01
+ ivibrte = 5.5
+
+ kvib init 0
+ kvbctl linen 1,.5,p3-ivibdel,.1 ; vibrato control envelope
+ krnd randi .0075,2 ; random deviation vib width
+ kvib oscili kvbctl*ivibwth+krnd,ivibrte*kvbctl ; generator
+
+ ktrans linseg 1,inoisdur,0,1,0 ; transient envelope
+ anoise randi ktrans*iamp/4,.2*ifqc ; attack noise...
+ attack oscili anoise,2000 ; ...centered around 2kHz
+
+ amod1 oscili ifm1*(indx1+ktrans),ifm1
+ amod2 oscili ifm2*(indx2+ktrans),ifm2
+ amod3 oscili ifm3*(indx3+ktrans),ifm3
+ asig oscili iamp,(ifqc+amod1+amod2+amod3)*(1+kvib)
+ asig linen (asig+attack),irise,idur,idec
+ asig butterhp asig, 800
+ asig butterhp asig, 200
+ kenv linseg 0, p3*0.25, 0.7, p3*0.5, 1, p3*0.25, 0
+ asig *= kenv
+ asig *= 0.2
+ aL = asig
+ aR = asig
+ bus_mix("delay1", aL, aR)
+bus_mix("reverb", aL, aR)
+
+
+endin
+
+
+instr play_303
+ iamp = bid_getparameter(p4, p5, 2)
+ ifilter = random(50, 70)
+ inote = tab_i(random(1, ftlen(gibid_chordfn) - 1), gibid_chordfn)
+
+ ifrq1 = 440 * exp(log(2) * (ifilter - 69) / 12) ; filter start freq.
+ kamp linseg 1, p3-0.01, 1, 0.025, 0, 1, 0 ; release envelope
+ kcps init cpsmidinn(inote)
+ kffrq port 0, 60/150, ifrq1 ; filter frequency
+ a1 phasor kcps ; oscillator
+ a1 = 1 - 2 * a1
+
+ a1x butterbp a1, kffrq, kcps * 1.0 ; filters
+ a1x = a1x * (2 + kffrq / kcps) ; correct amplitude
+ a1 = a1x + a1 * 0.25 ; 0.5
+ a1 butterlp a1, kffrq
+
+ a1 = taninv(a1 * 4 * iamp) ; distortion ; 2.5
+
+ keqf limit kffrq * 4, 10, sr * 0.48 ; EQ frequency
+ a1 pareq a1 * 0.4, keqf, 4.0, 1.0, 2
+ a1 butterhp a1, 250
+ a1 = a1 * kamp * 0.72
+ aL, aR pan2 a1, random(0.3, 0.7)
+ bus_mix("reverb", aL*0.3, aR*0.3)
+ bus_mix("master", aL*0.8, aR*0.8)
+endin
+
+instr chord1
+ inote = p4
+ iamp = p5
+ kfreq init cpsmidinn(inote)
+
+ aphs1 phasor kfreq
+ aphs2 phasor kfreq
+ koda = abs(oscil(random(0, 2), random(0, 1)))
+ a1 tablei aphs1, gifnSine, 1, 0, 1
+ a1 *= linseg(1, p3*0.9, 0)
+
+ av1L linseg 3, p3, 0
+ aL tablei (aphs2+a1)+av1L+koda, gifnSine, 1, 0, 1
+
+ av1R linseg 4, p3, 0
+ aR tablei (aphs2+a1)+av1R+koda, gifnSine, 1, 0, 1
+
+ kfi linseg 0, p3*0.2, 1, p3*0.8, 1
+ aL phaser1 aL*kfi, oscil:k(7400, 0.1, gifnSine, random(0, 0.5)) + 1000, 8, .9
+ aR phaser1 aR*kfi, oscil:k(7400, 0.1, gifnSine, random(0, 0.5)) + 1000, 8, .9
+ aL *= 0.16 * iamp
+ aR *= 0.16 * iamp
+ aL butterhp aL, 520
+ aR butterhp aR, 520
+ if (i(gksection) == 3) then
+ aL butterlp aL, 1000
+ aR butterlp aR, 1000
+ endif
+ bus_mix("delay1", aL, aR)
+ ;bus_mix("master", aL, aR)
+endin
+
+
+/*
+ Play chord1 above, called from BID
+*/
+instr play_chord1
+ chordinstrument "chord1", p4, p5
+ turnoff
+endin
+
+instr play_stringchord
+ chordinstrument "string", p4, p5
+ turnoff
+endin
+
+
+
+#end
diff --git a/BID-rework/txt_tools.udo b/BID-rework/txt_tools.udo
new file mode 100644
index 0000000..a6c4511
--- /dev/null
+++ b/BID-rework/txt_tools.udo
@@ -0,0 +1,82 @@
+#ifndef UDO_TXTTOOLS
+#define UDO_TXTTOOLS ##
+/*
+ Debugger - Unfixed Bugs : BUG #5
+
+ Text tools
+*/
+
+
+/*
+ Print a notification prepended with a line of asterisks
+
+ tt_notify Stext
+
+ Stext text to print
+*/
+opcode tt_notify, 0, S
+ Stext xin
+ Snew = "\n"
+ iwidth = 60
+ index = 0
+ while (index < iwidth) do
+ Snew = strcat(Snew, "*");
+ index += 1
+ od
+ prints strcat(strcat(Snew, "\n"), strcat(Stext, "\n\n"))
+endop
+
+
+
+/*
+ Print a notification prepended with a line of asterisks and exit
+
+ tt_notify Stext
+
+ Stext text to print
+*/
+opcode tt_notify_fatal, 0, S
+ Stext xin
+ tt_notify(Stext)
+ exitnow
+endop
+
+
+/*
+ Return a number of seconds as HH:MM:SS format
+
+ Stime tt_parsetime iseconds
+
+ iseconds seconds to parse
+
+ Stime formatted time
+
+*/
+opcode tt_parsetime, S, i
+ input xin
+ ihours = floor(input / 3600)
+ iminutes = floor((input - (ihours * 3600)) / 60)
+ iseconds = input - (ihours * 3600) - (iminutes * 60)
+ xout sprintf("%02d:%02d:%05.2f", ihours, iminutes, iseconds)
+endop
+
+
+/*
+ Strip newline from end of line: built-in opcode has some problems
+
+ Soutput tt_stripnewline Sinput
+
+ Soutput processed without newline at end if existent
+
+ Sinput line to process
+*/
+opcode tt_stripnewline, S, S
+ Sline xin
+ index = strindex(Sline, "\n")
+ if (index != -1) then
+ Sline = strsub(Sline, 0, index)
+ endif
+ xout Sline
+endop
+
+#end
diff --git a/BID-rework/wavetables.udo b/BID-rework/wavetables.udo
new file mode 100644
index 0000000..1b2c209
--- /dev/null
+++ b/BID-rework/wavetables.udo
@@ -0,0 +1,16 @@
+#ifndef UDO_WAVETABLES
+#define UDO_WAVETABLES ##
+/*
+ Debugger - Unfixed Bugs : BUG #5
+
+ General waveforms
+*/
+
+ipoints = 16384
+gifnCosine ftgen 0, 0, ipoints, 9, 1, 1, 90
+gifnSine ftgen 0, 0, ipoints, 10, 1
+gifnSquare ftgen 0, 0, ipoints, 10, 1, 0, 0.3, 0, 0.2, 0, 0.14, 0, .111
+gifnSaw ftgen 0, 0, ipoints, 10, 0, .2, 0, .4, 0, .6, 0, .8, 0, 1, 0, .8, 0, .6, 0, .4, 0, .2
+
+#end
+
diff --git a/BUG3/BUG3.csd b/BUG3/BUG3.csd
index 3496201..2902a67 100644
--- a/BUG3/BUG3.csd
+++ b/BUG3/BUG3.csd
@@ -20,6 +20,7 @@ nchnls = 2
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
@@ -96,9 +97,11 @@ endin
Global send effects: reverb
*/
instr global_reverb
+#ifndef CPUSAVER
aL, aR bus_read "reverb"
- ;aL, aR freeverb aL, aR, 0.4, 0.3
+ aL, aR freeverb aL, aR, 0.4, 0.3
bus_mix("master", aL, aR)
+#endif
endin
diff --git a/BUG3/bid.udo b/BUG3/bid.udo
index b26750e..61891b3 100644
--- a/BUG3/bid.udo
+++ b/BUG3/bid.udo
@@ -364,11 +364,7 @@ opcode bid_loadfile, 0, S
tt_notify(sprintf("Directive file cannot be found: '%s'", Sfile))
exitnow
endif
- iparameter = -1
- isection = -1
- ichordnum = -1
- isectiondataindex = -1
- imode = -1
+ idata[] fillarray -1, -1, -1, -1, -1
read:
Sline, ilinenum readfi Sfile
Sline = tt_stripnewline(Sline)
diff --git a/BUG3/instruments.udo b/BUG3/instruments.udo
index 195e3eb..d8e384d 100644
--- a/BUG3/instruments.udo
+++ b/BUG3/instruments.udo
@@ -146,7 +146,11 @@ instr chord2
a1 fmbell 0.2*iamp, cpsmidinn(inote+12), 1, 3, 0.05, 10, gifnSine, gifnSquare, gifnSine, gifnSquare, gifnSine
a1 butterhp a1, 700
kenv linseg 0, p3*0.5, 1, p3*0.4, 1, p3*0.1, 0
- aL, aR ensembleChorus a1*9*kenv, .07, .003, .75, 1, 12, gifnSine
+ ivoices = 12
+#ifdef CPUSAVER
+ ivoices = 4
+#endif
+ aL, aR ensembleChorus a1*9*kenv, .07, .003, .75, 1, ivoices, gifnSine
aL pareq aL, 1000, 0.4, 0.6
aR pareq aR, 1000, 0.4, 0.6
bus_mix("reverb", aL*0.2, aR*0.2)
@@ -313,11 +317,11 @@ instr play_clap909
aR butterbp aR, 1200, 1100
aL butterhp aL, 400
aR butterhp aR, 400
- irevsend = 0.2
+ irevsend = 0.15
if (ilowpass == 1) then
aL butterlp aL, 900
aR butterlp aR, 900
- irevsend = 0.6
+ irevsend = 0.4
endif
kamp1 linseg 1, p3*0.1, 0, p3*0.1, 1, p3*0.2, 0.1, p3*0.3, 0.5, p3*0.2, 0, p3*0.05, 0.4, p3*0.05, 0
kamp2 linseg 1, p3*0.15, 0, p3*0.15, 1, p3*0.1, 0.1, p3*0.2, 0.5, p3*0.3, 0, p3*0.05, 0.4, p3*0.05, 0
diff --git a/BUG4/BUG4.csd b/BUG4/BUG4.csd
index fbeefa3..a506e53 100644
--- a/BUG4/BUG4.csd
+++ b/BUG4/BUG4.csd
@@ -1,6 +1,7 @@
<CsoundSynthesizer>
<CsOptions>
-odac
+-m0
</CsOptions>
<CsInstruments>
/*
@@ -8,36 +9,42 @@
http://git.1bpm.net/csd-unfixedbugs1/about/
- By Richard Knight 2021
+ By Richard Knight 2022
http://1bpm.net
q@1bpm.net
*/
sr = 44100
-ksmps = 10
+ksmps = 100
nchnls = 2
0dbfs = 1
seed 0
-gitempo = 118
+#define NOFILEIO ## ; file IO with readfi not supported on all platforms: disables bid_loadfile
+
gkmastergain init 1 ; master gain
gkpump = 0 ; kick ducking control
-gkreverse init 0 ; global reverse
+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
+/*
+ Global delay instrument 1
+*/
instr global_delay1
aL, aR bus_read "delay1"
- ifreq1 = (118 / 60) / 2
- kfdbkL = abs(oscil(0.6, 1.63))
- kfdbkR = abs(oscil(0.6, 1.67))
+ ifreq1 = (gibid_tempo / 60) / 8
+ kfdbkL = abs(oscil(0.8, 1.63))
+ kfdbkR = abs(oscil(0.8, 1.67))
- atimeL = abs(oscil(0.3, ifreq1))
- atimeR = abs(oscil(0.3, ifreq1))
+ atimeL = abs(oscil(0.2, ifreq1)) + 0.01
+ atimeR = abs(oscil(0.2, ifreq1)) + 0.01
aLdlr delayr 1
aLdel deltapi atimeL
@@ -49,10 +56,15 @@ instr global_delay1
aRdel butterhp aRdel, 130
delayw aR + (aRdel * kfdbkR)
-
+ aLdel *= 1-gkpump
+ aRdel *= 1-gkpump
bus_mix("master", aLdel, aRdel)
endin
+
+/*
+ Global delay instrument 2
+*/
instr global_delay2
aL, aR bus_read "delay2"
aLdlr delayr 0.2
@@ -65,64 +77,139 @@ instr global_delay2
bus_mix("master", aLdel, aRdel)
endin
+
/*
Master audio output
*/
instr global_master
- igain = 0.4
+ igain = 1
aL, aR bus_read "master"
- ;aL limit aL*0.8, 0, 1
- ;aR limit aR*0.8, 0, 1
+
+ awindex phasor giglitchsamples/sr
+ tablew aL, awindex*giglitchsamples, giglitchbufferL
+ tablew aR, awindex*giglitchsamples, giglitchbufferR
+
+ if (gksection == 1 || gksection == 2) then
+ aL butterhp aL, 100
+ aR butterhp aR, 100
+ elseif (gksection == 8) then
+ islen = tab_i(8, gibid_sectionlengths)*gibid_beattime
+ khpf linseg 0, islen*0.5, 0, islen*0.2, 30, islen*0.2, 60, islen*0.1, 1000
+ aL butterhp aL, khpf
+ aR butterhp aR, khpf
+ endif
+
+
+ aL limit aL*0.5, -1, 1
+ aR limit aR*0.5, -1, 1
outs aL*gkmastergain*igain, aR*gkmastergain*igain
endin
-instr seq
- event_i "i", "global_master", 0, p3
- event_i "i", "global_delay1", 0, p3
- event_i "i", "global_delay2", 0, p3
- kbeat metro (gitempo / 60) * 4
- kpos init 0
- if (kbeat == 1) then
- if (kpos % 3 == 0) then
- event "i", "play_rim", 0, 1
- endif
- if ((kpos+1) % 2 == 0 && random:k(0, 1) > 0.8) then
- event "i", "play_303", 0, 0.01, 106, 106, 90, 1
- endif
+/*
+ Print notification of performance time since last notification
+ or if isection is -1, print completion notification
+*/
+gitimetrack times
+instr notify_change
+ isection = p4
+ itime times
+ if (isection == -1) then
+ tt_notify(sprintf"Complete, runtime: %s", tt_parsetime(itime)))
+ exitnow
+ else
+ isectiontime = itime - gitimetrack
+ tt_notify(sprintf("%s : section %d complete in %s", tt_parsetime(itime), isection, tt_parsetime(isectiontime)))
+ gitimetrack = itime
+ endif
+ turnoff
+endin
- km8m init 0
- if ((kpos+1) % 8 == 0) then
- kstart = (km8m == 0) ? 40 : 45
- kend = (km8m == 0) ? 43 : 38
- event "i", "play_303", 0, 0.3, kstart, kend, 40, 0
- km8m = 1- km8m
- endif
-
- if (kpos % 9 == 0) then
- ;event "i", "play_blip", 0, 0.01
- endif
+/*
+ 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
- if (kpos % 4 == 0) then
- event "i", "play_kick", 0, 0.2, 0
- endif
- if ((kpos+2) % 16 == 0) then
- event "i", "play_kick", 0, 0.4, 1
+
+/*
+ Sequence BID elements
+*/
+instr sequencer
+ isection = 1
+ event_i "i", "bid_setcurrentchord", 0, 1, isection, 0
+ event_i "i", "global_master", 0, p3
+ event_i "i", "global_delay1", 0, p3
+ event_i "i", "global_delay2", 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", "notify_change", p3, 1, -1
+ turnoff
endif
- if (kpos % 8 == 0) then
- event "i", "play_clap", 0, 0.02
+ ; sequence BID elements
+ bid_seq "kick", kpos, ksection
+ bid_seq "kick2", kpos, ksection
+ bid_seq "clap", kpos, ksection
+ bid_seq "blip", kpos, ksection
+ bid_seq "303", kpos, ksection
+ bid_seq "hat1", kpos, ksection
+ bid_seq "chord1", kpos, ksection
+ bid_seq "chord2", kpos, ksection
+ bid_seq "chord3", kpos, ksection
+ bid_seq "snare", kpos, ksection
+ bid_seq "mel1", kpos, ksection
+ bid_seq "hat2", kpos, ksection
+ bid_seq "303b", kpos, ksection
+ bid_seq "shaker", kpos, ksection
+ bid_seq "glitchread", kpos, ksection
+
+ kpos = (kpos < 31) ? kpos + 1 : 0
+ ksection16ths = bid_getsectionlength(ksection) * 4
+
+ if (kposabs+1 < ksection16ths) then
+ kposabs += 1
+ else
+ event "i", "notify_change", 0, 1, ksection
+ event "i", "play_crash", 0, gibid_beattime
+ 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
+
- kpos += 1
endif
+
endin
</CsInstruments>
<CsScore>
-i"seq" 0 400
-
+i"parseandrun" 0 1
</CsScore>
</CsoundSynthesizer> \ No newline at end of file
diff --git a/BUG4/bid.udo b/BUG4/bid.udo
new file mode 100644
index 0000000..a5eea11
--- /dev/null
+++ b/BUG4/bid.udo
@@ -0,0 +1,425 @@
+#ifndef UDO_BID
+#define UDO_BID ##
+/*
+ Debugger - Unfixed Bugs : BUG #4
+
+ Bug Infested Directive file parser v1 and tools
+
+ Designed to create a reusable loop based score format in the Unfixed Bugs project and beyond.
+*/
+
+
+#define BID_VERSION #1.0#
+
+#include "txt_tools.udo"
+
+; globals
+gibid_tempo init -1 ; beats per minute
+gibid_beattime init -1 ; time of one beat in second
+gibid_maxsection init -1 ; max number of sections
+gibid_chordfn init -1 ; current chord ftable
+gkbid_chordlength init -1 ; current chord length
+
+; BID internals
+gibid_sectionlengths ftgen 0, 0, -64, -7, 0 ; section lengths
+gibid_sections[][] init 64, 64 ; section pointers to data
+gibid_sectiondata[][] init 99, 6 ; section data, ftables contained
+
+gibid_chordgroups[][] init 16, 12 ; chord groups, pointers to sectionchords by section
+gibid_sectionchords[] init 16 ; ftables of section chords
+
+gibid_currentchordnum = 0 ; current chord number
+gibid_lastchordgroup = -1 ; last chord group
+gibid_lastsection = -1 ; last section
+
+gSbid_sequenced[] init 1 ; internal tracking of sequenced elements
+gibid_sequenceinit init 1 ; internal tracking of sequenced init
+gibid_swingtime init -1 ; swing time calculated from percent
+
+/*
+ Get BID instrument index, creating new reference if specified.
+ Internal use only.
+
+ index _bid_gettextindex Sname, [iaddifnotexists = -1]
+
+ index BID instrument index
+
+ Sname name to look up or create
+ iaddifnotexists 1=create , default=fatal if not exists
+*/
+opcode _bid_gettextindex, i, Sj
+ Sname, iaddifnotexists xin
+ ifinalindex = -1
+ index = 0
+ while (index < lenarray(gSbid_sequenced)) do
+ if (strcmp(gSbid_sequenced[index], Sname) == 0) then
+ ifinalindex = index
+ igoto complete
+ endif
+ index += 1
+ od
+
+ if (iaddifnotexists == 1) then
+ if (gibid_sequenceinit == 1) then
+ gibid_sequenceinit = 0
+ SequencedNew[] fillarray Sname
+ ifinalindex = 0
+ else
+ SequencedNew[] init lenarray(gSbid_sequenced) + 1
+ index = 0
+ while (index < lenarray(gSbid_sequenced)) do
+ SequencedNew[index] = gSbid_sequenced[index]
+ index += 1
+ od
+ SequencedNew[index] = Sname
+ ifinalindex = index
+ endif
+ gSbid_sequenced = SequencedNew
+ igoto complete
+ else
+ tt_notify_fatal(sprintf("Sequenced index for '%s' not found", Sname))
+ endif
+
+complete:
+ xout ifinalindex
+endop
+
+
+
+/*
+ Parse a row of comma-separated numerical values of either patterns or chords.
+ Internal use only.
+
+ inum _bid_parserowitems Sline, ix1, ix2, imode
+
+ inum number of elements found parsed
+
+ Sline input line
+ ix1 array dimension 1 index
+ ix2 array dimension 2 index
+ imode 0=count elements; 1=write patterns; 2=write chords
+*/
+opcode _bid_parserowitems, i, Siii
+ Sline, ix1, ix2, imode xin
+ inum = 0
+ while (strlen(Sline) > 0) do
+ icomma = strindex(Sline, ",")
+ Stemp = strsub(Sline, 0, icomma)
+ icomma = (icomma == -1) ? 0 : icomma
+ Sline = strsub(Sline, icomma + 1)
+ if (imode == 1) then
+ tabw_i strtod(Stemp), inum, gibid_sectiondata[ix1][ix2]
+ elseif (imode == 2) then
+ tabw_i strtod(Stemp), inum, gibid_chordgroups[ix1][ix2]
+ endif
+ inum += 1
+ od
+ xout inum
+endop
+
+
+/*
+ Read BID data for specified element and trigger accordingly.
+
+ bid_seq Splayer, kposition, ksection
+
+ Splayer name of BID element
+ kposition position in pattern provided by master sequencer
+ ksection section in composition provided by master sequencer
+
+*/
+opcode bid_seq, 0, Skk
+ Splayer, kpos, ksection xin
+ Sinstrument = sprintf("play_%s", Splayer)
+ instrindex = _bid_gettextindex(Splayer)
+ kdata = gibid_sections[ksection][instrindex]
+
+ if (kdata != -1) then ; null section
+ kon = tablekt:k(kpos, gibid_sectiondata[kdata][0])
+
+ if (kon == 1) then
+ kchance = tablekt:k(kpos, gibid_sectiondata[kdata][3])
+ if (random:k(0, 1) < kchance) then
+ ktime = (kpos % 2 == 0) ? 0 : gibid_swingtime
+ kdur = tablekt:k(kpos, gibid_sectiondata[kdata][1])
+ ;kamp = tablekt:k(kpos, gisectiondata[kdata][2])
+ event "i", Sinstrument, ktime, kdur, kpos, kdata
+ endif
+ endif
+ endif
+endop
+
+
+/*
+ Get a parameter for the specified pattern position.
+ ipos and idataindex are provided as p4 and p5 to instruments scheduled by bid_seq,
+ hence can typically used as bid_getparameter(p4, p5, iparameter)
+
+ idata bid_getparameter ipos, idataindex, iparameter
+
+ idata the resulting value
+
+ ipos position in pattern
+ idataindex section specific data index; pointer to ftable
+ iparameter parameter index as in BID file; defaults include 0=on/off, 1=duration, 2=amp, 3=chance
+
+*/
+opcode bid_getparameter, i, iii
+ ipos, idataindex, iparameter xin
+ xout tab_i(ipos, gibid_sectiondata[idataindex][iparameter])
+endop
+
+
+/*
+ Get a section length in beats
+
+ klength bid_getsectionlength ksection
+
+ klength length in beats
+
+ ksection section to look up
+*/
+opcode bid_getsectionlength, k, k
+ ksection xin
+ xout tab:k(ksection, gibid_sectionlengths)
+endop
+
+/*
+ Parse a row of comma-separated values to either section patterns or chord storage.
+ Scans row, assigns ftable of appropriate length and then fills ftable.
+ Internal use only.
+
+ _bid_parserow Sline, ix1, ix2, imode
+
+ Sline line to parse
+ ix1 array dimension 1 index of target storage
+ ix2 array dimension 2 index of target storage
+ imode 1=section patterns, 2=chords
+*/
+opcode _bid_parserow, 0, Siii
+ Sline, ix1, ix2, imode xin
+ isize = _bid_parserowitems(Sline, ix1, ix2, 0)
+ if (imode == 1) then
+ gibid_sectiondata[ix1][ix2] ftgen 0, 0, -isize, -7, 0
+ elseif (imode == 2) then
+ gibid_chordgroups[ix1][ix2] ftgen 0, 0, -isize, -7, 0
+ endif
+ isize = _bid_parserowitems(Sline, ix1, ix2, imode)
+endop
+
+
+
+/*
+ Parse a line from a BID string
+ Internal use only.
+
+ idataout[] _bid_parseline Sline, idatain[]
+
+ idataout[] state data
+
+ Sline line to parse
+ idatain[] state data
+
+*/
+opcode _bid_parseline, i[], Si[]
+ Sline, idata[] xin
+ iparameter = idata[0]
+ isection = idata[1]
+ ichordnum = idata[2]
+ isectiondataindex = idata[3]
+ imode = idata[4]
+
+ if (strlen(Sline) > 0) then
+ Sfirstchar = strsub(Sline, 0, 1)
+
+ ; comment
+ if (strcmp(Sfirstchar, ";") == 0) then
+ ; no action
+
+ ; version check
+ elseif (strcmp(Sfirstchar, "v") == 0) then
+ imode = 0
+ iversion = strtod(strsub(Sline, 2))
+ if (iversion != $BID_VERSION) then
+ tt_notify(sprintf("Incompatible BID file version: got %.2f , expected %.2f", iversion, $BID_VERSION))
+ exitnow
+ endif
+
+ ; section header
+ elseif (strcmp(Sfirstchar, "s") == 0) then
+ imode = 1
+ icomma = strindex(Sline, ",")
+ isectionnum = strtod(strsub(Sline, 2, icomma))
+ Sub = strsub(Sline, icomma+1)
+ icomma = strindex(Sub, ",")
+ isectionlength = strtod(strsub(Sub, 0, icomma))
+ ichordgroup = strtod(strsub(Sub, icomma+1))
+ gibid_sectionchords[isectionnum] = ichordgroup
+ tabw_i isectionlength, isectionnum, gibid_sectionlengths
+
+ ; tempo
+ elseif (strcmp(Sfirstchar, "b") == 0) then
+ imode = -1
+ icomma = strindex(Sline, ",")
+ gibid_tempo = strtod(strsub(Sline, 2, icomma))
+ gibid_beattime = 60 / gibid_tempo
+ iswingpercent = strtod(strsub(Sline, icomma+1))
+ gibid_swingtime = ((gibid_beattime/4)/100) * iswingpercent
+
+ ; chord group header
+ elseif (strcmp(Sfirstchar, "c") == 0) then
+ imode = 3
+ ichordgroup = strtod(strsub(Sline, 2))
+ ichordnum = 0
+
+ ; pattern header
+ elseif (strcmp(Sfirstchar, "i") == 0) then
+ imode = 4
+ iparameter = 0
+
+ icomma = strindex(Sline, ",")
+ instrindex = _bid_gettextindex(strsub(Sline, 2, icomma), 1)
+ Sub = strsub(Sline, icomma+1)
+ icomma2 = strindex(Sub, ",")
+ isection = strtod(strsub(Sub, 0, icomma2))
+ if (isection > gibid_maxsection) then
+ gibid_maxsection = isection
+ endif
+ if (icomma2 != -1) then ; repeat or null section
+ irepeatsection = strtod(strsub(Sub, icomma2+1))
+ if (irepeatsection == -1) then
+ inewsection = -1
+ else
+ inewsection = gibid_sections[irepeatsection][instrindex]
+ endif
+ gibid_sections[isection][instrindex] = inewsection
+ else
+ isectiondataindex += 1
+ gibid_sections[isection][instrindex] = isectiondataindex
+ endif
+
+ ; chord row
+ elseif (imode == 3) then
+ _bid_parserow(Sline, ichordgroup, ichordnum, 2)
+ ichordnum += 1
+
+ ; pattern row
+ elseif (imode == 4) then
+ _bid_parserow(Sline, isectiondataindex, iparameter, 1)
+ iparameter += 1
+ endif
+ endif
+ idata[0] = iparameter
+ idata[1] = isection
+ idata[2] = ichordnum
+ idata[3] = isectiondataindex
+ idata[4] = imode
+ xout idata
+endop
+
+
+/*
+ Parse a Bug Infested Directive Format string to global arrays, ftables and variables.
+ Handles patterns, tempo, chord groups and sections etc accordingly.
+
+ bid_loadtext Sfile, [imode = 0]
+
+ Stext directive data as string to parse
+*/
+opcode bid_loadtext, 0, S
+ Stext xin
+ idata[] fillarray -1, -1, -1, -1, -1
+read:
+ index = strindex(Stext, "\n")
+ if (index != -1) then
+ Sline = strsub(Stext, 0, index)
+ Stext = strsub(Stext, index + 1)
+ idata[] _bid_parseline Sline, idata
+
+ igoto read
+ else
+ igoto complete
+ endif
+
+complete:
+endop
+
+
+/*
+ Parse a Bug Infested Directive Format string to global arrays, ftables and variables.
+ Handles patterns, tempo, chord groups and sections etc accordingly.
+ Requires readfi support which is not available on all platforms. Platforms that do not support that
+ should set NOFILEIO.
+
+ bid_loadfile Sfile
+
+ Sfile directive file to parse
+*/
+opcode bid_loadfile, 0, S
+ Sfile xin
+#ifdef NOFILEIO
+ tt_notify_fatal("Attempting to use parsefile when NOFILEIO is set")
+#else
+ if (filevalid(Sfile) == 0) then
+ tt_notify(sprintf("Directive file cannot be found: '%s'", Sfile))
+ exitnow
+ endif
+ idata[] fillarray -1, -1, -1, -1, -1
+read:
+ Sline, ilinenum readfi Sfile
+ Sline = tt_stripnewline(Sline)
+
+ idata[] _bid_parseline Sline, idata
+
+ if (ilinenum != -1) igoto read
+#endif
+endop
+
+
+
+/*
+ Set the current chord given a section
+ p4 the section number
+ p5 0=start at beginning, 1=increment chord index
+*/
+instr bid_setcurrentchord
+ isection = p4
+ ichordincrement = p5
+ if (isection > gibid_maxsection) then
+ turnoff
+ endif
+
+ ichordgroup = gibid_sectionchords[isection]
+ if (ichordgroup != gibid_lastchordgroup || isection != gibid_lastsection) then
+ gibid_currentchordnum = 0
+ gibid_lastchordgroup = ichordgroup
+ gibid_lastsection = isection
+ elseif (ichordincrement == 1) then
+ if (gibid_currentchordnum + 1 < lenarray(gibid_chordgroups, 2) - 1) then
+ if (gibid_chordgroups[ichordgroup][gibid_currentchordnum + 1] == 0) then
+ gibid_currentchordnum = 0
+ else
+ gibid_currentchordnum += 1
+ endif
+ else
+ gibid_currentchordnum = 0
+ endif
+ else
+ gibid_currentchordnum = 0
+ endif
+
+ ifn = gibid_chordgroups[ichordgroup][gibid_currentchordnum]
+
+ if (ifn > 0) then
+ gkbid_chordlength = tab:k(0, ifn)
+ gibid_chordfn = ifn
+ endif
+
+ if (timeinstk() > 2) then
+ turnoff
+ endif
+endin
+
+
+#end
+
diff --git a/BUG4/bid_source.udo b/BUG4/bid_source.udo
new file mode 100644
index 0000000..36536ba
--- /dev/null
+++ b/BUG4/bid_source.udo
@@ -0,0 +1,494 @@
+/*
+ Debugger - Unfixed Bugs : BUG #4
+
+ Bug Infested Directives source
+ Provided as a string due to readfi not being available on all platforms.
+ Used with bid_loadtext (whereas a separate file would be used with bid_loadfile and requires readfi support)
+*/
+
+SBID = {{
+; Bug Infested Directives : Debugger - Unfixed Bugs : BUG #4
+v 1.0
+
+; tempo, swing percent
+b 118, 42
+
+; chord groups
+c 1
+ 4, 60, 65, 67, 71, 72
+ 4, 63, 65, 66, 71, 72
+
+c 2
+ 4, 67, 72, 76, 78, 79
+ 4, 63, 65, 66, 71, 72
+
+
+; sections: section number, length, chordgroup
+s 1, 28, 1
+s 2, 4, 2
+s 3, 64, 1
+s 4, 64, 1
+s 5, 64, 1
+s 6, 28, 1
+s 7, 4, 1
+s 8, 64, 1
+s 9, 64, 1
+s 10, 60, 1
+s 11, 4, 2
+s 12, 64, 1
+s 13, 8, 1
+
+; patterns: trig , dur, amp, chance
+
+i glitchread, 1, -1
+i glitchread, 2, -1
+i glitchread, 3, -1
+i glitchread, 4, -1
+i glitchread, 5
+; 1 - - - 2 - - - 3 - - - 4 - - - 5 - - - 6 - - - 7 - - - 8 - - -
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0
+ .1,.1,.1,.1,.1,.1,.1,.1,.1,.1,.1,.1,.1,.1,.3,.1,.1,.1,.1,.1,.1,.1,.1,.1,.1,.1,.1,.1,.1,.1,.1,.1
+ 1, 1, 1, 1, 1,.9, 1,.8, 1, 1, 1,.9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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
+i kick2, 2
+; 1 - - - 2 - - - 3 - - - 4 - - - 5 - - - 6 - - - 7 - - - 8 - - -
+ 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0
+ .4,.4,.4,.4,.4,.4,.4,.4,.4,.3,.2,.4,.4,.4,.4,.4,.4,.4,.4,.4,.4,.4,.4,.4,.4,.4,.4,.4,.4,.4,.3,.3
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
+i kick2, 3, -1
+i kick2, 4, -1
+i kick2, 5, -1
+i kick2, 6, 1
+i kick2, 7, 2
+i kick2, 8, -1
+i kick2, 9, -1
+i kick2, 10, 1
+i kick2, 11, 2
+i kick2, 12, 1
+i kick2, 13, -1
+}}
diff --git a/BUG4/bussing.udo b/BUG4/bussing.udo
index 78755ce..62e4e1c 100644
--- a/BUG4/bussing.udo
+++ b/BUG4/bussing.udo
@@ -1,5 +1,10 @@
#ifndef UDO_BUSSING
#define UDO_BUSSING ##
+/*
+ Debugger - Unfixed Bugs : BUG #4
+
+ Global audio bussing
+*/
/*
diff --git a/BUG4/instruments.udo b/BUG4/instruments.udo
index e8f85d3..8de11c9 100644
--- a/BUG4/instruments.udo
+++ b/BUG4/instruments.udo
@@ -10,14 +10,28 @@
#include "wavetables.udo"
#include "bussing.udo"
+#include "bid.udo"
+/*
+ 303 bendy bass
+*/
instr play_303
- iamp = 1.2 ;getparameter(p4, p5, 2)
-
- inote1 = p4
- inote2 = p5
- ifilter = p6
+ iamp = bid_getparameter(p4, p5, 2)
+ idirection = bid_getparameter(p4, p5, 4)
+
+ if (idirection < 2) then
+ inote1b = tab_i(1, gibid_chordfn) - 24
+ inote2b = tab_i(2, gibid_chordfn) - 36
+ ifilter = (idirection == 0) ? 35 : 45
+ inote1 = (idirection == 0) ? inote1b : inote2b
+ inote2 = (idirection == 0) ? inote2b : inote1b
+ else
+ inote1 = tab_i(random(1, ftlen(gibid_chordfn) - 1), gibid_chordfn) - 24
+ inote2 = inote1
+ ifilter = random(30, 50)
+ endif
+
ifrq1 = 440 * exp(log(2) * (ifilter - 69) / 12) ; filter start freq.
kamp linseg 1, p3*0.8, 1, p3*0.2, 0
@@ -36,60 +50,67 @@ instr play_303
keqf limit kffrq * 4, 10, sr * 0.48 ; EQ frequency
a1 pareq a1 * 0.4, keqf, 4.0, 1.0, 2
a1 butterhp a1, 50
- a1 = a1 * kamp
+ a1 pareq a1, 200, 0.8, 0.7
+ a1 = a1 * kamp * 0.8
+ a1 *= 1-gkpump
aL, aR pan2 a1, random(0.3, 0.7)
- if (p7 == 1 && random(0, 1) > 0.6) then
- bus_mix("delay2", aL, aR)
- endif
+ ;bus_mix("delay2", aL, aR)
bus_mix("master", aL, aR)
endin
/*
- Istvan Varga
-*/
-instr play_rim
- iamp = 1
- icps = 220
- acps expon icps, 0.0025, icps * 0.5
- acps = acps + icps
- iamp = 1
- a1a phasor acps, 0.0
- a1b phasor acps, 0.5
- afmenv expon 1.0, 0.02, 0.5
- a1 = (a1a-a1b)*6.0*afmenv
- acps = acps*(1.0+a1)
- a0 oscil3 1.0, acps
- a1 unirand 2.0
- a1 tone a1-1.0, 2000
- a0 = a0 + a1*0.1
- aenv expon 1.0, 0.005, 0.5
- a0 limit 4.0*iamp*a0*aenv, -1.0, 1.0
- a0 table3 a0*4096.0, gifnSaw, 0, 0, 1
- kffrq expseg 2000, 0.07, 100, 1, 100
- a0x tone a0, 10000
- a0y = a0 - a0x
- a0x delay a0y, 0.0002
- a0 = a0 - a0x*4.0
- a0 pareq a0, kffrq, 0, 0.7071, 2
- a_ linseg 1, p3-0.1, 1, 0.025, 0, 1, 0
- a0 = a0*a_
- aL, aR pan2 a0*iamp, random(0.3, 0.8)
+ 303 higher register melodics
+*/
+instr play_303b
+ iamp = bid_getparameter(p4, p5, 2)
+ ifilter = random(50, 90)
+ inote = tab_i(random(1, ftlen(gibid_chordfn) - 1), gibid_chordfn)
- bus_mix("delay1", aL, aR)
+ ifrq1 = 440 * exp(log(2) * (ifilter - 69) / 12) ; filter start freq.
+ kamp linseg 1, p3*0.8, 1, p3*0.2, 0
+ kcps init cpsmidinn(inote)
+ kffrq port 0, 60/150, ifrq1 ; filter frequency
+ a1 phasor kcps ; oscillator
+ a1 = 1 - 2 * a1
+
+ a1x butterbp a1, kffrq, kcps * 1.0 ; filters
+ a1x = a1x * (2 + kffrq / kcps) ; correct amplitude
+ a1 = a1x + a1 * 0.25 ; 0.5
+ a1 butterlp a1, kffrq
+
+ a1 = taninv(a1 * 4 * iamp) ; distortion ; 2.5
+
+ keqf limit kffrq * 4, 10, sr * 0.48 ; EQ frequency
+ a1 pareq a1 * 0.4, keqf, 4.0, 1.0, 2
+ a1 butterhp a1, 150
+ a1 = a1 * kamp * 0.8
+ a1 *= 1-gkpump
+ aL, aR pan2 a1, random(0.3, 0.7)
+ bus_mix("delay2", aL*0.3, aR*0.3)
bus_mix("master", aL, aR)
endin
+
+/*
+ Delayed watery blip
+*/
instr play_blip
- a1 oscil 0.6, 4400
- kamp line 1, p3, 0
- a1 *= kamp
+ iamp = bid_getparameter(p4, p5, 2)
+ a0 oscil 0.6, cpsmidinn(tab_i(1, gibid_chordfn)+48)
+ kamp linseg 1, p3*0.1, 0, p3*0.9, 0
+ a0 *= kamp
+ aL, aR pan2 a0*iamp, random(0.3, 0.8)
- bus_mix("delay2", a1, a1)
+ bus_mix("delay1", aL, aR)
+ ;bus_mix("master", aL, aR)
endin
-
+/*
+ Harsh clap
+*/
instr play_clap
+ iamp = bid_getparameter(p4, p5, 2)
aL noise 1, 0.3
aR noise 1, 0.4
aL butterbp aL, 1200, 700
@@ -98,19 +119,100 @@ instr play_clap
aR taninv aR*7
kamp linseg 2, p3, 0
- aL *= kamp
- aR *= kamp
+ aL *= kamp * iamp
+ aR *= kamp * iamp
bus_mix("delay2", aL, aR)
bus_mix("master", aL, aR)
endin
-instr play_kick ; 808 style kick
- iamp = 1
+/*
+ Closed lower frequency hi-hat
+*/
+instr play_hat1
+ iamp = bid_getparameter(p4, p5, 2)
+ idel = random(0.001, 0.02)
+ xtratim idel
+ p3 = random(0.02, 0.1)
+ ifreq = (i(gksection) < 3) ? 600 : 840 ; 840
+ aenv expsega .1, .0005, 1, p3 - .0005, .01
+ asqr1 oscil 1, ifreq, gifnSquare, -1
+ asqr2 oscil 1, ifreq*1.4471, gifnSquare, -1
+ asqr3 oscil 1, ifreq*1.6170, gifnSquare, -1
+ asqr4 oscil 1, ifreq*1.9265, gifnSquare, -1
+ asqr5 oscil 1, ifreq*2.5028, gifnSquare, -1
+ asqr6 oscil 1, ifreq*2.6637, gifnSquare, -1
+ a808 sum asqr1, asqr2, asqr3, asqr4, asqr5, asqr6
+ a808 butterhp a808, 4270
+ a808 butterhp a808, 4270
+ aout = a808 * aenv * iamp
+ aout delay aout, idel
+ if (i(gksection) == 1) then
+ bus_mix("delay2", aout*0.9, aout*0.9)
+ endif
+ bus_mix("master", aout, aout)
+endin
+
+
+/*
+ Open higher frequency hi-hat
+*/
+instr play_hat2
+ iamp = bid_getparameter(p4, p5, 2)
+ idel1 = random(0.005, 0.02)
+ idel2 = random(0.005, 0.02)
+ xtratim(max(idel1, idel2))
+ p3 = 0.1
+ kfreq line 1000, p3, 300
+ aenv expsega .1, .0005, 1, p3 - .0005, .01
+ asqr1 oscil 1, kfreq, gifnSquare, -1
+ asqr2 oscil 1, kfreq*1.4471, gifnSquare, -1
+ asqr3 oscil 1, kfreq*1.6170, gifnSquare, -1
+ asqr4 oscil 1, kfreq*1.9265, gifnSquare, -1
+ asqr5 oscil 1, kfreq*2.5028, gifnSquare, -1
+ asqr6 oscil 1, kfreq*2.6637, gifnSquare, -1
+ a808 sum asqr1, asqr2, asqr3, asqr4, asqr5, asqr6
+ a808 butterhp a808, 3270
+ a808 butterhp a808, 3270
+ aout = a808 * aenv * iamp * 0.9
+ aL delay aout, idel1
+ aR delay aout, idel2
+ bus_mix("master", aL, aR)
+endin
+
+
+/*
+ Blocky square-ish FM chord clunk
+*/
+instr play_mel1
+ iamp = bid_getparameter(p4, p5, 2)
+ inote1 = tab_i(ftlen(gibid_chordfn) - 3, gibid_chordfn)
+ inote2 = tab_i(ftlen(gibid_chordfn) - 4, gibid_chordfn)
+ a1 foscil 0.46, cpsmidinn(inote1), 1, 2, 1, gifnSine
+ a2 foscil 0.46, cpsmidinn(inote2), 1, 2, 1, gifnSine
+ a1 += a2
+ a1 butterhp a1, 130
+ kenv linseg 1, p3*0.1, 0.6, p3*0.5, 0.4, p3*0.4, 0
+ aout = a1*kenv*iamp*2
+ aL, aR pan2 aout, random(0, 1)
+ bus_mix("master", aL, aR)
+ if (random(0, 1) > 0.77) then
+ bus_mix("delay1", aL*0.9, aR*0.9)
+ endif
+endin
+
+
+/*
+ Lightly distorted 808 style kick
+*/
+instr play_kick
+ iamp = bid_getparameter(p4, p5, 2)
+
+ idist = 0.35
xtratim 0.1
krelease release
- ktune init -1.1
+ ktune init -1.4
kmul transeg 0.2, p3*0.5, -15, 0.01, p3*0.5, 0, 0
kbend transeg 0.5, 1.2, -4, 0, 1, 0, 0
asig gbuzz 0.5, 50*octave(ktune)*semitone(kbend), 20, 1, kmul, gifnCosine
@@ -123,12 +225,293 @@ instr play_kick ; 808 style kick
aimp oscili aenv, acps*octave(ktune*0.25)
amix = ((asig*0.7)+(aimp*0.35))*2*iamp
gkpump = min(rms(amix) * 7, 1)
- aout1 pareq amix, 100, 0.01, 0.6
- aout1 distort aout1, 0.25, (p4 == 1 && random(0, 1) > 0.6) ? gifnSaw : gifnSine
- aout1 pareq aout1, 100, 0.01, 0.6
- aout1 *= 3
+ aout1 pareq amix, 100, 0.01, 0.7
+ aout1 distort aout1, idist, gifnSine
+ aout1 pareq aout1, 40, 3, 0.4
+ aout1 pareq aout1, 130, 0.04, 0.6
+ aout1 pareq aout1, 4900, 2, 0.7
+ aout1 pareq aout1, 8900, 8, 0.7
+ aout1 *= 2
bus_mix("master", aout1, aout1)
endin
+/*
+ Heavily waveshape distorted clunky pseudo kick
+*/
+instr play_kick2
+ iamp = bid_getparameter(p4, p5, 2)
+ xtratim 0.1
+ krelease release
+ ktune random -1, 1
+ ifn = gibid_chordgroups[1][1] ; gibid_chordfn
+ ifreq = cpsmidinn(tab_i(1, ifn) - 24)
+ kmul transeg 0.2, p3*0.5, -15, 0.01, p3*0.5, 0, 0
+ kbend transeg 0.5, 1.2, -4, 0, 1, 0, 0
+ ;ifreq = 50*octave(ktune)
+ asig gbuzz 0.5, ifreq*semitone(kbend), 20, 1, kmul, gifnCosine
+ aenv transeg 1, p3-0.004, -6, 0
+ gkpump = k(aenv)
+ aatt linseg 0, 0.004, 1
+ asig = asig*aenv*aatt
+ aenv linseg 1, 0.07, 0
+ acps expsega 400, 0.07, 0.001, 1, 0.001
+ aimp oscili aenv, acps*octave(ktune*0.25)
+ amix = ((asig*0.7)+(aimp*0.35))*2*iamp
+ aout1 pareq amix, 100, 0.01, 0.6
+ aout1 distort aout1, random(0.1, 0.7), gifnSaw
+ aout1 pareq aout1, 100, 0.01, 0.3
+ aout1 butterhp aout1, 80
+ aout1 *= 5
+ if (random(0, 1) > 0.5) then
+ if (random(0, 1) > 0.7) then
+ bus_mix("delay1", aout1*0.6, aout1*0.3)
+ endif
+ if (random(0, 1) > 0.7) then
+ bus_mix("delay2", aout1*0.6, aout1*0.3)
+ endif
+ endif
+ aout1 *= 1-gkpump
+ bus_mix("master", aout1*0.7, aout1)
+endin
+
+
+/*
+ Shaker
+*/
+instr play_shaker
+ iamp = bid_getparameter(p4, p5, 2)
+ idel1 = random(0.005, 0.02)
+ idel2 = random(0.005, 0.02)
+ xtratim(max(idel1, idel2))
+ p3 = 0.05
+ kfreq line 700, p3, 300
+ aenv expsega .1, .0005, 1, p3 - .0005, .01
+ asqr1 oscil 1, kfreq, gifnSaw, -1
+ asqr2 oscil 1, kfreq*1.4471, gifnSaw, -1
+ asqr3 oscil 1, kfreq*1.6170, gifnSaw, -1
+ asqr4 oscil 1, kfreq*1.9265, gifnSaw, -1
+ asqr5 oscil 1, kfreq*2.5028, gifnSine, -1
+ asqr6 oscil 1, kfreq*2.6637, gifnSine, -1
+ a808 sum asqr1, asqr2, asqr3, asqr4, asqr5, asqr6
+ a808 butterhp a808, 2270
+ a808 butterhp a808, 2270
+ aout = a808 * aenv * iamp * 0.3 * (1-gkpump)
+ aL delay aout, idel1
+ aR delay aout, idel2
+ bus_mix("master", aL, aR)
+ bus_mix("delay1", aL*0.25, aR*0.25)
+
+endin
+
+
+/*
+ Beef snare informed by original instrument by Istvan Varga
+*/
+instr play_snare
+ icps0 = 111
+ iamp = bid_getparameter(p4, p5, 2)
+ p3 = random(0.03, 0.1)
+ icps1 = 2.0 * icps0
+ kcps port icps0, 0.007, icps1
+ kcpsx = kcps * 1.5
+
+ kfmd port 0.0, 0.01, 0.7
+ aenv1 expon 1.0, 0.03, 0.5
+ kenv2 port 1.0, 0.008, 0.0
+ aenv2 interp kenv2
+ aenv3 expon 1.0, 0.025, 0.5
+
+ a_ oscili 1.0, kcps
+ a1 oscili 1.0, kcps * (1.0 + a_*kfmd)
+ a_ oscili 1.0, kcpsx
+ a2 oscili 1.0, kcpsx * (1.0 + a_*kfmd)
+
+ a3 unirand 2.0
+ a3 = a3 - 1.0
+ a3 butterbp a3, 3200, 1500
+ a3 = a3 * aenv2
+
+ a0 = a1 + a2*aenv3 + a3*1.0
+ a0 = a0 * aenv1
+ a0 butterhp a0, 210
+ aout = a0*iamp
+ bus_mix("master", aout, aout)
+
+endin
+
+
+/*
+ Convenience opcode for playing current chord on given instrument, passing p4 as note and p5 as amp
+
+ chordinstrument Sinstrument
+
+ Sinstrument the instrument name
+ ipos position in pattern
+ idataindex section specific data index; pointer to ftable
+*/
+opcode chordinstrument, 0, Sii
+ Sinstrument, ipos, idataindex xin
+ iamp = bid_getparameter(ipos, idataindex, 2)
+ index = 1 ; index 0 is chordgroup length
+ while (index < ftlen(gibid_chordfn)) do
+ event_i "i", Sinstrument, 0, p3, tab_i(index, gibid_chordfn), iamp
+ index += 1
+ od
+
+endop
+
+
+/*
+ Flutey chord
+*/
+instr chord1
+ inote = p4
+ iamp = p5
+ aL fmpercfl 0.65, cpsmidinn(inote), 1, 2, 0.1, 10, gifnSine, gifnSquare, gifnSine, gifnSquare, gifnSine
+ aR fmpercfl 0.65, cpsmidinn(inote), 1, 1.4, 0.2, 10, gifnSine, gifnSaw, gifnSine, gifnSquare, gifnSine
+ aL butterhp aL, 340
+ aR butterhp aR, 340
+ aL butterlp aL, 4000
+ aR butterlp aR, 4000
+ kenv linseg 1, p3*0.5, 1, p3*0.4, 1, p3*0.1, 0
+ aL *= kenv
+ aR *= kenv
+ bus_mix("master", aL, aR)
+endin
+
+
+/*
+ Play chord1 above, called from BID
+*/
+instr play_chord1
+ chordinstrument "chord1", p4, p5
+ turnoff
+endin
+
+
+/*
+ Not really a crash, more just noise
+*/
+instr play_crash
+ aL noise 1.7, 0.2
+ aR noise 1.7, 0.3
+ ifreq1 random 100, 1000
+ ifreq2 random 7000, 12000
+ if (random(0, 1) > 0.5) then
+ istartfreq = ifreq1
+ iendfreq = ifreq2
+ else
+ istartfreq = ifreq2
+ iendfreq = ifreq1
+ endif
+ kfreq line 500, p3, 9000
+ aL butterhp aL, kfreq
+ aR butterhp aR, kfreq
+ kenv linseg 0, p3*0.5, 1, p3*0.5, 0
+ aL *= kenv
+ aR *= kenv
+ ;bus_mix("master", aL, aR)
+ bus_mix("delay1", aL, aR)
+endin
+
+
+/*
+ Warped chord
+*/
+instr chord2
+ inote = p4
+ iamp = p5
+ ilower = p6
+ iamp = 0.55
+ if (ilower == 1) then
+ iamp = 1
+ else
+ inote += 12
+ endif
+ kfmod oscil 10, 6
+ kfl linseg 1, p3*0.8, 1, p3*0.2, 0.1
+ aL fmpercfl iamp, (cpsmidinn(inote)+kfmod)*kfl*0.5, 1, 2, 0.6, 10, gifnSine, gifnSquare, gifnSine, gifnSquare, gifnSine
+ aR fmpercfl iamp, (cpsmidinn(inote)+kfmod)*kfl*0.5, 1, 1.4, 0.9, 10, gifnSine, gifnSaw, gifnSine, gifnSquare, gifnSine
+ aL butterhp aL, 540
+ aR butterhp aR, 540
+ kenv line 0, p3, 1
+ aL *= kenv
+ aR *= kenv
+ bus_mix("master", aL, aR)
+endin
+
+
+/*
+ Play chord2 above, called from BID
+*/
+instr play_chord2
+ iamp = bid_getparameter(p4, p5, 2)
+ ilower = bid_getparameter(p4, p5, 4)
+ index = 1 ; index 0 is chordgroup length
+ while (index < ftlen(gibid_chordfn)) do
+ event_i "i", "chord2", 0, p3, tab_i(index, gibid_chordfn), iamp, ilower
+ index += 1
+ od
+ turnoff
+endin
+
+
+/*
+ Organ type chord
+*/
+instr chord3
+ inote = p4 - 12
+ iamp = p5
+ ifreq = cpsmidinn(inote)
+ kfreq linseg 10, p3*0.4, ifreq, p3*0.6, ifreq
+ aL fmb3 0.65, kfreq, 1, random(1.2, 2.2), random(0.1, 0.3), random(5, 15), gifnSine, gifnSquare, gifnSine, gifnSquare, gifnSine
+ aR fmb3 0.65, kfreq, 1, random(1.2, 2.2), random(0.1, 0.3), random(5, 15), gifnSine, gifnSaw, gifnSine, gifnSquare, gifnSine
+ aL butterhp aL, 340
+ aR butterhp aR, 340
+
+ kenv linseg 1, p3*0.95, 1, p3*0.05, 0
+ aL *= kenv
+ aR *= kenv
+ bus_mix("master", aL, aR)
+endin
+
+/*
+ Play chord3 above, called from BID
+*/
+instr play_chord3
+ chordinstrument "chord3", p4, p5
+ turnoff
+endin
+
+
+/*
+ Retrigger sampler with appropriate pitching
+*/
+giglitchsamples = 44100
+giglitchbufferL ftgen 0, 0, giglitchsamples, 7, 0
+giglitchbufferR ftgen 0, 0, giglitchsamples, 7, 0
+instr play_glitchread
+ iamp = bid_getparameter(p4, p5, 2)
+ ifreq = cpsmidinn(tab_i(random(1, ftlen(gibid_chordfn) - 1), gibid_chordfn))
+ ilen = ((1/(ifreq))*sr)*pow(2, round(random(0, 4)))
+ istart random 0, giglitchsamples-ilen
+ awindex phasor giglitchsamples / ilen
+ aL table awindex*giglitchsamples, giglitchbufferL
+ aR table awindex*giglitchsamples, giglitchbufferR
+ aL butterhp aL, 350
+ aR butterhp aL, 350
+ aL *= 0.2 * iamp
+ aR *= 0.2 * iamp
+ if (random(0, 1) > 0.7) then
+ if (random(0, 1) > 0.5) then
+ bus_mix("delay2", aL, aR)
+ else
+ bus_mix("delay2", aL, aR)
+ endif
+ endif
+ bus_mix("master", aL, aR)
+endin
+
+
#end
diff --git a/BUG4/txt_tools.udo b/BUG4/txt_tools.udo
new file mode 100644
index 0000000..d34459e
--- /dev/null
+++ b/BUG4/txt_tools.udo
@@ -0,0 +1,82 @@
+#ifndef UDO_TXTTOOLS
+#define UDO_TXTTOOLS ##
+/*
+ Debugger - Unfixed Bugs : BUG #4
+
+ Text tools
+*/
+
+
+/*
+ Print a notification prepended with a line of asterisks
+
+ tt_notify Stext
+
+ Stext text to print
+*/
+opcode tt_notify, 0, S
+ Stext xin
+ Snew = "\n"
+ iwidth = 60
+ index = 0
+ while (index < iwidth) do
+ Snew = strcat(Snew, "*");
+ index += 1
+ od
+ prints strcat(strcat(Snew, "\n"), strcat(Stext, "\n\n"))
+endop
+
+
+
+/*
+ Print a notification prepended with a line of asterisks and exit
+
+ tt_notify Stext
+
+ Stext text to print
+*/
+opcode tt_notify_fatal, 0, S
+ Stext xin
+ tt_notify(Stext)
+ exitnow
+endop
+
+
+/*
+ Return a number of seconds as HH:MM:SS format
+
+ Stime tt_parsetime iseconds
+
+ iseconds seconds to parse
+
+ Stime formatted time
+
+*/
+opcode tt_parsetime, S, i
+ input xin
+ ihours = floor(input / 3600)
+ iminutes = floor((input - (ihours * 3600)) / 60)
+ iseconds = input - (ihours * 3600) - (iminutes * 60)
+ xout sprintf("%02d:%02d:%05.2f", ihours, iminutes, iseconds)
+endop
+
+
+/*
+ Strip newline from end of line: built-in opcode has some problems
+
+ Soutput tt_stripnewline Sinput
+
+ Soutput processed without newline at end if existent
+
+ Sinput line to process
+*/
+opcode tt_stripnewline, S, S
+ Sline xin
+ index = strindex(Sline, "\n")
+ if (index != -1) then
+ Sline = strsub(Sline, 0, index)
+ endif
+ xout Sline
+endop
+
+#end
diff --git a/BUG4/wavetables.udo b/BUG4/wavetables.udo
index e81f075..82b0552 100644
--- a/BUG4/wavetables.udo
+++ b/BUG4/wavetables.udo
@@ -1,7 +1,7 @@
#ifndef UDO_WAVETABLES
#define UDO_WAVETABLES ##
/*
- Debugger - Unfixed Bugs : BUG #3
+ Debugger - Unfixed Bugs : BUG #4
General waveforms
*/
diff --git a/BUG5/BUG5.csd b/BUG5/BUG5.csd
new file mode 100644
index 0000000..e240fcf
--- /dev/null
+++ b/BUG5/BUG5.csd
@@ -0,0 +1,157 @@
+<CsoundSynthesizer>
+<CsOptions>
+-odac
+</CsOptions>
+<CsInstruments>
+/*
+ Debugger - Unfixed Bugs : BUG #5
+
+ http://git.1bpm.net/csd-unfixedbugs1/about/
+
+ By Richard Knight 2022
+ http://1bpm.net
+ q@1bpm.net
+
+*/
+
+sr = 44100
+ksmps = 10
+nchnls = 2
+0dbfs = 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"
+ 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
+
+
+ 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
+
+</CsInstruments>
+<CsScore>
+i"parseandrun" 0 1
+
+</CsScore>
+</CsoundSynthesizer> \ No newline at end of file
diff --git a/BUG5/bid.udo b/BUG5/bid.udo
new file mode 100644
index 0000000..17e9be2
--- /dev/null
+++ b/BUG5/bid.udo
@@ -0,0 +1,425 @@
+#ifndef UDO_BID
+#define UDO_BID ##
+/*
+ Debugger - Unfixed Bugs : BUG #5
+
+ Bug Infested Directive file parser v1 and tools
+
+ Designed to create a reusable loop based score format in the Unfixed Bugs project and beyond.
+*/
+
+
+#define BID_VERSION #1.1#
+
+#include "txt_tools.udo"
+
+; globals
+gibid_tempo init -1 ; beats per minute
+gibid_beattime init -1 ; time of one beat in second
+gibid_maxsection init -1 ; max number of sections
+gibid_chordfn init -1 ; current chord ftable
+gkbid_chordlength init -1 ; current chord length
+
+; BID internals
+gibid_sectionlengths ftgen 0, 0, -64, -7, 0 ; section lengths
+gibid_sections[][] init 64, 64 ; section pointers to data
+gibid_sectiondata[][] init 99, 6 ; section data, ftables contained
+
+gibid_chordgroups[][] init 16, 12 ; chord groups, pointers to sectionchords by section
+gibid_sectionchords[] init 16 ; ftables of section chords
+
+gibid_currentchordnum = 0 ; current chord number
+gibid_lastchordgroup = -1 ; last chord group
+gibid_lastsection = -1 ; last section
+
+gSbid_sequenced[] init 1 ; internal tracking of sequenced elements
+gibid_sequenceinit init 1 ; internal tracking of sequenced init
+gibid_swingtime init -1 ; swing time calculated from percent
+
+/*
+ Get BID instrument index, creating new reference if specified.
+ Internal use only.
+
+ index _bid_gettextindex Sname, [iaddifnotexists = -1]
+
+ index BID instrument index
+
+ Sname name to look up or create
+ iaddifnotexists 1=create , default=fatal if not exists
+*/
+opcode _bid_gettextindex, i, Sj
+ Sname, iaddifnotexists xin
+ ifinalindex = -1
+ index = 0
+ while (index < lenarray(gSbid_sequenced)) do
+ if (strcmp(gSbid_sequenced[index], Sname) == 0) then
+ ifinalindex = index
+ igoto complete
+ endif
+ index += 1
+ od
+
+ if (iaddifnotexists == 1) then
+ if (gibid_sequenceinit == 1) then
+ gibid_sequenceinit = 0
+ SequencedNew[] fillarray Sname
+ ifinalindex = 0
+ else
+ SequencedNew[] init lenarray(gSbid_sequenced) + 1
+ index = 0
+ while (index < lenarray(gSbid_sequenced)) do
+ SequencedNew[index] = gSbid_sequenced[index]
+ index += 1
+ od
+ SequencedNew[index] = Sname
+ ifinalindex = index
+ endif
+ gSbid_sequenced = SequencedNew
+ igoto complete
+ else
+ tt_notify_fatal(sprintf("Sequenced index for '%s' not found", Sname))
+ endif
+
+complete:
+ xout ifinalindex
+endop
+
+
+
+/*
+ Parse a row of comma-separated numerical values of either patterns or chords.
+ Internal use only.
+
+ inum _bid_parserowitems Sline, ix1, ix2, imode
+
+ inum number of elements found parsed
+
+ Sline input line
+ ix1 array dimension 1 index
+ ix2 array dimension 2 index
+ imode 0=count elements; 1=write patterns; 2=write chords
+*/
+opcode _bid_parserowitems, i, Siii
+ Sline, ix1, ix2, imode xin
+ inum = 0
+ while (strlen(Sline) > 0) do
+ icomma = strindex(Sline, ",")
+ Stemp = strsub(Sline, 0, icomma)
+ icomma = (icomma == -1) ? 0 : icomma
+ Sline = strsub(Sline, icomma + 1)
+ if (imode == 1) then
+ tabw_i strtod(Stemp), inum, gibid_sectiondata[ix1][ix2]
+ elseif (imode == 2) then
+ tabw_i strtod(Stemp), inum, gibid_chordgroups[ix1][ix2]
+ endif
+ inum += 1
+ od
+ xout inum
+endop
+
+
+/*
+ Read BID data for specified element and trigger accordingly.
+
+ bid_seq Splayer, kposition, ksection
+
+ Splayer name of BID element
+ kposition position in pattern provided by master sequencer
+ ksection section in composition provided by master sequencer
+
+*/
+opcode bid_seq, 0, Skk
+ Splayer, kpos, ksection xin
+ Sinstrument = sprintf("play_%s", Splayer)
+ instrindex = _bid_gettextindex(Splayer)
+ kdata = gibid_sections[ksection][instrindex]
+
+ if (kdata != -1) then ; null section
+ kon = tablekt:k(kpos, gibid_sectiondata[kdata][0])
+
+ if (kon == 1) then
+ kchance = tablekt:k(kpos, gibid_sectiondata[kdata][3])
+ if (random:k(0, 1) < kchance) then
+ ktime = (kpos % 2 == 0) ? 0 : gibid_swingtime
+ kdur = tablekt:k(kpos, gibid_sectiondata[kdata][1]) * gibid_beattime
+ ;kamp = tablekt:k(kpos, gisectiondata[kdata][2])
+ event "i", Sinstrument, ktime, kdur, kpos, kdata
+ endif
+ endif
+ endif
+endop
+
+
+/*
+ Get a parameter for the specified pattern position.
+ ipos and idataindex are provided as p4 and p5 to instruments scheduled by bid_seq,
+ hence can typically used as bid_getparameter(p4, p5, iparameter)
+
+ idata bid_getparameter ipos, idataindex, iparameter
+
+ idata the resulting value
+
+ ipos position in pattern
+ idataindex section specific data index; pointer to ftable
+ iparameter parameter index as in BID file; defaults include 0=on/off, 1=duration, 2=amp, 3=chance
+
+*/
+opcode bid_getparameter, i, iii
+ ipos, idataindex, iparameter xin
+ xout tab_i(ipos, gibid_sectiondata[idataindex][iparameter])
+endop
+
+
+/*
+ Get a section length in beats
+
+ klength bid_getsectionlength ksection
+
+ klength length in beats
+
+ ksection section to look up
+*/
+opcode bid_getsectionlength, k, k
+ ksection xin
+ xout tab:k(ksection, gibid_sectionlengths)
+endop
+
+/*
+ Parse a row of comma-separated values to either section patterns or chord storage.
+ Scans row, assigns ftable of appropriate length and then fills ftable.
+ Internal use only.
+
+ _bid_parserow Sline, ix1, ix2, imode
+
+ Sline line to parse
+ ix1 array dimension 1 index of target storage
+ ix2 array dimension 2 index of target storage
+ imode 1=section patterns, 2=chords
+*/
+opcode _bid_parserow, 0, Siii
+ Sline, ix1, ix2, imode xin
+ isize = _bid_parserowitems(Sline, ix1, ix2, 0)
+ if (imode == 1) then
+ gibid_sectiondata[ix1][ix2] ftgen 0, 0, -isize, -7, 0
+ elseif (imode == 2) then
+ gibid_chordgroups[ix1][ix2] ftgen 0, 0, -isize, -7, 0
+ endif
+ isize = _bid_parserowitems(Sline, ix1, ix2, imode)
+endop
+
+
+
+/*
+ Parse a line from a BID string
+ Internal use only.
+
+ idataout[] _bid_parseline Sline, idatain[]
+
+ idataout[] state data
+
+ Sline line to parse
+ idatain[] state data
+
+*/
+opcode _bid_parseline, i[], Si[]
+ Sline, idata[] xin
+ iparameter = idata[0]
+ isection = idata[1]
+ ichordnum = idata[2]
+ isectiondataindex = idata[3]
+ imode = idata[4]
+
+ if (strlen(Sline) > 0) then
+ Sfirstchar = strsub(Sline, 0, 1)
+
+ ; comment
+ if (strcmp(Sfirstchar, ";") == 0) then
+ ; no action
+
+ ; version check
+ elseif (strcmp(Sfirstchar, "v") == 0) then
+ imode = 0
+ iversion = strtod(strsub(Sline, 2))
+ if (iversion != $BID_VERSION) then
+ tt_notify(sprintf("Incompatible BID file version: got %.2f , expected %.2f", iversion, $BID_VERSION))
+ exitnow
+ endif
+
+ ; section header
+ elseif (strcmp(Sfirstchar, "s") == 0) then
+ imode = 1
+ icomma = strindex(Sline, ",")
+ isectionnum = strtod(strsub(Sline, 2, icomma))
+ Sub = strsub(Sline, icomma+1)
+ icomma = strindex(Sub, ",")
+ isectionlength = strtod(strsub(Sub, 0, icomma))
+ ichordgroup = strtod(strsub(Sub, icomma+1))
+ gibid_sectionchords[isectionnum] = ichordgroup
+ tabw_i isectionlength, isectionnum, gibid_sectionlengths
+
+ ; tempo
+ elseif (strcmp(Sfirstchar, "b") == 0) then
+ imode = -1
+ icomma = strindex(Sline, ",")
+ gibid_tempo = strtod(strsub(Sline, 2, icomma))
+ gibid_beattime = 60 / gibid_tempo
+ iswingpercent = strtod(strsub(Sline, icomma+1))
+ gibid_swingtime = ((gibid_beattime/4)/100) * iswingpercent
+
+ ; chord group header
+ elseif (strcmp(Sfirstchar, "c") == 0) then
+ imode = 3
+ ichordgroup = strtod(strsub(Sline, 2))
+ ichordnum = 0
+
+ ; pattern header
+ elseif (strcmp(Sfirstchar, "i") == 0) then
+ imode = 4
+ iparameter = 0
+
+ icomma = strindex(Sline, ",")
+ instrindex = _bid_gettextindex(strsub(Sline, 2, icomma), 1)
+ Sub = strsub(Sline, icomma+1)
+ icomma2 = strindex(Sub, ",")
+ isection = strtod(strsub(Sub, 0, icomma2))
+ if (isection > gibid_maxsection) then
+ gibid_maxsection = isection
+ endif
+ if (icomma2 != -1) then ; repeat or null section
+ irepeatsection = strtod(strsub(Sub, icomma2+1))
+ if (irepeatsection == -1) then
+ inewsection = -1
+ else
+ inewsection = gibid_sections[irepeatsection][instrindex]
+ endif
+ gibid_sections[isection][instrindex] = inewsection
+ else
+ isectiondataindex += 1
+ gibid_sections[isection][instrindex] = isectiondataindex
+ endif
+
+ ; chord row
+ elseif (imode == 3) then
+ _bid_parserow(Sline, ichordgroup, ichordnum, 2)
+ ichordnum += 1
+
+ ; pattern row
+ elseif (imode == 4) then
+ _bid_parserow(Sline, isectiondataindex, iparameter, 1)
+ iparameter += 1
+ endif
+ endif
+ idata[0] = iparameter
+ idata[1] = isection
+ idata[2] = ichordnum
+ idata[3] = isectiondataindex
+ idata[4] = imode
+ xout idata
+endop
+
+
+/*
+ Parse a Bug Infested Directive Format string to global arrays, ftables and variables.
+ Handles patterns, tempo, chord groups and sections etc accordingly.
+
+ bid_loadtext Sfile, [imode = 0]
+
+ Stext directive data as string to parse
+*/
+opcode bid_loadtext, 0, S
+ Stext xin
+ idata[] fillarray -1, -1, -1, -1, -1
+read:
+ index = strindex(Stext, "\n")
+ if (index != -1) then
+ Sline = strsub(Stext, 0, index)
+ Stext = strsub(Stext, index + 1)
+ idata[] _bid_parseline Sline, idata
+
+ igoto read
+ else
+ igoto complete
+ endif
+
+complete:
+endop
+
+
+/*
+ Parse a Bug Infested Directive Format string to global arrays, ftables and variables.
+ Handles patterns, tempo, chord groups and sections etc accordingly.
+ Requires readfi support which is not available on all platforms. Platforms that do not support that
+ should set NOFILEIO.
+
+ bid_loadfile Sfile
+
+ Sfile directive file to parse
+*/
+opcode bid_loadfile, 0, S
+ Sfile xin
+#ifdef NOFILEIO
+ tt_notify_fatal("Attempting to use parsefile when NOFILEIO is set")
+#else
+ if (filevalid(Sfile) == 0) then
+ tt_notify(sprintf("Directive file cannot be found: '%s'", Sfile))
+ exitnow
+ endif
+ idata[] fillarray -1, -1, -1, -1, -1
+read:
+ Sline, ilinenum readfi Sfile
+ Sline = tt_stripnewline(Sline)
+
+ idata[] _bid_parseline Sline, idata
+
+ if (ilinenum != -1) igoto read
+#endif
+endop
+
+
+
+/*
+ Set the current chord given a section
+ p4 the section number
+ p5 0=start at beginning, 1=increment chord index
+*/
+instr bid_setcurrentchord
+ isection = p4
+ ichordincrement = p5
+ if (isection > gibid_maxsection) then
+ turnoff
+ endif
+
+ ichordgroup = gibid_sectionchords[isection]
+ if (ichordgroup != gibid_lastchordgroup || isection != gibid_lastsection) then
+ gibid_currentchordnum = 0
+ gibid_lastchordgroup = ichordgroup
+ gibid_lastsection = isection
+ elseif (ichordincrement == 1) then
+ if (gibid_currentchordnum + 1 < lenarray(gibid_chordgroups, 2) - 1) then
+ if (gibid_chordgroups[ichordgroup][gibid_currentchordnum + 1] == 0) then
+ gibid_currentchordnum = 0
+ else
+ gibid_currentchordnum += 1
+ endif
+ else
+ gibid_currentchordnum = 0
+ endif
+ else
+ gibid_currentchordnum = 0
+ endif
+
+ ifn = gibid_chordgroups[ichordgroup][gibid_currentchordnum]
+
+ if (ifn > 0) then
+ gkbid_chordlength = tab:k(0, ifn)
+ gibid_chordfn = ifn
+ endif
+
+ if (timeinstk() > 2) then
+ turnoff
+ endif
+endin
+
+
+#end
+
diff --git a/BUG5/bid_source.udo b/BUG5/bid_source.udo
new file mode 100644
index 0000000..a64d00a
--- /dev/null
+++ b/BUG5/bid_source.udo
@@ -0,0 +1,135 @@
+/*
+ Debugger - Unfixed Bugs : BUG #5
+
+ Bug Infested Directives source
+ Provided as a string due to readfi not being available on all platforms.
+ Used with bid_loadtext (whereas a separate file would be used with bid_loadfile and requires readfi support)
+*/
+
+SBID = {{
+; Bug Infested Directives : Debugger - Unfixed Bugs : BUG #5
+v 1.1
+
+; tempo, swing percent
+b 123, 41
+
+; chord groups
+c 1
+ 3.5, 56, 59, 61, 64
+ 4.5, 56, 59, 63
+ 8, 59, 60, 62, 65, 69
+
+c 2
+ 8, 56, 59, 61, 64, 69
+ 8, 56, 59, 65, 71, 73
+;8, 56, 59, 63, 68
+;4.5, 57, 60, 65, 69, 71
+; 4.5, 60, 61, 65, 67, 70 ; 57, 60, 65, 69, 71
+
+
+; sections: section number, length, chordgroup
+s 1, 32, 2
+s 2, 32, 1
+s 3, 32, 1
+
+
+
+; patterns: trig , dur, amp, chance
+i stringchord, 1
+; 1 - - - 2 - - - 3 - - - 4 - - - 5 - - - 6 - - - 7 - - - 8 - - -
+ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4.5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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.2,.2,.2,.2,.2,.2,.2,.2,.5,.2,.2,.2,.2,.2,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1,.8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,.8, 1,.8, 1, 1, 1, 1, 1, 1
+ 1, 1, 1, 1, 1, 1, 1, 1, 1,.5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,.5, 1,.5, 1, 1, 1, 1, 1, 1
+i bass, 3, 2
+
+
+i kick, 1
+; 1 - - - 2 - - - 3 - - - 4 - - - 5 - - - 6 - - - 7 - - - 8 - - -
+ 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0
+ .9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9,.9
+ 1, 0,.8, 0, 1, 0, 0, 0, 1, 0,.7, 0, 1, 0, 0, 0, 1, 0,.8, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0,.6,.6
+ 1, 1,.1, 1, 1, 1, 1, 1, 1, 1,.5, 1, 1, 1, 1, 1, 1, 1,.1, 1, 1, 1, 1, 1, 1, 1,.5, 1, 1, 1,.6,.2
+i kick, 2, 1
+i kick, 3, 1
+}}
diff --git a/BUG5/bussing.udo b/BUG5/bussing.udo
new file mode 100644
index 0000000..78755ce
--- /dev/null
+++ b/BUG5/bussing.udo
@@ -0,0 +1,62 @@
+#ifndef UDO_BUSSING
+#define UDO_BUSSING ##
+
+
+/*
+ Get the stereo L and R names for a singular bus name
+
+ SnameL, SnameR bus_name Sbus
+
+ SnameL left bus identifier
+ SnameR right bus identifier
+
+ Sbus bus name
+*/
+opcode bus_name, SS, S
+ Sbus xin
+ xout sprintf("%sL", Sbus), sprintf("%sR", Sbus)
+endop
+
+
+/*
+ Mix to a stereo bus
+
+ bus_mix Sbus, aL, aR
+
+ Sbus bus name
+ aL left channel
+ aR right channel
+*/
+opcode bus_mix, 0, Saa
+ Sbus, aL, aR xin
+ SbusL, SbusR bus_name Sbus
+ chnmix aL, SbusL
+ chnmix aR, SbusR
+endop
+
+
+
+/*
+ Read from a stereo bus, and then clear the bus
+
+ aL, aR bus_read Sbus
+
+ aL left channel
+ aR right channel
+
+ Sbus bus name
+*/
+opcode bus_read, aa, S
+ Sbus xin
+ SbusL, SbusR bus_name Sbus
+ aL chnget SbusL
+ aR chnget SbusR
+ chnclear SbusL
+ chnclear SbusR
+ xout aL, aR
+endop
+
+
+
+
+#end
diff --git a/BUG5/instruments.udo b/BUG5/instruments.udo
new file mode 100644
index 0000000..834f942
--- /dev/null
+++ b/BUG5/instruments.udo
@@ -0,0 +1,312 @@
+#ifndef UDO_INSTRUMENTS
+#define UDO_INSTRUMENTS ##
+/*
+ Debugger - Unfixed Bugs : BUG #5
+
+ Sound generators
+ Names should correspond to those used in BID file, prepended with play_
+*/
+
+
+#include "wavetables.udo"
+#include "bussing.udo"
+#include "bid.udo"
+
+
+instr play_hat1
+ iamp = bid_getparameter(p4, p5, 2)
+ idel1 = random(0.01, 0.03)
+ idel2 = random(0.01, 0.03)
+ xtratim(max(idel1, idel2))
+ p3 = 0.22
+ kfreq linseg 1000, p3*0.2, 300, p3*0.8, 500 ; mid as 500 not 300
+ aenv expsega .1, .0005, 1, p3 - .0005, .01
+ asqr1 oscil 1, kfreq, gifnSquare, -1
+ asqr2 oscil 1, kfreq*1.4471, gifnSquare, -1
+ asqr3 oscil 1, kfreq*1.6170, gifnSquare, -1
+ asqr4 oscil 1, kfreq*1.9265, gifnSquare, -1
+ asqr5 oscil 1, kfreq*2.5028, gifnSquare, -1
+ asqr6 oscil 1, kfreq*2.6637, gifnSquare, -1
+ a808 sum asqr1, asqr2, asqr3, asqr4, asqr5, asqr6
+ a808 butterhp a808, 3270
+ a808 butterhp a808, 3270
+ aout = a808 * aenv * iamp
+ aL delay aout, idel1
+ aR delay aout, idel2
+ bus_mix("master", aL, aR)
+endin
+
+
+instr play_hat2
+ iamp = bid_getparameter(p4, p5, 2)
+ idel1 = random(0.005, 0.02)
+ idel2 = random(0.005, 0.02)
+ xtratim(max(idel1, idel2))
+ kfreq init 415.3*0.8
+ aenv expsega .1, .0005, 1, p3 - .0005, .01
+ asqr1 oscil 1, kfreq, gifnSquare, -1
+ asqr2 oscil 1, kfreq*1.4471, gifnSquare, -1
+ asqr3 oscil 1, kfreq*1.6170, gifnSquare, -1
+ asqr4 oscil 1, kfreq*1.9265, gifnSquare, -1
+ asqr5 oscil 1, kfreq*2.5028, gifnSaw, -1
+ asqr6 oscil 1, kfreq*2.6637, gifnSaw, -1
+ a808 sum asqr1, asqr2, asqr3, asqr4, asqr5, asqr6
+ a808 butterhp a808, 3270
+ a808 butterhp a808, 3270
+ aout = a808 * aenv * iamp
+ aL delay aout, idel1
+ aR delay aout, idel2
+ bus_mix("master", aL, aR)
+endin
+
+instr play_bass
+ iamp = bid_getparameter(p4, p5, 2)
+ inote = tab_i(random(1, ftlen(gibid_chordfn) - 3), gibid_chordfn) - 24
+ a1 foscil 0.56, cpsmidinn(inote), 1, 2, random(0, 6), gifnSine
+ a1 pareq a1, 150, 0.24, 0.9
+ a1 pareq a1, 80, 1.3, 0.9
+ kenv linseg 1, p3, 0
+ aout = a1*kenv
+ bus_mix("master", aout, aout)
+endin
+
+
+instr play_kick ; 808 style kick
+ iamp = bid_getparameter(p4, p5, 2)
+
+ idist = 0.35 ;= (i(gksection) == 1) ? 0.55 : 0.35
+ xtratim 0.1
+ krelease release
+ ktune init 0
+ kmul transeg 0.2, p3*0.5, -15, 0.01, p3*0.5, 0, 0
+ kbend transeg 0.5, 1.2, -4, 0, 1, 0, 0
+ asig gbuzz 0.5, 50*octave(ktune)*semitone(kbend), 20, 1, kmul, gifnCosine
+ aenv transeg 1, p3-0.004, -6, 0
+ gkpump = k(aenv)
+ aatt linseg 0, 0.004, 1
+ asig = asig*aenv*aatt
+ aenv linseg 1, 0.07, 0
+ acps expsega 400, 0.07, 0.001, 1, 0.001
+ aimp oscili aenv, acps*octave(ktune*0.25)
+ amix = ((asig*0.7)+(aimp*0.35))*2*iamp
+ gkpump = min(rms(amix) * 7, 1)
+ aout1 distort amix, idist, gifnSine
+
+
+ aout1 *= 1.6
+ bus_mix("master", aout1, aout1)
+endin
+
+
+instr play_snare
+ icps0 = 211
+ iamp = bid_getparameter(p4, p5, 2)
+ ;p3 = random(0.03, 0.5)
+ icps1 = 2.0 * icps0
+ kcps port icps0, 0.007, icps1
+ kcpsx = kcps * 1.5
+
+ kfmd port 0.0, 0.01, 0.7
+ aenv1 expon 1.0, 0.03, 0.5
+ kenv2 port 1.0, 0.008, 0.0
+ aenv2 interp kenv2
+ aenv3 expon 1.0, 0.025, 0.5
+
+ a_ oscili 1.0, kcps
+ a1 oscili 1.0, kcps * (1.0 + a_*kfmd)
+ a_ oscili 1.0, kcpsx
+ a2 oscili 1.0, kcpsx * (1.0 + a_*kfmd)
+
+ a3 unirand 2.0
+ a3 = a3 - 1.0
+ a3 butterbp a3, 3200, 1500
+ a3 = a3 * aenv2
+
+ a0 = a1 + a2*aenv3 + a3*1.0
+ a0 = a0 * aenv1
+ a0 butterhp a0, 210
+ aout = a0*iamp
+ bus_mix("master", aout, aout)
+
+endin
+
+
+/*
+ Convenience opcode for playing current chord on given instrument, passing p4 as note and p5 as amp
+
+ chordinstrument Sinstrument
+
+ Sinstrument the instrument name
+ ipos position in pattern
+ idataindex section specific data index; pointer to ftable
+*/
+opcode chordinstrument, 0, Sii
+ Sinstrument, ipos, idataindex xin
+ iamp = bid_getparameter(ipos, idataindex, 2)
+ index = 1 ; index 0 is chordgroup length
+ while (index < ftlen(gibid_chordfn)) do
+ event_i "i", Sinstrument, 0, p3, tab_i(index, gibid_chordfn), iamp
+ index += 1
+ od
+
+endop
+
+
+
+instr play_clap
+ iamp = bid_getparameter(p4, p5, 2)
+ ;p3 = 0.065
+ aL noise 1, 0.9
+ aR noise 0.5, 0.4
+ aL butterbp aL, 1200, 1100
+ aR butterbp aR, 1200, 1100
+ aL butterhp aL, 400
+ aR butterhp aR, 400
+ kamp1 linseg 1, p3*0.1, 0, p3*0.1, 1, p3*0.2, 0.1, p3*0.3, 0.5, p3*0.2, 0, p3*0.05, 0.4, p3*0.05, 0
+ kamp2 linseg 1, p3*0.15, 0, p3*0.15, 1, p3*0.1, 0.1, p3*0.2, 0.5, p3*0.3, 0, p3*0.05, 0.4, p3*0.05, 0
+
+ aL = aL*kamp1*12*iamp
+ aR = aR*kamp2*12*iamp
+ bus_mix("master", aL, aR)
+ bus_mix("reverb", aL*0.2, aR*0.2)
+endin
+
+instr play_mel1
+ iamp = bid_getparameter(p4, p5, 2)
+ inote = tab_i(1, gibid_chordfn) ;tab_i(random(1, ftlen(gibid_chordfn) - 3), gibid_chordfn) - 12
+ inote2 = tab_i(2, gibid_chordfn) ;tab_i(random(1, ftlen(gibid_chordfn) - 3), gibid_chordfn) - 12
+ aL moog 0.6*iamp, cpsmidinn(inote - 12), 0.1, 0.02, 4, 0.01, gifnSine, gifnSaw, gifnSine
+ aR moog 0.6*iamp, cpsmidinn(inote2 - 12), 0.1, 0.002, 4, 0.01, gifnSine, gifnSaw, gifnSine
+ kenv linseg 1, p3*0.8, 0, p3*0.2, 0
+ aL *= kenv
+ aR *= kenv
+ bus_mix("master", aL, aR)
+endin
+
+instr string
+ if (random(0, 1) > 0.8) then
+ ifqc = cpsmidinn(p4)
+ else
+ ifqc = cpsmidinn(p4+12)
+ endif
+ iamp = p5
+idur = p3
+ ifm1 = ifqc
+ ifm2 = ifqc*3
+ ifm3 = ifqc*4
+ indx1 = 7.5/log(ifqc) ;range from ca 2 to 1
+ indx2 = 15/sqrt(ifqc) ;range from ca 2.6 to .5
+ indx3 = 1.25/sqrt(ifqc) ;range from ca .2 to .038
+
+ irise = 0.1
+ idec = 0.4
+ inoisdur= .1
+ ivibdel = 0.25
+ ivibwth = 0.01
+ ivibrte = 5.5
+
+ kvib init 0
+ kvbctl linen 1,.5,p3-ivibdel,.1 ; vibrato control envelope
+ krnd randi .0075,2 ; random deviation vib width
+ kvib oscili kvbctl*ivibwth+krnd,ivibrte*kvbctl ; generator
+
+ ktrans linseg 1,inoisdur,0,1,0 ; transient envelope
+ anoise randi ktrans*iamp/4,.2*ifqc ; attack noise...
+ attack oscili anoise,2000 ; ...centered around 2kHz
+
+ amod1 oscili ifm1*(indx1+ktrans),ifm1
+ amod2 oscili ifm2*(indx2+ktrans),ifm2
+ amod3 oscili ifm3*(indx3+ktrans),ifm3
+ asig oscili iamp,(ifqc+amod1+amod2+amod3)*(1+kvib)
+ asig linen (asig+attack),irise,idur,idec
+ asig butterhp asig, 800
+ asig butterhp asig, 200
+ kenv linseg 0, p3*0.25, 0.7, p3*0.5, 1, p3*0.25, 0
+ asig *= kenv
+ asig *= 0.2
+ aL = asig
+ aR = asig
+ bus_mix("delay1", aL, aR)
+bus_mix("reverb", aL, aR)
+
+
+endin
+
+
+instr play_303
+ iamp = bid_getparameter(p4, p5, 2)
+ ifilter = random(50, 70)
+ inote = tab_i(random(1, ftlen(gibid_chordfn) - 1), gibid_chordfn)
+
+ ifrq1 = 440 * exp(log(2) * (ifilter - 69) / 12) ; filter start freq.
+ kamp linseg 1, p3-0.01, 1, 0.025, 0, 1, 0 ; release envelope
+ kcps init cpsmidinn(inote)
+ kffrq port 0, 60/150, ifrq1 ; filter frequency
+ a1 phasor kcps ; oscillator
+ a1 = 1 - 2 * a1
+
+ a1x butterbp a1, kffrq, kcps * 1.0 ; filters
+ a1x = a1x * (2 + kffrq / kcps) ; correct amplitude
+ a1 = a1x + a1 * 0.25 ; 0.5
+ a1 butterlp a1, kffrq
+
+ a1 = taninv(a1 * 4 * iamp) ; distortion ; 2.5
+
+ keqf limit kffrq * 4, 10, sr * 0.48 ; EQ frequency
+ a1 pareq a1 * 0.4, keqf, 4.0, 1.0, 2
+ a1 butterhp a1, 250
+ a1 = a1 * kamp * 0.72
+ aL, aR pan2 a1, random(0.3, 0.7)
+ bus_mix("reverb", aL*0.3, aR*0.3)
+ bus_mix("master", aL*0.8, aR*0.8)
+endin
+
+instr chord1
+ inote = p4
+ iamp = p5
+ kfreq init cpsmidinn(inote)
+
+ aphs1 phasor kfreq
+ aphs2 phasor kfreq
+ koda = abs(oscil(random(0, 2), random(0, 1)))
+ a1 tablei aphs1, gifnSine, 1, 0, 1
+ a1 *= linseg(1, p3*0.9, 0)
+
+ av1L linseg 3, p3, 0
+ aL tablei (aphs2+a1)+av1L+koda, gifnSine, 1, 0, 1
+
+ av1R linseg 4, p3, 0
+ aR tablei (aphs2+a1)+av1R+koda, gifnSine, 1, 0, 1
+
+ kfi linseg 0, p3*0.2, 1, p3*0.8, 1
+ aL phaser1 aL*kfi, oscil:k(7400, 0.1, gifnSine, random(0, 0.5)) + 1000, 8, .9
+ aR phaser1 aR*kfi, oscil:k(7400, 0.1, gifnSine, random(0, 0.5)) + 1000, 8, .9
+ aL *= 0.16 * iamp
+ aR *= 0.16 * iamp
+ aL butterhp aL, 520
+ aR butterhp aR, 520
+ if (i(gksection) == 3) then
+ aL butterlp aL, 1000
+ aR butterlp aR, 1000
+ endif
+ bus_mix("delay1", aL, aR)
+ ;bus_mix("master", aL, aR)
+endin
+
+
+/*
+ Play chord1 above, called from BID
+*/
+instr play_chord1
+ chordinstrument "chord1", p4, p5
+ turnoff
+endin
+
+instr play_stringchord
+ chordinstrument "string", p4, p5
+ turnoff
+endin
+
+
+
+#end
diff --git a/BUG5/txt_tools.udo b/BUG5/txt_tools.udo
new file mode 100644
index 0000000..a6c4511
--- /dev/null
+++ b/BUG5/txt_tools.udo
@@ -0,0 +1,82 @@
+#ifndef UDO_TXTTOOLS
+#define UDO_TXTTOOLS ##
+/*
+ Debugger - Unfixed Bugs : BUG #5
+
+ Text tools
+*/
+
+
+/*
+ Print a notification prepended with a line of asterisks
+
+ tt_notify Stext
+
+ Stext text to print
+*/
+opcode tt_notify, 0, S
+ Stext xin
+ Snew = "\n"
+ iwidth = 60
+ index = 0
+ while (index < iwidth) do
+ Snew = strcat(Snew, "*");
+ index += 1
+ od
+ prints strcat(strcat(Snew, "\n"), strcat(Stext, "\n\n"))
+endop
+
+
+
+/*
+ Print a notification prepended with a line of asterisks and exit
+
+ tt_notify Stext
+
+ Stext text to print
+*/
+opcode tt_notify_fatal, 0, S
+ Stext xin
+ tt_notify(Stext)
+ exitnow
+endop
+
+
+/*
+ Return a number of seconds as HH:MM:SS format
+
+ Stime tt_parsetime iseconds
+
+ iseconds seconds to parse
+
+ Stime formatted time
+
+*/
+opcode tt_parsetime, S, i
+ input xin
+ ihours = floor(input / 3600)
+ iminutes = floor((input - (ihours * 3600)) / 60)
+ iseconds = input - (ihours * 3600) - (iminutes * 60)
+ xout sprintf("%02d:%02d:%05.2f", ihours, iminutes, iseconds)
+endop
+
+
+/*
+ Strip newline from end of line: built-in opcode has some problems
+
+ Soutput tt_stripnewline Sinput
+
+ Soutput processed without newline at end if existent
+
+ Sinput line to process
+*/
+opcode tt_stripnewline, S, S
+ Sline xin
+ index = strindex(Sline, "\n")
+ if (index != -1) then
+ Sline = strsub(Sline, 0, index)
+ endif
+ xout Sline
+endop
+
+#end
diff --git a/BUG5/wavetables.udo b/BUG5/wavetables.udo
new file mode 100644
index 0000000..1b2c209
--- /dev/null
+++ b/BUG5/wavetables.udo
@@ -0,0 +1,16 @@
+#ifndef UDO_WAVETABLES
+#define UDO_WAVETABLES ##
+/*
+ Debugger - Unfixed Bugs : BUG #5
+
+ General waveforms
+*/
+
+ipoints = 16384
+gifnCosine ftgen 0, 0, ipoints, 9, 1, 1, 90
+gifnSine ftgen 0, 0, ipoints, 10, 1
+gifnSquare ftgen 0, 0, ipoints, 10, 1, 0, 0.3, 0, 0.2, 0, 0.14, 0, .111
+gifnSaw ftgen 0, 0, ipoints, 10, 0, .2, 0, .4, 0, .6, 0, .8, 0, 1, 0, .8, 0, .6, 0, .4, 0, .2
+
+#end
+
diff --git a/BUG6/BUG6.csd b/BUG6/BUG6.csd
new file mode 100644
index 0000000..2520d25
--- /dev/null
+++ b/BUG6/BUG6.csd
@@ -0,0 +1,245 @@
+<CsoundSynthesizer>
+<CsOptions>
+-odac
+;-m0
+</CsOptions>
+<CsInstruments>
+/*
+ Debugger - Unfixed Bugs : BUG #6
+
+ http://git.1bpm.net/csd-unfixedbugs1/about/
+
+ By Richard Knight 2021
+ http://1bpm.net
+ q@1bpm.net
+
+*/
+
+sr = 44100
+ksmps = 10
+nchnls = 2
+0dbfs = 1
+seed 0
+
+#define NOFILEIO ## ; file IO with readfi not supported on all platforms: disables bid_loadfile
+
+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"
+ ifreq1 = (gibid_tempo / 60) / 4
+ kfdbkL = abs(oscil(0.8, 1.67))
+ kfdbkR = abs(oscil(0.8, 1.67))
+
+ atimeL = abs(oscil(0.2, ifreq1)) + 0.3
+ atimeR = abs(oscil(0.2, ifreq1)) + 0.3
+
+ aLdlr delayr 1
+ aLdel deltapi atimeL
+ aLdel butterhp aLdel, 130
+ delayw aL + (aLdel * kfdbkL)
+
+ aRdlr delayr 1
+ aRdel deltapi atimeR
+ aRdel butterhp aRdel, 130
+ delayw aR + (aRdel * kfdbkR)
+
+ aLdel *= 1-gkpump
+ aRdel *= 1-gkpump
+ bus_mix("master", aLdel, aRdel)
+endin
+
+instr global_delay2
+ aL, aR bus_read "delay2"
+ aLdlr delayr 0.2
+ kdeltime = abs(oscil(0.02, 0.04)) + 0.01
+ aLdel deltapi kdeltime + 0.002
+ delayw aL + (aLdel * 0.7)
+ aRdlr delayr 0.2
+ aRdel deltapi kdeltime + 0.001
+ delayw aR + (aRdel * 0.7)
+ ;aLdel *= 1-gkpump
+ ;aRdel *= 1-gkpump
+ bus_mix("master", aLdel, aRdel)
+endin
+
+instr global_delay3
+ aL, aR bus_read "delay3"
+ ifreq1 = (gibid_tempo / 60) / 8
+ kfdbkL = abs(oscil(0.8, 1.63))
+ kfdbkR = abs(oscil(0.8, 1.67))
+
+ atimeL = abs(oscil(0.2, ifreq1)) + 0.01
+ atimeR = abs(oscil(0.2, ifreq1)) + 0.01
+
+ aLdlr delayr 1
+ aLdel deltapi atimeL
+ aLdel butterhp aLdel, 130
+ delayw aL + (aLdel * kfdbkL)
+
+ aRdlr delayr 1
+ aRdel deltapi atimeR
+ aRdel butterhp aRdel, 130
+ delayw aR + (aRdel * kfdbkR)
+
+ aLdel *= 1-gkpump
+ aRdel *= 1-gkpump
+ bus_mix("master", aLdel, aRdel)
+endin
+
+/*
+ Master audio output
+*/
+instr global_master
+ igain = 1
+ aL, aR bus_read "master"
+
+ awindex phasor giglitchsamples/sr
+ tablew aL, awindex*giglitchsamples, giglitchbufferL
+ tablew aR, awindex*giglitchsamples, giglitchbufferR
+
+ if (gksection == 1) then
+ ilen = tab_i(1, gibid_sectionlengths) * gibid_beattime
+ khpf linseg 0, ilen*0.5, 0, ilen*0.3, 100, ilen*0.1, 200, ilen*0.1, 900
+ knoiseamp linseg 0, ilen*0.8, 0.04, ilen*0.1, 0.1, ilen*0.1, 0.6
+ anL = noise(0.5, 0.2)
+ anR = noise(0.5, 0.3)
+ ifreq1 = cpsmidinn(table(0.5, gibid_chordfn, 1))
+ ifreq2 = cpsmidinn(table(0.1, gibid_chordfn, 1))
+ kfreq linseg ifreq1, ilen*0.8, ifreq1, ilen*0.2, ifreq2
+ aL += resony(anL, kfreq*4, 8, 24, 4) * 0.01 * knoiseamp
+ aR += resony(anR, kfreq*4, 8, 24, 4) * 0.01 * knoiseamp
+ aL butterhp aL, khpf
+ aR butterhp aR, khpf
+ elseif (gksection == 3) then
+ ilen = tab_i(3, gibid_sectionlengths) * gibid_beattime
+ anL = noise(0.5, 0.5)
+ anR = noise(0.5, 0.5)
+ knoiseamp linseg 0, ilen*0.7, 0.1, ilen*0.1, 0.2, ilen*0.2, 0.9
+ ifreq1 = cpsmidinn(table(0.3, gibid_chordfn, 1))
+ ifreq2 = cpsmidinn(table(0.6, gibid_chordfn, 1)) * 0.1
+ kfreq linseg ifreq1, ilen*0.8, ifreq1, ilen*0.2, ifreq2
+ aL += resony(anL, kfreq*4, 3, 24, 4) * 0.005 * knoiseamp
+ aR += resony(anR, kfreq*4, 3, 24, 4) * 0.005 * knoiseamp
+ bus_mix("delay1", aL*knoiseamp*0.5, aR*knoiseamp*0.5)
+ endif
+ aL limit aL*0.5, -1, 1
+ aR limit aR*0.5, -1, 1
+ outs aL*gkmastergain*igain, aR*gkmastergain*igain
+endin
+
+
+/*
+ Print notification of performance time since last notification
+ or if isection is -1, print completion notification
+*/
+gitimetrack times
+instr notify_change
+ isection = p4
+ itime times
+ if (isection == -1) then
+ tt_notify(sprintf"Complete, runtime: %s", tt_parsetime(itime)))
+ exitnow
+ else
+ isectiontime = itime - gitimetrack
+ tt_notify(sprintf("%s : section %d complete in %s", tt_parsetime(itime), isection, tt_parsetime(isectiontime)))
+ gitimetrack = itime
+ endif
+ turnoff
+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_master", 0, p3
+ event_i "i", "global_delay1", 0, p3
+ event_i "i", "global_delay2", 0, p3
+ event_i "i", "global_delay3", 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
+ event "i", "notify_change", p3, 1, -1
+ turnoff
+ endif
+
+ bid_seq "kick", kpos, ksection
+ bid_seq "kick2", kpos, ksection
+ bid_seq "clap", kpos, ksection
+ bid_seq "303", kpos, ksection
+ bid_seq "hat1", kpos, ksection
+ bid_seq "snare", kpos, ksection
+ bid_seq "hat2", kpos, ksection
+ bid_seq "303b", kpos, ksection
+ bid_seq "glitchread", kpos, ksection
+ bid_seq "blip", kpos, ksection
+ bid_seq "shaker", kpos, ksection
+
+
+ kpos = (kpos < 31) ? kpos + 1 : 0
+ ksection16ths = bid_getsectionlength(ksection) * 4
+
+ if (kposabs+1 < ksection16ths) then
+ kposabs += 1
+ else
+ event "i", "notify_change", 0, 1, ksection
+ ;event "i", "play_crash", 0, gibid_beattime*4
+ 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
+
+</CsInstruments>
+<CsScore>
+i"parseandrun" 0 1
+</CsScore>
+</CsoundSynthesizer> \ No newline at end of file
diff --git a/BUG6/bid.udo b/BUG6/bid.udo
new file mode 100644
index 0000000..17e9be2
--- /dev/null
+++ b/BUG6/bid.udo
@@ -0,0 +1,425 @@
+#ifndef UDO_BID
+#define UDO_BID ##
+/*
+ Debugger - Unfixed Bugs : BUG #5
+
+ Bug Infested Directive file parser v1 and tools
+
+ Designed to create a reusable loop based score format in the Unfixed Bugs project and beyond.
+*/
+
+
+#define BID_VERSION #1.1#
+
+#include "txt_tools.udo"
+
+; globals
+gibid_tempo init -1 ; beats per minute
+gibid_beattime init -1 ; time of one beat in second
+gibid_maxsection init -1 ; max number of sections
+gibid_chordfn init -1 ; current chord ftable
+gkbid_chordlength init -1 ; current chord length
+
+; BID internals
+gibid_sectionlengths ftgen 0, 0, -64, -7, 0 ; section lengths
+gibid_sections[][] init 64, 64 ; section pointers to data
+gibid_sectiondata[][] init 99, 6 ; section data, ftables contained
+
+gibid_chordgroups[][] init 16, 12 ; chord groups, pointers to sectionchords by section
+gibid_sectionchords[] init 16 ; ftables of section chords
+
+gibid_currentchordnum = 0 ; current chord number
+gibid_lastchordgroup = -1 ; last chord group
+gibid_lastsection = -1 ; last section
+
+gSbid_sequenced[] init 1 ; internal tracking of sequenced elements
+gibid_sequenceinit init 1 ; internal tracking of sequenced init
+gibid_swingtime init -1 ; swing time calculated from percent
+
+/*
+ Get BID instrument index, creating new reference if specified.
+ Internal use only.
+
+ index _bid_gettextindex Sname, [iaddifnotexists = -1]
+
+ index BID instrument index
+
+ Sname name to look up or create
+ iaddifnotexists 1=create , default=fatal if not exists
+*/
+opcode _bid_gettextindex, i, Sj
+ Sname, iaddifnotexists xin
+ ifinalindex = -1
+ index = 0
+ while (index < lenarray(gSbid_sequenced)) do
+ if (strcmp(gSbid_sequenced[index], Sname) == 0) then
+ ifinalindex = index
+ igoto complete
+ endif
+ index += 1
+ od
+
+ if (iaddifnotexists == 1) then
+ if (gibid_sequenceinit == 1) then
+ gibid_sequenceinit = 0
+ SequencedNew[] fillarray Sname
+ ifinalindex = 0
+ else
+ SequencedNew[] init lenarray(gSbid_sequenced) + 1
+ index = 0
+ while (index < lenarray(gSbid_sequenced)) do
+ SequencedNew[index] = gSbid_sequenced[index]
+ index += 1
+ od
+ SequencedNew[index] = Sname
+ ifinalindex = index
+ endif
+ gSbid_sequenced = SequencedNew
+ igoto complete
+ else
+ tt_notify_fatal(sprintf("Sequenced index for '%s' not found", Sname))
+ endif
+
+complete:
+ xout ifinalindex
+endop
+
+
+
+/*
+ Parse a row of comma-separated numerical values of either patterns or chords.
+ Internal use only.
+
+ inum _bid_parserowitems Sline, ix1, ix2, imode
+
+ inum number of elements found parsed
+
+ Sline input line
+ ix1 array dimension 1 index
+ ix2 array dimension 2 index
+ imode 0=count elements; 1=write patterns; 2=write chords
+*/
+opcode _bid_parserowitems, i, Siii
+ Sline, ix1, ix2, imode xin
+ inum = 0
+ while (strlen(Sline) > 0) do
+ icomma = strindex(Sline, ",")
+ Stemp = strsub(Sline, 0, icomma)
+ icomma = (icomma == -1) ? 0 : icomma
+ Sline = strsub(Sline, icomma + 1)
+ if (imode == 1) then
+ tabw_i strtod(Stemp), inum, gibid_sectiondata[ix1][ix2]
+ elseif (imode == 2) then
+ tabw_i strtod(Stemp), inum, gibid_chordgroups[ix1][ix2]
+ endif
+ inum += 1
+ od
+ xout inum
+endop
+
+
+/*
+ Read BID data for specified element and trigger accordingly.
+
+ bid_seq Splayer, kposition, ksection
+
+ Splayer name of BID element
+ kposition position in pattern provided by master sequencer
+ ksection section in composition provided by master sequencer
+
+*/
+opcode bid_seq, 0, Skk
+ Splayer, kpos, ksection xin
+ Sinstrument = sprintf("play_%s", Splayer)
+ instrindex = _bid_gettextindex(Splayer)
+ kdata = gibid_sections[ksection][instrindex]
+
+ if (kdata != -1) then ; null section
+ kon = tablekt:k(kpos, gibid_sectiondata[kdata][0])
+
+ if (kon == 1) then
+ kchance = tablekt:k(kpos, gibid_sectiondata[kdata][3])
+ if (random:k(0, 1) < kchance) then
+ ktime = (kpos % 2 == 0) ? 0 : gibid_swingtime
+ kdur = tablekt:k(kpos, gibid_sectiondata[kdata][1]) * gibid_beattime
+ ;kamp = tablekt:k(kpos, gisectiondata[kdata][2])
+ event "i", Sinstrument, ktime, kdur, kpos, kdata
+ endif
+ endif
+ endif
+endop
+
+
+/*
+ Get a parameter for the specified pattern position.
+ ipos and idataindex are provided as p4 and p5 to instruments scheduled by bid_seq,
+ hence can typically used as bid_getparameter(p4, p5, iparameter)
+
+ idata bid_getparameter ipos, idataindex, iparameter
+
+ idata the resulting value
+
+ ipos position in pattern
+ idataindex section specific data index; pointer to ftable
+ iparameter parameter index as in BID file; defaults include 0=on/off, 1=duration, 2=amp, 3=chance
+
+*/
+opcode bid_getparameter, i, iii
+ ipos, idataindex, iparameter xin
+ xout tab_i(ipos, gibid_sectiondata[idataindex][iparameter])
+endop
+
+
+/*
+ Get a section length in beats
+
+ klength bid_getsectionlength ksection
+
+ klength length in beats
+
+ ksection section to look up
+*/
+opcode bid_getsectionlength, k, k
+ ksection xin
+ xout tab:k(ksection, gibid_sectionlengths)
+endop
+
+/*
+ Parse a row of comma-separated values to either section patterns or chord storage.
+ Scans row, assigns ftable of appropriate length and then fills ftable.
+ Internal use only.
+
+ _bid_parserow Sline, ix1, ix2, imode
+
+ Sline line to parse
+ ix1 array dimension 1 index of target storage
+ ix2 array dimension 2 index of target storage
+ imode 1=section patterns, 2=chords
+*/
+opcode _bid_parserow, 0, Siii
+ Sline, ix1, ix2, imode xin
+ isize = _bid_parserowitems(Sline, ix1, ix2, 0)
+ if (imode == 1) then
+ gibid_sectiondata[ix1][ix2] ftgen 0, 0, -isize, -7, 0
+ elseif (imode == 2) then
+ gibid_chordgroups[ix1][ix2] ftgen 0, 0, -isize, -7, 0
+ endif
+ isize = _bid_parserowitems(Sline, ix1, ix2, imode)
+endop
+
+
+
+/*
+ Parse a line from a BID string
+ Internal use only.
+
+ idataout[] _bid_parseline Sline, idatain[]
+
+ idataout[] state data
+
+ Sline line to parse
+ idatain[] state data
+
+*/
+opcode _bid_parseline, i[], Si[]
+ Sline, idata[] xin
+ iparameter = idata[0]
+ isection = idata[1]
+ ichordnum = idata[2]
+ isectiondataindex = idata[3]
+ imode = idata[4]
+
+ if (strlen(Sline) > 0) then
+ Sfirstchar = strsub(Sline, 0, 1)
+
+ ; comment
+ if (strcmp(Sfirstchar, ";") == 0) then
+ ; no action
+
+ ; version check
+ elseif (strcmp(Sfirstchar, "v") == 0) then
+ imode = 0
+ iversion = strtod(strsub(Sline, 2))
+ if (iversion != $BID_VERSION) then
+ tt_notify(sprintf("Incompatible BID file version: got %.2f , expected %.2f", iversion, $BID_VERSION))
+ exitnow
+ endif
+
+ ; section header
+ elseif (strcmp(Sfirstchar, "s") == 0) then
+ imode = 1
+ icomma = strindex(Sline, ",")
+ isectionnum = strtod(strsub(Sline, 2, icomma))
+ Sub = strsub(Sline, icomma+1)
+ icomma = strindex(Sub, ",")
+ isectionlength = strtod(strsub(Sub, 0, icomma))
+ ichordgroup = strtod(strsub(Sub, icomma+1))
+ gibid_sectionchords[isectionnum] = ichordgroup
+ tabw_i isectionlength, isectionnum, gibid_sectionlengths
+
+ ; tempo
+ elseif (strcmp(Sfirstchar, "b") == 0) then
+ imode = -1
+ icomma = strindex(Sline, ",")
+ gibid_tempo = strtod(strsub(Sline, 2, icomma))
+ gibid_beattime = 60 / gibid_tempo
+ iswingpercent = strtod(strsub(Sline, icomma+1))
+ gibid_swingtime = ((gibid_beattime/4)/100) * iswingpercent
+
+ ; chord group header
+ elseif (strcmp(Sfirstchar, "c") == 0) then
+ imode = 3
+ ichordgroup = strtod(strsub(Sline, 2))
+ ichordnum = 0
+
+ ; pattern header
+ elseif (strcmp(Sfirstchar, "i") == 0) then
+ imode = 4
+ iparameter = 0
+
+ icomma = strindex(Sline, ",")
+ instrindex = _bid_gettextindex(strsub(Sline, 2, icomma), 1)
+ Sub = strsub(Sline, icomma+1)
+ icomma2 = strindex(Sub, ",")
+ isection = strtod(strsub(Sub, 0, icomma2))
+ if (isection > gibid_maxsection) then
+ gibid_maxsection = isection
+ endif
+ if (icomma2 != -1) then ; repeat or null section
+ irepeatsection = strtod(strsub(Sub, icomma2+1))
+ if (irepeatsection == -1) then
+ inewsection = -1
+ else
+ inewsection = gibid_sections[irepeatsection][instrindex]
+ endif
+ gibid_sections[isection][instrindex] = inewsection
+ else
+ isectiondataindex += 1
+ gibid_sections[isection][instrindex] = isectiondataindex
+ endif
+
+ ; chord row
+ elseif (imode == 3) then
+ _bid_parserow(Sline, ichordgroup, ichordnum, 2)
+ ichordnum += 1
+
+ ; pattern row
+ elseif (imode == 4) then
+ _bid_parserow(Sline, isectiondataindex, iparameter, 1)
+ iparameter += 1
+ endif
+ endif
+ idata[0] = iparameter
+ idata[1] = isection
+ idata[2] = ichordnum
+ idata[3] = isectiondataindex
+ idata[4] = imode
+ xout idata
+endop
+
+
+/*
+ Parse a Bug Infested Directive Format string to global arrays, ftables and variables.
+ Handles patterns, tempo, chord groups and sections etc accordingly.
+
+ bid_loadtext Sfile, [imode = 0]
+
+ Stext directive data as string to parse
+*/
+opcode bid_loadtext, 0, S
+ Stext xin
+ idata[] fillarray -1, -1, -1, -1, -1
+read:
+ index = strindex(Stext, "\n")
+ if (index != -1) then
+ Sline = strsub(Stext, 0, index)
+ Stext = strsub(Stext, index + 1)
+ idata[] _bid_parseline Sline, idata
+
+ igoto read
+ else
+ igoto complete
+ endif
+
+complete:
+endop
+
+
+/*
+ Parse a Bug Infested Directive Format string to global arrays, ftables and variables.
+ Handles patterns, tempo, chord groups and sections etc accordingly.
+ Requires readfi support which is not available on all platforms. Platforms that do not support that
+ should set NOFILEIO.
+
+ bid_loadfile Sfile
+
+ Sfile directive file to parse
+*/
+opcode bid_loadfile, 0, S
+ Sfile xin
+#ifdef NOFILEIO
+ tt_notify_fatal("Attempting to use parsefile when NOFILEIO is set")
+#else
+ if (filevalid(Sfile) == 0) then
+ tt_notify(sprintf("Directive file cannot be found: '%s'", Sfile))
+ exitnow
+ endif
+ idata[] fillarray -1, -1, -1, -1, -1
+read:
+ Sline, ilinenum readfi Sfile
+ Sline = tt_stripnewline(Sline)
+
+ idata[] _bid_parseline Sline, idata
+
+ if (ilinenum != -1) igoto read
+#endif
+endop
+
+
+
+/*
+ Set the current chord given a section
+ p4 the section number
+ p5 0=start at beginning, 1=increment chord index
+*/
+instr bid_setcurrentchord
+ isection = p4
+ ichordincrement = p5
+ if (isection > gibid_maxsection) then
+ turnoff
+ endif
+
+ ichordgroup = gibid_sectionchords[isection]
+ if (ichordgroup != gibid_lastchordgroup || isection != gibid_lastsection) then
+ gibid_currentchordnum = 0
+ gibid_lastchordgroup = ichordgroup
+ gibid_lastsection = isection
+ elseif (ichordincrement == 1) then
+ if (gibid_currentchordnum + 1 < lenarray(gibid_chordgroups, 2) - 1) then
+ if (gibid_chordgroups[ichordgroup][gibid_currentchordnum + 1] == 0) then
+ gibid_currentchordnum = 0
+ else
+ gibid_currentchordnum += 1
+ endif
+ else
+ gibid_currentchordnum = 0
+ endif
+ else
+ gibid_currentchordnum = 0
+ endif
+
+ ifn = gibid_chordgroups[ichordgroup][gibid_currentchordnum]
+
+ if (ifn > 0) then
+ gkbid_chordlength = tab:k(0, ifn)
+ gibid_chordfn = ifn
+ endif
+
+ if (timeinstk() > 2) then
+ turnoff
+ endif
+endin
+
+
+#end
+
diff --git a/BUG6/bid_source.udo b/BUG6/bid_source.udo
new file mode 100644
index 0000000..fd2b6b6
--- /dev/null
+++ b/BUG6/bid_source.udo
@@ -0,0 +1,169 @@
+/*
+ Debugger - Unfixed Bugs : BUG #4
+
+ Bug Infested Directives source
+ Provided as a string due to readfi not being available on all platforms.
+ Used with bid_loadtext (whereas a separate file would be used with bid_loadfile and requires readfi support)
+*/
+
+SBID = {{
+; Bug Infested Directives : Debugger - Unfixed Bugs : BUG #4
+v 1.1
+
+; tempo, swing percent
+b 128, 40
+
+; chord groups
+c 1
+ 4, 59, 63, 65, 69, 71, 72, 75, 77, 79, 82
+ 4, 59, 63, 65, 69, 71, 72, 75, 77, 79, 82
+
+c 2
+ 4, 71, 72, 75, 77
+
+; sections: section number, length, chordgroup
+s 1, 64, 1
+s 2, 64, 1
+s 3, 8, 2
+s 4, 56, 1
+
+
+i glitchread, 1, -1
+i glitchread, 2, -1
+i glitchread, 3, -1
+i glitchread, 4
+; 1 - - - 2 - - - 3 - - - 4 - - - 5 - - - 6 - - - 7 - - - 8 - - -
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0
+ .1,.1,.1,.1,.1,.1,.1,.1,.1,.1,.1,.1,.1,.1,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UG6/bussing.udo
@@ -0,0 +1,62 @@
+#ifndef UDO_BUSSING
+#define UDO_BUSSING ##
+
+
+/*
+ Get the stereo L and R names for a singular bus name
+
+ SnameL, SnameR bus_name Sbus
+
+ SnameL left bus identifier
+ SnameR right bus identifier
+
+ Sbus bus name
+*/
+opcode bus_name, SS, S
+ Sbus xin
+ xout sprintf("%sL", Sbus), sprintf("%sR", Sbus)
+endop
+
+
+/*
+ Mix to a stereo bus
+
+ bus_mix Sbus, aL, aR
+
+ Sbus bus name
+ aL left channel
+ aR right channel
+*/
+opcode bus_mix, 0, Saa
+ Sbus, aL, aR xin
+ SbusL, SbusR bus_name Sbus
+ chnmix aL, SbusL
+ chnmix aR, SbusR
+endop
+
+
+
+/*
+ Read from a stereo bus, and then clear the bus
+
+ aL, aR bus_read Sbus
+
+ aL left channel
+ aR right channel
+
+ Sbus bus name
+*/
+opcode bus_read, aa, S
+ Sbus xin
+ SbusL, SbusR bus_name Sbus
+ aL chnget SbusL
+ aR chnget SbusR
+ chnclear SbusL
+ chnclear SbusR
+ xout aL, aR
+endop
+
+
+
+
+#end
diff --git a/BUG6/instruments.udo b/BUG6/instruments.udo
new file mode 100644
index 0000000..55a7b93
--- /dev/null
+++ b/BUG6/instruments.udo
@@ -0,0 +1,491 @@
+#ifndef UDO_INSTRUMENTS
+#define UDO_INSTRUMENTS ##
+/*
+ Debugger - Unfixed Bugs : BUG #4
+
+ Sound generators
+ Names should correspond to those used in BID file, prepended with play_
+*/
+
+
+#include "wavetables.udo"
+#include "bussing.udo"
+#include "bid.udo"
+
+instr play_303
+ iamp = bid_getparameter(p4, p5, 2)
+
+ inote1 = table(p4+1, gibid_chordfn, 0, 0, 1) - 24
+
+ ifilter = random(30, 50)
+
+ ifrq1 = 440 * exp(log(2) * (ifilter - 69) / 12) ; filter start freq.
+ kamp linseg 1, p3*0.8, 1, p3*0.2, 0
+ kcps init cpsmidinn(inote1)
+ kffrq port 0, 60/150, ifrq1 ; filter frequency
+ a1 phasor kcps ; oscillator
+ a1 = 1 - 2 * a1
+
+ a1x butterbp a1, kffrq, kcps * 1.0 ; filters
+ a1x = a1x * (2 + kffrq / kcps) ; correct amplitude
+ a1 = a1x + a1 * 0.25 ; 0.5
+ a1 butterlp a1, kffrq
+
+ a1 = taninv(a1 * 2.5 * iamp) ; distortion ; 2.5
+
+ keqf limit kffrq * 4, 10, sr * 0.48 ; EQ frequency
+ a1 pareq a1 * 0.6, keqf, 4.0, 1.0, 2
+ a1 pareq a1, 50, 1.3, 0.6
+ a1 pareq a1, 130, 0.6, 0.6
+ a1 = a1 * kamp * 0.8
+ a1 *= 1-gkpump
+ aL, aR pan2 a1, random(0.3, 0.7)
+ ;bus_mix("delay2", aL, aR)
+ bus_mix("master", aL, aR)
+endin
+
+
+instr play_303b
+ iamp = bid_getparameter(p4, p5, 2)
+ ifilter = 50 ;random(50, 90)
+ index = 30-p4
+ inote = table(max(1, index), gibid_chordfn, 0, 0, 1) -12
+
+ ifrq1 = 440 * exp(log(2) * (ifilter - 69) / 12) ; filter start freq.
+ kamp linseg 1, p3*0.8, 1, p3*0.2, 0
+ kcps init cpsmidinn(inote)
+ kffrq port 0, 60/150, ifrq1 ; filter frequency
+ a1 phasor kcps ; oscillator
+ a1 = 1 - 2 * a1
+
+ a1x butterbp a1, kffrq, kcps * 1.0 ; filters
+ a1x = a1x * (2 + kffrq / kcps) ; correct amplitude
+ a1 = a1x + a1 * 0.25 ; 0.5
+ a1 butterlp a1, kffrq
+
+ a1 = taninv(a1 * 2 * iamp) ; distortion ; 2.5
+
+ keqf limit kffrq * 4, 10, sr * 0.48 ; EQ frequency
+ a1 pareq a1 * 0.4, keqf, 4.0, 1.0, 2
+ a1 butterhp a1, 250
+ a1 = a1 * kamp * 0.8
+ a1 *= 1-gkpump
+ aL, aR pan2 a1, random(0.3, 0.7)
+ bus_mix("master", aL, aR)
+endin
+
+
+
+instr play_blip
+ iamp = bid_getparameter(p4, p5, 2)
+ inote1 = table(p4+3, gibid_chordfn, 0, 0, 1) +12
+ inote2 = table(p4+5, gibid_chordfn, 0, 0, 1) +12
+ a1 oscil 1, cpsmidinn(inote1)
+ a2 oscil 1, cpsmidinn(inote2)
+ kamp linseg 1, p3*0.2, 0, p3*0.8, 0
+ aL = a1 * kamp
+ aR = a2 * kamp
+ aL butterhp aL, 150
+ aR butterhp aR, 150
+ bus_mix("master", aL, aR)
+endin
+
+instr play_blip
+ a1 oscil 0.6, 4400
+ kamp line 1, p3, 0
+ a1 *= kamp
+
+ bus_mix("delay2", a1, a1)
+endin
+
+
+instr play_clap
+ iamp = bid_getparameter(p4, p5, 2)
+ aL noise 1, 0.3
+ aR noise 1, 0.4
+ aL butterbp aL, 1200, 700
+ aR butterbp aR, 1200, 700
+ aL taninv aL*7
+ aR taninv aR*7
+
+ kamp linseg 2, p3, 0
+ aL *= kamp * iamp
+ aR *= kamp * iamp
+ bus_mix("master", aL, aR)
+
+endin
+
+instr play_hat1
+ iamp = bid_getparameter(p4, p5, 2)
+ idel = random(0.001, 0.02)
+ xtratim idel
+ p3 = random(0.02, 0.1)
+ kfreq line 300, p3, 100
+ aenv expsega .1, .0005, 1, p3 - .0005, .01
+ asqr1 oscil 1, kfreq, gifnSquare, -1
+ asqr2 oscil 1, kfreq*1.4471, gifnSaw, -1
+ asqr3 oscil 1, kfreq*1.6170, gifnSaw, -1
+ asqr4 oscil 1, kfreq*1.9265, gifnSaw, -1
+ asqr5 oscil 1, kfreq*2.5028, gifnSaw, -1
+ asqr6 oscil 1, kfreq*2.6637, gifnSaw, -1
+ a808 sum asqr1, asqr2, asqr3, asqr4, asqr5, asqr6
+ a808 butterhp a808, 4270
+ a808 butterhp a808, 4270
+ aout = a808 * aenv * iamp * 0.5
+ aout delay aout, idel
+ bus_mix("master", aout, aout)
+endin
+
+instr play_hat2
+ iamp = bid_getparameter(p4, p5, 2)
+ ixtend = bid_getparameter(p4, p5, 4)
+ idel1 = random(0.005, 0.02)
+ idel2 = random(0.005, 0.02)
+ xtratim(max(idel1, idel2))
+ if (ixtend == 0) then
+ p3 = 0.1
+ endif
+
+ kfreq line 800, p3, 300
+ aenv expsega .1, .0005, 1, p3 - .0005, .01
+ asqr1 oscil 1, kfreq, gifnSquare, -1
+ asqr2 oscil 1, kfreq*1.4471, gifnSquare, -1
+ asqr3 oscil 1, kfreq*1.6170, gifnSquare, -1
+ asqr4 oscil 1, kfreq*1.9265, gifnSquare, -1
+ asqr5 oscil 1, kfreq*2.5028, gifnSaw, -1
+ asqr6 oscil 1, kfreq*2.6637, gifnSaw, -1
+ a808 sum asqr1, asqr2, asqr3, asqr4, asqr5, asqr6
+ a808 butterhp a808, 3270
+ a808 butterhp a808, 3270
+ aout = a808 * aenv * iamp * 1.1
+ aL delay aout, idel1
+ aR delay aout, idel2
+ if (i(gksection) == 1 && random(0, 1) > 0.7) then
+ bus_mix("delay2", aL*0.4, aR*0.4)
+ endif
+ bus_mix("master", aL, aR)
+endin
+
+
+/*
+ Blocky square-ish sounding FM bass
+*/
+instr play_mel1
+ iamp = bid_getparameter(p4, p5, 2)
+ inote1 = tab_i(ftlen(gibid_chordfn) - 3, gibid_chordfn)
+ inote2 = tab_i(ftlen(gibid_chordfn) - 4, gibid_chordfn)
+ a1 foscil 0.46, cpsmidinn(inote1), 1, 2, 1, gifnSine
+ a2 foscil 0.46, cpsmidinn(inote2), 1, 2, 1, gifnSine
+ a1 += a2
+ a1 butterhp a1, 130
+ kenv linseg 1, p3*0.1, 0.6, p3*0.5, 0.4, p3*0.4, 0
+ aout = a1*kenv*iamp*2
+ aL, aR pan2 aout, random(0, 1)
+ bus_mix("master", aL, aR)
+ if (random(0, 1) > 0.77) then
+ bus_mix("delay1", aL*0.9, aR*0.9)
+ endif
+endin
+
+
+instr play_kick ; 808 style kick
+ iamp = bid_getparameter(p4, p5, 2)
+
+ idist = 0.5 ;= (i(gksection) == 1) ? 0.55 : 0.35
+ xtratim 0.1
+ krelease release
+ ktune init 0
+ kmul transeg 0.2, p3*0.5, -15, 0.01, p3*0.5, 0, 0
+ kbend transeg 0.5, 1.2, -4, 0, 1, 0, 0
+ asig gbuzz 0.5, 50*octave(ktune)*semitone(kbend), 20, 1, kmul, gifnCosine
+ aenv transeg 1, p3-0.004, -6, 0
+ gkpump = k(aenv)
+ aatt linseg 0, 0.004, 1
+ asig = asig*aenv*aatt
+ aenv linseg 1, 0.07, 0
+ acps expsega 400, 0.07, 0.001, 1, 0.001
+ aimp oscili aenv, acps*octave(ktune*0.25)
+ amix = ((asig*0.7)+(aimp*0.35))*2*iamp
+ gkpump = min(rms(amix) * 7, 1)
+ aout1 pareq amix, 100, 0.01, 0.7
+ aout1 distort aout1, idist, gifnSquare
+ aout1 pareq aout1, 50, 2, 0.4
+ aout1 pareq aout1, 190, 0.7, 0.6
+ aout1 pareq aout1, 4900, 2, 0.7
+ aout1 pareq aout1, 8900, 2, 0.7
+ aout1 *= 2
+ bus_mix("master", aout1, aout1)
+endin
+
+instr play_kick2
+ iamp = bid_getparameter(p4, p5, 2)
+ xtratim 0.1
+ krelease release
+ ktune init 1
+ ifn = gibid_chordgroups[1][1] ; gibid_chordfn
+ ifreq = cpsmidinn(tab_i(1, ifn) - 18) * 0.1
+ kmul transeg 0.2, p3*0.5, -15, 0.01, p3*0.5, 0, 0
+ kbend transeg 0.5, 1.2, -4, 0, 1, 0, 0
+ asig gbuzz 0.5, ifreq, 20, 1, kmul, gifnCosine
+ aenv transeg 1, p3-0.004, -6, 0
+ aatt linseg 0, 0.004, 1
+ asig = asig*aenv*aatt
+ aenv linseg 1, 0.07, 0
+ acps expsega 400, 0.07, 0.001, 1, 0.001
+ aimp oscili aenv, acps*octave(ktune*0.25)
+ amix = ((asig*0.7)+(aimp*0.35))*2*iamp
+ aout1 pareq amix, 100, 0.01, 0.6
+ aout1 distort aout1, 0.6, gifnSaw
+ aout1 pareq aout1, 100, 0.8, 0.3
+ aout1 butterhp aout1, 30
+ aout1 *= 3.6
+ ;aout1 *= 1-gkpump
+ bus_mix("master", aout1, aout1)
+endin
+
+
+instr play_shaker
+ iamp = bid_getparameter(p4, p5, 2)
+ idel1 = random(0.005, 0.02)
+ idel2 = random(0.005, 0.02)
+ xtratim(max(idel1, idel2))
+ p3 = 0.05
+ kfreq line 700, p3, 300
+ aenv expsega .1, .0005, 1, p3 - .0005, .01
+ asqr1 oscil 1, kfreq, gifnSaw, -1
+ asqr2 oscil 1, kfreq*1.4471, gifnSaw, -1
+ asqr3 oscil 1, kfreq*1.6170, gifnSaw, -1
+ asqr4 oscil 1, kfreq*1.9265, gifnSaw, -1
+ asqr5 oscil 1, kfreq*2.5028, gifnSine, -1
+ asqr6 oscil 1, kfreq*2.6637, gifnSine, -1
+ a808 sum asqr1, asqr2, asqr3, asqr4, asqr5, asqr6
+ a808 butterhp a808, 2270
+ a808 butterhp a808, 2270
+ aout = a808 * aenv * iamp * 0.9 * (1-gkpump)
+ aL delay aout, idel1
+ aR delay aout, idel2
+ bus_mix("master", aL, aR)
+ bus_mix("delay3", aL*0.25, aR*0.25)
+endin
+
+
+instr play_snare
+ icps0 = 211
+ iamp = bid_getparameter(p4, p5, 2)
+ p3 = random(0.03, 0.1)
+ icps1 = 2.0 * icps0
+ kcps port icps0, 0.007, icps1
+ kcpsx = kcps * 1.5
+
+ kfmd port 0.0, 0.01, 0.7
+ aenv1 expon 1.0, 0.03, 0.5
+ kenv2 port 1.0, 0.008, 0.0
+ aenv2 interp kenv2
+ aenv3 expon 1.0, 0.025, 0.5
+
+ a_ oscili 1.0, kcps
+ a1 oscili 1.0, kcps * (1.0 + a_*kfmd)
+ a_ oscili 1.0, kcpsx
+ a2 oscili 1.0, kcpsx * (1.0 + a_*kfmd)
+
+ a3 unirand 2.0
+ a3 = a3 - 1.0
+ a3 butterbp a3, 3200, 1500
+ a3 = a3 * aenv2
+
+ a0 = a1 + a2*aenv3 + a3*1.0
+ a0 = a0 * aenv1
+ a0 butterhp a0, 210
+ aout = a0 * iamp * 1.4
+ bus_mix("master", aout, aout)
+
+endin
+
+
+/*
+ Convenience opcode for playing current chord on given instrument, passing p4 as note and p5 as amp
+
+ chordinstrument Sinstrument
+
+ Sinstrument the instrument name
+ ipos position in pattern
+ idataindex section specific data index; pointer to ftable
+*/
+opcode chordinstrument, 0, Sii
+ Sinstrument, ipos, idataindex xin
+ iamp = bid_getparameter(ipos, idataindex, 2)
+ index = 1 ; index 0 is chordgroup length
+ while (index < ftlen(gibid_chordfn)) do
+ event_i "i", Sinstrument, 0, p3, tab_i(index, gibid_chordfn), iamp
+ index += 1
+ od
+
+endop
+
+
+/*
+ Housey organ, internal use
+*/
+instr chord1
+ inote = p4
+ iamp = p5
+ aL fmpercfl 0.65, cpsmidinn(inote), 1, 2, 0.1, 10, gifnSine, gifnSquare, gifnSine, gifnSquare, gifnSine
+ aR fmpercfl 0.65, cpsmidinn(inote), 1, 1.4, 0.2, 10, gifnSine, gifnSaw, gifnSine, gifnSquare, gifnSine
+ aL butterhp aL, 340
+ aR butterhp aR, 340
+ aL butterlp aL, 4000
+ aR butterlp aR, 4000
+ kenv linseg 1, p3*0.5, 1, p3*0.4, 1, p3*0.1, 0
+ aL *= kenv
+ aR *= kenv
+ bus_mix("master", aL, aR)
+endin
+
+
+/*
+ Play chord1 above, called from BID
+*/
+instr play_chord1
+ chordinstrument "chord1", p4, p5
+ turnoff
+endin
+
+
+instr chord2NOTUSED
+ inote = p4
+ iamp = p5
+ ilower = p6
+ if (ilower == 1) then
+ inote -= 12
+ else
+ inote -= 12
+ endif
+
+ aphs1 phasor cpsmidinn(inote)
+ a1 tablei aphs1, gifnSine, 1, 0, 1
+ a1 *= linseg(1, p3*0.9, 0)
+
+ av1L linseg 3, p3, 0
+ aL tablei (aphs1+a1)+av1L, gifnSine, 1, 0, 1
+
+ av1R linseg 4, p3, 0
+ aR tablei (aphs1+a1)+av1R, gifnSine, 1, 0, 1
+ kenv line 1, p3, 0
+ aL *= 0.2 * kenv
+ aR *= 0.2 * kenv
+ aL butterhp aL, 290
+ aR butterhp aR, 290
+
+ bus_mix("master", aL, aR)
+endin
+
+instr play_crash
+ iamp = 1 ;bid_getparameter(p4, p5, 2)
+ kfreq line 5000, p3, 2000
+ aenv expsega .1, .0005, 1, p3 - .0005, .01
+ asqr1 oscil 1, kfreq, gifnSquare, -1
+ asqr2 oscil 1, kfreq*1.4471, gifnSine, -1
+ asqr3 oscil 1, kfreq*1.6170, gifnSine, -1
+ asqr4 oscil 1, kfreq*1.9265, gifnSine, -1
+ asqr5 oscil 1, kfreq*2.5028, gifnSine, -1
+ asqr6 oscil 1, kfreq*2.6637, gifnSine, -1
+ aL butterhp asqr1+asqr3+asqr5, 3270
+ aR butterhp asqr2+asqr4+asqr6, 3270
+ aL *= aenv * iamp * 0.4
+ aR *= aenv * iamp * 0.4
+ bus_mix("master", aL, aR)
+ bus_mix("delay1", aL, aR)
+endin
+
+
+instr chord2
+ inote = p4
+ iamp = p5
+ ilower = p6
+ iamp = 0.55
+ if (ilower == 1) then
+ iamp = 1
+ else
+ inote += 12
+ endif
+ kfmod oscil 10, 6
+ kfl linseg 1, p3*0.8, 1, p3*0.2, 0.1
+ aL fmpercfl iamp, (cpsmidinn(inote)+kfmod)*kfl*0.5, 1, 2, 0.6, 10, gifnSine, gifnSquare, gifnSine, gifnSquare, gifnSine
+ aR fmpercfl iamp, (cpsmidinn(inote)+kfmod)*kfl*0.5, 1, 1.4, 0.9, 10, gifnSine, gifnSaw, gifnSine, gifnSquare, gifnSine
+ aL butterhp aL, 540
+ aR butterhp aR, 540
+ kenv line 0, p3, 1
+ aL *= kenv
+ aR *= kenv
+ bus_mix("master", aL, aR)
+endin
+
+
+/*
+ Play chord2 above, called from BID
+*/
+instr play_chord2
+ iamp = bid_getparameter(p4, p5, 2)
+ ilower = bid_getparameter(p4, p5, 4)
+ index = 1 ; index 0 is chordgroup length
+ while (index < ftlen(gibid_chordfn)) do
+ event_i "i", "chord2", 0, p3, tab_i(index, gibid_chordfn), iamp, ilower
+ index += 1
+ od
+ turnoff
+endin
+
+
+instr chord3
+ inote = p4 - 12
+ iamp = p5
+ ifreq = cpsmidinn(inote)
+ kfreq linseg 10, p3*0.4, ifreq, p3*0.6, ifreq
+ aL fmb3 0.65, kfreq, 1, random(1.2, 2.2), random(0.1, 0.3), random(5, 15), gifnSine, gifnSquare, gifnSine, gifnSquare, gifnSine
+ aR fmb3 0.65, kfreq, 1, random(1.2, 2.2), random(0.1, 0.3), random(5, 15), gifnSine, gifnSaw, gifnSine, gifnSquare, gifnSine
+ aL butterhp aL, 340
+ aR butterhp aR, 340
+
+ kenv linseg 1, p3*0.95, 1, p3*0.05, 0
+ aL *= kenv
+ aR *= kenv
+ bus_mix("master", aL, aR)
+endin
+
+/*
+ Play chord3 above, called from BID
+*/
+instr play_chord3
+ chordinstrument "chord3", p4, p5
+ turnoff
+endin
+
+
+;glitch sampler vars
+giglitchsamples = 44100
+giglitchbufferL ftgen 0, 0, giglitchsamples, 7, 0
+giglitchbufferR ftgen 0, 0, giglitchsamples, 7, 0
+instr play_glitchread
+ iamp = bid_getparameter(p4, p5, 2)
+ ifreq = cpsmidinn(tab_i(random(1, ftlen(gibid_chordfn) - 1), gibid_chordfn))
+ ilen = ((1/(ifreq))*sr)*pow(2, round(random(0, 4)))
+ istart random 0, giglitchsamples-ilen
+ awindex phasor giglitchsamples / ilen
+ aL table awindex*giglitchsamples, giglitchbufferL
+ aR table awindex*giglitchsamples, giglitchbufferR
+ aL butterhp aL, 350
+ aR butterhp aL, 350
+ aL *= 0.4 * iamp
+ aR *= 0.4 * iamp
+ if (random(0, 1) > 0.7) then
+ if (random(0, 1) > 0.5) then
+ bus_mix("delay1", aL, aR)
+ else
+ bus_mix("delay2", aL, aR)
+ endif
+ endif
+ bus_mix("master", aL, aR)
+endin
+
+
+#end
diff --git a/BUG6/txt_tools.udo b/BUG6/txt_tools.udo
new file mode 100644
index 0000000..eb0cc86
--- /dev/null
+++ b/BUG6/txt_tools.udo
@@ -0,0 +1,82 @@
+#ifndef UDO_TXTTOOLS
+#define UDO_TXTTOOLS ##
+/*
+ Debugger - Unfixed Bugs : BUG #3
+
+ Text tools
+*/
+
+
+/*
+ Print a notification prepended with a line of asterisks
+
+ tt_notify Stext
+
+ Stext text to print
+*/
+opcode tt_notify, 0, S
+ Stext xin
+ Snew = "\n"
+ iwidth = 60
+ index = 0
+ while (index < iwidth) do
+ Snew = strcat(Snew, "*");
+ index += 1
+ od
+ prints strcat(strcat(Snew, "\n"), strcat(Stext, "\n\n"))
+endop
+
+
+
+/*
+ Print a notification prepended with a line of asterisks and exit
+
+ tt_notify Stext
+
+ Stext text to print
+*/
+opcode tt_notify_fatal, 0, S
+ Stext xin
+ tt_notify(Stext)
+ exitnow
+endop
+
+
+/*
+ Return a number of seconds as HH:MM:SS format
+
+ Stime tt_parsetime iseconds
+
+ iseconds seconds to parse
+
+ Stime formatted time
+
+*/
+opcode tt_parsetime, S, i
+ input xin
+ ihours = floor(input / 3600)
+ iminutes = floor((input - (ihours * 3600)) / 60)
+ iseconds = input - (ihours * 3600) - (iminutes * 60)
+ xout sprintf("%02d:%02d:%05.2f", ihours, iminutes, iseconds)
+endop
+
+
+/*
+ Strip newline from end of line: built-in opcode has some problems
+
+ Soutput tt_stripnewline Sinput
+
+ Soutput processed without newline at end if existent
+
+ Sinput line to process
+*/
+opcode tt_stripnewline, S, S
+ Sline xin
+ index = strindex(Sline, "\n")
+ if (index != -1) then
+ Sline = strsub(Sline, 0, index)
+ endif
+ xout Sline
+endop
+
+#end
diff --git a/BUG6/wavetables.udo b/BUG6/wavetables.udo
new file mode 100644
index 0000000..e81f075
--- /dev/null
+++ b/BUG6/wavetables.udo
@@ -0,0 +1,16 @@
+#ifndef UDO_WAVETABLES
+#define UDO_WAVETABLES ##
+/*
+ Debugger - Unfixed Bugs : BUG #3
+
+ General waveforms
+*/
+
+ipoints = 16384
+gifnCosine ftgen 0, 0, ipoints, 9, 1, 1, 90
+gifnSine ftgen 0, 0, ipoints, 10, 1
+gifnSquare ftgen 0, 0, ipoints, 10, 1, 0, 0.3, 0, 0.2, 0, 0.14, 0, .111
+gifnSaw ftgen 0, 0, ipoints, 10, 0, .2, 0, .4, 0, .6, 0, .8, 0, 1, 0, .8, 0, .6, 0, .4, 0, .2
+
+#end
+
diff --git a/BUG7/BUG7.csd b/BUG7/BUG7.csd
new file mode 100644
index 0000000..b1b478e
--- /dev/null
+++ b/BUG7/BUG7.csd
@@ -0,0 +1,192 @@
+<CsoundSynthesizer>
+<CsOptions>
+-odac
+-m0
+</CsOptions>
+<CsInstruments>
+/*
+ Debugger - Unfixed Bugs : BUG #7
+
+ http://git.1bpm.net/csd-unfixedbugs1/about/
+
+ By Richard Knight 2021
+ http://1bpm.net
+ q@1bpm.net
+
+*/
+
+sr = 44100
+ksmps = 10
+nchnls = 2
+0dbfs = 1
+seed 0
+
+#define NOFILEIO ## ; file IO with readfi not supported on all platforms: disables bid_loadfile
+
+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
+ itm = gibid_beattime
+ aL, aR bus_read "delay1"
+ aL multitap aL, itm/2, random(0.1, 0.5), itm/4, random(0.1, 0.5), itm*2, random(0.1, 0.5)
+ aR multitap aL, itm, random(0.1, 0.5), itm*3, random(0.1, 0.5), itm/8, random(0.1, 0.5)
+ bus_mix("master", aL*0.8, aR*0.8)
+endin
+
+/*
+ Master audio output
+*/
+instr global_master
+ igain = 1
+ aL, aR bus_read "master"
+
+ itime1 = tab_i(1, gibid_sectionlengths)*gibid_beattime
+
+ aclapL, aclapR bus_read "clap"
+ acofferL, acofferR bus_read "coffer"
+ akickL, akickR bus_read "kick"
+ ahat1L, ahat1R bus_read "hat1"
+ arimL, arimR bus_read "rim"
+ kclapamp init 0
+ kcofferamp init 0
+ if (gksection == 1) then
+ kclapamp linseg 0, itime1*0.6, 1, itime1*0.4, 1
+ kcofferamp line 0, itime1, 1
+ krevamp linseg 1, itime1*0.1, 0, itime1*0.9, 0
+
+ arL, arR freeverb aL*2, aR*2, 0.9, 0.9
+ ir = 512
+ fL pvsanal arL, ir, ir/4, ir, 1
+ fR pvsanal arR, ir, ir/4, ir, 1
+ kshift = line(1000, itime1*0.1, 0)
+ kshifto = abs(oscil(100, 10))
+ f1L pvshift fL, kshift+kshifto, 300
+ f1R pvshift fR, kshift+kshifto, 300
+ arL pvsynth f1L
+ arR pvsynth f1R
+ aL = (krevamp*arL) + ((1-krevamp)*aL)
+ aR = (krevamp*arR) + ((1-krevamp)*aR)
+
+
+ endif
+ aL += (aclapL * kclapamp) + (acofferL * kcofferamp) + (akickL * kclapamp) + (ahat1L * kcofferamp) + (arimL * kcofferamp)
+ aR += (aclapR * kclapamp) + (acofferR * kcofferamp) + (akickR * kclapamp) + (ahat1R * kcofferamp) + (arimR * kcofferamp)
+
+
+ aL limit aL*0.5, -1, 1
+ aR limit aR*0.5, -1, 1
+ outs aL*gkmastergain*igain, aR*gkmastergain*igain
+endin
+
+
+/*
+ Print notification of performance time since last notification
+ or if isection is -1, print completion notification
+*/
+gitimetrack times
+instr notify_change
+ isection = p4
+ itime times
+ if (isection == -1) then
+ tt_notify(sprintf"Complete, runtime: %s", tt_parsetime(itime)))
+ exitnow
+ else
+ isectiontime = itime - gitimetrack
+ tt_notify(sprintf("%s : section %d complete in %s", tt_parsetime(itime), isection, tt_parsetime(isectiontime)))
+ gitimetrack = itime
+ endif
+ turnoff
+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_master", 0, p3
+ event_i "i", "global_delay1", 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
+ event "i", "notify_change", p3, 1, -1
+ turnoff
+ endif
+
+ bid_seq "kick", kpos, ksection
+ bid_seq "koffer", kpos, ksection
+ bid_seq "clap", kpos, ksection
+ bid_seq "hat1", kpos, ksection
+ bid_seq "3031", kpos, ksection
+ bid_seq "3032", kpos, ksection
+ ;bid_seq "hat2", kpos, ksection
+ bid_seq "rim", kpos, ksection
+
+
+ kpos = (kpos < 31) ? kpos + 1 : 0
+ ksection16ths = bid_getsectionlength(ksection) * 4
+
+ if (kposabs+1 < ksection16ths) then
+ kposabs += 1
+ else
+ event "i", "notify_change", 0, 1, ksection
+ ;event "i", "play_crash", 0, gibid_beattime*4
+ 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
+
+</CsInstruments>
+<CsScore>
+i"parseandrun" 0 1
+</CsScore>
+</CsoundSynthesizer> \ No newline at end of file
diff --git a/BUG7/basis.csd b/BUG7/basis.csd
new file mode 100644
index 0000000..ff5b2c5
--- /dev/null
+++ b/BUG7/basis.csd
@@ -0,0 +1,62 @@
+<CsoundSynthesizer>
+<CsOptions>
+-odac
+</CsOptions>
+<CsInstruments>
+sr = 44100
+kr = 4410
+nchnls = 2
+0dbfs = 1
+seed 0
+gifnSine = 1
+
+instr rim
+ icps = p4 ;1000
+ acps expon icps, 0.0025, icps * 0.5
+ acps = acps + icps
+ iamp = 0.1
+ a1a phasor acps, 0
+ a1b phasor acps, random(0, 1)
+ afmenv expon 1.0, 0.02, 0.4
+ a1 = (a1a-a1b)*random(1, 10)*afmenv
+ acps = acps*(1.0+a1)
+ a0 oscil3 1.0, acps
+ aenv expon 1.0, 0.005, 0.5
+ a0 limit 4.0*a0*aenv, -1.0, 1.0
+ a0 butterhp a0, 230
+ aL, aR pan2 a0*iamp, random(0.3, 0.8)
+ outs aL, aR
+endin
+
+instr play_rim
+ if (random:k(0, 1) > 0.3) then
+ event "i", "play_rim", 0, 0.4, 3000
+ endif
+ if (random:k(0, 1) > 0.3) then
+ event "i", "play_rim", 0, 0.4, 1000
+ endif
+ if (random:k(0, 1) > 0.3) then
+ event "i", "play_rim", 0, 0.4, 2000
+ endif
+ if (random:k(0, 1) > 0.3) then
+ event "i", "play_rim", 0, 0.4, 500
+ endif
+ if (random:k(0, 1) > 0.3) then
+ event "i", "play_rim", 0, 0.4, 2500
+ endif
+ if (random:k(0, 1) > 0.3) then
+ event "i", "play_rim", 0, 0.4, 3500
+ endif
+endin
+
+
+</CsInstruments>
+<CsScore>
+i1 0 100
+f1 0 16384 10 1 ; Sine
+f2 0 16384 10 1 0.5 0.3 0.25 0.2 0.167 0.14 0.125 .111 ; Sawtooth
+f3 0 16384 10 1 0 0.3 0 0.2 0 0.14 0 .111 ; Square
+f4 0 16384 10 1 1 1 1 0.7 0.5 0.3 0.1 ; Pulse
+
+</CsScore>
+</CsoundSynthesizer> \ No newline at end of file
diff --git a/BUG7/bid.udo b/BUG7/bid.udo
new file mode 100644
index 0000000..17e9be2
--- /dev/null
+++ b/BUG7/bid.udo
@@ -0,0 +1,425 @@
+#ifndef UDO_BID
+#define UDO_BID ##
+/*
+ Debugger - Unfixed Bugs : BUG #5
+
+ Bug Infested Directive file parser v1 and tools
+
+ Designed to create a reusable loop based score format in the Unfixed Bugs project and beyond.
+*/
+
+
+#define BID_VERSION #1.1#
+
+#include "txt_tools.udo"
+
+; globals
+gibid_tempo init -1 ; beats per minute
+gibid_beattime init -1 ; time of one beat in second
+gibid_maxsection init -1 ; max number of sections
+gibid_chordfn init -1 ; current chord ftable
+gkbid_chordlength init -1 ; current chord length
+
+; BID internals
+gibid_sectionlengths ftgen 0, 0, -64, -7, 0 ; section lengths
+gibid_sections[][] init 64, 64 ; section pointers to data
+gibid_sectiondata[][] init 99, 6 ; section data, ftables contained
+
+gibid_chordgroups[][] init 16, 12 ; chord groups, pointers to sectionchords by section
+gibid_sectionchords[] init 16 ; ftables of section chords
+
+gibid_currentchordnum = 0 ; current chord number
+gibid_lastchordgroup = -1 ; last chord group
+gibid_lastsection = -1 ; last section
+
+gSbid_sequenced[] init 1 ; internal tracking of sequenced elements
+gibid_sequenceinit init 1 ; internal tracking of sequenced init
+gibid_swingtime init -1 ; swing time calculated from percent
+
+/*
+ Get BID instrument index, creating new reference if specified.
+ Internal use only.
+
+ index _bid_gettextindex Sname, [iaddifnotexists = -1]
+
+ index BID instrument index
+
+ Sname name to look up or create
+ iaddifnotexists 1=create , default=fatal if not exists
+*/
+opcode _bid_gettextindex, i, Sj
+ Sname, iaddifnotexists xin
+ ifinalindex = -1
+ index = 0
+ while (index < lenarray(gSbid_sequenced)) do
+ if (strcmp(gSbid_sequenced[index], Sname) == 0) then
+ ifinalindex = index
+ igoto complete
+ endif
+ index += 1
+ od
+
+ if (iaddifnotexists == 1) then
+ if (gibid_sequenceinit == 1) then
+ gibid_sequenceinit = 0
+ SequencedNew[] fillarray Sname
+ ifinalindex = 0
+ else
+ SequencedNew[] init lenarray(gSbid_sequenced) + 1
+ index = 0
+ while (index < lenarray(gSbid_sequenced)) do
+ SequencedNew[index] = gSbid_sequenced[index]
+ index += 1
+ od
+ SequencedNew[index] = Sname
+ ifinalindex = index
+ endif
+ gSbid_sequenced = SequencedNew
+ igoto complete
+ else
+ tt_notify_fatal(sprintf("Sequenced index for '%s' not found", Sname))
+ endif
+
+complete:
+ xout ifinalindex
+endop
+
+
+
+/*
+ Parse a row of comma-separated numerical values of either patterns or chords.
+ Internal use only.
+
+ inum _bid_parserowitems Sline, ix1, ix2, imode
+
+ inum number of elements found parsed
+
+ Sline input line
+ ix1 array dimension 1 index
+ ix2 array dimension 2 index
+ imode 0=count elements; 1=write patterns; 2=write chords
+*/
+opcode _bid_parserowitems, i, Siii
+ Sline, ix1, ix2, imode xin
+ inum = 0
+ while (strlen(Sline) > 0) do
+ icomma = strindex(Sline, ",")
+ Stemp = strsub(Sline, 0, icomma)
+ icomma = (icomma == -1) ? 0 : icomma
+ Sline = strsub(Sline, icomma + 1)
+ if (imode == 1) then
+ tabw_i strtod(Stemp), inum, gibid_sectiondata[ix1][ix2]
+ elseif (imode == 2) then
+ tabw_i strtod(Stemp), inum, gibid_chordgroups[ix1][ix2]
+ endif
+ inum += 1
+ od
+ xout inum
+endop
+
+
+/*
+ Read BID data for specified element and trigger accordingly.
+
+ bid_seq Splayer, kposition, ksection
+
+ Splayer name of BID element
+ kposition position in pattern provided by master sequencer
+ ksection section in composition provided by master sequencer
+
+*/
+opcode bid_seq, 0, Skk
+ Splayer, kpos, ksection xin
+ Sinstrument = sprintf("play_%s", Splayer)
+ instrindex = _bid_gettextindex(Splayer)
+ kdata = gibid_sections[ksection][instrindex]
+
+ if (kdata != -1) then ; null section
+ kon = tablekt:k(kpos, gibid_sectiondata[kdata][0])
+
+ if (kon == 1) then
+ kchance = tablekt:k(kpos, gibid_sectiondata[kdata][3])
+ if (random:k(0, 1) < kchance) then
+ ktime = (kpos % 2 == 0) ? 0 : gibid_swingtime
+ kdur = tablekt:k(kpos, gibid_sectiondata[kdata][1]) * gibid_beattime
+ ;kamp = tablekt:k(kpos, gisectiondata[kdata][2])
+ event "i", Sinstrument, ktime, kdur, kpos, kdata
+ endif
+ endif
+ endif
+endop
+
+
+/*
+ Get a parameter for the specified pattern position.
+ ipos and idataindex are provided as p4 and p5 to instruments scheduled by bid_seq,
+ hence can typically used as bid_getparameter(p4, p5, iparameter)
+
+ idata bid_getparameter ipos, idataindex, iparameter
+
+ idata the resulting value
+
+ ipos position in pattern
+ idataindex section specific data index; pointer to ftable
+ iparameter parameter index as in BID file; defaults include 0=on/off, 1=duration, 2=amp, 3=chance
+
+*/
+opcode bid_getparameter, i, iii
+ ipos, idataindex, iparameter xin
+ xout tab_i(ipos, gibid_sectiondata[idataindex][iparameter])
+endop
+
+
+/*
+ Get a section length in beats
+
+ klength bid_getsectionlength ksection
+
+ klength length in beats
+
+ ksection section to look up
+*/
+opcode bid_getsectionlength, k, k
+ ksection xin
+ xout tab:k(ksection, gibid_sectionlengths)
+endop
+
+/*
+ Parse a row of comma-separated values to either section patterns or chord storage.
+ Scans row, assigns ftable of appropriate length and then fills ftable.
+ Internal use only.
+
+ _bid_parserow Sline, ix1, ix2, imode
+
+ Sline line to parse
+ ix1 array dimension 1 index of target storage
+ ix2 array dimension 2 index of target storage
+ imode 1=section patterns, 2=chords
+*/
+opcode _bid_parserow, 0, Siii
+ Sline, ix1, ix2, imode xin
+ isize = _bid_parserowitems(Sline, ix1, ix2, 0)
+ if (imode == 1) then
+ gibid_sectiondata[ix1][ix2] ftgen 0, 0, -isize, -7, 0
+ elseif (imode == 2) then
+ gibid_chordgroups[ix1][ix2] ftgen 0, 0, -isize, -7, 0
+ endif
+ isize = _bid_parserowitems(Sline, ix1, ix2, imode)
+endop
+
+
+
+/*
+ Parse a line from a BID string
+ Internal use only.
+
+ idataout[] _bid_parseline Sline, idatain[]
+
+ idataout[] state data
+
+ Sline line to parse
+ idatain[] state data
+
+*/
+opcode _bid_parseline, i[], Si[]
+ Sline, idata[] xin
+ iparameter = idata[0]
+ isection = idata[1]
+ ichordnum = idata[2]
+ isectiondataindex = idata[3]
+ imode = idata[4]
+
+ if (strlen(Sline) > 0) then
+ Sfirstchar = strsub(Sline, 0, 1)
+
+ ; comment
+ if (strcmp(Sfirstchar, ";") == 0) then
+ ; no action
+
+ ; version check
+ elseif (strcmp(Sfirstchar, "v") == 0) then
+ imode = 0
+ iversion = strtod(strsub(Sline, 2))
+ if (iversion != $BID_VERSION) then
+ tt_notify(sprintf("Incompatible BID file version: got %.2f , expected %.2f", iversion, $BID_VERSION))
+ exitnow
+ endif
+
+ ; section header
+ elseif (strcmp(Sfirstchar, "s") == 0) then
+ imode = 1
+ icomma = strindex(Sline, ",")
+ isectionnum = strtod(strsub(Sline, 2, icomma))
+ Sub = strsub(Sline, icomma+1)
+ icomma = strindex(Sub, ",")
+ isectionlength = strtod(strsub(Sub, 0, icomma))
+ ichordgroup = strtod(strsub(Sub, icomma+1))
+ gibid_sectionchords[isectionnum] = ichordgroup
+ tabw_i isectionlength, isectionnum, gibid_sectionlengths
+
+ ; tempo
+ elseif (strcmp(Sfirstchar, "b") == 0) then
+ imode = -1
+ icomma = strindex(Sline, ",")
+ gibid_tempo = strtod(strsub(Sline, 2, icomma))
+ gibid_beattime = 60 / gibid_tempo
+ iswingpercent = strtod(strsub(Sline, icomma+1))
+ gibid_swingtime = ((gibid_beattime/4)/100) * iswingpercent
+
+ ; chord group header
+ elseif (strcmp(Sfirstchar, "c") == 0) then
+ imode = 3
+ ichordgroup = strtod(strsub(Sline, 2))
+ ichordnum = 0
+
+ ; pattern header
+ elseif (strcmp(Sfirstchar, "i") == 0) then
+ imode = 4
+ iparameter = 0
+
+ icomma = strindex(Sline, ",")
+ instrindex = _bid_gettextindex(strsub(Sline, 2, icomma), 1)
+ Sub = strsub(Sline, icomma+1)
+ icomma2 = strindex(Sub, ",")
+ isection = strtod(strsub(Sub, 0, icomma2))
+ if (isection > gibid_maxsection) then
+ gibid_maxsection = isection
+ endif
+ if (icomma2 != -1) then ; repeat or null section
+ irepeatsection = strtod(strsub(Sub, icomma2+1))
+ if (irepeatsection == -1) then
+ inewsection = -1
+ else
+ inewsection = gibid_sections[irepeatsection][instrindex]
+ endif
+ gibid_sections[isection][instrindex] = inewsection
+ else
+ isectiondataindex += 1
+ gibid_sections[isection][instrindex] = isectiondataindex
+ endif
+
+ ; chord row
+ elseif (imode == 3) then
+ _bid_parserow(Sline, ichordgroup, ichordnum, 2)
+ ichordnum += 1
+
+ ; pattern row
+ elseif (imode == 4) then
+ _bid_parserow(Sline, isectiondataindex, iparameter, 1)
+ iparameter += 1
+ endif
+ endif
+ idata[0] = iparameter
+ idata[1] = isection
+ idata[2] = ichordnum
+ idata[3] = isectiondataindex
+ idata[4] = imode
+ xout idata
+endop
+
+
+/*
+ Parse a Bug Infested Directive Format string to global arrays, ftables and variables.
+ Handles patterns, tempo, chord groups and sections etc accordingly.
+
+ bid_loadtext Sfile, [imode = 0]
+
+ Stext directive data as string to parse
+*/
+opcode bid_loadtext, 0, S
+ Stext xin
+ idata[] fillarray -1, -1, -1, -1, -1
+read:
+ index = strindex(Stext, "\n")
+ if (index != -1) then
+ Sline = strsub(Stext, 0, index)
+ Stext = strsub(Stext, index + 1)
+ idata[] _bid_parseline Sline, idata
+
+ igoto read
+ else
+ igoto complete
+ endif
+
+complete:
+endop
+
+
+/*
+ Parse a Bug Infested Directive Format string to global arrays, ftables and variables.
+ Handles patterns, tempo, chord groups and sections etc accordingly.
+ Requires readfi support which is not available on all platforms. Platforms that do not support that
+ should set NOFILEIO.
+
+ bid_loadfile Sfile
+
+ Sfile directive file to parse
+*/
+opcode bid_loadfile, 0, S
+ Sfile xin
+#ifdef NOFILEIO
+ tt_notify_fatal("Attempting to use parsefile when NOFILEIO is set")
+#else
+ if (filevalid(Sfile) == 0) then
+ tt_notify(sprintf("Directive file cannot be found: '%s'", Sfile))
+ exitnow
+ endif
+ idata[] fillarray -1, -1, -1, -1, -1
+read:
+ Sline, ilinenum readfi Sfile
+ Sline = tt_stripnewline(Sline)
+
+ idata[] _bid_parseline Sline, idata
+
+ if (ilinenum != -1) igoto read
+#endif
+endop
+
+
+
+/*
+ Set the current chord given a section
+ p4 the section number
+ p5 0=start at beginning, 1=increment chord index
+*/
+instr bid_setcurrentchord
+ isection = p4
+ ichordincrement = p5
+ if (isection > gibid_maxsection) then
+ turnoff
+ endif
+
+ ichordgroup = gibid_sectionchords[isection]
+ if (ichordgroup != gibid_lastchordgroup || isection != gibid_lastsection) then
+ gibid_currentchordnum = 0
+ gibid_lastchordgroup = ichordgroup
+ gibid_lastsection = isection
+ elseif (ichordincrement == 1) then
+ if (gibid_currentchordnum + 1 < lenarray(gibid_chordgroups, 2) - 1) then
+ if (gibid_chordgroups[ichordgroup][gibid_currentchordnum + 1] == 0) then
+ gibid_currentchordnum = 0
+ else
+ gibid_currentchordnum += 1
+ endif
+ else
+ gibid_currentchordnum = 0
+ endif
+ else
+ gibid_currentchordnum = 0
+ endif
+
+ ifn = gibid_chordgroups[ichordgroup][gibid_currentchordnum]
+
+ if (ifn > 0) then
+ gkbid_chordlength = tab:k(0, ifn)
+ gibid_chordfn = ifn
+ endif
+
+ if (timeinstk() > 2) then
+ turnoff
+ endif
+endin
+
+
+#end
+
diff --git a/BUG7/bid_source.udo b/BUG7/bid_source.udo
new file mode 100644
index 0000000..bf034b4
--- /dev/null
+++ b/BUG7/bid_source.udo
@@ -0,0 +1,103 @@
+/*
+ Debugger - Unfixed Bugs : BUG #4
+
+ Bug Infested Directives source
+ Provided as a string due to readfi not being available on all platforms.
+ Used with bid_loadtext (whereas a separate file would be used with bid_loadfile and requires readfi support)
+*/
+
+SBID = {{
+; Bug Infested Directives : Debugger - Unfixed Bugs : BUG #7
+v 1.1
+
+; tempo, swing percent
+b 121, 27
+
+; chord groups
+c 1
+ 4, 59, 63, 67, 69, 71, 72, 75, 77, 79, 82
+ 4, 59, 63, 67, 69, 71, 72, 75, 77, 79, 82
+
+
+
+; sections: section number, length, chordgroup
+s 1, 256, 1
+s 2, 64, 1
+
+
+i glitchread, 1
+; 1 - - - 2 - - - 3 - - - 4 - - - 5 - - - 6 - - - 7 - - - 8 - - -
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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.3
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
+
+}}
diff --git a/BUG7/bussing.udo b/BUG7/bussing.udo
new file mode 100644
index 0000000..78755ce
--- /dev/null
+++ b/BUG7/bussing.udo
@@ -0,0 +1,62 @@
+#ifndef UDO_BUSSING
+#define UDO_BUSSING ##
+
+
+/*
+ Get the stereo L and R names for a singular bus name
+
+ SnameL, SnameR bus_name Sbus
+
+ SnameL left bus identifier
+ SnameR right bus identifier
+
+ Sbus bus name
+*/
+opcode bus_name, SS, S
+ Sbus xin
+ xout sprintf("%sL", Sbus), sprintf("%sR", Sbus)
+endop
+
+
+/*
+ Mix to a stereo bus
+
+ bus_mix Sbus, aL, aR
+
+ Sbus bus name
+ aL left channel
+ aR right channel
+*/
+opcode bus_mix, 0, Saa
+ Sbus, aL, aR xin
+ SbusL, SbusR bus_name Sbus
+ chnmix aL, SbusL
+ chnmix aR, SbusR
+endop
+
+
+
+/*
+ Read from a stereo bus, and then clear the bus
+
+ aL, aR bus_read Sbus
+
+ aL left channel
+ aR right channel
+
+ Sbus bus name
+*/
+opcode bus_read, aa, S
+ Sbus xin
+ SbusL, SbusR bus_name Sbus
+ aL chnget SbusL
+ aR chnget SbusR
+ chnclear SbusL
+ chnclear SbusR
+ xout aL, aR
+endop
+
+
+
+
+#end
diff --git a/BUG7/instruments.udo b/BUG7/instruments.udo
new file mode 100644
index 0000000..6c3bb31
--- /dev/null
+++ b/BUG7/instruments.udo
@@ -0,0 +1,272 @@
+#ifndef UDO_INSTRUMENTS
+#define UDO_INSTRUMENTS ##
+/*
+ Debugger - Unfixed Bugs : BUG #7
+
+ Sound generators
+ Names should correspond to those used in BID file, prepended with play_
+*/
+
+
+#include "wavetables.udo"
+#include "bussing.udo"
+#include "bid.udo"
+
+
+gi3031index = 1
+instr play_3031
+ iamp = bid_getparameter(p4, p5, 2)
+
+
+ inote1 = table(gi3031index, gibid_chordfn, 0, 0, 1)
+ if (gi3031index < 5) then
+ gi3031index += 1
+ else
+ gi3031index = 1
+ endif
+
+ ifilter = random(20, 40)
+
+ ifrq1 = 440 * exp(log(2) * (ifilter - 69) / 12) ; filter start freq.
+ kamp linseg 1, p3*0.8, 1, p3*0.2, 0
+ kcps init cpsmidinn(inote1)
+ kffrq port 0, 60/150, ifrq1 ; filter frequency
+ a1 phasor kcps ; oscillator
+ a1 = 1 - 2 * a1
+
+ a1x butterbp a1, kffrq, kcps * 1.0 ; filters
+ a1x = a1x * (2 + kffrq / kcps) ; correct amplitude
+ a1 = a1x + a1 * 0.25 ; 0.5
+ a1 butterlp a1, kffrq
+
+ a1 = taninv(a1 * 2.5 * iamp) ; distortion ; 2.5
+
+ keqf limit kffrq * 4, 10, sr * 0.48 ; EQ frequency
+ a1 pareq a1 * 0.6, keqf, 4.0, 1.0, 2
+ a1 pareq a1, 50, 1.3, 0.6
+ a1 pareq a1, 130, 0.6, 0.6
+ a1 = a1 * kamp * 0.8
+ ;a1 *= line(0, p3, 1)
+ aL, aR pan2 a1, random(0.3, 0.7)
+ bus_mix("delay1", aL*0.3, aR*0.3)
+ bus_mix("master", aL, aR)
+endin
+
+
+gi3032index = 3
+instr play_3032
+ iamp = bid_getparameter(p4, p5, 2)
+
+
+ inote1 = table(gi3032index, gibid_chordfn, 0, 0, 1)
+ if (gi3032index < 9) then
+ gi3032index += 1
+ else
+ gi3032index = 3
+ endif
+
+ ifilter = random(20, 40)
+
+ ifrq1 = 440 * exp(log(2) * (ifilter - 69) / 12) ; filter start freq.
+ kamp linseg 1, p3*0.8, 1, p3*0.2, 0
+ kcps init cpsmidinn(inote1)
+ kffrq port 0, 60/150, ifrq1 ; filter frequency
+ a1 phasor kcps ; oscillator
+ a1 = 1 - 2 * a1
+
+ a1x butterbp a1, kffrq, kcps * 1.0 ; filters
+ a1x = a1x * (2 + kffrq / kcps) ; correct amplitude
+ a1 = a1x + a1 * 0.25 ; 0.5
+ a1 butterlp a1, kffrq
+
+ a1 = taninv(a1 * 2.5 * iamp) ; distortion ; 2.5
+
+ keqf limit kffrq * 4, 10, sr * 0.48 ; EQ frequency
+ a1 pareq a1 * 0.6, keqf, 4.0, 1.0, 2
+ a1 pareq a1, 50, 1.3, 0.6
+ a1 pareq a1, 130, 0.6, 0.6
+ a1 = a1 * kamp * 0.8
+ ;a1 *= line(0, p3, 1)
+ aL, aR pan2 a1, random(0.3, 0.7)
+ bus_mix("delay1", aL*0.3, aR*0.3)
+ bus_mix("master", aL, aR)
+endin
+
+instr play_clap
+ iamp = bid_getparameter(p4, p5, 2) * random(0.4, 1) * 0.8
+ aL noise 1, 0.3
+ aR noise 1, 0.4
+ aL butterbp aL, random(1200, 1800), random(800, 1200)
+ aR butterbp aR, random(1200, 1800), random(800, 1200)
+ aL taninv aL*7
+ aR taninv aR*7
+
+ kamp linseg 2, p3*0.1, 0, p3*0.1, 2, p3*0.1, 0, p3*0.1, 1.5, p3*0.1, 0, p3*0.1, 1, p3*0.4, 0
+ aL *= kamp * iamp
+ aR *= kamp * iamp
+ bus_mix("clap", aL, aR)
+
+endin
+
+
+
+instr play_hat1
+ iamp = bid_getparameter(p4, p5, 2)
+ idel1 = random(0.005, 0.02)
+ idel2 = random(0.005, 0.02)
+ xtratim(max(idel1, idel2))
+
+ kfreq = 380 + oscil(50, 23);550 ;line 600, p3, 600
+ aenv expsega .1, .0005, 1.5, p3 - .0005, .01
+ asqr1 oscil 1, kfreq, gifnSquare, -1
+ asqr2 oscil 1, kfreq*1.4471, gifnSquare, -1
+ asqr3 oscil 1, kfreq*1.6170, gifnSaw, -1
+ asqr4 oscil 1, kfreq*1.9265, gifnSaw, -1
+ asqr5 oscil 1, kfreq*4.5028, gifnSine, -1
+ asqr6 oscil 1, kfreq*3.6637, gifnSine, -1
+ a808L sum asqr1, asqr2, asqr3
+ a808R sum asqr4, asqr5, asqr6
+ a808L butterhp a808L, 4270
+ a808R butterhp a808R, 4270
+ aoutL = a808L * aenv * iamp
+ aoutR = a808R * aenv * iamp
+ aL delay aoutL, idel1
+ aR delay aoutR, idel2
+ bus_mix("hat1", aL, aR)
+endin
+
+
+instr play_hat2
+ iamp = bid_getparameter(p4, p5, 2) * 0.7
+ kfreq line 880, p3, 400
+ aenv expsega .1, .0005, 1.5, p3 - .0005, .01
+ asqr1 oscil 1, kfreq, gifnSquare, -1
+ asqr2 oscil 1, kfreq*1.4471, gifnSquare, -1
+ asqr3 oscil 1, kfreq*1.6170, gifnSquare, -1
+ asqr4 oscil 1, kfreq*1.9265, gifnSquare, -1
+ asqr5 oscil 1, kfreq*2.5028, gifnSquare, -1
+ asqr6 oscil 1, kfreq*2.6637, gifnSquare, -1
+ a808L sum asqr4, asqr5, asqr6
+ a808R sum asqr1, asqr2, asqr3
+ a808L butterhp a808L, 3270
+ a808R butterhp a808R, 3270
+ aL = a808L * aenv * iamp
+ aR = a808R * aenv * iamp
+ bus_mix("master", aL, aR*0.7)
+endin
+
+
+instr rim
+ icps = p4 ;1000
+ iamp = p5
+ acps expon icps, 0.0025, icps * 0.5
+ acps = acps + icps
+ iamp = iamp * 0.3
+ a1a phasor acps, 0
+ a1b phasor acps, random(0, 1)
+ afmenv expon 1.0, 0.02, 0.4
+ a1 = (a1a-a1b)*random(1, 10)*afmenv
+ acps = acps*(1.0+a1)
+ a0 oscil3 1.0, acps
+ aenv expon 1.0, 0.005, 0.5
+ a0 limit 4.0*a0*aenv, -1.0, 1.0
+ a0 butterhp a0, 230
+ aL, aR pan2 a0*iamp, random(0.3, 0.8)
+ bus_mix("rim", aL, aR)
+ bus_mix("delay1", butterlp(aL*0.6, 2000), butterlp(aR*0.6, 2000))
+endin
+
+
+instr blip1
+ iup = p4
+ iamp = p5
+ inote1 = table(p4+3, gibid_chordfn, 0, 0, 1) + iup
+ inote2 = table(p4+5, gibid_chordfn, 0, 0, 1) + iup
+ a1 oscil 0.7, cpsmidinn(inote1)
+ a2 oscil 0.7, cpsmidinn(inote2)
+ kamp linseg 1, p3*0.2, 0, p3*0.8, 0
+ a1 *= kamp
+ a2 *= kamp
+ a1 butterhp a1, 250
+ a2 butterhp a2, 250
+ a1 butterhp a1, 250
+ a2 butterhp a2, 250
+ aL1, aR1 pan2 a1, random(0, 1)
+ aL2, aR2 pan2 a2, random(0, 1)
+ bus_mix("master", aL1+aL2, aR1+aR2)
+ bus_mix("delay1", butterlp(aL1*0.5, 4000), butterlp(aR2*0.5, 4000))
+endin
+
+instr play_rim
+ iamp = bid_getparameter(p4, p5, 2)
+ if (random(0, 1) > 0.6) then
+ event_i "i", "rim", 0, 0.4, 3000, iamp
+ endif
+ if (random(0, 1) > 0.6) then
+ event_i "i", "rim", 0, 0.4, 1000, iamp
+ endif
+ if (random(0, 1) > 0.6) then
+ event_i "i", "rim", 0, 0.4, 2000, iamp
+ endif
+ if (random(0, 1) > 0.6) then
+ event_i "i", "rim", 0, 0.4, 2500, iamp
+ endif
+ if (random(0, 1) > 0.6) then
+ event_i "i", "rim", 0, 0.4, 3500, iamp
+ endif
+ if (random(0, 1) > 0.6) then
+ event_i "i", "blip1", 0, random(0.01, 0.1), 48, iamp
+ endif
+ if (random(0, 1) > 0.6) then
+ event_i "i", "blip1", 0, random(0.01, 0.1), 24, iamp
+ endif
+ if (random(0, 1) > 0.6) then
+ event_i "i", "blip1", 0, random(0.01, 0.1), 36, iamp
+ endif
+endin
+
+
+
+instr play_kick ; 808 style kick
+ iamp = bid_getparameter(p4, p5, 2)
+
+ idist = 0.5 ;= (i(gksection) == 1) ? 0.55 : 0.35
+ xtratim 0.1
+ krelease release
+ ktune init -1.5
+ kmul transeg 0.2, p3*0.5, -15, 0.01, p3*0.5, 0, 0
+ kbend transeg 0.5, 1.2, -4, 0, 1, 0, 0
+ asig gbuzz 0.5, 50*octave(ktune)*semitone(kbend), 20, 1, kmul, gifnCosine
+ aenv linseg 0, p3*0.8, 1, p3*0.2, 0
+ gkpump = k(aenv)
+ asig = asig*aenv
+ aenv linseg 0, 0.07, 1
+ acps expsega 400, 0.07, 0.001, 1, 0.001
+ amix = (asig*0.7)*1*iamp
+ gkpump = min(rms(amix) * 7, 1)
+ aout1 pareq amix, 100, 0.01, 0.7
+ aout1 distort aout1, idist, gifnSquare
+ aout1 pareq aout1, 50, 2, 0.4
+ aout1 pareq aout1, 190, 0.7, 0.6
+ aout1 butterlp aout1, 140
+ aout1 *= 2
+ bus_mix("kick", aout1, aout1)
+endin
+
+instr play_koffer
+ iamp = bid_getparameter(p4, p5, 2)
+ ifreq = cpsmidinn(tab_i(ftlen(gibid_chordfn) - 2, gibid_chordfn)+12)
+ aL buzz 2, ifreq, random(7, 12), gifnSquare
+ aL butterhp aL, 500
+ aR buzz 2, ifreq, random(7, 12), gifnSquare
+ aR butterhp aR, 500
+ kamp linseg 0, p3*0.2, 1, p3*0.1, 0, p3*0.7, 0
+ aL *= kamp
+ aR *= kamp
+
+ bus_mix("koffer", aL, aR)
+endin
+
+
+
+#end
diff --git a/BUG7/txt_tools.udo b/BUG7/txt_tools.udo
new file mode 100644
index 0000000..eb0cc86
--- /dev/null
+++ b/BUG7/txt_tools.udo
@@ -0,0 +1,82 @@
+#ifndef UDO_TXTTOOLS
+#define UDO_TXTTOOLS ##
+/*
+ Debugger - Unfixed Bugs : BUG #3
+
+ Text tools
+*/
+
+
+/*
+ Print a notification prepended with a line of asterisks
+
+ tt_notify Stext
+
+ Stext text to print
+*/
+opcode tt_notify, 0, S
+ Stext xin
+ Snew = "\n"
+ iwidth = 60
+ index = 0
+ while (index < iwidth) do
+ Snew = strcat(Snew, "*");
+ index += 1
+ od
+ prints strcat(strcat(Snew, "\n"), strcat(Stext, "\n\n"))
+endop
+
+
+
+/*
+ Print a notification prepended with a line of asterisks and exit
+
+ tt_notify Stext
+
+ Stext text to print
+*/
+opcode tt_notify_fatal, 0, S
+ Stext xin
+ tt_notify(Stext)
+ exitnow
+endop
+
+
+/*
+ Return a number of seconds as HH:MM:SS format
+
+ Stime tt_parsetime iseconds
+
+ iseconds seconds to parse
+
+ Stime formatted time
+
+*/
+opcode tt_parsetime, S, i
+ input xin
+ ihours = floor(input / 3600)
+ iminutes = floor((input - (ihours * 3600)) / 60)
+ iseconds = input - (ihours * 3600) - (iminutes * 60)
+ xout sprintf("%02d:%02d:%05.2f", ihours, iminutes, iseconds)
+endop
+
+
+/*
+ Strip newline from end of line: built-in opcode has some problems
+
+ Soutput tt_stripnewline Sinput
+
+ Soutput processed without newline at end if existent
+
+ Sinput line to process
+*/
+opcode tt_stripnewline, S, S
+ Sline xin
+ index = strindex(Sline, "\n")
+ if (index != -1) then
+ Sline = strsub(Sline, 0, index)
+ endif
+ xout Sline
+endop
+
+#end
diff --git a/BUG7/wavetables.udo b/BUG7/wavetables.udo
new file mode 100644
index 0000000..e81f075
--- /dev/null
+++ b/BUG7/wavetables.udo
@@ -0,0 +1,16 @@
+#ifndef UDO_WAVETABLES
+#define UDO_WAVETABLES ##
+/*
+ Debugger - Unfixed Bugs : BUG #3
+
+ General waveforms
+*/
+
+ipoints = 16384
+gifnCosine ftgen 0, 0, ipoints, 9, 1, 1, 90
+gifnSine ftgen 0, 0, ipoints, 10, 1
+gifnSquare ftgen 0, 0, ipoints, 10, 1, 0, 0.3, 0, 0.2, 0, 0.14, 0, .111
+gifnSaw ftgen 0, 0, ipoints, 10, 0, .2, 0, .4, 0, .6, 0, .8, 0, 1, 0, .8, 0, .6, 0, .4, 0, .2
+
+#end
+
diff --git a/README.md b/README.md
index 15c0d9c..1f73a02 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,16 @@ Significant work has been done on contructing a custom arrangment format for int
The original BID file is provided as text (bid\_source.txt), but not all platforms support the readfi opcode as required by bid\_loadfile, hence it has been encapsulated in a string within bid_source.udo , and bid\_loadtext is used instead. If readfi is supported and bid\_loadfile is to be used, NOFILEIO should be unset.
-### BUG4 (2021) : Not Complete
+### BUG4 (2021)
+Utilises the BID loop arrangement format created in BUG3 and computed during realtime playback. Designed to be a lightly glitchy, relatively downtempo minimal techno type piece.
+
+### BUG5 (2021) : Not Complete
+In progress.
+
+### BUG6 (2021) : Not Complete
+In progress.
+
+### BUG7 (2021) : Not Complete
In progress.
## Credits
diff --git a/README.md~ b/README.md~
deleted file mode 100644
index 5c385ee..0000000
--- a/README.md~
+++ /dev/null
@@ -1,43 +0,0 @@
-# Debugger - Unfixed Bugs Volume 1
-
-## Overview
-Unfixed Bugs is a series of pieces of music by the artist Debugger, which may take the form of a traditional album, but solely feature compositions created using textual programming languages. The pieces are presented as open-source code and do not use any binary supporting files (such as PCM samples, analysis data etc). Hence Unfixed Bugs projects are fully readable, open-source musical works which describe both sound and arrangement. The compiled audio may be made available for release elsewhere.
-
-Aesthetically the project aims to represent the general approach to experimental techno music consistent with other output by Debugger, and exploit generative possibilities provided by defining musical structure with code.
-
-
-
-## Composition Notes
-
-### BUG1 (2019)
-This is the first completed work in the series and uses preset arrays defining the frequencies of two chords. FM synthesis is used quite extensively and the sequencing is done in a set of conditional statements. The arrangement is computed at initialisation time.
-
-### BUG2 (2019)
-A relatively simple composition of clicks and bleeps stochastically computed at initialisation time.
-
-### BUG3 (2021)
-Significant work has been done on contructing a custom arrangment format for interpretation: the Bug Infested Directives (BID) format. This allows for reusable loop-based sequencing beyond the regular capabilities of the Csound score format. Also notably, a sample of a 909 hi-hat has been converted to a Csound instrument using FFT analysis, resulting in a large number of enveloped oscillators. This hi-hat instrument is too computationally heavy to be consistently run in realtime, so is recorded to memory before playback begins. The arrangement is computed during realtime playback.
-
-The original BID file is provided as text (bid\_source.txt), but not all platforms support the readfi opcode as required by bid\_loadfile, hence it has been encapsulated in a string within bid_source.udo , and bid\_loadtext is used instead. If readfi is supported and bid\_loadfile is to be used, NOFILEIO should be unset.
-
-### BUG4 (2021) : Not Complete
-In progress.
-
-## Credits
-All design, composition and programming by Richard Knight as Debugger.
-
-
-
-## License
-Licensed under the Unlicense, so you can do as you please with the code. See the UNLICENSE file for more details.
-
-
-
-## Links
-* [git repository for Unfixed Bugs Volume 1](http://git.1bpm.net/csd-unfixedbugs1/about/)
-* [Other Debugger releases on the Discogs page](https://www.discogs.com/artist/7224268-Debugger-3)
-* [Richard Knight artist profile](http://rk.1bpm.net)
-* [1bpm.net main page](http://1bpm.net/)
-* [Csound page at 1bpm.net with plugin opcodes, builds etc](http://csound.1bpm.net/)
-* [Official Csound site](https://csound.com/)
-