Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added new pitch and notes helper function #24

Merged
merged 3 commits into from
Jan 26, 2024

Conversation

SebastianBoldt
Copy link
Contributor

@SebastianBoldt SebastianBoldt commented Jan 26, 2024

Description

Currently it is impossible to extract the correct notes and their respective octaves from a chord object for a specific inversion.

I tried to obtain the correct notes and pitches for a chord by mapping all the note classes, since it was the only property available in the chord object.
I used the following code:

chord.noteClasses.map {
    Note($0.letter, accidental: $0.accidental, octave: 0).pitch
}

Unfortunately, the noteClasses do not contain the octave information, making it impossible for me to obtain the correct pitches for a specific chord inversion.

Proposed Solution

I would like to be able to do something like this:

chord.pitches(octave: 1) // Return the correct pitches taking into account the inversion
chord.notes(octave: 1) // Return the correct notes taking into account the inversion

@aure aure merged commit 27e8c54 into AudioKit:main Jan 26, 2024
21 checks passed
@SebastianBoldt
Copy link
Contributor Author

🥳

@SebastianBoldt
Copy link
Contributor Author

@aure I think we could also try to build something similar for Scales.
If we obtain the Notes via the noteSet and map them to pitches they also do have the wrong octave order.

lldb) po Key.init(root: .init(.D, accidental: .natural), scale: .major).noteSet.array
 7 elements
   0 : C4
     noteClass : C
      - letter : Tonic.Letter.C
      - accidental : 
    - octave : 4
   1 : D4
     noteClass : D
      - letter : Tonic.Letter.D
      - accidental : 
    - octave : 4
   2 : E4
     noteClass : E
      - letter : Tonic.Letter.E
      - accidental : 
    - octave : 4
   3 : F4
     noteClass : F
      - letter : Tonic.Letter.F
      - accidental : 
    - octave : 4
   4 : G4
     noteClass : G
      - letter : Tonic.Letter.G
      - accidental : 
    - octave : 4
   5 : A4
     noteClass : A
      - letter : Tonic.Letter.A
      - accidental : 
    - octave : 4
   6 : B4
     noteClass : B
      - letter : Tonic.Letter.B
      - accidental : 
    - octave : 4
    ```

@Matt54
Copy link
Member

Matt54 commented Jan 26, 2024

Did we solve issue #25 with merging this PR?

@SebastianBoldt
Copy link
Contributor Author

Did we solve issue #25 by merging this PR?

@Matt54 Nope, we solved this one
#22

#25 is about Keys
#22 was about Chords

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants