The Brc namespace provides functionality for reading and writing .brc files, which are used to represent structured musical data.
The BrcWriter class is responsible for serializing Brc objects into .brc file format.
- Write Method: Converts
Brcobjects into.brcfile format and writes them to a specified file path. - Sentence Serialization: Handles serialization of
BrcSentenceobjects, including their properties such asBeatsPerMinute,BeatsPerBar,NotePerBeat, andOffset. - Word Serialization: Encodes
BrcWordobjects, ensuring special characters are escaped and durations are properly represented.
The BrcReader class is responsible for deserializing .brc files into Brc objects.
- Read Method: Parses
.brcfiles and constructsBrcobjects. - Sentence Deserialization: Extracts
BrcSentenceproperties and reconstructs their structure. - Word Deserialization: Decodes
BrcWordobjects, handling escaped characters and duration calculations.
The .brc file format is designed to represent structured musical data, including beats, notes, and lyrics. It is used by the BrcReader and BrcWriter classes for deserialization and serialization, respectively.
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-;;
...