Last active
August 9, 2016 15:30
-
-
Save zeffii/c0010ab57a881d19606462d911beb205 to your computer and use it in GitHub Desktop.
add UTrk and add 3 tracks.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pybuzz is py2.4+, thus expect less pythonic code | |
# edited from supplied python file bassdrum.py | |
import sys | |
sys.path.append(r'C:\Python24\Lib') | |
import random | |
import buzz | |
from buzz import * | |
import pybuzz_helpers | |
from pybuzz_helpers.funcs import ( | |
hex_to_int, | |
seq_sample_from, | |
random_choice, | |
assign_utrk9, | |
format_params, | |
pbseq, pbseq_func | |
) | |
bpm = 0 | |
tpb = 0 | |
sps = 0 | |
spt = 0 | |
pit = 0 | |
tps = 0 | |
trigger = NOTE_NO | |
tick = 0 | |
params = [ | |
'offset', 3, | |
'note', 5, | |
'smp', 6, | |
'vol', 7, | |
'pan', 8, | |
'p1', 9, | |
'p1v', 10, | |
'p2', 11, | |
'p2v',12 | |
] | |
utrk9p = assign_utrk9(buzz, "UTrk", 0, params) | |
def UpdateMasterInfo(): | |
global bpm,tpb,sps,spt,pit,tps | |
bpm,tpb,sps,spt,pit,tps = GetMasterInfo() | |
def OnStop(): | |
global trigger,tick | |
trigger = NOTE_NO | |
tick = 0 | |
def OnTick(): | |
global trigger,tick,tpb | |
if (trigger != NOTE_NO): | |
# print(trigger) | |
kick = 6 | |
# Example 1 | |
# --- utrk9p params (all optional) :: trk offset note smp vol pan p1 p1val p2 p2val | |
if (tick in pbseq("1...1...1...1..1..1...1.1..1..1..1")): | |
utrk9p(trk=0, note=69, smp=kick, vol=30) # , p1=25, p1val=hexval, p2=aux, p2val=2) | |
# returns None if ' . ' | |
lookup1 = {'1':2, '2':3, '3':7, '4':4, 'b':5} | |
perc_vals1 = pbseq_func("1..2..14..3..b.4..1..4.2.", lookup1, tick) | |
if perc_vals1: | |
hexval = hex_to_int(random_choice(["7000", "aa00", "2a10"])) | |
utrk9p(trk=1, note=65, smp=perc_vals1, vol=30) | |
perc_vals2 = pbseq_func("11.11.11.2..1..11.12", {'1':8, '2':9}, tick) | |
if perc_vals2: | |
utrk9p(trk=2, note=65, smp=perc_vals2, vol=30) | |
tick += 1 | |
def OnCommand(text): | |
print text | |
def OnParameter(track,index,value): | |
global trigger,tick | |
print "[%02i] %i: %i" % (track,index,value) | |
if (index == 0): | |
if (value == NOTE_OFF): | |
trigger = NOTE_NO | |
else: | |
trigger = value | |
tick = 0 | |
def OnMasterInfoChange(): | |
UpdateMasterInfo() | |
def OnSave(): | |
print "Saving state..." | |
return [4,2,8,"ficken"] | |
def OnLoad(data): | |
# set aux tracks | |
aux = hex_to_int(78) # for multi out use : (... p2=aux, p2val=track) | |
for track in range(3): | |
utrk9p(trk=track, p2=aux, p2val=track) | |
print "Loading state..." | |
print "State is " + str(data) | |
SetEventTarget("OnTick",OnTick) | |
SetEventTarget("OnCommand",OnCommand) | |
SetEventTarget("OnParameter",OnParameter) | |
SetEventTarget("OnMasterInfoChange",OnMasterInfoChange) | |
SetEventTarget("OnStop",OnStop) | |
SetEventTarget("OnSave",OnSave) | |
SetEventTarget("OnLoad",OnLoad) | |
UpdateMasterInfo() | |
SetPeerCtrlName(0,"Note Out") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment