Skip to content

Utility to parse songbeamer files into a javascript structure.

Notifications You must be signed in to change notification settings

lal12/songbeamer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#Songbeamer parser

This little utility parses a songbeamer file into the beaneath described structure. ##Usage

NodeJS

const songbeamer = require('songbeamer');
try{
	songbeamer(data); //Data has to be string of songbeamer file in UTF-8
}catch(e){
	console.log(e.msg, e.data); // e.msg is the error message, e.data are variables passed as additional informations 
}

Structure

{
	props: {
		name: value,
		...
	}
	texts: { // Contains Verses as array
		verseName: [  //Verse: Contains slides as array
			[ //Slide: contains lines as array
				[ // Line: contains translations as string
					"Text ...",
					...
				]
				...
			]
			...
		]
	}
}

props

name and value are represeting key-value-pairs as in the upper section of the songbeamer file. The most properties are stored as strings matching the content of the sng file, but the following exceptions are handled different:

Title, TitleLang*

Will be stored in an Array under the name Title

"Title": [Title, TitleLang1, TitleLang2, ..., TitleLangN]

VerseOrder

Will be stored in an Array with a comma as seperator. If this is not defined in the file, it will be created and generated by the songtext. For this the first line of every verse is used and will be set as the name of the verse. If this is one of the Tags specified in songbeamer wiki, the line will be removed from songtext otherwise it is kept in the text.

Comments

Is stored in base64 encoding, this utility will decode it to normal string.

Chords

Is stored in base64 encoding, this utility will decode it to normal string. Afterwards it is splitted into an array (seperator is "\r")

Keywords

Is splitted into an array (seperator is " ")

Categories

Is splitted into an array (seperator is ",")

BackgroundImage

Will be returned the same as in the file, except the strings is a color ("color://$00000000"), then it will be saved as:

"BackgroundColor": {rgb: val}

"val" is the parsed hex color value ANDed with 0xFFFFFF and thereby represents an rgb value. The first byte of the songbeamer file color string has yet unknown functionality.

(c)

Is renamed to Copyright

Version, FontSize, Tempo, LangCount, ChurchSongID, CCLI

Values from theese keys will be parsed as integers.

texts

Is an associative array (object) of verses, how the key is determined is described in props:VerseOrder. Each verse is an array containing slides, each slide is also an array containing lines, each line is also an array containing different translations. The first translation is the main language (may be defined in props["Lang"]).

Usually in every line of a song there should be the same number of translations, but the last/only lines of a slide may contain less. This is either due to a malformed file or (if the line contains one translation) it could also mean that every language contains this last line. This behaviour was watched often in cases like "2x" or "(3x)", of course this make sense to be shown in every translation.

Links

  1. Official Songbeamer manual, is not really extensive
  2. Songbeamer file format descriptions

About

Utility to parse songbeamer files into a javascript structure.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published