Skip to content

Beginner interval question #25

@theogf

Description

@theogf

I am a novice in music theory but I would like to create new scales.
Since I don't know how to create intervals I tried to revert engineer it:
I googled the Major 7th scale for C: C, E, G, and B.
And tried to build the scale out of it:

intervals = [
    Interval(MusicTheory.C[4], MusicTheory.E[4]),
    Interval(MusicTheory.E[4], MusicTheory.G[4]),
    Interval(MusicTheory.G[4], MusicTheory.B[5]),
    Interval(MusicTheory.B[5], MusicTheory.C[5]),
]
4-element Vector{Interval}:
 Major 3rd
 Minor 3rd
 Major 10th
 Major 7th

However sum(intervals) fails due to

ERROR: KeyError: key 9 not found
Stacktrace:
  [1] getindex(h::Dict{Int64, Int64}, key::Int64)
    @ Base ./dict.jl:498
  [2] semitone(interval::Interval)
    @ MusicTheory ~/.julia/packages/MusicTheory/onUoY/src/intervals.jl:42
  [3] +(n::PitchClass, interval::Interval)
    @ MusicTheory ~/.julia/packages/MusicTheory/onUoY/src/intervals.jl:97
  [4] +
    @ ~/.julia/packages/MusicTheory/onUoY/src/intervals.jl:108 [inlined]
  [5] +(::Pitch, ::Interval, ::Interval)
    @ Base ./operators.jl:587
  [6] +(i1::Interval, i2::Interval)
    @ MusicTheory ~/.julia/packages/MusicTheory/onUoY/src/intervals.jl:117
  [7] add_sum
    @ ./reduce.jl:24 [inlined]
  [8] _mapreduce(f::typeof(identity), op::typeof(Base.add_sum), ::IndexLinear, A::Vector{Interval})
    @ Base ./reduce.jl:443
  [9] _mapreduce_dim
    @ ./reducedim.jl:365 [inlined]
 [10] mapreduce
    @ ./reducedim.jl:357 [inlined]
 [11] _sum
    @ ./reducedim.jl:1015 [inlined]
 [12] _sum
    @ ./reducedim.jl:1014 [inlined]
 [13] sum(a::Vector{Interval})
    @ Base ./reducedim.jl:1010

Can it be due to a bug in the implementation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions