def group_bars(note_list):
    """
    Returns a list of bars, where each bar is a list of notes. The 
    start and end times of each note are rescaled to units of bars, and
    expressed relative to the beginning of the current bar.
    
    Parameters
    ----------
    note_list : list of tuples
        List of notes to group into bars. 
    """
    bar_list = []
    current_bar = []
    current_bar_start_time = 0
    
    for raw_note in note_list:
        if raw_note[0] != -1:
            current_bar.append(raw_note)
        elif raw_note[0] == -1:
            quarter_notes_per_bar = raw_note[2] - current_bar_start_time
            current_bar_scaled = []
            for note in current_bar:
                current_bar_scaled.append((note[0],
                                           note[1],
                                           min([(note[2]
                                                 - current_bar_start_time)
                                                 / quarter_notes_per_bar, 1]),
                                           min([(note[3]
                                                 - current_bar_start_time)
                                                 / quarter_notes_per_bar, 1])))
                
            bar_list.append(current_bar_scaled)
            current_bar = []
            current_bar_start_time = raw_note[2]
            
    return bar_list