Skip to content

Python library for opening and managing Band-in-a-Box (BIAB) files.

License

Notifications You must be signed in to change notification settings

andreamust/biab-library

Repository files navigation

BIAB Library

A pybind11 module built with a CMake-based build system for converting Band-in-a-Box files.

The C++ source code has been provided by Andrew Choi, to whom all credits must be given.

Installation

Installation via pip

You can install the library using pip, by running the command:

pip install biab-library

You can also find the PyPi documentation at this link.

Local installation

For installing the library locally, you can follow these steps:

  • clone this repository running git clone https://github.com/andreamust/biab-library.git
  • run pip install ./biab-library

Usage

The library implements three different methods for accessing the data stored in the Band-in-a-Box files.

The methods are as follows:

  • biab_data: given a Band-in-a-Box file path, it returns all the data stored in the file;
  • biab_meta: given a Band-in-a-Box file path, it returns the file metadata;
  • biab_chords: given a Band-in-a-Box file path, it returns all the chords contained in the file.

All the methods aforementioned can be called as follows:

import biab

biab_path = "path/to/biabfile"

biab_data = biab.biab_data(biab_path)
biab_meta = biab.biab_meta(biab_path)
biab_chords = biab.biab_chords(biab_path)

Output

The output of the biab_meta() method consists of a list containing the following elements:

[Track Title, Metre numerator, Metre denominator, Key, Tempo]

The output of the biab_chords() method consists of a list of lists, each of which containing the following elements:

[Chord starting time, Chord duration, Chord value]

The output of the biab_data() method consists of a tuple which is the combination of the biab_meta() and the biab_chords() outputs.

Below, you can find an example of a biab_data() method call:

(['April In Paris', '4', '4', 'C', '130'], 
    [
        ['0', '4', 'F:min'], 
        ['4', '4', 'C:maj7'], 
        ['8', '4', 'D:(b3,b5,b7)'], 
        ['12', '4', 'G:(3,5,b7)'], 
        ['16', '8', 'C:maj7'], 
        ['24', '4', 'G:min(b7)'], 
        ['28', '4', 'C:(3,5,b7)'], 
        ['32', '4', 'F:maj7'], 
        ['36', '4', 'F:maj7'], 
        ['40', '2', 'B:(b3,b5,b7)'], 
        ['42', '2', 'E:(3,5,b7)'], 
        ['44', '2', 'A:min'], 
        ['46', '2', 'A:min/G'], 
        ['48', '4', 'F#:(b3,b5,b7)/D'], 
        ['52', '4', 'B:(3,5,b7,b9)'], 
        ['56', '2', 'B:min(b7)'], 
        ['58', '2', 'E:(3,5,b7)'], 
        ['60', '2', 'E:(b3,b5,b7)'], 
        ['62', '2', 'A:(3,5,b7,b9)'], 
        ['64', '2', 'D:min(b7)'], 
        ['66', '2', 'F:min'], 
        ['68', '2', 'C:maj/E'], 
        ['70', '2', 'Eb:dim'], 
        ['72', '2', 'D:(b3,b5,b7)'], 
        ['74', '2', 'F:min'], 
        ['76', '4', 'C:maj'], 
        ['80', '2', 'B:(b3,b5,b7)'], 
        ['82', '2', 'E:(3,5,b7)'], 
        ['84', '2', 'A:min'], 
        ['86', '2', 'A:min/G'], 
        ['88', '2', 'F#:(b3,b5,b7)/D'], 
        ['90', '2', 'B:(3,5,b7,b9)'], 
        ['92', '2', 'E:maj7'], 
        ['94', '1', 'D:min(b7)'], 
        ['95', '1', 'G:(3,5,b7,9)'], 
        ['96', '4', 'F:min'], 
        ['100', '4', 'C:maj7'], 
        ['104', '4', 'E:(b3,b5,b7)'], 
        ['108', '4', 'A:(3,#5,b7)'], 
        ['112', '4', 'D:(3,5,b7,9)'], 
        ['116', '2', 'D:(b3,b5,b7)'], 
        ['118', '2', 'G:(3,5,b7)'], 
        ['120', '4', 'C:maj']
    ]
)

Tests

TBD

Building the documentation

Documentation for the example project is generated using Sphinx. Sphinx has the ability to automatically inspect the signatures and documentation strings in the extension module to generate beautiful documentation in a variety formats. The following command generates HTML-based reference documentation; for other formats please refer to the Sphinx manual:

  • cd python_example/docs
  • make html

License

pybind11 is provided under a BSD-style license that can be found in the LICENSE file. By using, distributing, or contributing to this project, you agree to the terms and conditions of this license.