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

[BUG] rtttl and random placed note, octave and bpm variables #9

Open
Nume1977 opened this issue Dec 17, 2024 · 0 comments
Open

[BUG] rtttl and random placed note, octave and bpm variables #9

Nume1977 opened this issue Dec 17, 2024 · 0 comments

Comments

@Nume1977
Copy link

Nume1977 commented Dec 17, 2024

If the rtttl note, octave or bmp values are not in a specific order, the parseDefaultValues function cannot extract the values.

Funky Town:o=4,b=125,d=8: will not work

Funky Town:d=8,o=4,b=125: will work (the order is hardcoded because of the way the function was made)

I have corrected it, so it works with any order.

In melody_factory_rtttl.cpp :

void MelodyFactoryClass::parseDefaultValues(String values) {

  for (int i=0 ;i <= strlen(values.c_str())-1; i++)
  {
    if (values.charAt(i) == 'd') { 
      int x = i + 1;
      duration = parseDuration(values, x);
      if (duration == 0) { duration = defaultDuration; }
     }

    if (values.charAt(i) == 'o') { 
      int x = i + 1;
      octave = parseOctave(values, x);
      if (octave == 0) { octave = defaultOctave; }
    }

    if (values.charAt(i) == 'b') {
      int x = i + 1;
      beat = parseBeat(values, x);
      if (beat == 0) { beat = defaultBeat; }
    }

  }

  //Serial.println(duration);
  //Serial.println(octave);
  //Serial.println(beat);

 // ORIGINAL CODE BELOW

  // if (values.charAt(i) == 'd') { i++; }
  // duration = parseDuration(values, i);
  // if (duration == 0) { duration = defaultDuration; }

  // if (values.charAt(i) == 'o') { i++; }
  // octave = parseOctave(values, i);
  // if (octave == 0) { octave = defaultOctave; }

  // if (values.charAt(i) == 'b') {
  //   i++;
  //   beat = parseBeat(values, i);
  // }
  // Serial.println(beat);
  // if (beat == 0) { beat = defaultBeat; }
  //Serial.println(beat);
}

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