"use strict";

/* --------------------------------------------------- */
/* SkyDragon Story track 06                            */
/* A Hymn of Flight                                    */
/* (shrine theme)                                      */
/* (c) Sean Kelly, 2014                                */
/* --------------------------------------------------- */
DATA_CHIPTUNES["a Hymn of Flight"] = {
		"chip": "oneofeach"
	,	"bpm": 120 // beats per minute
	,	"priority": 1 // baseline nonzero for BGM
	,	"songdata" : {
			"st":	// name of a channel on the chip	
				[
					{"command": "env", // set linear ramp envelope applied to every note; dur is measured in seconds, 0 means length of current note
						"data": {"start": 0.75, "end": 1.0, "dur": 1}
					}
				,	{"command": "sweep", // set linear frequency sweep applied to every note (start and end multiply base note frequency)
						"data": {"start": 1.0, "end": 1.0, "dur": 0}
					}
				,	{"command": "vol", // set overall volume of channel; 0.1 is a sane "loud" level
						"data": {"level": 0.05}
					}
				,	{"command": "pan", // linearly-divided fraction of the audio going to the right channel, with the remainder going to the left
						"data": {"position": 0.5}
					}
				//,	{"command": "tempo", // change tempo mid-tune
				//		"data": {"bpm": 120}
				//	}
				,	{"command": "detune", // detune in cents to be applied to the oscillator (for "richer" sound when 2 similar frequencies overlap)
						"data": {"cents": 0}
					}

				,	{"command": "jump", // reset the loop counter
						"data": {"reset": true}
					}
				,	{"command": "env", // set linear ramp envelope applied to every note; dur is measured in seconds, 0 means length of current note
						"data": {"start": 0.75, "end": 1.0, "dur": 1}
					}
				,	{"command": "notes", // strings of the form "NnO L" where NnO is the Note-modifier-Octave note to play (from DEF_CHIPTUNE_PITCHES) and L is the length in beats or fractions (can be multiple characters as long as parseFloat will take it)
						"data": [
							"Bf1 3"
						]
					}
				,	{"command": "env", // set linear ramp envelope applied to every note; dur is measured in seconds, 0 means length of current note
						"data": {"start": 1.0, "end": 0.75, "dur": 1}
					}
				,	{"command": "notes", // strings of the form "NnO L" where NnO is the Note-modifier-Octave note to play (from DEF_CHIPTUNE_PITCHES) and L is the length in beats or fractions (can be multiple characters as long as parseFloat will take it)
						"data": [
							"Bf1 3"
						]
					}
				,	{"command": "jump", // go forwards/backwards delta commands if loop counter < times; increase loop counter
						"data": {"delta": -4, "times": 19}
					}
				]
		,	"tri":	// name of a channel on the chip	
				[
					{"command": "env", // set linear ramp envelope applied to every note
						"data": {"start": 0.5, "end": 1.0, "dur": 1}
					}
				,	{"command": "sweep", // set linear frequency sweep applied to every note (start and end multiply base note frequency)
						"data": {"start": 1.0, "end": 1.0, "dur": 0}
					}
				,	{"command": "vol", // set overall volume of channel
						"data": {"level": 0.1}
					}
				,	{"command": "pan", // linearly-divided fraction of the audio going to the right channel, with the remainder going to the left
						"data": {"position": 0.5}
					}
				//,	{"command": "tempo", // change tempo mid-tune
				//		"data": {"bpm": 120}
				//	}
				,	{"command": "detune", // detune in cents to be applied to the oscillator (for "richer" sound when 2 similar frequencies overlap)
						"data": {"cents": 0}
					}


				,	{"command": "pan", // linearly-divided fraction of the audio going to the right channel, with the remainder going to the left
						"data": {"position": 0.4}
					}

				,	{"command": "jump", // reset the loop counter
						"data": {"reset": true}
					}
				,	{"command": "notes", // strings of the form "NnO L" where NnO is the Note-modifier-Octave note to play (from DEF_CHIPTUNE_PITCHES) and L is the length in beats or fractions (can be multiple characters as long as parseFloat will take it)
						"data": [
							"Ef5 1"
						,	"Ef5 1"
						,	"Ef5 1"
						,	"Ef5 3"
						,	"Dn5 1"
						,	"Dn5 1"
						,	"Dn5 1"
						,	"Dn5 3"
						]
					}
				,	{"command": "jump", // go forwards/backwards delta commands if loop counter < times; increase loop counter
						"data": {"delta": -1, "times": 1}
					}

				,	{"command": "pan", // linearly-divided fraction of the audio going to the right channel, with the remainder going to the left
						"data": {"position": 0.5}
					}

				,	{"command": "jump", // reset the loop counter
						"data": {"reset": true}
					}
				,	{"command": "notes", // strings of the form "NnO L" where NnO is the Note-modifier-Octave note to play (from DEF_CHIPTUNE_PITCHES) and L is the length in beats or fractions (can be multiple characters as long as parseFloat will take it)
						"data": [
							"Ef5 1"
						,	"Ef5 1"
						,	"Ef5 1"
						,	"Ef5 3"
						,	"Dn5 1"
						,	"Dn5 1"
						,	"Dn5 1"
						,	"Dn5 3"
						]
					}
				,	{"command": "jump", // go forwards/backwards delta commands if loop counter < times; increase loop counter
						"data": {"delta": -1, "times": 7}
					}
				]
		,	"sq":	// name of a channel on the chip	
				[
					{"command": "env", // set linear ramp envelope applied to every note
						"data": {"start": 1.0, "end": 0.0, "dur": 0.5}
					}
				,	{"command": "sweep", // set linear frequency sweep applied to every note (start and end multiply base note frequency)
						"data": {"start": 1.0, "end": 1.0, "dur": 0}
					}
				,	{"command": "vol", // set overall volume of channel
						"data": {"level": 0.05}
					}
				,	{"command": "pan", // linearly-divided fraction of the audio going to the right channel, with the remainder going to the left
						"data": {"position": 0.5}
					}
				,	{"command": "tempo", // change tempo mid-tune
						"data": {"bpm": 120}
					}
				,	{"command": "detune", // detune in cents to be applied to the oscillator (for "richer" sound when 2 similar frequencies overlap)
						"data": {"cents": 5}
					}

				,	{"command": "notes", // strings of the form "NnO L" where NnO is the Note-modifier-Octave note to play (from DEF_CHIPTUNE_PITCHES) and L is the length in beats or fractions (can be multiple characters as long as parseFloat will take it)
						"data": [
							"Rst 24"
						]
					}

				,	{"command": "tempo", // change tempo mid-tune
						"data": {"bpm": 240} // 120 in 8ths
					}

				,	{"command": "jump", // reset the loop counter
						"data": {"reset": true}
					}
				,	{"command": "pan", // linearly-divided fraction of the audio going to the right channel, with the remainder going to the left
						"data": {"position": 0.75}
					}
				,	{"command": "notes", // strings of the form "NnO L" where NnO is the Note-modifier-Octave note to play (from DEF_CHIPTUNE_PITCHES) and L is the length in beats or fractions (can be multiple characters as long as parseFloat will take it)
						"data": [
							"Ef5 1"
						,	"Bf4 1"
						,	"Fn4 1"
						,	"Dn4 1"
						,	"Ef4 1"
						,	"Fn4 1"
						]
					}
				,	{"command": "pan", // linearly-divided fraction of the audio going to the right channel, with the remainder going to the left
						"data": {"position": 0.25}
					}
				,	{"command": "notes", // strings of the form "NnO L" where NnO is the Note-modifier-Octave note to play (from DEF_CHIPTUNE_PITCHES) and L is the length in beats or fractions (can be multiple characters as long as parseFloat will take it)
						"data": [
							"Ef5 1"
						,	"Bf4 1"
						,	"Fn4 1"
						,	"Dn4 1"
						,	"Ef4 1"
						,	"Fn4 1"
						]
					}
				,	{"command": "pan", // linearly-divided fraction of the audio going to the right channel, with the remainder going to the left
						"data": {"position": 0.75}
					}
				,	{"command": "notes", // strings of the form "NnO L" where NnO is the Note-modifier-Octave note to play (from DEF_CHIPTUNE_PITCHES) and L is the length in beats or fractions (can be multiple characters as long as parseFloat will take it)
						"data": [
							"Dn5 1"
						,	"Bf4 1"
						,	"Fn4 1"
						,	"Bf3 1"
						,	"Dn4 1"
						,	"Fn4 1"
						]
					}
				,	{"command": "pan", // linearly-divided fraction of the audio going to the right channel, with the remainder going to the left
						"data": {"position": 0.25}
					}
				,	{"command": "notes", // strings of the form "NnO L" where NnO is the Note-modifier-Octave note to play (from DEF_CHIPTUNE_PITCHES) and L is the length in beats or fractions (can be multiple characters as long as parseFloat will take it)
						"data": [
							"Dn5 1"
						,	"Bf4 1"
						,	"Fn4 1"
						,	"Bf3 1"
						,	"Dn4 1"
						,	"Fn4 1"
						]
					}
				,	{"command": "jump", // go forwards/backwards delta commands if loop counter < times; increase loop counter
						"data": {"delta": -8, "times": 5}
					}

				,	{"command": "tempo", // change tempo mid-tune
						"data": {"bpm": 120}
					}
				,	{"command": "pan", // linearly-divided fraction of the audio going to the right channel, with the remainder going to the left
						"data": {"position": 0.5}
					}

				,	{"command": "env", // set linear ramp envelope applied to every note
						"data": {"start": 1.0, "end": 0.0, "dur": 0}
					}

				,	{"command": "notes", // strings of the form "NnO L" where NnO is the Note-modifier-Octave note to play (from DEF_CHIPTUNE_PITCHES) and L is the length in beats or fractions (can be multiple characters as long as parseFloat will take it)
						"data": [
							"Fn4 1"
						,	"Fn4 1"
						,	"Fn4 1"
						,	"Fn4 3"

						,	"Fn4 1"
						,	"Fn4 1"
						,	"Fn4 1"
						,	"Fn4 3"

						,	"Fn4 1"
						,	"Fn4 1"
						,	"Fn4 1"
						,	"Fn4 3"
						
						,	"Fn4 1"
						,	"Fn4 1"
						,	"Fn4 1"
						,	"Fn4 3"
						]
					}
				]
		,	"sin":	// name of a channel on the chip	
				[
					{"command": "env", // set linear ramp envelope applied to every note
						"data": {"start": 0.5, "end": 1.0, "dur": 1}
					}
				,	{"command": "sweep", // set linear frequency sweep applied to every note (start and end multiply base note frequency)
						"data": {"start": 1.0, "end": 1.0, "dur": 0}
					}
				,	{"command": "vol", // set overall volume of channel
						"data": {"level": 0.125}
					}
				,	{"command": "pan", // linearly-divided fraction of the audio going to the right channel, with the remainder going to the left
						"data": {"position": 0.6}
					}
				//,	{"command": "tempo", // change tempo mid-tune
				//		"data": {"bpm": 120}
				//	}
				,	{"command": "detune", // detune in cents to be applied to the oscillator (for "richer" sound when 2 similar frequencies overlap)
						"data": {"cents": 0}
					}
				,	{"command": "notes", // strings of the form "NnO L" where NnO is the Note-modifier-Octave note to play (from DEF_CHIPTUNE_PITCHES) and L is the length in beats or fractions (can be multiple characters as long as parseFloat will take it)
						"data": [
							"Fn4 3"
						,	"Fn4 3"
						,	"Fn4 3"
						,	"Fn4 3"
						,	"Fn4 3"
						,	"Fn4 3"
						,	"Fn4 3"
						,	"Fn4 3"
						]
					}

				,	{"command": "vol", // set overall volume of channel
						"data": {"level": 0.25}
					}
				,	{"command": "pan", // linearly-divided fraction of the audio going to the right channel, with the remainder going to the left
						"data": {"position": 0.5}
					}

				,	{"command": "notes", // strings of the form "NnO L" where NnO is the Note-modifier-Octave note to play (from DEF_CHIPTUNE_PITCHES) and L is the length in beats or fractions (can be multiple characters as long as parseFloat will take it)
						"data": [
							"Bf4 3"

						,	"Fn5 0.5"
						,	"Ef5 0.5"
						,	"Dn5 1"
						,	"Ef5 1"

						,	"Dn5 1"
						,	"Bf4 5"

						,	"Af4 3"
						
						,	"Fn4 2"
						,	"Ef4 1"

						,	"Dn4 6"


						,	"Bf4 3"

						,	"Fn5 0.5"
						,	"Ef5 0.5"
						,	"Dn5 1"
						,	"Ef5 1"

						,	"Dn5 1"
						,	"Bf4 5"

						,	"Af4 3"
						
						,	"Fn4 2"
						,	"Af4 1"

						,	"Bf4 6"

						// Section B

						,	"Rst 1"
						,	"Bf4 1"
						,	"Cn5 1"

						,	"Df5 1"
						,	"Bf4 1"
						,	"Fn4 1"

						,	"Dn4 1"
						,	"Bf4 5"

						,	"Rst 1"
						,	"Bf4 1"
						,	"Cn5 1"

						,	"Df5 1"
						,	"Cn5 1"
						,	"Bf4 1"

						,	"Fn4 0.5"
						,	"Ef4 0.5"
						,	"Dn4 5"


						,	"Ef4 3"
						,	"Cn4 3"
						,	"Dn4 6"

						,	"Ef4 3"
						,	"Cn4 3"
						,	"Dn4 6"
						]
					}
				]
		}
	};
