piccal/p_ac.yml
kpl fc1a0d8a61 Added calibrate.py, plot_calibrate.py and made associated changes.
Added plot_calibrate.ipynb jupyter notebook.
2019-11-24 20:07:47 -05:00

292 lines
17 KiB
YAML

{
p_ac: {
# Audio device setup
audio: {
inPortLabel: "5 USB Audio CODEC:", #"HDA Intel PCH: CS4208", # "5 USB Audio CODEC:", #"5 USB Sound Device",
outPortLabel: ,
},
midi_off: {
inMonitorFl: False,
outMonitorFl: False,
throughFl: False,
inPortLabel: "Fastlane:Fastlane MIDI A",
outPortLabel: "Fastlane:Fastlane MIDI A"
#inPortLabel: "picadae:picadae MIDI 1",
#outPortLabel: "picadae:picadae MIDI 1"
},
# Picadae API args
serial_dev: "/dev/ttyACM0",
serial_baud: 38400,
i2c_base_addr: 21,
prescaler_usec: 16,
serial_sync_timeout_ms: 10000,
# MeasureSeq args
outDir: "~/temp/p_ac_3c",
noteDurMs: 1000,
pauseDurMs: 1000,
holdDutyPctL: [ [0,50], [22000,55] ],
full_pulse0L: [ 500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 8000, 9000, 10000, 12000, 14000, 18000, 22000, 26000, 30000, 34000, 40000],
full_pulse1L: [ 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 20000, 22000, 24000, 26000, 30000, 32000, 34000, 36000, 40000],
full_pulse2L: [ 10000, 10500, 11000, 11500, 12000, 12500, 13000, 13500, 14000, 14500, 15000, 15500, 16000, 16500, 17000, 17500, 18000, 18500, 20000, 22000, 24000, 26000, 30000, 32000, 34000, 36000, 40000],
full_pulse3L: [ 10000, 10125, 10250, 10500, 10625, 10750, 10875, 11000, 11125, 11250, 11500, 11625, 11750, 11875, 12000, 12125, 12250, 12500, 12625, 12750, 12875, 13000, 13125, 13250, 13500, 13625, 13750, 13875, 14000, 14125, 14250, 14500, 14625, 14750, 14875, 15000, 15500, 16000, 16500, 17000, 17500, 18000, 18500, 20000, 22000, 24000, 26000, 30000, 32000, 34000, 36000, 40000],
full_pulse4L: [ 8000, 8125, 8250, 8375, 8500, 8625, 8750, 8875, 9000, 9125, 9250, 9375, 9500, 9625, 9750, 9875, 10000, 10125, 10250, 10375, 10500, 10625, 10750, 10875, 11000, 11125, 11250, 11375, 11500, 11625, 11750, 11875, 12000, 12125, 12250, 12375, 12500, 12625, 12750, 12875, 13000, 13125, 13250, 13375, 13500, 13625, 13750, 13875, 14000, 14125, 14375, 14250, 14500, 14625, 14750, 14875, 15000, 15250, 15375, 15500, 15750, 16000, 16250, 16500, 16750, 17000, 17250, 17500, 17750, 18000, 18250, 18500, 18750, 20000, 21000, 22000, 23000, 24000, 25000, 26000, 27000, 28000, 30000, 32000, 34000, 36000, 40000],
full_pulse5L: [ 10000, 10125, 10250, 10375, 10500, 10625, 10750, 10875, 11000, 11125, 11250, 11375, 11500, 11625, 11750, 11875, 12000, 12125, 12250, 12375, 12500, 12625, 12750, 12875, 13000, 13125, 13250, 13375, 13500, 13625, 13750, 13875, 14000, 14125, 14250, 14375, 14500, 14625, 14750, 14875, 15000, 15250, 15375, 15500, 15750, 16000, 16250, 16500, 16750, 17000, 17250, 17500, 17750, 18000, 18250, 18500, 18750, 20000, 21000, 22000, 23000, 24000, 25000, 26000, 27000, 28000, 30000, 32000, 34000, 36000, 40000],
full_pulse6L: [ 12000, 12125, 12250, 12375, 12500, 12625, 12750, 12875, 13000, 13125, 13250, 13375, 13500, 13625, 13750, 13875, 14000, 14125, 14250, 14375, 14500, 14625, 14750, 14875, 15000, 15250, 15375, 15500, 15750, 16000, 16250, 16500, 16750, 17000, 17250, 17500, 17750, 18000, 18250, 18500, 18750, 19000, 19500, 20000, 20500, 21000, 21500, 22000, 22500, 23000, 23500, 24000, 24500, 25000, 25500, 26000, 26500, 27000, 27500, 28000, 28500, 29000, 30000, 31000, 32000, 33000, 34000, 35000, 36000, 37000, 38000, 39000, 40000 ],
full_pulseL: [ 11000, 11125, 11250, 11375, 11500, 11625, 11750, 11875, 12000, 12125, 12250, 12375, 12500, 12625, 12750, 12875, 13000, 13125, 13250, 13375, 13500, 13625, 13750, 13875, 14000, 14125, 14250, 14375, 14500, 14625, 14750, 14875, 15000, 15250, 15375, 15500, 15750, 16000, 16250, 16500, 16750, 17000, 17250, 17500, 17750, 18000, 18250, 18500, 18750, 19000, 19500, 20000, 20500, 21000, 21500, 22000, 22500, 23000, 23500, 24000, 24500, 25000, 25500, 26000, 26500, 27000, 27500, 28000, 28500, 29000, 30000, 31000, 32000, 33000, 34000, 35000, 36000, 37000, 38000, 39000, 40000 ],
full_pulse7L: [ 10000, 10050, 10100, 10150, 10200, 10250, 10300, 10350, 10400, 10450, 10500, 10550, 10600, 10650, 10700, 10750, 10800, 10850, 10900, 10950, 11000, 11125, 11250, 11375, 11500, 11625, 11750, 11875, 12000, 12125, 12250, 12375, 12500, 12625, 12750, 12875, 13000, 13125, 13250, 13375, 13500, 13625, 13750, 13875, 14000, 14125, 14250, 14375, 14500, 14625, 14750, 14875, 15000, 15250, 15375, 15500, 15750, 16000, 16250, 16500, 16750, 17000, 17250, 17500, 17750, 18000, 18250, 18500, 18750, 19000, 19500, 20000, 20500, 21000, 21500, 22000, 22500, 23000, 23500, 24000, 24500, 25000, 25500, 26000, 26500, 27000, 27500, 28000, 28500, 29000, 30000, 31000, 32000, 33000, 34000, 35000, 36000, 37000, 38000, 39000, 40000 ],
full_pulse9L: [ 8750, 8800, 8850, 8900, 8950, 9000, 9050, 9100, 9150, 9200, 9250, 9300, 9350, 9400, 9450,9500, 9550, 9600, 9650, 9700, 9750, 9800, 9850, 9900, 9950, 10000, 10050, 10100, 10150, 10200, 10250, 10300, 10350, 10400, 10450, 10500, 10550, 10600, 10650, 10700, 10750, 10800, 10850, 10900, 10950, 11000, 11125, 11250, 11375, 11500, 11625, 11750, 11875, 12000, 12125, 12250, 12375, 12500, 12625, 12750, 12875, 13000, 13125, 13250, 13375, 13500, 13625, 13750, 13875, 14000, 14125, 14250, 14375, 14500, 14625, 14750, 14875, 15000, 15250, 15375, 15500, 15750, 16000, 16250, 16500, 16750, 17000, 17250, 17500, 17750, 18000, 18250, 18500, 18750, 19000, 19500, 20000, 20500, 21000, 21500, 22000, 22500, 23000, 23500, 24000, 24500, 25000, 25500, 26000, 26500, 27000, 27500, 28000, 28500, 29000, 30000, 31000, 32000, 33000, 34000, 35000, 36000, 37000, 38000, 39000, 40000 ],
# RMS analysis args
analysisArgs: {
rmsAnalysisArgs: {
rmsWndMs: 300, # length of the RMS measurment window
rmsHopMs: 30, # RMS measurement inter window distance
dbRefWndMs: 500, # length of initial portion of signal to use to calculate the dB reference level
harmCandN: 5, # count of harmonic candidates to locate during harmonic based RMS analysis
harmN: 3, # count of harmonics to use to calculate harmonic based RMS analysis
},
minAttkDb: 7.0, # threshold of silence level
maxDbOffset: 0.25, # travel down the from the max. note level by at most this amount to locate the max. peak
maxDeltaDb: 1.5, # maximum db change between volume samples (changes greater than this will trigger resampling)
samplesPerDb: 4, # count of samples per dB to resample ranges whose range is less than maxDeltaDb
minSampleDistUs: 50, # minimum distance between sample points in microseconds
auditionNoteN: 19, # count of notes to play for audition
finalPulseListCacheFn: "/home/kevin/temp/final_pulse_list_cache.pickle",
rmsAnalysisCacheFn: "/home/kevin/temp/rms_analysis_cache.pickle"
},
calibrateArgs: {
outDir: "~/temp/calib0",
outLabel: "test",
analysisD: {
rmsWndMs: 300, # length of the RMS measurment window
rmsHopMs: 30, # RMS measurement inter window distance
dbRefWndMs: 500, # length of initial portion of signal to use to calculate the dB reference level
harmCandN: 5, # count of harmonic candidates to locate during harmonic based RMS analysis
harmN: 3, # count of harmonics to use to calculate harmonic based RMS analysis
durDecayPct: 40 # percent drop in RMS to indicate the end of a note
},
noteOnDurMs: 1000,
noteOffDurMs: 1000,
pitchL: [ 50, 51, 52 ], # list of pitches
targetDbL: [ 16, 20, 23 ], # list of target db
minMeasDurMs: 800, # minimum candidate note duration
tolDbPct: 5.0, # tolerance as a percent of targetDb above/below used to form match db window
maxPulseUs: 45000, # max. allowable pulse us
minPulseUs: 8000, # min. allowable pulse us
initPulseUs: 15000, # pulseUs for first note
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
dbSrcLabel: 'td', # source of the db measurement 'td' (time-domain) or 'hm' (harmonic)
holdDutyPctD: {
23: [[0, 70]],
24: [[0, 75]],
25: [[0, 70]],
26: [[0, 65]],
27: [[0, 70]],
28: [[0, 70]],
29: [[0, 65]],
30: [[0, 65]],
31: [[0, 65]],
32: [[0, 60]],
33: [[0, 65]],
34: [[0, 65]],
35: [[0, 65]],
36: [[0, 65]],
37: [[0, 65]],
38: [[0, 60]],
39: [[0, 60]],
40: [[0, 55]],
41: [[0, 60]],
42: [[0, 60]],
43: [[0, 65]],
44: [[0, 60]],
45: [[0, 60]],
46: [[0, 60]],
47: [[0, 60]],
48: [[0, 70]],
49: [[0, 60]],
50: [[0, 50]],
51: [[0, 50]],
52: [[0, 55]],
53: [[0, 50]],
54: [[0, 50]],
55: [[0, 50], [22000, 55]],
56: [[0, 50]],
57: [[0, 50]],
58: [[0, 50]],
59: [[0, 60]],
60: [[0, 50]],
61: [[0, 50]],
62: [[0, 55]],
63: [[0, 50]],
64: [[0, 50]],
65: [[0, 50], [17000, 65]],
66: [[0, 53]],
67: [[0, 55]],
68: [[0, 53]],
69: [[0, 55]],
70: [[0, 50]],
71: [[0, 50]],
72: [[0, 60]],
73: [[0, 50]],
74: [[0, 60]],
75: [[0, 55]],
76: [[0, 70]],
77: [[0, 50], [15000, 60], [19000, 70]],
78: [[0, 60]],
79: [[0, 50], [15000, 60], [19000, 70]],
80: [[0, 45]],
81: [[0, 50], [15000, 70]],
82: [[0, 50], [12500, 60], [14000, 65], [17000, 70]],
83: [[0, 50], [15000, 65]],
84: [[0, 50], [12500, 60], [14000, 65], [17000, 70]],
85: [[0, 50], [12500, 60], [14000, 65], [17000, 70]],
86: [[0, 50], [12500, 60], [14000, 65], [17000, 70]],
87: [[0, 50], [14000, 60]],
88: [[0, 50], [12500, 60], [14000, 65], [17000, 70]],
89: [[0, 50], [12500, 60], [14000, 65], [17000, 70]],
91: [[0, 40], [12500, 50], [14000, 60], [17000, 65]],
92: [[0, 40], [14000, 50]],
93: [[0, 40], [12500, 50], [14000, 60], [17000, 65]],
94: [[0, 40], [14000, 50]],
95: [[0, 40], [12500, 50], [14000, 60], [17000, 65]],
96: [[0, 40], [12500, 50], [14000, 60], [17000, 65]],
97: [[0, 40], [14000, 50]],
98: [[0, 50]],
99: [[0, 50]],
100: [[0, 50]],
101: [[0, 50]],
106: [[0, 50]]
},
},
key_mapL: [
{ index: 0, board: 1, ch: 1, type: 'wB', midi: 21, class: 'A' },
{ index: 1, board: 1, ch: 2, type: 'Bl', midi: 22, class: 'A#' },
{ index: 2, board: 1, ch: 3, type: 'wF', midi: 23, class: 'B' },
{ index: 3, board: 1, ch: 4, type: 'wB', midi: 24, class: 'C' },
{ index: 4, board: 1, ch: 5, type: 'Bl', midi: 25, class: 'C#' },
{ index: 5, board: 1, ch: 6, type: 'wF', midi: 26, class: 'D' },
{ index: 6, board: 1, ch: 7, type: 'Bl', midi: 27, class: 'D#' },
{ index: 7, board: 1, ch: 8, type: 'wB', midi: 28, class: 'E' },
{ index: 8, board: 1, ch: 9, type: 'wF', midi: 29, class: 'F' },
{ index: 9, board: 1, ch: 10, type: 'Bl', midi: 30, class: 'F#' },
{ index: 10, board: 1, ch: 11, type: 'wB', midi: 31, class: 'G' },
{ index: 11, board: 2, ch: 1, type: 'Bl', midi: 32, class: 'G#' },
{ index: 12, board: 2, ch: 2, type: 'wF', midi: 33, class: 'A' },
{ index: 13, board: 2, ch: 3, type: 'Bl', midi: 34, class: 'A#' },
{ index: 14, board: 2, ch: 4, type: 'wB', midi: 35, class: 'B' },
{ index: 15, board: 2, ch: 5, type: 'wF', midi: 36, class: 'C' },
{ index: 16, board: 2, ch: 6, type: 'Bl', midi: 37, class: 'C#' },
{ index: 17, board: 2, ch: 7, type: 'wB', midi: 38, class: 'D' },
{ index: 18, board: 2, ch: 8, type: 'Bl', midi: 39, class: 'D#' },
{ index: 19, board: 2, ch: 9, type: 'wF', midi: 40, class: 'E' },
{ index: 20, board: 2, ch: 10, type: 'wB', midi: 41, class: 'F' },
{ index: 21, board: 2, ch: 11, type: 'Bl', midi: 42, class: 'F#' },
{ index: 22, board: 3, ch: 1, type: 'wF', midi: 43, class: 'G' },
{ index: 23, board: 3, ch: 2, type: 'Bl', midi: 44, class: 'G#' },
{ index: 24, board: 3, ch: 3, type: 'wB', midi: 45, class: 'A' },
{ index: 25, board: 3, ch: 4, type: 'Bl', midi: 46, class: 'A#' },
{ index: 26, board: 3, ch: 5, type: 'wF', midi: 47, class: 'B' },
{ index: 27, board: 3, ch: 6, type: 'wB', midi: 48, class: 'C' },
{ index: 28, board: 3, ch: 7, type: 'Bl', midi: 49, class: 'C#' },
{ index: 29, board: 3, ch: 8, type: 'wF', midi: 50, class: 'D' },
{ index: 30, board: 3, ch: 9, type: 'Bl', midi: 51, class: 'D#' },
{ index: 31, board: 3, ch: 10, type: 'wB', midi: 52, class: 'E' },
{ index: 32, board: 3, ch: 11, type: 'wF', midi: 53, class: 'F' },
{ index: 33, board: 4, ch: 1, type: 'Bl', midi: 54, class: 'F#' },
{ index: 34, board: 4, ch: 2, type: 'wB', midi: 55, class: 'G' },
{ index: 35, board: 4, ch: 3, type: 'Bl', midi: 56, class: 'G#' },
{ index: 36, board: 4, ch: 4, type: 'wF', midi: 57, class: 'A' },
{ index: 37, board: 4, ch: 5, type: 'Bl', midi: 58, class: 'A#' },
{ index: 38, board: 4, ch: 6, type: 'wB', midi: 59, class: 'B' },
{ index: 39, board: 4, ch: 7, type: 'wF', midi: 60, class: 'C' },
{ index: 40, board: 4, ch: 8, type: 'Bl', midi: 61, class: 'C#' },
{ index: 41, board: 4, ch: 9, type: 'wB', midi: 62, class: 'D' },
{ index: 42, board: 4, ch: 10, type: 'Bl', midi: 63, class: 'D#' },
{ index: 43, board: 4, ch: 11, type: 'wF', midi: 64, class: 'E' },
{ index: 44, board: 5, ch: 1, type: 'wB', midi: 65, class: 'F' },
{ index: 45, board: 5, ch: 2, type: 'Bl', midi: 66, class: 'F#' },
{ index: 46, board: 5, ch: 3, type: 'wF', midi: 67, class: 'G' },
{ index: 47, board: 5, ch: 4, type: 'Bl', midi: 68, class: 'G#' },
{ index: 48, board: 5, ch: 5, type: 'wB', midi: 69, class: 'A' },
{ index: 49, board: 5, ch: 6, type: 'Bl', midi: 70, class: 'A#' },
{ index: 50, board: 5, ch: 7, type: 'wF', midi: 71, class: 'B' },
{ index: 51, board: 5, ch: 8, type: 'wB', midi: 72, class: 'C' },
{ index: 52, board: 5, ch: 9, type: 'Bl', midi: 73, class: 'C#' },
{ index: 53, board: 5, ch: 10, type: 'wF', midi: 74, class: 'D' },
{ index: 54, board: 5, ch: 11, type: 'Bl', midi: 75, class: 'D#' },
{ index: 55, board: 6, ch: 1, type: 'wB', midi: 76, class: 'E' },
{ index: 56, board: 6, ch: 2, type: 'wF', midi: 77, class: 'F' },
{ index: 57, board: 6, ch: 3, type: 'Bl', midi: 78, class: 'F#' },
{ index: 58, board: 6, ch: 4, type: 'wB', midi: 79, class: 'G' },
{ index: 59, board: 6, ch: 5, type: 'Bl', midi: 80, class: 'G#' },
{ index: 60, board: 6, ch: 6, type: 'wF', midi: 81, class: 'A' },
{ index: 61, board: 6, ch: 7, type: 'Bl', midi: 82, class: 'A#' },
{ index: 62, board: 6, ch: 8, type: 'wB', midi: 83, class: 'B' },
{ index: 63, board: 6, ch: 9, type: 'wF', midi: 84, class: 'C' },
{ index: 64, board: 6, ch: 10, type: 'Bl', midi: 85, class: 'C#' },
{ index: 65, board: 6, ch: 11, type: 'wB', midi: 86, class: 'D' },
{ index: 66, board: 6, ch: 1, type: 'Bl', midi: 87, class: 'D#' },
{ index: 67, board: 6, ch: 2, type: 'wF', midi: 88, class: 'E' },
{ index: 68, board: 6, ch: 3, type: 'wB', midi: 89, class: 'F' },
{ index: 69, board: 6, ch: 4, type: 'Bl', midi: 90, class: 'F#' },
{ index: 70, board: 6, ch: 5, type: 'wF', midi: 91, class: 'G' },
{ index: 71, board: 6, ch: 6, type: 'Bl', midi: 92, class: 'G#' },
{ index: 72, board: 6, ch: 7, type: 'wB', midi: 93, class: 'A' },
{ index: 73, board: 6, ch: 8, type: 'Bl', midi: 94, class: 'A#' },
{ index: 74, board: 6, ch: 9, type: 'wF', midi: 95, class: 'B' },
{ index: 75, board: 6, ch: 10, type: 'wB', midi: 96, class: 'C' },
{ index: 76, board: 6, ch: 11, type: 'Bl', midi: 97, class: 'C#' },
{ index: 77, board: 7, ch: 1, type: 'wF', midi: 98, class: 'D' },
{ index: 78, board: 7, ch: 2, type: 'Bl', midi: 99, class: 'D#' },
{ index: 79, board: 7, ch: 3, type: 'wB', midi: 100, class: 'E' },
{ index: 80, board: 7, ch: 4, type: 'wF', midi: 101, class: 'F' },
{ index: 81, board: 7, ch: 5, type: 'Bl', midi: 102, class: 'F#' },
{ index: 82, board: 7, ch: 6, type: 'wB', midi: 103, class: 'G' },
{ index: 83, board: 7, ch: 7, type: 'Bl', midi: 104, class: 'G#' },
{ index: 84, board: 7, ch: 8, type: 'wF', midi: 105, class: 'A' },
{ index: 85, board: 7, ch: 9, type: 'Bl', midi: 106, class: 'A#' },
{ index: 86, board: 7, ch: 10, type: 'wB', midi: 107, class: 'B' },
{ index: 87, board: 7, ch: 11, type: 'wF', midi: 108, class: 'C' },
]
}
}