Skip to content

Commit be29c52

Browse files
authored
Set version to 0.1 and update README (#11)
1 parent b1f88c5 commit be29c52

File tree

2 files changed

+45
-15
lines changed

2 files changed

+45
-15
lines changed

Project.toml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
name = "MusicTheory"
22
uuid = "564e61e1-4667-41b2-a4a2-754a0240c775"
33
authors = ["David Sanders <[email protected]> and contributors"]
4-
version = "1.0.0-DEV"
4+
version = "0.1"
55

66
[deps]
7-
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
8-
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
9-
GeometryTypes = "4d00f742-c7ba-57c2-abde-4428a4b178cb"
10-
Luxor = "ae8d54c2-7ccd-5906-9d76-62fc9837b5bc"
11-
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
127

138
[compat]
149
julia = "1"

README.md

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22

33
[![Build Status](https://github.com/dpsanders/MusicTheory.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/dpsanders/MusicTheory.jl/actions/workflows/CI.yml?query=branch%3Amain)
44

5-
A Julia package for the basics of ("Western") music theory.
6-
(Currently) everything is based on semitones.
5+
The goal of this package is to provide a Julian interface for representing
6+
the objects and structures in ("Western") music theory (based on semitones).
77

88
## Contents
99
- Pitches with scientific notation, e.g. C4 for middle C
1010
- Intervals
1111
- Scales
12-
- Chords
1312
- Notes and rests with durations
13+
- Chords
1414

1515
## Pitches
1616
Pitch names are exported in the `MusicTheory.PitchNames` submodule.
1717

1818
Specifying just the name of a pitch gives a `PitchClass`, representing all notes of that
1919
pitch, e.g.
20-
```
20+
```jl
2121
julia> C♯
2222
C♯
2323

@@ -26,28 +26,28 @@ PitchClass
2626
```
2727

2828
Indexing gives a pitch with a specific octave, e.g.
29-
```
29+
```jl
3030
julia> C♯[4]
3131
C♯₄
3232
```
3333

3434
## Intervals
3535
The `Interval` type computes the interval between two pitches:
36-
```
36+
```jl
3737
julia> Interval(C[4], E[4])
3838
Major 3rd
3939
```
4040

4141
## Scales
4242
General scales are supported; they are specified as a sequence of intervals dividing up an
4343
octave, e.g.
44-
```
44+
```jl
4545
julia> show(major_scale)
4646
Interval[Major 2nd, Major 2nd, Minor 2nd, Major 2nd, Major 2nd, Major 2nd, Minor 2nd]
4747
```
4848

4949
The `Scale` type is a standard Julia iterator over the scale:
50-
```
50+
```jl
5151
julia> scale = Scale(C[4], major_scale)
5252
Scale{Pitch}(C₄, Dict{PitchClass, Interval}(C => Major 2nd, E => Minor 2nd, B => Minor 2nd, F => Major 2nd, D => Major 2nd, G => Major 2nd, A => Major 2nd))
5353

@@ -60,14 +60,49 @@ Pitch[C₄, D₄, E₄, F₄, G₄, A₄, B₄, C₅]
6060
## Notes
6161
Notes have a pitch and a duration, which is a rational number, e.g. `1 // 4` for a
6262
quarter note (crotchet). Rests are specified using `rest`, e.g.
63-
```
63+
```jl
6464
julia> notes = [C[5] / 4, rest / 8, D[5] / 8]
6565
3-element Vector{Note}:
6666
Note(C₅, 1//4)
6767
Note(MusicTheory.Rest(), 1//8)
6868
Note(D₅, 1//8)
6969
```
7070

71+
## Example
72+
A motivating example for writing this package was to be able to do the following types of
73+
computations.
74+
75+
When playing the violin, it's common to have a scale in thirds: take a scale and for each
76+
scale tone, play the note two steps above it in the scale at the same time.
77+
78+
Question: Which combinations of half/whole steps and pairs of major/minor thirds
79+
are possible?
80+
81+
Answer:
82+
```jl
83+
julia> scale = Scale(C[4], major_scale)
84+
85+
julia> notes = Base.Iterators.take(scale, 10) |> collect
86+
87+
julia> thirds = zip(notes, notes[3:end]) |> collect
88+
89+
julia> thirds_intervals = Interval.(thirds)
90+
91+
julia> note_intervals = Interval.(zip(notes, notes[2:end]))
92+
93+
julia> combinations =
94+
[ (note_intervals[i], thirds_intervals[i], thirds_intervals[i+1])
95+
for i in 1:(length(thirds)-1)
96+
]
97+
98+
julia> result = unique(combinations)
99+
4-element Vector{Tuple{Interval, Interval, Interval}}:
100+
(Major 2nd, Major 3rd, Minor 3rd)
101+
(Major 2nd, Minor 3rd, Minor 3rd)
102+
(Minor 2nd, Minor 3rd, Major 3rd)
103+
(Major 2nd, Major 3rd, Major 3rd)
104+
```
105+
71106
## Author
72107

73108
Copyright David P. Sanders, 2024

0 commit comments

Comments
 (0)