vault backup: 2025-12-29 12:07:42
This commit is contained in:
+1
-98
@@ -12,104 +12,7 @@ tags:
|
||||
|
||||
## 2025-12-19 06:22
|
||||
|
||||
PowerShell module to assist in translating between banjo fingerings and concert notes,
|
||||
as well as between [[lilypond]] and conventional notation.
|
||||
|
||||
```powershell
|
||||
$Db4 = [Pitch]::FromLilyPond("des'")
|
||||
[Note]::($Db4,1/4).PlayInTime(120)
|
||||
|
||||
$str1 = [FrettedStringTuning]::FromOpen([Pitch]::FromLilyPond("d,,,"))
|
||||
$str1c2 = $str1.Capo(2)
|
||||
|
||||
$openGtuning = [FrettedStringInstrumentTuning]::FromStringTunings(@(
|
||||
[FrettedStringTuning]::FromOpen([Pitch]::FromLilyPond("d,,,")),
|
||||
[FrettedStringTuning]::FromOpen([Pitch]::FromLilyPond("b,,")),
|
||||
[FrettedStringTuning]::FromOpen([Pitch]::FromLilyPond("g,")),
|
||||
[FrettedStringTuning]::FromOpen([Pitch]::FromLilyPond("d")),
|
||||
[FrettedStringTuning]::FromOpen([Pitch]::FromLilyPond("g'")),
|
||||
# note: the notation used above is concert octave,
|
||||
# banjo is transposed up one octave.
|
||||
))
|
||||
[Note]::($openGc2tuning.GetPitchFromFingering(4,11)/4).PlayInTime(120) # play Db4
|
||||
|
||||
$openGc2tuning = $openGtuning.Capo(2)
|
||||
[Note]::($openGc2tuning.GetPitchFromFingering(4,9),1/4).PlayInTime(120) # play Db4
|
||||
|
||||
# TODO: class iFrettedStringInstrument
|
||||
# class Banjo implements iFrettedStringInstrument
|
||||
|
||||
```
|
||||
|
||||
```powershell
|
||||
class Pitch {
|
||||
[Pitch] TransposeOctave([Note]$note1,[Note]$note2) {}
|
||||
[Pitch] TransposeOctave([int]$modifier) {}
|
||||
}
|
||||
|
||||
class Duration {
|
||||
# 1/4, 1/8, etc.
|
||||
# does not encode timing.
|
||||
}
|
||||
|
||||
class Note {
|
||||
[Pitch]$_pitch
|
||||
[Duration]$_duration
|
||||
}
|
||||
```
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
%% simple score definition, does not support polyphony
|
||||
class Score {
|
||||
List~Note~ notes
|
||||
float beatsPerMinute
|
||||
+Beep() void
|
||||
}
|
||||
|
||||
Score *-- Note
|
||||
class Note {
|
||||
Pitch pitch
|
||||
float beats
|
||||
+BeepInTime(int bpm)
|
||||
}
|
||||
|
||||
Note *-- Pitch
|
||||
class Pitch {
|
||||
+Transpose(Pitch from, Pitch to) Pitch
|
||||
+TransposeOctave(int modifier) Pitch
|
||||
+FromLilyPond(string text) Pitch
|
||||
+GetFrequency() float
|
||||
+Beep(int milliseconds) void
|
||||
}
|
||||
|
||||
class Banjo {
|
||||
+FromNamedTuning(string tuningName) Banjo
|
||||
}
|
||||
|
||||
Banjo <|.. iFrettedStringInstrument
|
||||
class iFrettedStringInstrument {
|
||||
-FrettedStringInstrumentTuning tuning
|
||||
+GetPitchFromFingering(int string,int fret) Pitch
|
||||
+GetFingeringsFromPitch(Pitch pitch) todo
|
||||
}
|
||||
|
||||
iFrettedStringInstrument *-- FrettedStringInstrumentTuning
|
||||
class FrettedStringInstrumentTuning {
|
||||
-List~FrettedStringTuning~ stringTunings
|
||||
+GetPitchFromFingering(int string,int fret) Pitch
|
||||
+GetFingeringsFromPitch(Pitch pitch) todo
|
||||
+Capo(int fret) FrettedStringInstrumentTuning
|
||||
}
|
||||
|
||||
FrettedStringInstrumentTuning *-- FrettedStringTuning
|
||||
class FrettedStringTuning {
|
||||
Pitch openPitch
|
||||
int fretOffset
|
||||
+GetPitchFromFret(int fret) Pitch
|
||||
+SetOffset(int fret) FrettedStringTuning
|
||||
}
|
||||
```
|
||||
[[music-theory-as-code]]
|
||||
|
||||
## 2025-12-19 10:44
|
||||
|
||||
|
||||
Reference in New Issue
Block a user