tonaljs / tonal

A music theory library for Javascript
https://tonaljs.github.io/tonal/docs
3.81k stars 219 forks source link

Can't transpose array of chord intervals to notes starting on a specific note in a specific octave #106

Closed vellebelle closed 5 years ago

vellebelle commented 5 years ago

I know this is not a forum to ask newbie questions, but I don\t know where else to ask, so please forgive me. And if there is a support/help forum elsewhere for Tonal, please let me know..

I made a project using tonal v2 and this weekend I started playing around with v3. I am not quite sure I understand how to do something.

In v2 I could import Chord, transpose and Interval from tonal like this:

import { Chord, transpose, Interval } from 'tonal';

And then I could get the intervals for a chord like this:

Chord.intervals("Maj7") // ["1P", "3M", "5P", "7M"]

Then I could take that array of intervals and get the notes starting from a specific tonic in a specific octave like this:

["1P", "3M", "5P", "7M"].map(transpose("F#3")) // ["F#3", "A#3", "C#4", "E#4"]

Which are the notes of an F#maj7 starting on the F# in the 3rd octave.

In v3 I import like this:

import { chord } from "@tonaljs/chord";

and I can get the intervals like this:

chord('Maj7').intervals // [ "1P", "3M", "5P", "7M" ]

But if I want to transpose those to give the same result as above I am not sure how to do that.

I have tried this:

import { transposeFrom } from "@tonaljs/note";

[ "1P", "3M", "5P", "7M" ].map(transposeFrom("F#3")) // ["", "", "", ""]

It just returns an array with 4 empty strings.

Is there a way to accomplish what I am trying to do in v3 of Tonal.

Thanks in advance.

danigb commented 5 years ago

Hi!

First of all, all kind of questions are welcomed 🤗

Then, I have to said that I'm on vacations, so I can't solve the issue until I'm back (look ma', no computer!)

Said that, the code you posted should work: it's the v3 way to do it. I'll take a look to the problem.

Meanwhile, maybe you can include the tonic in the name and query for the notes. Something like chord("f#7Maj7").notes

Hope it helps

danigb commented 5 years ago

Hi @vellebelle

I've fixed the problem in the new 3.2.2 version. Now you code: chord('Maj7').intervals.map(tranposeFrom('F#7')) should work properly.

Sorry for the inconvenience.

vellebelle commented 5 years ago

Thank you so much. Hope you had a good vacation :)