p_ac.py, p_ac.yml : Changes to support Steinway D calibration.
This commit is contained in:
parent
011606c5cf
commit
648e29c4c4
52
p_ac.py
52
p_ac.py
@ -59,10 +59,12 @@ class AttackPulseSeq:
|
|||||||
self.beginMs = ms
|
self.beginMs = ms
|
||||||
self.playOnlyFl = playOnlyFl
|
self.playOnlyFl = playOnlyFl
|
||||||
|
|
||||||
|
|
||||||
# kpl if not playOnlyFl:
|
# kpl if not playOnlyFl:
|
||||||
self.audio.record_enable(True) # start recording audio
|
self.audio.record_enable(True) # start recording audio
|
||||||
|
|
||||||
|
print("Hold Delay from end of attack:",cfg.defaultHoldDelayUsecs)
|
||||||
|
self.api.set_hold_delay(pitch,cfg.defaultHoldDelayUsecs)
|
||||||
|
|
||||||
self.tick(ms) # play the first note
|
self.tick(ms) # play the first note
|
||||||
|
|
||||||
def stop(self, ms):
|
def stop(self, ms):
|
||||||
@ -124,16 +126,9 @@ class AttackPulseSeq:
|
|||||||
def _get_duty_cycle( self, pulseUsec ):
|
def _get_duty_cycle( self, pulseUsec ):
|
||||||
return self.holdDutyPctD[ pulseUsec ]
|
return self.holdDutyPctD[ pulseUsec ]
|
||||||
|
|
||||||
dutyPct = self.holdDutyPctL[0][1]
|
|
||||||
for refUsec,refDuty in self.holdDutyPctL:
|
|
||||||
if pulseUsec < refUsec:
|
|
||||||
break
|
|
||||||
dutyPct = refDuty
|
|
||||||
|
|
||||||
return dutyPct
|
|
||||||
|
|
||||||
def _set_duty_cycle( self, pitch, pulseUsec ):
|
def _set_duty_cycle( self, pitch, pulseUsec ):
|
||||||
|
|
||||||
|
|
||||||
dutyPct = self._get_duty_cycle( pulseUsec )
|
dutyPct = self._get_duty_cycle( pulseUsec )
|
||||||
|
|
||||||
if dutyPct != self.prevHoldDutyPct:
|
if dutyPct != self.prevHoldDutyPct:
|
||||||
@ -267,14 +262,18 @@ class CalibrateKeys:
|
|||||||
#self.pulseUsL,_,_ = form_resample_pulse_time_list( outDir, self.cfg.analysisArgs )
|
#self.pulseUsL,_,_ = form_resample_pulse_time_list( outDir, self.cfg.analysisArgs )
|
||||||
self.pulseUsL = get_resample_points_wrap( baseDir, pitch, self.cfg.analysisArgs )
|
self.pulseUsL = get_resample_points_wrap( baseDir, pitch, self.cfg.analysisArgs )
|
||||||
|
|
||||||
|
|
||||||
holdDutyPctL = self.cfg.calibrateArgs['holdDutyPctD'][pitch]
|
holdDutyPctL = self.cfg.calibrateArgs['holdDutyPctD'][pitch]
|
||||||
|
|
||||||
|
|
||||||
if playOnlyFl:
|
if playOnlyFl:
|
||||||
self.pulseUsL,_,holdDutyPctL = form_final_pulse_list( outDir, pitch, self.cfg.analysisArgs, take_id=None )
|
|
||||||
|
self.pulseUsL,_,holdDutyPctL = form_final_pulse_list( baseDir, pitch, self.cfg.analysisArgs, take_id=None )
|
||||||
|
|
||||||
noteN = cfg.analysisArgs['auditionNoteN']
|
noteN = cfg.analysisArgs['auditionNoteN']
|
||||||
self.pulseUsL = [ self.pulseUsL[ int(round(i*126.0/(noteN-1)))] for i in range(noteN) ]
|
self.pulseUsL = [ self.pulseUsL[ int(round(i*126.0/(noteN-1)))] for i in range(noteN) ]
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
outDir = os.path.join( outDir, str(outDir_id) )
|
outDir = os.path.join( outDir, str(outDir_id) )
|
||||||
|
|
||||||
@ -339,6 +338,7 @@ class App:
|
|||||||
self.audio_dev_list(0)
|
self.audio_dev_list(0)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
print("The cfg file has no audio stanza. No audio device will be initialized.")
|
||||||
self.audioDev = None
|
self.audioDev = None
|
||||||
|
|
||||||
if True:
|
if True:
|
||||||
@ -389,10 +389,12 @@ class App:
|
|||||||
self.midiFilePlayer.tick(ms)
|
self.midiFilePlayer.tick(ms)
|
||||||
|
|
||||||
def audio_dev_list( self, ms ):
|
def audio_dev_list( self, ms ):
|
||||||
portL = self.audioDev.get_port_list( True )
|
|
||||||
|
|
||||||
for port in portL:
|
if self.audioDev is not None:
|
||||||
print("chs:%4i label:%s" % (port['chN'],port['label']))
|
portL = self.audioDev.get_port_list( True )
|
||||||
|
|
||||||
|
for port in portL:
|
||||||
|
print("chs:%4i label:%s" % (port['chN'],port['label']))
|
||||||
|
|
||||||
def midi_dev_list( self, ms ):
|
def midi_dev_list( self, ms ):
|
||||||
d = self.midiDev.get_port_list( True )
|
d = self.midiDev.get_port_list( True )
|
||||||
@ -411,7 +413,7 @@ class App:
|
|||||||
self.cal_keys.start( ms, pitchL, cfg.full_pulseL )
|
self.cal_keys.start( ms, pitchL, cfg.full_pulseL )
|
||||||
|
|
||||||
def play_keys_start( self, ms, pitchRangeL ):
|
def play_keys_start( self, ms, pitchRangeL ):
|
||||||
chordL = [ [pitch] for pitch in range(pitchRangeL[0], pitchRangeL[1]+1)]
|
chordL = [ pitch for pitch in range(pitchRangeL[0], pitchRangeL[1]+1)]
|
||||||
self.cal_keys.start( ms, chordL, cfg.full_pulseL, playOnlyFl=True )
|
self.cal_keys.start( ms, chordL, cfg.full_pulseL, playOnlyFl=True )
|
||||||
|
|
||||||
def keyboard_start_pulse_idx( self, ms, argL ):
|
def keyboard_start_pulse_idx( self, ms, argL ):
|
||||||
@ -709,10 +711,30 @@ def parse_args():
|
|||||||
return ap.parse_args()
|
return ap.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
def create_logger():
|
||||||
|
import multiprocessing, logging
|
||||||
|
logger = multiprocessing.get_logger()
|
||||||
|
logger.setLevel(logging.INFO)
|
||||||
|
formatter = logging.Formatter(\
|
||||||
|
'[%(asctime)s| %(levelname)s| %(processName)s] %(message)s')
|
||||||
|
handler = logging.FileHandler('/home/kevin/temp/p_ac_log.txt')
|
||||||
|
handler.setFormatter(formatter)
|
||||||
|
|
||||||
|
# this bit will make sure you won't have
|
||||||
|
# duplicated messages in the output
|
||||||
|
if not len(logger.handlers):
|
||||||
|
logger.addHandler(handler)
|
||||||
|
return logger
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
logging.basicConfig()
|
|
||||||
|
from multiprocessing import Pool
|
||||||
|
logger = create_logger()
|
||||||
|
logger.info('Starting pooling')
|
||||||
|
#p = Pool()
|
||||||
|
|
||||||
|
#logging.basicConfig()
|
||||||
|
|
||||||
#mplog = multiprocessing.log_to_stderr()
|
#mplog = multiprocessing.log_to_stderr()
|
||||||
#mplog.setLevel(logging.INFO)
|
#mplog.setLevel(logging.INFO)
|
||||||
|
54
p_ac.yml
54
p_ac.yml
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
|
|
||||||
# MeasureSeq args
|
# MeasureSeq args
|
||||||
outDir: "~/temp/p_ac_3_oe",
|
outDir: "~/temp/p_ac_3_of",
|
||||||
noteDurMs: 500,
|
noteDurMs: 500,
|
||||||
pauseDurMs: 500,
|
pauseDurMs: 500,
|
||||||
reversePulseListFl: True,
|
reversePulseListFl: True,
|
||||||
@ -37,6 +37,8 @@
|
|||||||
silentNoteMaxPulseUs: 15000,
|
silentNoteMaxPulseUs: 15000,
|
||||||
silentNoteMinDurMs: 180, #250,
|
silentNoteMinDurMs: 180, #250,
|
||||||
|
|
||||||
|
defaultHoldDelayUsecs: 1000,
|
||||||
|
|
||||||
# Midi file player
|
# Midi file player
|
||||||
midiFileFn: "/home/kevin/media/audio/midi/txt/round4.txt",
|
midiFileFn: "/home/kevin/media/audio/midi/txt/round4.txt",
|
||||||
|
|
||||||
@ -87,14 +89,12 @@
|
|||||||
|
|
||||||
full_pulse20L: [ 1000, 1250, 1500, 1750, 2000, 2250, 2500, 2750, 3000, 3250, 3500, 3750, 4000, 4250, 4500, 4750, 5000, 5250, 5500, 5750, 6000, 6250, 6500, 6750, 7000, 7250, 7500, 7750, 8000, 8250, 8500, 8750, 9000, 9250, 9500, 9750, 10000, 10250, 10500, 10750, 11000, 11250, 11500, 11750, 12000, 12250, 12500, 12750, 13000, 13500, 14000, 14500, 15000, 15500 ],
|
full_pulse20L: [ 1000, 1250, 1500, 1750, 2000, 2250, 2500, 2750, 3000, 3250, 3500, 3750, 4000, 4250, 4500, 4750, 5000, 5250, 5500, 5750, 6000, 6250, 6500, 6750, 7000, 7250, 7500, 7750, 8000, 8250, 8500, 8750, 9000, 9250, 9500, 9750, 10000, 10250, 10500, 10750, 11000, 11250, 11500, 11750, 12000, 12250, 12500, 12750, 13000, 13500, 14000, 14500, 15000, 15500 ],
|
||||||
|
|
||||||
# 60,72
|
|
||||||
full_pulse21L: [ 1000, 1250, 1500, 1750, 2000, 2250, 2500, 2750, 3000, 3250, 3500, 3750, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000 ],
|
full_pulse21L: [ 1000, 1250, 1500, 1750, 2000, 2250, 2500, 2750, 3000, 3250, 3500, 3750, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000 ],
|
||||||
|
|
||||||
# 48,36,85
|
|
||||||
full_pulse22L: [ 3500, 3750, 4000, 4250, 4500, 4750, 5000, 5250, 5500, 5750, 6000, 6250, 6500, 6750, 7000, 7500, 8000, 8500, 9000, 9500, 10000, 10500, 11000, 12000, 12500, 13000, 14000, 15000, 16000, 17000, 18000, 19000 ],
|
full_pulse22L: [ 3500, 3750, 4000, 4250, 4500, 4750, 5000, 5250, 5500, 5750, 6000, 6250, 6500, 6750, 7000, 7500, 8000, 8500, 9000, 9500, 10000, 10500, 11000, 12000, 12500, 13000, 14000, 15000, 16000, 17000, 18000, 19000 ],
|
||||||
|
|
||||||
# 84
|
# 60,72,84
|
||||||
full_pulseL: [ 2000, 2250, 2500,2750, 3000, 3250, 3500, 3750, 4000, 4250, 4500, 4750, 5000, 5250, 5500, 5750, 6000, 6250, 6500, 6750, 7000, 7500, 8000, 8500, 9000, 9500, 10000, 10500, 11000, 12000, 12500, 13000, 14000, 15000, 16000 ],
|
full_pulseL: [ 2000, 2250, 2500,2750, 3000, 3250, 3500, 3750, 4000, 4250, 4500, 4750, 5000, 5250, 5500, 5750, 6000, 6250, 6500, 6750, 7000, 7500, 8000, 8500, 9000, 9500, 10000, 10500, 11000, 11500, 12000, 12500, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000, 22000 ],
|
||||||
|
|
||||||
# RMS analysis args
|
# RMS analysis args
|
||||||
analysisArgs: {
|
analysisArgs: {
|
||||||
@ -249,7 +249,7 @@
|
|||||||
minMeasDurMs: 140, # minimum candidate note duration
|
minMeasDurMs: 140, # minimum candidate note duration
|
||||||
tolDbPct: 2.0, # tolerance as a percent of targetDb above/below used to form match db window
|
tolDbPct: 2.0, # tolerance as a percent of targetDb above/below used to form match db window
|
||||||
maxPulseUs: 45000, # max. allowable pulse us
|
maxPulseUs: 45000, # max. allowable pulse us
|
||||||
minPulseUs: 8000, # min. allowable pulse us
|
minPulseUs: 2000, # min. allowable pulse us
|
||||||
initPulseUs: 15000, # pulseUs for first note
|
initPulseUs: 15000, # pulseUs for first note
|
||||||
minMatchN: 3, # at least 3 candidate notes must be within tolDbPct to move on to a new targetDb
|
minMatchN: 3, # at least 3 candidate notes must be within tolDbPct to move on to a new targetDb
|
||||||
maxAttemptN: 30, # give up if more than 20 candidate notes fail for a given targetDb
|
maxAttemptN: 30, # give up if more than 20 candidate notes fail for a given targetDb
|
||||||
@ -269,7 +269,7 @@
|
|||||||
33: [[0, 40]],
|
33: [[0, 40]],
|
||||||
34: [[0, 40]],
|
34: [[0, 40]],
|
||||||
35: [[0, 40]],
|
35: [[0, 40]],
|
||||||
36: [[0, 45]],
|
36: [[0, 40]],
|
||||||
37: [[0, 40]],
|
37: [[0, 40]],
|
||||||
38: [[0, 40]],
|
38: [[0, 40]],
|
||||||
39: [[0, 40]],
|
39: [[0, 40]],
|
||||||
@ -292,12 +292,12 @@
|
|||||||
56: [[0, 40]],
|
56: [[0, 40]],
|
||||||
57: [[0, 40]],
|
57: [[0, 40]],
|
||||||
58: [[0, 40]],
|
58: [[0, 40]],
|
||||||
59: [[0, 40]],
|
59: [[0, 45]],
|
||||||
60: [[0, 50]],
|
60: [[0, 40],[10000,50]],
|
||||||
61: [[0, 43]],
|
61: [[0, 40],[10000,50]],
|
||||||
62: [[0, 43]],
|
62: [[0, 40],[10000,50]],
|
||||||
63: [[0, 43]],
|
63: [[0, 40],[10000,50]],
|
||||||
64: [[0, 40],[14000, 45],[15000,50],[16000,55],[17000,60],[18000,65],[19000,55]],
|
64: [[0, 40],[10000,50]],
|
||||||
65: [[0, 99]],
|
65: [[0, 99]],
|
||||||
66: [[0, 40]],
|
66: [[0, 40]],
|
||||||
67: [[0, 40],[14000, 45],[15000,50],[16000,55],[17000,60],[18000,65],[19000,55]],
|
67: [[0, 40],[14000, 45],[15000,50],[16000,55],[17000,60],[18000,65],[19000,55]],
|
||||||
@ -305,20 +305,20 @@
|
|||||||
69: [[0, 40],[14000, 45],[15000,50],[16000,55],[17000,60],[18000,65],[19000,55]],
|
69: [[0, 40],[14000, 45],[15000,50],[16000,55],[17000,60],[18000,65],[19000,55]],
|
||||||
70: [[0, 40],[14000, 45],[15000,50],[16000,55],[17000,60],[18000,65],[19000,55]],
|
70: [[0, 40],[14000, 45],[15000,50],[16000,55],[17000,60],[18000,65],[19000,55]],
|
||||||
71: [[0, 40],[14000, 45],[15000,50],[16000,55],[17000,60],[18000,65],[19000,55]],
|
71: [[0, 40],[14000, 45],[15000,50],[16000,55],[17000,60],[18000,65],[19000,55]],
|
||||||
72: [[0, 45],[11000, 65] ],
|
72: [[0, 42],[8000,44],[9000,46],[10000, 48],[11000,50],[12000,52],[13000,54],[14000,56],[15000,58],[16000,60],[17000,60],[18000,60],[19000,60],[20000,60] ],
|
||||||
73: [[0, 45],[14000,45],[15000,50],[16000,55],[17000,60],[18000,65],[19000,55]],
|
73: [[0, 42],[8000,44],[9000,46],[10000, 48],[11000,50],[12000,52],[13000,54],[14000,56],[15000,58],[16000,60],[17000,60],[18000,60],[19000,60],[20000,60] ],
|
||||||
74: [[0, 40],[14000,45],[15000,50],[16000,55],[17000,60],[18000,65],[19000,55]],
|
74: [[0, 42],[8000,44],[9000,46],[10000, 48],[11000,50],[12000,52],[13000,54],[14000,56],[15000,58],[16000,60],[17000,60],[18000,60],[19000,60],[20000,60] ],
|
||||||
75: [[0, 40],[14000,45],[15000,50],[16000,55],[17000,60],[18000,65],[19000,55]],
|
75: [[0, 42],[8000,44],[9000,46],[10000, 48],[11000,50],[12000,52],[13000,54],[14000,56],[15000,58],[16000,60],[17000,60],[18000,60],[19000,60],[20000,60] ],
|
||||||
76: [[0, 40],[14000,45],[15000,50],[16000,55],[17000,60],[18000,65],[19000,55]],
|
76: [[0, 42],[8000,44],[9000,46],[10000, 48],[11000,50],[12000,52],[13000,54],[14000,56],[15000,58],[16000,60],[17000,60],[18000,60],[19000,60],[20000,60] ],
|
||||||
77: [[0, 40],[14000,45],[15000,50],[16000,55],[17000,60],[18000,65],[19000,55]],
|
77: [[0, 42],[8000,44],[9000,46],[10000, 48],[11000,50],[12000,52],[13000,54],[14000,56],[15000,58],[16000,60],[17000,60],[18000,60],[19000,60],[20000,60] ],
|
||||||
78: [[0, 40],[14000,45],[15000,50],[16000,55],[17000,60],[18000,65],[19000,55]],
|
78: [[0, 42],[8000,44],[9000,46],[10000, 48],[11000,50],[12000,52],[13000,54],[14000,56],[15000,58],[16000,60],[17000,60],[18000,60],[19000,60],[20000,60] ],
|
||||||
79: [[0, 40],[14000,45],[15000,50],[16000,55],[17000,60],[18000,65],[19000,55]],
|
79: [[0, 42],[8000,44],[9000,46],[10000, 48],[11000,50],[12000,52],[13000,54],[14000,56],[15000,58],[16000,60],[17000,60],[18000,60],[19000,60],[20000,60] ],
|
||||||
80: [[0, 40],[14000,45],[15000,50],[16000,55],[17000,60],[18000,65],[19000,55]],
|
80: [[0, 42],[8000,44],[9000,46],[10000, 48],[11000,50],[12000,52],[13000,54],[14000,56],[15000,58],[16000,60],[17000,60],[18000,60],[19000,60],[20000,60] ],
|
||||||
81: [[0, 40],[14000,45],[15000,50],[16000,55],[17000,60],[18000,65],[19000,55]],
|
81: [[0, 42],[8000,44],[9000,46],[10000, 48],[11000,50],[12000,52],[13000,54],[14000,56],[15000,58],[16000,60],[17000,60],[18000,60],[19000,60],[20000,60] ],
|
||||||
82: [[0, 40],[14000,45],[15000,50],[16000,55],[17000,60],[18000,65],[19000,55]],
|
82: [[0, 42],[8000,44],[9000,46],[10000, 48],[11000,50],[12000,52],[13000,54],[14000,56],[15000,58],[16000,60],[17000,60],[18000,60],[19000,60],[20000,60] ],
|
||||||
83: [[0, 42]],
|
83: [[0, 42],[8000,44],[9000,46],[10000, 48],[11000,50],[12000,52],[13000,54],[14000,56],[15000,58],[16000,60],[17000,60],[18000,60],[19000,60],[20000,60] ],
|
||||||
84: [[0, 42],[10000,50],[11000,60]],
|
84: [[0, 42],[8000,44],[9000,46],[10000, 48],[11000,50],[12000,52],[13000,54],[14000,56],[15000,58],[16000,60],[17000,60],[18000,60],[19000,60],[20000,60] ],
|
||||||
85: [[0, 42],[9000,45],[10000,50],[11000,60]],
|
85: [[0, 42],[8000,44],[9000,46],[10000, 48],[11000,50],[12000,52],[13000,54],[14000,56],[15000,58],[16000,60],[17000,60],[18000,60],[19000,60],[20000,60] ],
|
||||||
86: [[0, 40]],
|
86: [[0, 40]],
|
||||||
87: [[0, 40]],
|
87: [[0, 40]],
|
||||||
88: [[0, 40]],
|
88: [[0, 40]],
|
||||||
|
Loading…
Reference in New Issue
Block a user