picadae_api.py,picadae_shell.py : Added 'flags' parameter and 'make_scale' API.
This commit is contained in:
parent
d5f215727a
commit
a3cda0b908
@ -17,7 +17,8 @@ class TinyOp(Enum):
|
||||
writeOp = 5
|
||||
writeTableOp = 6
|
||||
holdDelayOp = 7
|
||||
invalidOp = 8
|
||||
flagsOp = 8
|
||||
invalidOp = 9
|
||||
|
||||
|
||||
class TinyRegAddr(Enum):
|
||||
@ -40,7 +41,22 @@ class TinyRegAddr(Enum):
|
||||
kMaxAllowTmrAddr = 16
|
||||
kDelayCoarseAddr = 17
|
||||
kDelayFineAddr = 18
|
||||
kFlagsAddr = 19
|
||||
|
||||
class TinyRegAddr0(Enum):
|
||||
kRdRegAddrAddr = 0
|
||||
kRdSrcAddr = 1
|
||||
kWrRegAddrAddr = 2
|
||||
kWrDstAddr = 3
|
||||
kAttkDutyAddr = 4
|
||||
kAttkDurHiAddr = 5
|
||||
kAttkDurLoAddr = 6
|
||||
kDecayStepAddr = 7
|
||||
kDecayDecrAddr = 8
|
||||
kPwmDutyAddr = 9
|
||||
kErrorCodeAddr = 10
|
||||
|
||||
|
||||
class TinyConst(Enum):
|
||||
kRdRegSrcId = TinyRegAddr.kRdRegAddrAddr.value # 0
|
||||
kRdTableSrcId = TinyRegAddr.kRdTableAddrAddr.value # 1
|
||||
@ -263,6 +279,14 @@ class Picadae:
|
||||
|
||||
return res
|
||||
|
||||
def set_flags( self, midi_pitch, flags ):
|
||||
return self.call_op( midi_pitch, TinyOp.flagsOp.value, [int(flags)] )
|
||||
#return self.call_op( midi_pitch, 5, [int(flags)] )
|
||||
|
||||
def get_flags( self, midi_pitch, time_out_ms=250 ):
|
||||
return self.block_on_picadae_read_reg( midi_pitch, TinyRegAddr.kFlagsAddr.value, byteOutN=1, time_out_ms=time_out_ms )
|
||||
#return self.block_on_picadae_read_reg( midi_pitch, TinyRegAddr.kAttkDutyAddr.value, byteOutN=1, time_out_ms=time_out_ms )
|
||||
|
||||
|
||||
def set_velocity_map( self, midi_pitch, midi_vel, pulse_usec ):
|
||||
coarse,fine = self._usec_to_coarse_and_fine( pulse_usec )
|
||||
@ -321,7 +345,18 @@ class Picadae:
|
||||
self.make_note( midi_pitch, base_atk_us + i*delta_us, dur_ms )
|
||||
time.sleep( dur_ms / 1000.0 )
|
||||
return Result()
|
||||
|
||||
def make_scale( self, pitch0, pitch1, atk_us, dur_ms ):
|
||||
|
||||
if pitch0>pitch1:
|
||||
printf("pitch0 must be <= pitch1")
|
||||
else:
|
||||
for pitch in range(pitch0,pitch1+1):
|
||||
self.make_note( pitch, atk_us, dur_ms )
|
||||
time.sleep( dur_ms / 1000.0 )
|
||||
return Result()
|
||||
|
||||
|
||||
def set_log_level( self, log_level ):
|
||||
self.log_level = log_level
|
||||
return Result()
|
||||
@ -344,6 +379,17 @@ class Picadae:
|
||||
|
||||
x = coarse*coarse_usec + fine*self.prescaler_usec
|
||||
|
||||
|
||||
|
||||
#####
|
||||
# n = int(16e6*usec/(256*1e6))
|
||||
|
||||
# coarse = n >> 8;
|
||||
# fine = n & 0xff;
|
||||
|
||||
# x = usec
|
||||
####
|
||||
|
||||
print("C:%i F:%i : %i %i (%i)" % (coarse,fine, x, usec, usec-x ))
|
||||
|
||||
return coarse,fine
|
||||
|
@ -27,9 +27,12 @@ class PicadaeShell:
|
||||
'f':{ "func":"get_pwm_freq", "minN":1, "maxN":1, "help":"pwm freq <pitch>"},
|
||||
'I':{ "func":"set_pwm_div", "minN":2, "maxN":2, "help":"pwm div <pitch> <div> div:2=2,3=4,4=8,(5)=16 1us,6=32,7=64,8=128,9=256,10=512 32us, 11=1024,12=2048,13=4096,14=8192,15=16384"},
|
||||
'i':{ "func":"get_pwm_div", "minN":1, "maxN":1, "help":"pwm div <pitch>"},
|
||||
'A':{ "func":"set_flags", "minN":2, "maxN":2, "help":"set flags <pitch> <flags>"},
|
||||
'a':{ "func":"get_flags", "minN":1, "maxN":1, "help":"get flags <pitch>"},
|
||||
'W':{ "func":"write_table", "minN":1, "maxN":1, "help":"write_table <pitch>"},
|
||||
'N':{ "func":"make_note", "minN":3, "maxN":3, "help":"note <pitch> <atkUs> <durMs>"},
|
||||
'S':{ "func":"make_seq", "minN":5, "maxN":5, "help":"seq <pitch> <atkUs> <durMs> <deltaUs> <note_count>"},
|
||||
'S':{ "func":"make_seq", "minN":5, "maxN":5, "help":"seq <pitch> <atkUs> <durMs> <deltaUs> <note_count>"},
|
||||
'C':{ "func":"make_scale", "minN":4, "maxN":4, "help":"scale <pitch0> <pitch1> <atkUs> <durMs>"},
|
||||
'L':{ "func":"set_log_level", "minN":1, "maxN":1, "help":"log <level> (0-1)."}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user