Gene Boggs > MIDI-Tab > MIDI::Tab



Annotate this POD

View/Report Bugs
Module Version: 0.04   Source  


MIDI::Tab - Generate MIDI from ASCII tablature


version 0.04


  use MIDI::Tab;
  use MIDI::Simple;

  patch_change 1, 34; # Bass
  patch_change 3, 49; # Strings

  my $drums = <<'EOF';
  CYM: 8-------------------------------
  BD:  8-4---8-2-8-----8-4---8-2-8-----
  SD:  ----8-------8-------8-------8---
  HH:  66--6-6-66--6-6-66--6-6-66--6-6-
  OHH: --6-------6-------6-------6-----

  my $bass = <<'EOF';
  G3: --------------------------------
  D3: --------------------------------
  A2: 5--53-4-5--53-1-----------------
  E2: ----------------3--31-2-3--23-4-

  my $strings = <<'EOF';
  A5: 55
  A4: 55

      sub {
          from_drum_tab($_[0], $drums, 'sn');
      sub {
          from_guitar_tab($_[0], $bass, 'sn', 'c1');
      sub {
          from_piano_tab($_[0], $strings, 'wn', 'c3');


  # Use of the (experimental) control line:
  $tab = <<'EOF';
  CTL: --------3-3-3-3---------
  HH:  959595959595959595959595


MIDI::Tab allows you to create MIDI files from ASCII tablature. It is designed to work alongside MIDI::Simple.

Currently, there are three types of tablature supported: drum, guitar and piano tab.

Note that bar lines (|) are ignored. Also a control line may be specified, in order to alter no-ops for individual notes. This is an incomplete, experimental but useful feature.


MIDI::Tab - Generate MIDI from ASCII tablature


Each of these routines generates a set of MIDI::Simple notes on the object passed as the first parameter. The parameters are:

 MIDI:Simple object
 Tab Notes (as ASCII text)
 Noop Arguments (for changing channels etc)

Parameters to the from_*_tab() routines, that are specified after the tablature string, are passed as MIDI::Simple::noop calls at the start of the tab rendering. For example, the length of each unit of time can be specified by passing a MIDI::Simple duration value (e.g. 'sn').

Additionally, a control line for individual note modification may be included in the tab, at the same vertical position as the note it modifies. This line must be named CTL. At this point it is only used to specify triplet timing.


  from_guitar_tab($object, $tab_text, @noops)

Notes are specified by an ASCII guitar where each horizontal line represents a guitar string (as if the guitar were laid face-up in front of you).

Time runs from left to right. You can 'tune' the guitar by specifying different root notes for the strings. These should be specified as a MIDI::Simple alphanumeric absolute note value (e.g. 'A2'). The numbers of the tablature represent the fret at which the note is played.


  from_drum_tab($object, $tab_text, @noops)

Each horizontal line represents a different drum part and time runs from left to right. Minus or plus characters represent rest intervals. As many or as few drums as required can be specified, each drum having a two or three letter code, such as BD for the General MIDI "Bass Drum 1" or SD for the "Acoustic Snare." These are all listed in %MIDI::Tab::drum_notes, which can be viewed or altered by your code.

The numbers on the tablature represent the volume of the drum hit, from 1 to 9, where 9 is the loudest.


  from_piano_tab($object, $tab_text, @noops)

Each horizontal line represents a different note on the piano and time runs from left to right. The values on the line represent volumes from 1 to 9.


* The code in the eg/ and t/ directories.

* MIDI::Simple


Rob Symes <> and Gene Boggs <>


This software is copyright (c) 2013 by Rob Symes and Gene Boggs.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

syntax highlighting: