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

Javascript version #1

Open
mpapec opened this issue Aug 2, 2017 · 8 comments
Open

Javascript version #1

mpapec opened this issue Aug 2, 2017 · 8 comments

Comments

@mpapec
Copy link

mpapec commented Aug 2, 2017

Hi,

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

@fizban99
Copy link
Owner

fizban99 commented Aug 3, 2017

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

@mpapec
Copy link
Author

mpapec commented Aug 3, 2017

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?

@fizban99
Copy link
Owner

fizban99 commented Aug 3, 2017

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)

@mpapec
Copy link
Author

mpapec commented Aug 4, 2017

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.

@mpapec
Copy link
Author

mpapec commented Aug 8, 2017

Is content of durationMap correct?

@fizban99
Copy link
Owner

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

@fizban99
Copy link
Owner

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

@fizban99
Copy link
Owner

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

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

2 participants