#NEWLINE# def adjust_times( self , original_times , new_times ) : #NEWLINE# #INDENT# "Adjusts the timing of the events in the MIDI object.\n        The parameters `original_times` and `new_times` define a mapping, so\n        that if an event originally occurs at time `original_times[n]`, it\n        will be moved so that it occurs at `new_times[n]`.  If events don't\n        occur exactly on a time in `original_times`, their timing will be\n        linearly interpolated.\n\n        Parameters\n        ----------\n        original_times : np.ndarray\n            Times to map from\n        new_times : np.ndarray\n            New times to map to\n\n        " #NEWLINE# for instrument in self . instruments : #NEWLINE# #INDENT# valid_notes = [ ] #NEWLINE# for note in instrument . notes : #NEWLINE# #INDENT# if ( ( note . start >= original_times [ 0 ] ) and ( note . end <= original_times [ ( - 1 ) ] ) ) : #NEWLINE# #INDENT# valid_notes . append ( copy . deepcopy ( note ) ) #NEWLINE# #UNINDENT# #UNINDENT# instrument . notes = valid_notes #NEWLINE# #UNINDENT# note_ons = np . array ( [ note . start for instrument in self . instruments for note in instrument . notes ] ) #NEWLINE# aligned_note_ons = np . interp ( note_ons , original_times , new_times ) #NEWLINE# note_offs = np . array ( [ note . end for instrument in self . instruments for note in instrument . notes ] ) #NEWLINE# aligned_note_offs = np . interp ( note_offs , original_times , new_times ) #NEWLINE# pitch_bends = np . array ( [ original_times . time for instrument in self . instruments for bend in instrument . pitch_bends ] ) #NEWLINE# aligned_pitch_bends = np . interp ( pitch_bends , original_times , new_times ) #NEWLINE# ccs = np . array ( [ cc . time for instrument in self . instruments for cc in instrument . control_changes ] ) #NEWLINE# aligned_ccs = np . interp ( ccs , original_times , new_times ) #NEWLINE# for ( n , note ) in enumerate ( [ note for instrument in self . instruments for note in instrument . notes ] ) : #NEWLINE# #INDENT# note . start = ( ( aligned_note_ons [ n ] > 0 ) * aligned_note_ons [ n ] ) #NEWLINE# note . end = ( ( aligned_note_offs [ n ] > 0 ) * aligned_note_offs [ n ] ) #NEWLINE# #UNINDENT# self . remove_invalid_notes ( ) #NEWLINE# for ( n , bend ) in enumerate ( [ bend for instrument in self . instruments for bend in instrument . pitch_bends ] ) : #NEWLINE# #INDENT# bend . time = ( ( aligned_pitch_bends [ n ] > 0 ) * aligned_pitch_bends [ n ] ) #NEWLINE# #UNINDENT# for ( n , cc ) in enumerate ( [ cc for instrument in self . instruments for cc in instrument . control_changes ] ) : #NEWLINE# #INDENT# cc . time = ( ( aligned_ccs [ n ] > 0 ) * aligned_ccs [ n ] )