Skip to content

lydian #5P pentatonic is recorded with an uppercase in dictionnary but tokenize of Scale.get transform the scale type in lowercase #482

@valentinMachado

Description

@valentinMachado

This line record in the dictionnary lydian #5P pentatonic is with an upppercase on the P
https://github.com/tonaljs/tonal/blob/5f41f55d73aaf8c48da9896a3c2fa03e7c67fa53/packages/scale-type/data.ts#L45C1-L45C47

But if I try something like Scale.get("C lydian #5P pentatonic") empty is returned this is due to this line:

const type = name.substring(tonic.name.length + 1).toLowerCase();

where the scale type is transform in lower case (also the case for minor #7M pentatonic)

Some code to demonstrate the bug:

const { Scale, ScaleType } = require("tonal");

const withUpperCase =
  ScaleType.all().filter(
    (scaleType) => scaleType.name === "lydian #5P pentatonic"
  ).length == 1;

console.log("lydian #5P pentatonic is found", withUpperCase);
console.log(ScaleType.get("lydian #5P pentatonic"));
console.log(
  "C lydian #5P pentatonic is empty",
  Scale.get("C lydian #5P pentatonic").empty
);

// lydian #5P pentatonic is found true
// {
//   empty: false,
//   name: 'lydian #5P pentatonic',
//   setNum: 2217,
//   chroma: '100010101001',
//   normalized: '100010101001',
//   intervals: [ '1P', '3M', '4A', '5A', '7M' ],
//   aliases: []
// }
// C lydian #5P pentatonic is empty true

I guess every scale type should be recorded in lower case, in that case, this function should transform name in lower case or at least console.warn something if that's not the case ?

export function add(

or tokenize should be modified.. I am beginner of tonal js so I am not sure how it should works but I can do a PR if needed :) let me know !

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