Skip to content

OLDRedstone/Brc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Brc

Overview

The Brc namespace provides functionality for reading and writing .brc files, which are used to represent structured musical data. The library currently exposes three serializer families with different goals:

  • text: readable, compatible text loading and saving
  • byte: fast byte-oriented loading and saving
  • bit: compact bit-oriented loading and saving

BrcTextReader

The BrcTextReader class is the public loader for .brc text files and returns BrcDocument objects.

Key Features

  • Read Method: Parses .brc text into BrcDocument objects.
  • Compatibility: Keeps the text format human-readable and forgiving for round-tripping.

BrcTextWriter

The BrcTextWriter class is responsible for saving BrcDocument objects into .brc text file format.

Key Features

  • WriteText Method: Converts BrcDocument objects into .brc text and writes them to a specified StreamWriter.
  • Sentence Serialization: Handles serialization of BrcSentence objects, including their properties such as Start and Duration.
  • Word Serialization: Encodes BrcWord objects, ensuring special characters are escaped and durations are properly represented.

BrcByteReader / BrcByteWriter

The byte serializers load and save BrcDocument objects using a byte-oriented binary layout optimized for speed.

BrcBitReader / BrcBitWriter

The bit serializers load and save BrcDocument objects using a bit-oriented binary layout optimized for compression.

BrcBinaryReader

The binary reader inspects the first bit of the stream and dispatches to BrcByteReader or BrcBitReader automatically.

Brc File Format

Overview

The .brc file format is designed to represent structured musical data, including beats, notes, and lyrics. It is used by the text, byte, and bit serializer families for loading and saving.

File Structure

Header

The header defines the global properties of the file, such as beats per bar, notes per beat, beats per minute, and offset. It is enclosed in square brackets [] and uses commas , to separate values.

Example:
  • [8, 4, 120, 20]
    • 8: Beats per bar, default is 8
    • 4: Notes per beat, default is 4
    • 120: Beats per minute, default is 100
    • 20: Offset in milliseconds`

Sentences

Sentences are separated by semicolons ; and represent a collection of lines. Each sentence can optionally redefine the header properties. Multiple sentences can be seperated by +.

Example:
  • +: Indicates a bar boundary.

Lines

Lines are sequences of words separated by -. Each line can span multiple bars, and words can have varying durations.

Example:
  • I ---wan|na |lea-ve---
    • I ---: A word with a duration of one beat (1/4 * (1 + 3)).
    • wan: A word with a duration of 1/4 beat.
    • |: A separator indicating a word boundary.
    • na: A word with a duration of 1/4 beat.
    • ...
  • \: Escaped characters.

Words

Words are the smallest unit in the .brc format. Each word can have a duration, which is represented by the number of | or - characters following it. Special characters are escaped using //.

Example:
  • To: A word with a duration of one beat.
  • |: Indicates a bar boundary.

Example

[4,4,108];;;;;;;;;
-I |don't//\\ -know -what -to -say -
I -think -I'm -wai-ting -for -you-;;
-To |tell -me -what -to -do -
To -tell -me -who -I -am-;;
...

About

Brc (beat lyric) is a format that can record song information by beat.

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages