Giter Club home page Giter Club logo

Comments (12)

danigb avatar danigb commented on August 15, 2024

Hi,

I'm working hard on next version of tonal (0.50.x series) that I hope will be release at the end of next week. It will include note-range by default. Meanwhile, the only option is to clone this repo and install the package manually:

npm install ../path-to-tonal/packages/note-range

Cheers,
Dani

from tonal.

devboell avatar devboell commented on August 15, 2024

Good to hear a new version is coming soon!
I think I have a workaround for now, but I have a question on how you will be handling enharmonics for chromatic scales. My use case is that I want to generate a noteMatrix representing a guitar fretboard, based on a tuning. So, roughly my code is this:

const defaultTuning = List(['e3', 'a3', 'd4', 'g4', 'b4', 'e5'])
const SCALE = '1 2b 2 3b 3 4 4# 5 6b 6 7b 7'.split(' ')

const noteMatrix = (tuning = defaultTuning) => {
  const matrix = []
  for (const note of tuning) {
    const string = []
    string.push(tonal.scale(SCALE, note))
    string.push(tonal.transpose(note, 'P8'))
    matrix.push(List(string));
  }
  return List(matrix)
}

This results f.i. in that a raised A3 on the sixth string will be A#3, but on the fifth string Bb3, because for each string the scale method uses a different tonic. But when I render the fretboard I want them both to display "A#3 / Bb3" (and this for all 'simple' enharmonics)
I will write a formatting method to handle this, but I am curious for your thoughts on this.

thanks a lot,
Rob

from tonal.

danigb avatar danigb commented on August 15, 2024

Hi Rob, this is an interesting use case. Currently I'm outside for three days, but I will think about it, and propose some solutions as soon I'm back. ๐Ÿ‘

El 30/04/2016, a las 09:35, devboell [email protected] escribiรณ:

Good to hear a new version is coming soon!
I think I have a workaround for now, but I have a question on how you will be handling enharmonics for chromatic scales. My use case is that I want to generate a noteMatrix representing a guitar fretboard, based on a tuning. So, roughly my code is this:

const defaultTuning = List(['e3', 'a3', 'd4', 'g4', 'b4', 'e5'])
const SCALE = '1 2b 2 3b 3 4 4# 5 6b 6 7b 7'.split(' ')

const noteMatrix = (tuning = defaultTuning) => {
const matrix = []
for (const note of tuning) {
const string = []
string.push(tonal.scale(SCALE, note))
string.push(tonal.transpose(note, 'P8'))
matrix.push(List(string));
}
return List(matrix)
}
This results f.i. in that a raised A3 on the sixth string will be A#3, but on the fifth string Bb3, because for each string the scale method uses a different tonic. But when I render the fretboard I want them both to display "A#3 / Bb3" (and this for all 'simple' enharmonics)
I will write a formatting method to handle this, but I am curious for your thoughts on this.

thanks a lot,
Rob

โ€”
You are receiving this because you commented.
Reply to this email directly or view it on GitHub

from tonal.

danigb avatar danigb commented on August 15, 2024

Hi Rob,

I'm back. I assume that you want to display the same scale over the fretboard. The problem with your example is that you are creating a different scale for each string (the same intervals, but with different tonic: different scale). What you need, in fact, is note-range. With note-range you can specify an scale and a first and last note and you will get that scale between that notes. The idea is to apply same scale to different note ranges. If you find useful, I don't mind to implement a tonal-fretboard module that help with that tasks.

from tonal.

devboell avatar devboell commented on August 15, 2024

Hi Dani,

Thanks for coming back to this. I agree using note-range would be the cleanest solution, so I'll just wait until you are ready with the next release. I don't think a special tonal-fretboard module is necessary, although I am unclear if the current version of note-range already supports the behaviour you describe (on the current master-branch I see range(scale, tonic, length).

I think I would need something like this:
range(scale, tonic, startnote, endnote)
or:
range(scale, tonic, startnote, length)

with either of these methods my use case would be adequately covered.

Cheers,
Rob

ps: It seems some of the examples in note-range aren't correct. I couldn't understand these two:

range('1 2 3 4 5 6 7', 'A2', 5) // => ['A2', 'C#3', 'E3', 'A3', 'C#4']
range('1 3 5', 'A2', -5) // => ['A2', 'E3', 'C#3', 'A1', 'E0']

from tonal.

danigb avatar danigb commented on August 15, 2024

Hi Rob,

The next iteration of tonal is being developed in the 0.50.x branch. Currently the scaleRange function is implemented at the bottom of: https://github.com/danigb/tonal/blob/tonal-0.50.x/packages/tonal-scales/lib/index.js (but I'm not sure if this is going to be the definitive place). The test are here: https://github.com/danigb/tonal/blob/tonal-0.50.x/packages/tonal-scales/test/scale-range-test.js

As you can see the signaure is what you expect:

scaleRange(scale|scaleName, startnote, endnote)

Thanks for pointing the problems with note-range module. I re-implemented the range related functions from scratch and I hope they are solved. Anyway I will look carefully to them.

Cheers,
Dani

from tonal.

devboell avatar devboell commented on August 15, 2024

Aha, that looks very good!

Thanks a lot Dani, and good luck with the release!

from tonal.

danigb avatar danigb commented on August 15, 2024

Thanks Rob. Latest update: range related methods finally has its own module (again): https://github.com/danigb/tonal/tree/tonal-0.50.x/packages/tonal-ranges

You can read the API here: https://github.com/danigb/tonal/blob/tonal-0.50.x/packages/tonal-ranges/API.md

from tonal.

devboell avatar devboell commented on August 15, 2024

cool, I also noticed the chromatic(...) method, which is very handy. I cloned the 0.50 branch on my machine, and tried to play with it, but I ran into some installation problems. This could well be because I am not installing correctly, or just because the branch-repo is in flux at the moment.
So, I still have a couple of questions, but since you're working on the release, I'm not sure if this the right time to raise them.

from tonal.

danigb avatar danigb commented on August 15, 2024

Great! This is the perfect time to raise them. Cheers, Dani

from tonal.

devboell avatar devboell commented on August 15, 2024

ok, then first about the installation, I opened a separate issue, please have look.

from tonal.

danigb avatar danigb commented on August 15, 2024

Hi again,

The first of 0.50.x series is released with tonal-range included and enhanced. As you can test, you can pass several notes to create comples ranges: tonal.range('C2 C4 E3') => ['C2' ... 'C4' ... 'E3']

I'm closing this issue but please reopen if you have any problem or question.

from tonal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.