Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 53 additions & 5 deletions Types/Frequency/get_Scale.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@ if ($this.'#Scale') { return $this.'#Scale'}
$majorScale = [Collections.ArrayList]::new()
$null = $majorScale.Add($this)

$currentNote = $this

#Start with constructing the major scale
foreach ($step in ("WWHWWWH".ToCharArray())) { #Standard major scale step pattern
$stepCount = if ($step -eq "W") { 2 } else { 1 }
$currentNote = $currentNote.Sharpen($stepCount)
$null = $majorScale.Add($currentNote)
$null = $majorScale.Add($majorScale[-1].Sharpen($stepCount))
}

$scaleTable = [Ordered]@{
Expand All @@ -32,12 +29,20 @@ $scaleTable = [Ordered]@{
MelodicMinor = $majorScale.Clone()
PentatonicMajor = $majorScale.Clone()
PentatonicMajorDescending = $majorScale.Clone()
PentatonicMinor = $null #These are derived from MINOR scale which isn't built yet
# Remaining scales are NOT derived from major scale
PentatonicMinor = $null
PentatonicMinorDescending = $null
PentatonicBlues = $null
PentatonicBluesDescending = $null
WholeTone = [Collections.ArrayList]::new()
WholeToneDescending = $null
Octatonic = [Collections.ArrayList]::new()
OctatonicDescending = $null
Augmented = [Collections.ArrayList]::new()
AugmentedDescending = $null
}

#region Diatonic Scales
# The minor scales are just the major scale with certain scale degrees flattened
$flat3rd = $majorScale[2].Flatten(1)
$scaleTable["Minor"][2] = $flat3rd
Expand All @@ -58,7 +63,9 @@ $scaleTable["MinorDescending"].Reverse()

$scaleTable["HarmonicMinorDescending"]= $scaleTable["HarmonicMinor"].Clone()
$scaleTable["HarmonicMinorDescending"].Reverse()
#endregion Diatonic Scales

#region Pentatonic Scales
# Pentatonic scales mainly derive from the major/minor scale,
# but with certain scale degrees removed to make them 5 notes long (hence 'penta'tonic)
$scaleTable["PentatonicMajor"].RemoveAt(3)
Expand All @@ -78,6 +85,47 @@ $aug4th = $scaleTable["PentatonicBlues"][2].Sharpen(1)
$scaleTable["PentatonicBlues"].Insert(3,$aug4th)
$scaleTable["PentatonicBluesDescending"] = $scaleTable["PentatonicBlues"].Clone()
$scaleTable["PentatonicBluesDescending"].Reverse()
#endregion Pentatonic Scales

#region Symmetric Scales
$null = $scaleTable["WholeTone"].Add($this)
$null = $scaleTable["Octatonic"].Add($this)
$null = $scaleTable["Augmented"].Add($this)

# Whole Tone scale is all whole steps up
1..6 | ForEach-Object {
$null = $scaleTable["WholeTone"].Add($scaleTable["WholeTone"][-1].Sharpen(2))
}
$scaleTable["WholeToneDescending"] = $scaleTable["WholeTone"].Clone()
$scaleTable["WholeToneDescending"].Reverse()

# Octatonic scale alternates b/w whole steps and half steps
1..8 | ForEach-Object {
$stepCount = if ($_ % 2 -eq 0) { 1 } else { 2 }
$null = $scaleTable["Octatonic"].Add($scaleTable["Octatonic"][-1].Sharpen($stepCount))
}
$scaleTable["OctatonicDescending"] = $scaleTable["Octatonic"].Clone()
$scaleTable["OctatonicDescending"].Reverse()

# Augmented scale alternates b/w minor 3rds and half steps
1..6 | ForEach-Object {
$stepCount = if ($_ % 2 -eq 0) { 1 } else { 3 }
$null = $scaleTable["Augmented"].Add($scaleTable["Augmented"][-1].Sharpen($stepCount))
}
$scaleTable["AugmentedDescending"] = $scaleTable["Augmented"].Clone()
$scaleTable["AugmentedDescending"].Reverse()
#endregion Symmetric Scales

# Because our descending scales are just the reverse of the originals right now,
# they start at the top note of each scale.
# Need to drop all descending scales down an octave to start on current note
foreach ($scale in $scaleTable.Keys) {
if ($scale -match "Descending$") {
foreach ($i in (1..$scaleTable[$scale].Count)) {
$scaleTable[$scale][($i - 1)] = $scaleTable[$scale][($i - 1)].Flatten(12)
}
}
}

$this | Add-Member NoteProperty '#Scale' $scaleTable -Force
return $scaleTable
58 changes: 53 additions & 5 deletions Wave.types.ps1xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,10 @@ if ($this.'#Scale') { return $this.'#Scale'}
$majorScale = [Collections.ArrayList]::new()
$null = $majorScale.Add($this)

$currentNote = $this

#Start with constructing the major scale
foreach ($step in ("WWHWWWH".ToCharArray())) { #Standard major scale step pattern
$stepCount = if ($step -eq "W") { 2 } else { 1 }
$currentNote = $currentNote.Sharpen($stepCount)
$null = $majorScale.Add($currentNote)
$null = $majorScale.Add($majorScale[-1].Sharpen($stepCount))
}

$scaleTable = [Ordered]@{
Expand All @@ -153,12 +150,20 @@ $scaleTable = [Ordered]@{
MelodicMinor = $majorScale.Clone()
PentatonicMajor = $majorScale.Clone()
PentatonicMajorDescending = $majorScale.Clone()
PentatonicMinor = $null #These are derived from MINOR scale which isn't built yet
# Remaining scales are NOT derived from major scale
PentatonicMinor = $null
PentatonicMinorDescending = $null
PentatonicBlues = $null
PentatonicBluesDescending = $null
WholeTone = [Collections.ArrayList]::new()
WholeToneDescending = $null
Octatonic = [Collections.ArrayList]::new()
OctatonicDescending = $null
Augmented = [Collections.ArrayList]::new()
AugmentedDescending = $null
}

#region Diatonic Scales
# The minor scales are just the major scale with certain scale degrees flattened
$flat3rd = $majorScale[2].Flatten(1)
$scaleTable["Minor"][2] = $flat3rd
Expand All @@ -179,7 +184,9 @@ $scaleTable["MinorDescending"].Reverse()

$scaleTable["HarmonicMinorDescending"]= $scaleTable["HarmonicMinor"].Clone()
$scaleTable["HarmonicMinorDescending"].Reverse()
#endregion Diatonic Scales

#region Pentatonic Scales
# Pentatonic scales mainly derive from the major/minor scale,
# but with certain scale degrees removed to make them 5 notes long (hence 'penta'tonic)
$scaleTable["PentatonicMajor"].RemoveAt(3)
Expand All @@ -199,6 +206,47 @@ $aug4th = $scaleTable["PentatonicBlues"][2].Sharpen(1)
$scaleTable["PentatonicBlues"].Insert(3,$aug4th)
$scaleTable["PentatonicBluesDescending"] = $scaleTable["PentatonicBlues"].Clone()
$scaleTable["PentatonicBluesDescending"].Reverse()
#endregion Pentatonic Scales

#region Symmetric Scales
$null = $scaleTable["WholeTone"].Add($this)
$null = $scaleTable["Octatonic"].Add($this)
$null = $scaleTable["Augmented"].Add($this)

# Whole Tone scale is all whole steps up
1..6 | ForEach-Object {
$null = $scaleTable["WholeTone"].Add($scaleTable["WholeTone"][-1].Sharpen(2))
}
$scaleTable["WholeToneDescending"] = $scaleTable["WholeTone"].Clone()
$scaleTable["WholeToneDescending"].Reverse()

# Octatonic scale alternates b/w whole steps and half steps
1..8 | ForEach-Object {
$stepCount = if ($_ % 2 -eq 0) { 1 } else { 2 }
$null = $scaleTable["Octatonic"].Add($scaleTable["Octatonic"][-1].Sharpen($stepCount))
}
$scaleTable["OctatonicDescending"] = $scaleTable["Octatonic"].Clone()
$scaleTable["OctatonicDescending"].Reverse()

# Augmented scale alternates b/w minor 3rds and half steps
1..6 | ForEach-Object {
$stepCount = if ($_ % 2 -eq 0) { 1 } else { 3 }
$null = $scaleTable["Augmented"].Add($scaleTable["Augmented"][-1].Sharpen($stepCount))
}
$scaleTable["AugmentedDescending"] = $scaleTable["Augmented"].Clone()
$scaleTable["AugmentedDescending"].Reverse()
#endregion Symmetric Scales

# Because our descending scales are just the reverse of the originals right now,
# they start at the top note of each scale.
# Need to drop all descending scales down an octave to start on current note
foreach ($scale in $scaleTable.Keys) {
if ($scale -match "Descending$") {
foreach ($i in (1..$scaleTable[$scale].Count)) {
$scaleTable[$scale][($i - 1)] = $scaleTable[$scale][($i - 1)].Flatten(12)
}
}
}

$this | Add-Member NoteProperty '#Scale' $scaleTable -Force
return $scaleTable
Expand Down
Loading