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
The BrcTextReader class is the public loader for .brc text files and returns BrcDocument objects.
- Read Method: Parses
.brctext intoBrcDocumentobjects. - Compatibility: Keeps the text format human-readable and forgiving for round-tripping.
The BrcTextWriter class is responsible for saving BrcDocument objects into .brc text file format.
- WriteText Method: Converts
BrcDocumentobjects into.brctext and writes them to a specifiedStreamWriter. - Sentence Serialization: Handles serialization of
BrcSentenceobjects, including their properties such asStartandDuration. - Word Serialization: Encodes
BrcWordobjects, ensuring special characters are escaped and durations are properly represented.
The byte serializers load and save BrcDocument objects using a byte-oriented binary layout optimized for speed.
The bit serializers load and save BrcDocument objects using a bit-oriented binary layout optimized for compression.
The binary reader inspects the first bit of the stream and dispatches to BrcByteReader or BrcBitReader automatically.
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.
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.
[8, 4, 120, 20]8: Beats per bar, default is 84: Notes per beat, default is 4120: Beats per minute, default is 10020: Offset in milliseconds`
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 +.
+: Indicates a bar boundary.
Lines are sequences of words separated by -. Each line can span multiple bars, and words can have varying durations.
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 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 //.
To: A word with a duration of one beat.|: Indicates a bar boundary.
[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-;;
...