     cache[name] = fn.call(this)
 
 class Fingering
-  constructor: ({@positions, @chord}) ->
+  constructor: ({@positions, @chord, @barres}) ->
     @positions.sort (a, b) -> a.string - b.string
 
   @cached_getter 'fretstring', ->

  fingerings = filter_fingerings fingerings
  fingerings = sort_fingerings fingerings

  # for fingering in fingerings
  #   console.info finger_count(fingering)
  return fingerings

best_fingering_for = (chord) ->

    return fingering.fretstring.match(/x$/)

  finger_count = (fingering) ->
    n = (pos for pos in fingering.positions when pos.fret > 0).length
    n -= barre.subsumption_count for barre in fingering.barres
    n

  four_fingers_or_fewer = (fingering) ->
    return finger_count(fingering) <= 4

  cmp = (fn) -> (x...) -> !fn(x...)

  # Construct the filter set

  filters = [
    {name: 'four fingers or fewer', filter: four_fingers_or_fewer}
  ]

  if options.filter
    filters.push name: 'has all chord notes', filter: has_all_notes

  unless options.fingerpicking
    filters.push name: 'no muted medial strings', filter: cmp(muted_medial_strings)
    filters.push name: 'no muted treble strings', filter: cmp(muted_treble_strings)

  # filter by all the filters in the list, except ignore those that wouldn't pass anything
  filter_fingerings = (fingerings) ->
    for {name, filter} in filters
      filtered = (fingering for fingering in fingerings when filter(fingering))
      unless filtered.length
        console.warn "#{chord_name}: no fingerings pass filter \"#{name}\"" if warn
        filtered = fingerings
      fingerings = filtered
    return fingerings
