"use strict";

/* --------------------------------------------------- */
/* SkyDragon Story track 28                            */
/* Hero of the Past                                    */
/* (Gargoyle War theme)                                */
/* (c) Sean Kelly, 2022                                */
/* --------------------------------------------------- */
DATA_CHIPTUNES["Hero of the Past"] = {
		"chip": "oneofeach"
	,	"bpm": 540 // beats per minute; 135 in 16ths
	,	"priority": 1 // baseline nonzero for BGM
	,	"songdata" : {
			"sq":	// 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": 1.125, "end": 1.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; 0.1 is a sane "loud" level
						"data": {"level": 0.075}
					}
				,	{"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": "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": [
							"Dn4 8"
						,	"An3 8"

						,	"Dn4 10"
						,	"Fn4 4"
						,	"An4 2"

						,	"Cn5 3"
						,	"Bn4 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": 1.25, "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": [
							"Gn4 26"
						]
					}
				,	{"command": "env", // set linear ramp envelope applied to every note; dur is measured in seconds, 0 means length of current note
						"data": {"start": 1.125, "end": 1.0, "dur": 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": [
							"Dn4 8"
						,	"An3 8"

						,	"Dn4 10"
						,	"Fn4 4"
						,	"An4 2"

						,	"Gn4 3"
						,	"Dn4 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": 1.25, "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 26"
						]
					}
				,	{"command": "env", // set linear ramp envelope applied to every note; dur is measured in seconds, 0 means length of current note
						"data": {"start": 1.125, "end": 1.0, "dur": 0.5}
					}


				,	{"command": "vol", // set overall volume of channel; 0.1 is a sane "loud" level
						"data": {"level": 0.0875}
					}
				,	{"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": [
							"Ef4 8"
						,	"Bf3 8"

						,	"Ef4 10"
						,	"Gn4 4"
						,	"Bf4 2"

						,	"An4 3"
						,	"Gn4 3"
						,	"Fn4 2"
						,	"Cn5 3"
						,	"Bf4 3"
						,	"An4 2"

						,	"Fn4 12"
						,	"Gn4 4"
						]
					}

				,	{"command": "vol", // set overall volume of channel; 0.1 is a sane "loud" level
						"data": {"level": 0.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": [
							"Af4 3"
						,	"Gn4 3"
						,	"Fn4 2"
						,	"Df4 4"
						,	"Af4 4"

						,	"Bf4 3"
						,	"Af4 3"
						,	"Gn4 2"
						,	"Ef4 4"
						,	"Bf4 4"

						,	"An4 1"
						,	"Bf4 1"
						,	"An4 1"
						,	"Gn4 1"
						,	"An4 12"

						,	"Fn4 12"
						,	"Fn4 1"
						,	"Gn4 1"
						,	"Gs4 1"
						,	"An4 1"
						]
					}
				//,	{"command": "jump", // reset the loop counter
				//		"data": {"reset": true}
				//	}
				//,	{"command": "jump", // go forwards/backwards delta commands if loop counter < times; increase loop counter
				//		"data": {"delta": -4, "times": 1}
				//	}

				// Fly wants 270, and we want to queue itup cleanly
				,	{"command": "tempo", // change tempo mid-tune
						"data": {"bpm": 270}
					}
				]
		,	"tri":	// name of a channel on the chip	
				[
					{"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": "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": "vol", // set overall volume of channel
						"data": {"level": 0.0875}
					}
				,	{"command": "env", // set linear ramp envelope applied to every note
						"data": {"start": 1.0, "end": 0.5, "dur": 0.5}
					}
				,	{"command": "pan", // linearly-divided fraction of the audio going to the right channel, with the remainder going to the left
						"data": {"position": 0.625}
					}
				,	{"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 8"
						,	"An4 4"
						,	"Fn4 4"

						,	"Dn5 4"
						,	"An4 4"
						,	"Fn4 4"
						,	"Cn5 4"
						]
					}
				,	{"command": "vol", // set overall volume of channel
						"data": {"level": 0.1}
					}
				,	{"command": "env", // set linear ramp envelope applied to every note
						"data": {"start": 0.875, "end": 1.0, "dur": 0}
					}
				,	{"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": [
							"Bn4 1"
						,	"Cn5 1"
						,	"Bn4 1"
						,	"Cn5 1"
						,	"Bn4 1"
						,	"Cn5 1"
						,	"Bn4 1"
						,	"Cn5 1"
						,	"Bn4 1"
						,	"Cn5 1"
						,	"Bn4 1"
						,	"Cn5 1"
						,	"Bn4 1"
						,	"Cn5 1"
						,	"Bn4 1"
						,	"Cn5 1"

						,	"Bn4 16"
						]
					}
				,	{"command": "jump", // go forwards/backwards delta commands if loop counter < times; increase loop counter
						"data": {"delta": -8, "times": 1}
					}


				,	{"command": "vol", // set overall volume of channel
						"data": {"level": 0.1}
					}
				,	{"command": "env", // set linear ramp envelope applied to every note
						"data": {"start": 1.0, "end": 0.5, "dur": 0.5}
					}
				,	{"command": "pan", // linearly-divided fraction of the audio going to the right channel, with the remainder going to the left
						"data": {"position": 0.625}
					}
				,	{"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": [
							"Gn4 8"
						,	"Bf4 4"
						,	"Gn4 4"

						,	"Ef5 4"
						,	"Bf4 4"
						,	"Gn4 4"
						,	"Bf4 4"
						]
					}
				,	{"command": "vol", // set overall volume of channel
						"data": {"level": 0.1}
					}
				,	{"command": "env", // set linear ramp envelope applied to every note
						"data": {"start": 0.875, "end": 1.0, "dur": 0}
					}
				,	{"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": [
							"Cn5 1"
						,	"Dn5 1"
						,	"Cn5 1"
						,	"Dn5 1"
						,	"Cn5 1"
						,	"Dn5 1"
						,	"Cn5 1"
						,	"Dn5 1"
						,	"Cn5 1"
						,	"Dn5 1"
						,	"Cn5 1"
						,	"Dn5 1"
						,	"Cn5 1"
						,	"Dn5 1"
						,	"Cn5 1"
						,	"Dn5 1"

						,	"Rst 4"
						,	"Bf4 12"
						]
					}


				,	{"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": [
							"Af4 1"
						,	"Bf4 1"
						,	"Af4 1"
						,	"Bf4 1"
						,	"Af4 1"
						,	"Bf4 1"
						,	"Af4 1"
						,	"Bf4 1"
						,	"Af4 2"
						,	"Fn4 4"
						,	"Af4 2"

						,	"Bf4 1"
						,	"Cn5 1"
						,	"Bf4 1"
						,	"Cn5 1"
						,	"Bf4 1"
						,	"Cn5 1"
						,	"Bf4 1"
						,	"Cn5 1"
						,	"Bf4 8"

						,	"Cn5 1"
						,	"Dn5 1"
						,	"Cn5 1"
						,	"Dn5 1"
						,	"Cn5 1"
						,	"Dn5 1"
						,	"Cn5 1"
						,	"Dn5 1"
						,	"Cn5 1"
						,	"Dn5 1"
						,	"Cn5 1"
						,	"Dn5 1"
						,	"Cn5 1"
						,	"Dn5 1"
						,	"Cn5 1"
						,	"Dn5 1"

						,	"Cn5 16"
						]
					}

				// Fly wants 270, and we want to queue itup cleanly
				,	{"command": "tempo", // change tempo mid-tune
						"data": {"bpm": 270}
					}
				]
		,	"st":	// name of a channel on the chip	
				[
					{"command": "env", // set linear ramp envelope applied to every note
						"data": {"start": 1.0, "end": 0.25, "dur": 0}
					}
				,	{"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": "detune", // detune in cents to be applied to the oscillator (for "richer" sound when 2 similar frequencies overlap)
						"data": {"cents": 2}
					}

				,	{"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": [
							"Dn3 2"
						,	"Dn3 1"
						,	"Dn3 1"
						,	"Dn3 2"
						,	"Dn3 4"
						,	"Dn3 2"
						,	"An2 2"
						,	"An2 2"

						,	"Dn3 2"
						,	"Dn3 1"
						,	"Dn3 1"
						,	"Dn3 2"
						,	"Dn3 4"
						,	"Dn3 2"
						,	"An2 2"
						,	"An2 2"

						,	"Gn3 2"
						,	"Gn3 1"
						,	"Gn3 1"
						,	"Gn3 2"
						,	"Gn3 4"
						,	"Gn3 2"
						,	"Dn3 2"
						,	"Dn3 2"

						,	"Gn3 2"
						,	"Gn3 1"
						,	"Gn3 1"
						,	"Gn3 2"
						,	"Fn3 4"
						,	"Fn3 2"
						,	"En3 2"
						,	"Dn3 2"
						]
					}


				,	{"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": [
							"Dn3 2"
						,	"Dn3 1"
						,	"Dn3 1"
						,	"Dn3 2"
						,	"Dn3 4"
						,	"Dn3 2"
						,	"An2 2"
						,	"An2 2"

						,	"Dn3 2"
						,	"Dn3 1"
						,	"Dn3 1"
						,	"Dn3 2"
						,	"Dn3 4"
						,	"Dn3 2"
						,	"An2 2"
						,	"An2 2"

						,	"Gn3 2"
						,	"Gn3 1"
						,	"Gn3 1"
						,	"Gn3 2"
						,	"Gn3 4"
						,	"Gn3 2"
						,	"Dn3 2"
						,	"Dn3 2"

						,	"Gn3 2"
						,	"Gn3 1"
						,	"Gn3 1"
						,	"Gn3 2"
						,	"Gn3 4"
						,	"Gn3 2"
						,	"Fn3 2"
						,	"Dn3 2"
						]
					}


				,	{"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": [
							"Ds3 2"
						,	"Ds3 1"
						,	"Ds3 1"
						,	"Ds3 2"
						,	"Ds3 4"
						,	"Ds3 2"
						,	"As2 2"
						,	"As2 2"

						,	"Ds3 2"
						,	"Ds3 1"
						,	"Ds3 1"
						,	"Ds3 2"
						,	"Ds3 4"
						,	"Ds3 2"
						,	"As2 2"
						,	"Ds3 2"

						,	"Fn3 2"
						,	"Fn3 1"
						,	"Fn3 1"
						,	"Fn3 2"
						,	"Fn3 4"
						,	"Fn3 2"
						,	"Cn3 2"
						,	"Cn3 2"

						,	"Fn3 2"
						,	"Fn3 1"
						,	"Fn3 1"
						,	"Fn3 2"
						,	"Fn3 4"
						,	"Fn3 2"
						,	"Fn3 2"
						,	"Fn3 2"
						]
					}


				,	{"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": [
							"Df3 2"
						,	"Df3 1"
						,	"Df3 1"
						,	"Df3 2"
						,	"Af2 2"
						,	"Df3 2"
						,	"Af2 2"
						,	"Df3 2"
						,	"Af2 2"

						,	"Ef3 2"
						,	"Ef3 1"
						,	"Ef3 1"
						,	"Ef3 2"
						,	"Bf2 2"
						,	"Ef3 2"
						,	"Bf2 2"
						,	"Ef3 2"
						,	"Bf2 2"
						]
					}


				,	{"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": [
							"Fn3 2"
						,	"Fn2 1"
						,	"Fn2 1"
						,	"Fn2 2"
						,	"Fn2 2"
						,	"Fn2 2"
						,	"Fn2 1"
						,	"Fn2 1"
						,	"Fn2 2"
						,	"Fn2 2"

						,	"Fn2 16"
						]
					}

				// Fly wants 270, and we want to queue itup cleanly
				,	{"command": "tempo", // change tempo mid-tune
						"data": {"bpm": 270}
					}
				]
		,	"sin":	// name of a channel on the chip	
				[
					{"command": "env", // set linear ramp envelope applied to every note
						"data": {"start": 1.25, "end": 1.0, "dur": 0.5}
					}
				,	{"command": "pan", // linearly-divided fraction of the audio going to the right channel, with the remainder going to the left
						"data": {"position": 0.375}
					}

				,	{"command": "vol", // set overall volume of channel
						"data": {"level": 0.0875}
					}
				,	{"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": [
							"Dn4 8"
						,	"Fn3 8"

						,	"An3 10"
						,	"Dn4 4"
						,	"Dn4 2"

						,	"Gn4 3"
						,	"Gn4 3"
						,	"Dn4 2"
						,	"Bn3 24"
						]
					}

				,	{"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": [
							"Dn4 8"
						,	"Fn3 8"

						,	"An3 10"
						,	"Dn4 4"
						,	"Dn4 2"

						,	"Bn3 3"
						,	"Bn3 3"
						,	"An3 26"
						]
					}

				,	{"command": "vol", // set overall volume of channel
						"data": {"level": 0.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": [
							"Ef4 8"
						,	"Gn3 8"

						,	"Bf3 10"
						,	"Ef4 4"
						,	"Ef4 2"

						,	"Cn4 6"
						,	"Cn4 2"
						,	"An3 6"
						,	"An3 2"

						,	"Dn4 8"
						,	"Df4 8"
						]
					}

				,	{"command": "env", // set linear ramp envelope applied to every note
						"data": {"start": 1.5, "end": 1.0, "dur": 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": [
							"Df4 6"
						,	"Df4 2"
						,	"Fn3 4"
						,	"Fn3 4"

						,	"Ef4 6"
						,	"Ef4 2"
						,	"Gn3 4"
						,	"Gn3 4"
						]
					}

				,	{"command": "env", // set linear ramp envelope applied to every note
						"data": {"start": 1.0, "end": 1.25, "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 16"

						,	"An3 16"
						]
					}

				// Fly wants 270, and we want to queue itup cleanly
				,	{"command": "tempo", // change tempo mid-tune
						"data": {"bpm": 270}
					}
				]
		,	"nz":	// 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.25}
					}
				,	{"command": "vol", // set overall volume of channel
						"data": {"level": 0.07}
					}
				,	{"command": "pan", 
						"data": {"position": 0.5}
					}

				,	{"command": "jump", // reset the loop counter
						"data": {"reset": true}
					}

				,	{"command": "notes", 
						"data": [
							"Cn6 2" //hat
						,	"En4 1" //snare
						,	"En4 1" //snare
						,	"En4 2" //snare
						,	"Cn2 2" //bd
						,	"En4 1" //snare
						,	"En4 1" //snare
						,	"En4 1" //snare
						,	"En4 1" //snare
						,	"Cn2 2" //bd
						,	"En4 1" //snare
						,	"En4 1" //snare

						,	"Cn2 2" //bd
						,	"En4 1" //snare
						,	"En4 1" //snare
						,	"En4 2" //snare
						,	"Cn2 2" //bd
						,	"En4 1" //snare
						,	"En4 1" //snare
						,	"En4 1" //snare
						,	"En4 1" //snare
						,	"Cn2 2" //bd
						,	"En4 1" //snare
						,	"En4 1" //snare

						,	"Cn2 2" //bd
						,	"En4 1" //snare
						,	"En4 1" //snare
						,	"En4 2" //snare
						,	"Cn2 2" //bd
						,	"En4 1" //snare
						,	"En4 1" //snare
						,	"En4 1" //snare
						,	"En4 1" //snare
						,	"Cn2 2" //bd
						,	"En4 1" //snare
						,	"En4 1" //snare

						,	"Cn2 2" //bd
						,	"En4 1" //snare
						,	"En4 1" //snare
						,	"En4 2" //snare
						,	"Cn2 2" //bd
						,	"En4 1" //snare
						,	"En4 1" //snare
						,	"En4 1" //snare
						,	"En4 1" //snare
						,	"Gn5 4" //crash
						]
					}
				,	{"command": "jump", // go forwards/backwards delta commands if loop counter < times; increase loop counter
						"data": {"delta": -1, "times": 2}
					}

				,	{"command": "notes", 
						"data": [
							"Gn5 2" //crash
						,	"En4 1" //snare
						,	"En4 1" //snare
						,	"En4 2" //snare
						,	"Gn5 2" //crash
						,	"En4 1" //snare
						,	"En4 1" //snare
						,	"En4 1" //snare
						,	"En4 1" //snare
						,	"Gn5 2" //crash
						,	"En4 1" //snare
						,	"En4 1" //snare

						,	"Gn5 2" //crash
						,	"En4 1" //snare
						,	"En4 1" //snare
						,	"En4 2" //snare
						,	"Gn5 2" //crash
						,	"En4 1" //snare
						,	"En4 1" //snare
						,	"En4 1" //snare
						,	"En4 1" //snare
						,	"Gn5 2" //crash
						,	"En4 1" //snare
						,	"En4 1" //snare
						]
					}
				,	{"command": "env", // set linear ramp envelope applied to every note
						"data": {"start": 1.0, "end": 0.25, "dur": 0.0}
					}
				,	{"command": "notes", 
						"data": [
							"Gn5 16" //crash
						,	"Rst 16"
						]
					}

				// Fly wants 270, and we want to queue itup cleanly
				,	{"command": "tempo", // change tempo mid-tune
						"data": {"bpm": 270}
					}
				]
		}

	};