"use strict";

/* --------------------------------------------------- */
/* SkyDragon Story track 11                            */
/* Creeping Shade, Crawling Shade                      */
/* (forest theme)                                      */
/* (c) Sean Kelly, 2015                                */
/* --------------------------------------------------- */
DATA_CHIPTUNES["Creeping Shade"] = {
		"chip": "oneofeach"
	,	"bpm": 120 // beats per minute
	,	"priority": 1 // baseline nonzero for BGM
	,	"songdata" : {
			"st":	// 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": "vol", // set overall volume of channel; 0.1 is a sane "loud" level
						"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": 0}
					}

				// intro
				,	{"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 3"
						,	"Rst 3"
						,	"Rst 3"
						,	"Rst 3"
						,	"Rst 3"
						,	"Rst 3"
						,	"Rst 3"
						,	"Rst 3"
						]
					}

				// section A1, A2, B
				,	{"command": "tempo", // change tempo mid-tune
						"data": {"bpm": 480} // 120 in 16ths
					}
				,	{"command": "vol", // set overall volume of channel; 0.1 is a sane "loud" level
						"data": {"level": 0.05}
					}
				,	{"command": "env", // set linear ramp envelope applied to every note; dur is measured in seconds, 0 means length of current note
						"data": {"start": 0.0, "end": 1.0, "dur": 0}
					}

				,	{"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": [
							"An4 3"
						,	"An4 3"
						,	"An4 3"
						,	"An4 3"
						,	"An4 2"
						,	"An4 2"
						,	"An4 1"
						,	"An4 1"
						,	"An4 1"
						,	"An4 2"
						,	"An4 2"
						,	"An4 2"
						,	"An4 2"
						,	"An4 1"
						,	"An4 2"
						,	"An4 2"
						]
					}

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

				,	{"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": -6, "times": 1}
					}
				]
		,	"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": "pan", // linearly-divided fraction of the audio going to the right channel, with the remainder going to the left
						"data": {"position": 0.5}
					}
				,	{"command": "detune", // detune in cents to be applied to the oscillator (for "richer" sound when 2 similar frequencies overlap)
						"data": {"cents": 2}
					}
				// intro
				,	{"command": "vol", // set overall volume of channel
						"data": {"level": 0.15}
					}
				,	{"command": "tempo", // change tempo mid-tune
						"data": {"bpm": 120}
					}
				,	{"command": "env", // set linear ramp envelope applied to every note
						"data": {"start": 1.0, "end": 0.5, "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": [
							"Dn4 3"
						,	"Cn4 3"
						,	"Fn4 3"
						,	"Gn4 3"
						,	"En4 12"
						]
					}

				// section A1, A2
				,	{"command": "vol", // set overall volume of channel
						"data": {"level": 0.1}
					}
				,	{"command": "tempo", // change tempo mid-tune
						"data": {"bpm": 240} // 120 in 8ths
					}
				,	{"command": "env", // set linear ramp envelope applied to every note
						"data": {"start": 1.0, "end": 0.0, "dur": 0.5}
					}
				,	{"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": 1.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": [
							"An4 2"
						,	"An4 2"
						,	"Gn4 2"
						,	"Gn4 2"

						,	"An4 2"
						,	"Bn4 2"
						,	"Cn5 1.15"
						,	"Bn4 0.85"
						,	"An4 2"

						,	"En5 2"
						,	"Dn5 2"
						,	"Cn5 2"
						,	"Dn5 2"

						,	"Cn5 1.15"
						,	"Bn4 0.85"
						,	"An4 1.15"
						,	"Gn4 0.85"
						,	"En4 2"
						,	"Dn4 2"
						]
					}
				,	{"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": [
							"An4 2"
						,	"An4 2"
						,	"Gn4 2"
						,	"Gn4 2"

						,	"An4 2"
						,	"Bn4 2"
						,	"Cn5 1.15"
						,	"Bn4 0.85"
						,	"An4 2"

						,	"En5 2"
						,	"Dn5 2"
						,	"En5 2"
						,	"Dn5 2"

						,	"Bn4 1.15"
						,	"An4 0.85"
						,	"Gs4 1.15"
						,	"An4 0.85"
						,	"Bn4 2"
						,	"En5 2"
						]
					}
				,	{"command": "jump", // go forwards/backwards delta commands if loop counter < times; increase loop counter
						"data": {"delta": -4, "times": 1}
					}

				// section B
				,	{"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": "vol", // set overall volume of channel
						"data": {"level": 0.2}
					}

				,	{"command": "env", // set linear ramp envelope applied to every note
						"data": {"start": 0.75, "end": 1.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": [
							"Cn5 8"
						]
					}
				,	{"command": "env", // set linear ramp envelope applied to every note
						"data": {"start": 1.0, "end": 0.75, "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": [
							"Cn5 6"
						]
					}

				,	{"command": "env", // set linear ramp envelope applied to every note
						"data": {"start": 1.0, "end": 1.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": [
							"Cn5 1"
						,	"Bn4 1"

						,	"Cn5 3"
						,	"An4 5"
						]
					}
				,	{"command": "env", // set linear ramp envelope applied to every note
						"data": {"start": 1.0, "end": 0.75, "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": [
							"An4 6"
						]
					}

				,	{"command": "env", // set linear ramp envelope applied to every note
						"data": {"start": 1.0, "end": 1.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": [
							"En4 1"
						,	"Fn4 1"
						]
					}

				,	{"command": "env", // set linear ramp envelope applied to every note
						"data": {"start": 0.75, "end": 1.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": [
							"Cn5 8"
						]
					}
				,	{"command": "env", // set linear ramp envelope applied to every note
						"data": {"start": 1.0, "end": 0.75, "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": [
							"Cn5 6"
						]
					}

				,	{"command": "env", // set linear ramp envelope applied to every note
						"data": {"start": 1.0, "end": 1.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": [
							"An4 1"
						,	"Bn4 1"

						,	"Cn5 2"
						,	"An4 1"
						,	"En5 3"
						,	"Dn5 4"
						,	"En5 6"
						]
					}

				,	{"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": -28, "times": 1}
					}

				]
		,	"sq":	// 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": "vol", // set overall volume of channel
						"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": "detune", // detune in cents to be applied to the oscillator (for "richer" sound when 2 similar frequencies overlap)
						"data": {"cents": -3}
					}

				// intro
				,	{"command": "tempo", // change tempo mid-tune
						"data": {"bpm": 240} // 120 in 16ths
					}
				,	{"command": "env", // set linear ramp envelope applied to every note
						"data": {"start": 1.0, "end": 0.5, "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 1"
						,	"Fn4 1"
						,	"An4 1"
						,	"Dn5 1"
						,	"Fn5 1"
						,	"Dn5 1"

						,	"En5 1"
						,	"Cn5 1"
						,	"Gn4 1"
						,	"En4 1"
						,	"Cn4 1"
						,	"An3 1"

						,	"Bf3 1"
						,	"Dn4 1"
						,	"Fn4 1"
						,	"Bf4 1"
						,	"Dn5 1"
						,	"Bf4 1"

						,	"Bn4 1"
						,	"Gn4 1"
						,	"Dn4 1"
						,	"Bn3 1"
						,	"Dn4 1"
						,	"Fn4 1"

						,	"En4 1"
						,	"Cs4 1"
						,	"An3 1"
						,	"En3 1"
						,	"An3 1"
						,	"Cs4 1"

						,	"En4 1"
						,	"An4 1"
						,	"Cs5 1"
						,	"En5 1"
						,	"An5 1"
						,	"Bn5 1"

						,	"Cs6 1"
						,	"An5 1"
						,	"En5 1"
						,	"Cs5 1"
						,	"An4 1"
						,	"En4 1"

						,	"Cs5 6"
						]
					}

				// section A1
				,	{"command": "tempo", // change tempo mid-tune
						"data": {"bpm": 120}
					}
				,	{"command": "vol", // set overall volume of channel
						"data": {"level": 0.05}
					}
				,	{"command": "env", // set linear ramp envelope applied to every note
						"data": {"start": 1.0, "end": 1.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": [
							"Rst 4"
						,	"Rst 4"
						,	"Rst 4"
						,	"Rst 4"
						,	"Rst 4"
						,	"Rst 4"
						,	"Rst 4"
						,	"Rst 4"
						]
					}

				// section A2
				,	{"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 1"
						,	"An2 3"

						,	"Rst 1"
						,	"An2 1"
						,	"En2 2"

						,	"Dn2 2"
						,	"En2 2"

						,	"Fn2 2"
						,	"Gn2 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": [
							"Rst 1"
						,	"An2 3"

						,	"Rst 1"
						,	"An2 1"
						,	"En2 2"

						,	"Dn2 1"
						,	"An1 1"
						,	"En2 1"
						,	"An1 1"
						
						,	"Fn2 1"
						,	"An1 1"
						,	"Gn2 1"
						,	"An1 1"
						]
					}

				// section B
				,	{"command": "tempo", // change tempo mid-tune
						"data": {"bpm": 240} // 120 in 8ths
					}
				,	{"command": "vol", // set overall volume of channel
						"data": {"level": 0.0625}
					}
				,	{"command": "env", // set linear ramp envelope applied to every note
						"data": {"start": 1.0, "end": 0.5, "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": [
							"Fn2 3"
						,	"Fn2 5"

						,	"Fn2 3"
						,	"Fn2 5"

						,	"En2 3"
						,	"Cn2 3"
						,	"An2 4"
						,	"En2 6"
						]
					}
				,	{"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": [
							"Fn2 3"
						,	"Fn2 5"

						,	"Fn2 3"
						,	"Fn2 5"

						,	"En2 3"
						,	"Cn2 3"
						,	"Bn1 10"
						]
					}

				,	{"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": -12, "times": 1}
					}

				]
		,	"sin":	// name of a channel on the chip	
				[
					{"command": "detune", // detune in cents to be applied to the oscillator (for "richer" sound when 2 similar frequencies overlap)
						"data": {"cents": 3}
					}

				// intro
				,	{"command": "vol", // set overall volume of channel
						"data": {"level": 0.15}
					}
				,	{"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.5, "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.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": [
							"An3 3"
						,	"An3 3"
						,	"An3 3"
						,	"Bn3 3"
						,	"Cs4 12"
						]
					}

				// section A1, A2
				,	{"command": "vol", // set overall volume of channel
						"data": {"level": 0.1}
					}
				,	{"command": "tempo", // change tempo mid-tune
						"data": {"bpm": 240} // 120 in 8ths
					}
				,	{"command": "env", // set linear ramp envelope applied to every note
						"data": {"start": 1.0, "end": 0.0, "dur": 0.5}
					}
				,	{"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.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": [
							"En4 2"
						,	"En4 1.15"
						,	"Fn4 0.85"
						,	"Gn4 1.15"
						,	"Fn4 0.85"
						,	"En4 2"

						,	"En4 1.15"
						,	"Fn4 0.85"
						,	"Gn4 1.15"
						,	"Fn4 0.85"
						,	"En4 2"
						,	"Cn4 2"

						,	"Bn3 1.15"
						,	"Cn4 0.85"
						,	"Fn4 2"
						,	"En4 1.15"
						,	"Fn4 0.85"
						,	"Bn4 2"

						,	"Rst 1.15"
						,	"En5 0.85"
						,	"Cn5 1.15"
						,	"En5 0.85"
						,	"Dn5 1.15"
						,	"Cn5 0.85"
						,	"Bn4 1.15"
						,	"Cn5 0.85"
						]
					}
				,	{"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": [
							"En4 2"
						,	"En4 1.15"
						,	"Fn4 0.85"
						,	"Gn4 1.15"
						,	"Fn4 0.85"
						,	"En4 2"

						,	"Cn5 1.15"
						,	"Dn5 0.85"
						,	"En5 1.15"
						,	"Dn5 0.85"
						,	"An5 2"
						,	"Gn5 2"

						,	"Bn4 1.15"
						,	"An4 0.85"
						,	"Fn4 2"
						,	"Bn4 2"
						,	"Gn4 1.15"
						,	"En4 0.85"

						,	"Fn4 1.15"
						,	"Cn4 0.85"
						,	"Cn5 1.15"
						,	"Cn4 0.85"
						,	"Gn4 1.15"
						,	"Dn4 0.85"
						,	"Bn4 1.15"
						,	"Cn5 0.85"
						]
					}
				,	{"command": "jump", // go forwards/backwards delta commands if loop counter < times; increase loop counter
						"data": {"delta": -4, "times": 1}
					}

				// section B
				,	{"command": "vol", // set overall volume of channel
						"data": {"level": 0.15}
					}
				,	{"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": [
							"Rst 2"
						,	"Fn4 1.15"
						,	"Cn4 0.85"
						,	"Fn4 2"
						,	"Cn4 2"

						,	"Fn4 1.15"
						,	"Gn4 0.85"
						,	"An4 1.15"
						,	"Gn4 0.85"
						,	"Fn4 2"
						,	"Fn4 1.15"
						,	"Gn4 0.85"
						]
					}

				,	{"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": [
							"En4 2"
						,	"En4 2"
						,	"En4 1.15"
						,	"Fn4 0.85"
						,	"Gn4 1.15"
						,	"Fn4 0.85"

						,	"En4 1.15"
						,	"An4 0.85"
						,	"Gn4 1.15"
						,	"En4 0.85"
						,	"Fn4 1.15"
						,	"En4 0.85"
						,	"Cn4 1.15"
						,	"En4 0.85"
						]
					}

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

						,	"Fn4 1.15"
						,	"Gn4 0.85"
						,	"An4 2"
						,	"An4 1.15"
						,	"Gn4 0.85"
						,	"Fn4 2"
						]
					}

				,	{"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": [
							"En4 1.15"
						,	"Fn4 0.85"
						,	"Gn4 2"
						,	"En4 1.15"
						,	"Fn4 0.85"
						,	"Gn4 2"

						,	"Rst 1.15"
						,	"Fn4 0.85"
						,	"Gn4 1.15"
						,	"An4 0.85"
						,	"Cn5 2"
						,	"En4 2"
						]
					}

				,	{"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": -19, "times": 1}
					}

				]
		}
	};
