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

Chord substitutions #115

Open
martijnmichel opened this issue Oct 17, 2019 · 12 comments
Open

Chord substitutions #115

martijnmichel opened this issue Oct 17, 2019 · 12 comments

Comments

@martijnmichel
Copy link
Contributor

martijnmichel commented Oct 17, 2019

It seems tonaljs is missing a feature to output chord subs (or i just missed it being there ;))

For instance:
Cmaj7 can be subbed with Em
or Cmaj79 with Em9
G7(9) -> Bm7b5
G7(9) -> Dm6
etc..

Actually I would be fine with helping out on inserting it in tonal if it is missing and if needed... ive finished conservatory jazz guitar so have all the knowledge to make it work.

@danigb
Copy link
Collaborator

danigb commented Mar 11, 2020

An implementation of this would be great! 👍

Do you have any ideas about how to implement it? Perhaps we can discuss them in this issue :-)

@martijnmichel
Copy link
Contributor Author

ill make a fork of tonal and see how the internals work, maybe itll give me an idea..

@martijnmichel
Copy link
Contributor Author

If im gonna be helping you with this it seems ill need to start learning typescript first...

@danigb
Copy link
Collaborator

danigb commented Mar 12, 2020

Okey, no worries. We can discuss what you need first...

@martijnmichel
Copy link
Contributor Author

martijnmichel commented Mar 12, 2020

Im not sure I understand the setup of tonal yet also... for example, how would I test new functionality? import it into another project with HMR ? I'd be happy to help though, just gonna need a bit of a learning curve first.

@martijnmichel
Copy link
Contributor Author

Well i'm deep into typescript atm ;)
Can you explain to me how i can setup a test env for a new module?

@danigb
Copy link
Collaborator

danigb commented Mar 15, 2020

I've updated CONTRIBUTING.md

Hope it helps

@martijnmichel
Copy link
Contributor Author

it did but it doesnt describe how to setup a test environment, does it?
I cant believe id have to run yarn test:ci everything i change something in my code and wait over a minute for the tests to complete?

@danigb
Copy link
Collaborator

danigb commented Mar 15, 2020

You can run npx jest module-name in root folder to run the test of one module. For example npx jest chord-detect

@martijnmichel
Copy link
Contributor Author

okay, thatll work.. though it still seems a bit slow to hit the terminal everytime i change a bit of code.
But, we can talk about the actual implementation ;)

@martijnmichel
Copy link
Contributor Author

Ive been trying to come up with a solution.. we need a way to:

  • add a seventh reliably to a triad chord to find the 3rd relationship of the 3rd in the chord.
  • substract to 6th from the root of the chord to find the 3rd relationship of the 6th.
export function sub(chordName: string): string[] | undefined {
  const [tonic, type] = tokenize(chordName);
  if (tonic) {
    let c = Chord.get(`${tonic}${type}`);
    let scales = Chord.chordScales(`${tonic}${type}`);
    return detect(c.notes);
  }
}

There are so many scales listed, many of which are very unknown to me that I find it hard to do the above. Do you have any ideas?

@danigb
Copy link
Collaborator

danigb commented Mar 23, 2020

Can you explain me how the algorithm works? For example, to go from "Cmaj7" to "Em" you need to remove the tonic. For example:

  • Remove the tonic
  • Map the intervals to make the 3th become tonic (Interval.add)
  • Find the chord in the dictionary (For example, calculating the set chroma)

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

No branches or pull requests

2 participants