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

Strange results when using isQuantizedSequence() method #622

Open
mattebass opened this issue Mar 11, 2022 · 0 comments
Open

Strange results when using isQuantizedSequence() method #622

mattebass opened this issue Mar 11, 2022 · 0 comments

Comments

@mattebass
Copy link

Hi,
I'm actually using magenta.js in node and trying to parse some generated melodies.
In my code I need to know if the generated melody is quantised in order to pass to the model
When using:

mm.sequences.isQuantizedSequence(melody1)

let melody1 = {
    notes: [
      {pitch: 60, startTime: 0.0, endTime: 0.5},
      {pitch: 60, startTime: 0.5, endTime: 1.0},
      {pitch: 67, startTime: 1.0, endTime: 1.5},
      {pitch: 67, startTime: 1.5, endTime: 2.0},
      {pitch: 69, startTime: 2.0, endTime: 2.5},
      {pitch: 69, startTime: 2.5, endTime: 3.0},
      {pitch: 67, startTime: 3.0, endTime: 4.0},
      {pitch: 65, startTime: 4.0, endTime: 4.5},
      {pitch: 65, startTime: 4.5, endTime: 5.0},
      {pitch: 64, startTime: 5.0, endTime: 5.5},
      {pitch: 64, startTime: 5.5, endTime: 6.0},
      {pitch: 62, startTime: 6.0, endTime: 6.5},
      {pitch: 62, startTime: 6.5, endTime: 7.0},
      {pitch: 60, startTime: 7.0, endTime: 8.0},
    ],
    tempos: [{
      time: 0, 
      qpm: 120
    }],
    totalTime: 8
};


const melody2 = { 
    notes: [
        {pitch: 50, quantizedStartStep: 0, quantizedEndStep: 1},
        {pitch: 53, quantizedStartStep: 1, quantizedEndStep: 2},
        {pitch: 58, quantizedStartStep: 2, quantizedEndStep: 3},
        {pitch: 58, quantizedStartStep: 3, quantizedEndStep: 4},
        {pitch: 58, quantizedStartStep: 4, quantizedEndStep: 5},
        {pitch: 53, quantizedStartStep: 5, quantizedEndStep: 6},
        {pitch: 53, quantizedStartStep: 6, quantizedEndStep: 7},
        {pitch: 53, quantizedStartStep: 7, quantizedEndStep: 8},
        {pitch: 52, quantizedStartStep: 8, quantizedEndStep: 9},
        {pitch: 55, quantizedStartStep: 9, quantizedEndStep: 10},
        {pitch: 60, quantizedStartStep: 10, quantizedEndStep: 11},
        {pitch: 60, quantizedStartStep: 11, quantizedEndStep: 12},
        {pitch: 60, quantizedStartStep: 12, quantizedEndStep: 13},
        {pitch: 60, quantizedStartStep: 13, quantizedEndStep: 14},
        {pitch: 60, quantizedStartStep: 14, quantizedEndStep: 15},
        {pitch: 52, quantizedStartStep: 15, quantizedEndStep: 16},
        {pitch: 57, quantizedStartStep: 16, quantizedEndStep: 17},
        {pitch: 57, quantizedStartStep: 17, quantizedEndStep: 18},
        {pitch: 57, quantizedStartStep: 18, quantizedEndStep: 19},
        {pitch: 65, quantizedStartStep: 19, quantizedEndStep: 20},
        {pitch: 65, quantizedStartStep: 20, quantizedEndStep: 21},
        {pitch: 65, quantizedStartStep: 21, quantizedEndStep: 22},
        {pitch: 57, quantizedStartStep: 22, quantizedEndStep: 23},
        {pitch: 57, quantizedStartStep: 23, quantizedEndStep: 24},
        {pitch: 57, quantizedStartStep: 24, quantizedEndStep: 25},
        {pitch: 57, quantizedStartStep: 25, quantizedEndStep: 26},
        {pitch: 62, quantizedStartStep: 26, quantizedEndStep: 27},
        {pitch: 62, quantizedStartStep: 27, quantizedEndStep: 28},
        {pitch: 65, quantizedStartStep: 28, quantizedEndStep: 29},
        {pitch: 65, quantizedStartStep: 29, quantizedEndStep: 30},
        {pitch: 69, quantizedStartStep: 30, quantizedEndStep: 31},
        {pitch: 69, quantizedStartStep: 31, quantizedEndStep: 32}
        ],
    totalQuantizedSteps: 32,
    quantizationInfo: { stepsPerQuarter: 4 },
    tempos: [{time: 0, qpm: 120}]
};

the result is true if the melody is quantised as for melody2, but undefined if not as for melody1.
Is It a bug or I'm missing something?
Thanks

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

1 participant