fizban99 / microbit_rttl

Excel file to convert rtttl melodies into microbit micropython tunes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Javascript version

mpapec opened this issue · comments

Hi,

I've used your code for js version.
At https://makecode.microbit.org/_9LphJJhvV7mz if you want to check/make improvements.

Nice! Good work.! Thanks for letting me know.

No problem, although I've noticed that some tunes are sounding strange so it might be buggy.

Can you paste translated versions of

Axel-F:d=4,o=5,b=125:g,8a#.,16g,16p,16g,8c6,8g,8f,g,8d.6,16g,16p,16g,8d#6,8d6,8a#,8g,8d6,8g6,16g,16f,16p,16f,8d,8a#,2g,p,16f6,8d6,8c6,8a#,g,8a#.,16g,16p,16g,8c6,8g,8f,g,8d.6,16g,16p,16g,8d#6,8d6,8a#,8g,8d6,8g6,16g,16f,16p,16f,8d,8a#,2g
missathing:d=4,o=5,b=125:2p,16a,16p,16a,16p,8a.,16p,a,16g,16p,2g,16p,p,8p,16g,16p,16g,16p,16g,8g.,16p,c6,16a#,16p,a,8g,f,g,8d,8f.,16p,16f,16p,16c,8c,16p,a,8g,16f,16p,8f,16p,16c,16p,g,f

so I can compare output from XLSM?

Your tempo does not seem right...

import music
music.set_tempo(ticks=8, bpm=125)
tune = ['G5:8', 'A#:6', 'G:2', 'R', 'G', 'C6:4', 'G5', 'F', 'G:8', 'D6:6',
'G5:2', 'R', 'G', 'D#6:4', 'D', 'A#5', 'G', 'D6', 'G', 'G5:2', 'F', 'R',
'F', 'D:4', 'A#', 'G:16', 'R:8', 'F6:2', 'D:4', 'C', 'A#5', 'G:8',
'A#:6', 'G:2', 'R', 'G', 'C6:4', 'G5', 'F', 'G:8', 'D6:6', 'G5:2', 'R',
'G', 'D#6:4', 'D', 'A#5', 'G', 'D6', 'G', 'G5:2', 'F', 'R', 'F', 'D:4',
'A#', 'G:16']
music.play(tune)

import music
music.set_tempo(ticks=8, bpm=125)
tune = ['R5:16', 'A:2', 'R', 'A', 'R', 'A:6', 'R:2', 'A:8', 'G:2', 'R', 'G:16',
'R:2', 'R:8', 'R:4', 'G:2', 'R', 'G', 'R', 'G', 'G:6', 'R:2', 'C6:8',
'A#5:2', 'R', 'A:8', 'G:4', 'F:8', 'G', 'D:4', 'F:6', 'R:2', 'F', 'R',
'C', 'C:4', 'R:2', 'A:8', 'G:4', 'F:2', 'R', 'F:4', 'R:2', 'C', 'R',
'G:8', 'F']
music.play(tune)

GetNoteDurationFromRTTTL("G", "4", "125") returns 16 and your outputs suggest it should be 8.

I can't see why it should be 8 as

    With durationMap
      .Add 1, "64"
      .Add 2, "32"
      .Add 4, "16"
      .Add 8, "8"
      .Add 16, "4"
      .Add 32, "2"
      .Add 64, "1"
    End With

suggest that 4 (second parameter to GetNoteDurationFromRTTTL()) maps to 16.

Is content of durationMap correct?

Sorry for my late answer... If it still useful, what the VBA code has is actually:

    With durationMap
      .Add 1, "32"
      .Add 2, "16"
      .Add 4, "8"
      .Add 8, "4"
      .Add 16, "2"
      .Add 32, "1"
    End With

And it seems that it also needs
music.setTempo(parseInt(lBPM) * 2)

Since you do not seem to take into account the bpm of the original rtttl

CircuitPlaygroundExpress version of your code as a custom block:
https://makecode.com/_41ze7iFv2ML9