Skip to content

OLDRedstone/Brc

Repository files navigation

Brc

Brc

Overview

The Brc namespace provides functionality for reading and writing .brc files, which are used to represent structured musical data.

BrcWriter

The BrcWriter class is responsible for serializing Brc objects into .brc file format.

Key Features

  • Write Method: Converts Brc objects into .brc file format and writes them to a specified file path.
  • Sentence Serialization: Handles serialization of BrcSentence objects, including their properties such as BeatsPerMinute, BeatsPerBar, NotePerBeat, and Offset.
  • Word Serialization: Encodes BrcWord objects, ensuring special characters are escaped and durations are properly represented.

Usage## BrcReader

The BrcReader class is responsible for deserializing .brc files into Brc objects.

Key Features

  • Read Method: Parses .brc files and constructs Brc objects.
  • Sentence Deserialization: Extracts BrcSentence properties and reconstructs their structure.
  • Word Deserialization: Decodes BrcWord objects, handling escaped characters and duration calculations.

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 BrcReader and BrcWriter classes for deserialization and serialization, respectively.

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.

Examble

[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

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages