Added make_seq() to picadae_api.py and picadae_shell.py
This commit is contained in:
parent
5ffd77da17
commit
0719427eb5
@ -275,6 +275,12 @@ class Picadae:
|
|||||||
time.sleep( dur_ms / 1000.0 )
|
time.sleep( dur_ms / 1000.0 )
|
||||||
return self.note_off(midi_pitch)
|
return self.note_off(midi_pitch)
|
||||||
|
|
||||||
|
def make_seq( self, midi_pitch, base_atk_us, dur_ms, delta_us, note_cnt ):
|
||||||
|
for i in range(note_cnt):
|
||||||
|
self.make_note( midi_pitch, base_atk_us + i*delta_us, dur_ms )
|
||||||
|
time.sleep( dur_ms / 1000.0 )
|
||||||
|
return Result()
|
||||||
|
|
||||||
def set_log_level( self, log_level ):
|
def set_log_level( self, log_level ):
|
||||||
self.log_level = log_level
|
self.log_level = log_level
|
||||||
return Result()
|
return Result()
|
||||||
@ -286,13 +292,17 @@ class Picadae:
|
|||||||
return vel
|
return vel
|
||||||
|
|
||||||
def _usec_to_coarse_and_fine( self, usec ):
|
def _usec_to_coarse_and_fine( self, usec ):
|
||||||
|
|
||||||
|
coarse_usec = self.prescaler_usec*255 # usec's in one coarse tick
|
||||||
|
|
||||||
coarse = int( usec / (self.prescaler_usec*255))
|
coarse = int( usec / coarse_usec )
|
||||||
fine = int((usec - coarse*self.prescaler_usec*255) / self.prescaler_usec)
|
fine = int((usec - coarse*coarse_usec) / self.prescaler_usec)
|
||||||
|
|
||||||
assert( coarse <= 255 )
|
assert( coarse <= 255 )
|
||||||
assert( fine <= 255)
|
assert( fine <= 255)
|
||||||
|
|
||||||
|
print("C:%i F:%i : %i " % (coarse,fine, coarse*coarse_usec + fine*self.prescaler_usec ))
|
||||||
|
|
||||||
return coarse,fine
|
return coarse,fine
|
||||||
|
|
||||||
def _send( self, opcode, i2c_addr, reg_addr, byteL ):
|
def _send( self, opcode, i2c_addr, reg_addr, byteL ):
|
||||||
|
@ -21,7 +21,8 @@ class PicadaeShell:
|
|||||||
'f':{ "func":"get_pwm_freq", "minN":1, "maxN":1, "help":"freq <pitch>"},
|
'f':{ "func":"get_pwm_freq", "minN":1, "maxN":1, "help":"freq <pitch>"},
|
||||||
'i':{ "func":"get_pwm_div", "minN":1, "maxN":1, "help":"div <pitch>"},
|
'i':{ "func":"get_pwm_div", "minN":1, "maxN":1, "help":"div <pitch>"},
|
||||||
'W':{ "func":"write_table", "minN":1, "maxN":1, "help":"write_table <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"},
|
'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>"},
|
||||||
'L':{ "func":"set_log_level","minN":1, "maxN":1, "help":"log <level> (0-1)."}
|
'L':{ "func":"set_log_level","minN":1, "maxN":1, "help":"log <level> (0-1)."}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user