Skip to content

Instantly share code, notes, and snippets.

@rxw1
Created July 13, 2014 16:24
Show Gist options
  • Save rxw1/16bfd219b18a8cd9fca9 to your computer and use it in GitHub Desktop.
Save rxw1/16bfd219b18a8cd9fca9 to your computer and use it in GitHub Desktop.
Disassemble guitar tabs
|--0--2--|--3----2--0-------0--2--|-------------0----------|------------------------|--------------------0--2--|--3----2--0-------0--2--|-------------0----------|---------------------------|---------------0--2--|---------------------|------------------3-----|--0---------------------|------------------------|-------------------------|-------3-----0----------|-------5-----2-------0--|----------------------------|-------------------7-----|-------------5-------3--|--2----0-----3-------1--|--0----5--0--2-------0--|-------------------0-----|--------------------------|-------------------------|---------------------------|---------------------|-------------------|
|--------|-------------4----------|--0----2--4-------3--1--|--0---------------------|--0-----------------------|-------------4----------|--0----2--4-------3--1--|--0------------------------|---------------------|---------------0-----|--3-------1--0-------3--|----------3--1----------|----------0--1----0-----|-------------------3-----|--0-------3----------3--|--1-------5-------2-----|--3----2--0--------------0--|--0-------------------7--|--9----7--5-------5-----|----------3-------3-----|------------------2-----|--4-------------------0--|--1-----3-----0-----1-----|--------0----------------|---------------------------|---------------0-----|-------------------|
|--------|------------------------|------------------------|-------2--0-------0--2--|-----2--0-----------------|------------------------|------------------------|-------2--0--------0----0--|--0------------------|--0---------------0--|-------2----------------|-------4----------4--2--|--1----2-------------2--|--2-------------------2--|------------------4-----|------------------------|-------------4-3-4-3-4-3----|-------------------------|------------------------|------------------------|------------------------|-------4-----------------|-----------2-----------0--|--2-----------0----------|-------------0----0--------|------------------0--|-------------------|
|--------|------------------------|------------------------|-------------4----------|-----------4--2-----------|------------------------|------------------------|-------------4-2-4---4-----|--0------------------|--0------------------|-------0----------------|------------------0-----|--2----------2----------|-------------------0-----|------------------------|-------------0----------|-------2-----4--------------|--------------1----------|------------------------|--0---------------------|------------------------|-------------------------|-----2--4--------1--2-----|-----------4-------4--2--|--1----2--4-----4---4-2-4--|--2------------------|--2----------------|
|--------|-------0-----2----0-----|------------------------|-------0-----2----0-----|--------2-----------------|-------0-----2----0-----|------------------------|-------3-----5-------5-----|--2------------------|--2------------------|------------------2-----|--3----------0----------|-------0----------------|--0--2--0----------------|-------2-----3----------|--0----4----------1-----|--2-------------------------|--2--1--2--4-------------|--7----5-----4----------|-------3-----2----------|--3----2-----0----------|--2-------3--2--0--------|--0-----------------------|-----4--6----------0-----|--2----0-----2-------------|---------------------|--2----------------|
|--3--2--|--0---------------------|--3----2-----0----2-----|--3---------------------|--3-----------0--2--3--2--|--0---------------------|--3----2-----0----2-----|--3------------------------|--3------------3--2--|--3------------3-----|--2----------3----------|-------4----------------|------------------0-----|-----------3--2----------|--3---------------4-----|------------------------|---------------------2------|-------------------7-----|------------------5-----|------------------3-----|------------------2-----|-------------------4-----|--------------3-----------|--2-----------0----------|---------------------------|--0------------3-----|--0----------------|
# Reads a file containing a guitar tabulature.
# Returns a sorted tabulature with all the unique patterns.
File.read(ARGV[0]).split.map{|x|x.split'|'}.transpose.map{|x|x.map{|y|y.scan(/./)}}.map(&:transpose).flatten(1).uniq.sort.transpose.map{|x|x.join('-')}
# For sample input see bouree.txt below. The whole tab should be without linebreaks except the one separating the strings. The output should look like this:
# "----------------------------------------------------------------------------------------------------------------------0-0-0-0-0-0-1-2-2-2-2-3-3-3-5-5-7"
# "----------------------------------------------------------------------0-0-0-0-0-1-1-1-2-2-2-3-3-3-3-3-3-4-4-5-5-7-7-9----------------------------------"
# "------------------------------------0-0-0-0-0-1-2-2-2-2-2-3-4-4-4-4-4----------------------------------------------------------------------------------"
# "----------------1-1-2-2-2-2-4-4-4-4---------0-2---------0---------0-4---------------2-----2---------0-4-----------------------------------0------------"
# "------0-1-2-3-4---2-----0-2---0-2-5-----0-2-2-------0-3---------------------2-6---0-----1---------2-------2-------5-7---------0-3-------0-------2-2-4--"
# "--2-3-----------------0---0-----------0-----3-----2-----------2-4-------0-3-----------2-------2-3-------------5---------0-3-4---------2-------0-------7"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment