Skip to content

Quick and dirty song parser to play obligatory Super Mario Bros. theme song.#1

Merged
fulldecent merged 3 commits intofulldecent:masterfrom
lberezy:master
Nov 12, 2017
Merged

Quick and dirty song parser to play obligatory Super Mario Bros. theme song.#1
fulldecent merged 3 commits intofulldecent:masterfrom
lberezy:master

Conversation

@lberezy
Copy link
Copy Markdown
Contributor

@lberezy lberezy commented Mar 1, 2016

This works on my MacBook Air (Mid 2013).

I wrote this small song parser very quickly to get the theme song to Super Mario Bros. playing.
The song does not repeat as the file pointer is not wound back to the start. Unexpected data in the file will most definitely break the parser.

@rocketinventor
Copy link
Copy Markdown
Contributor

@lberezy It seems like it would be easy to add a quick and dirty if statement that checks for a token such as :end; or :repeat; and resets the file pointer. Do you think you could do that?

@fulldecent
Copy link
Copy Markdown
Owner

Is this a standard file format for the audio tune?

@lberezy
Copy link
Copy Markdown
Contributor Author

lberezy commented Mar 1, 2016

@rocketinventor: almost certainly that is possible, but read on because...
@fulldecent: Nope, I don't think this is a standard file format, but it was one of the first results in Google for "super mario theme frequencies". I just threw this together a short while before bed last night so it's exceptionally dirty.
Perhaps it might be possible to add an MML parser or even a much more complex MIDI parser.

Take a look at the example from the tinyMML parser, looks straight forward to implement.

@rocketinventor
Copy link
Copy Markdown
Contributor

@lberezy @fulldecent It seems excessive to add an MML parser or a MIDI player to the main program, at least at this point.
I like what @lberezy did because it has little overhead and makes it more modular so that it is possible to change the set of frequencies being transmitted easily without having to change or recompile the main program. Having a list of commands with a simple syntax is also great because the file could be systematically edited to transmit other types of data.
The only problem with the pull request in my opinion would be that it doesn't loop, so adding a loop statement would bring functional parity to it.

Having a separate program that parses MML or MIDI and spits out a list of frequencies in the format of the smb.song file might be a fun idea and could be implemented in any language without introducing bugs into the main program or making it bloated.

@lberezy
Copy link
Copy Markdown
Contributor Author

lberezy commented Mar 1, 2016

I completely agree. The tinyMML parser is the smallest fully fledged song
solution I could find and I was already thinking it was far too big. Does
anyone know a more common and simple song description format?

And yes, I'll get around to adding in a loop.

On Wed, 2 Mar 2016, 9:45 AM Elliot Gerchak notifications@github.com wrote:

@lberezy https://github.com/lberezy @fulldecent
https://github.com/fulldecent It seems excessive to add an MML parser
or a MIDI player to the main program, at least at this point.
I like what @lberezy https://github.com/lberezy did because it has
little overhead and makes it more modular so that it is possible to change
the set of frequencies being transmitted easily without having to change or
recompile the main program. Having a list of commands with a simple syntax
is also great because the file could be systematically edited to transmit
other types of data.
The only problem with the pull request in my opinion would be that it
doesn't loop, so adding a loop statement would bring functional parity to
it.

Having a separate program that parses MML or MIDI and spits out a list of
frequencies in the format of the smb.song file might be a fun idea and
could be implemented in any language without introducing bugs into the main
program or making it bloated.


Reply to this email directly or view it on GitHub
#1 (comment)
.

@lberezy
Copy link
Copy Markdown
Contributor Author

lberezy commented Mar 1, 2016

It now repeats on the ":end" token in the song.

@rocketinventor
Copy link
Copy Markdown
Contributor

Awesome! I hope it gets merged!

somini added a commit to somini/system-bus-radio that referenced this pull request Mar 1, 2016
somini added a commit to somini/system-bus-radio that referenced this pull request Mar 1, 2016
@ericoporto
Copy link
Copy Markdown

ericoporto commented Mar 4, 2016

I kind of have a json descriptor idea here that I made for a game engine based on that old music tracker software that I can't recall the name right now. It's basically an array of channels, that are an array of beats each that's a array that includes first the note, than the instrument, and then the volume. I ditched effects and have a synthesizer one folder up. It's missing a bpm field right now.

rocketinventor referenced this pull request in rocketinventor/system-bus-radio Mar 8, 2016
I copied the file from pull request #1.
rocketinventor referenced this pull request in rocketinventor/system-bus-radio Mar 8, 2016
Based on pull request #1...
The list of frequencies to be played has been moved from the JS to a textbox in the HTML.
Editing the content of the box will change what gets played.
The format also is more human human readable and consistent with the songfile from #1.
If you copy and paste the smb.song file, it should work.
@rocketinventor
Copy link
Copy Markdown
Contributor

@lberezy As you can probably see, I have ported your code, as well as the smb.song file over into the Vanilla JS version.
I'm looking for testers (It should work the same as #20 but just want to make sure).

@fulldecent fulldecent mentioned this pull request Oct 4, 2016
6 tasks
@fulldecent
Copy link
Copy Markdown
Owner

Blocker #28

@rocketinventor
Copy link
Copy Markdown
Contributor

@lberezy Thank you for your contributions! I'd love to see it added to the main branch but, that is currently not possible (because of the conflicts). Do you have any plans on updating the source for the new parser?

@fulldecent
Copy link
Copy Markdown
Owner

Here is conversion to .song format:

660 100
150 0
660 100
300 0
660 100
300 0
510 100
100 0
660 100
300 0
770 100
550 0
380 100
575 0
510 100
450 0
380 100
400 0
320 100
500 0
440 100
300 0
480 80
330 0
450 100
150 0
430 100
300 0
380 100
200 0
660 80
200 0
760 50
150 0
860 100
300 0
700 80
150 0
760 50
350 0
660 80
300 0
520 80
150 0
580 80
150 0
480 80
500 0
510 100
450 0
380 100
400 0
320 100
500 0
440 100
300 0
480 80
330 0
450 100
150 0
430 100
300 0
380 100
200 0
660 80
200 0
760 50
150 0
860 100
300 0
700 80
150 0
760 50
350 0
660 80
300 0
520 80
150 0
580 80
150 0
480 80
500 0
500 100
300 0
760 100
100 0
720 100
150 0
680 100
150 0
620 150
300 0
650 150
300 0
380 100
150 0
430 100
150 0
500 100
300 0
430 100
150 0
500 100
100 0
570 100
220 0
500 100
300 0
760 100
100 0
720 100
150 0
680 100
150 0
620 150
300 0
650 200
300 0
1020 80
300 0
1020 80
150 0
1020 80
300 0
380 100
300 0
500 100
300 0
760 100
100 0
720 100
150 0
680 100
150 0
620 150
300 0
650 150
300 0
380 100
150 0
430 100
150 0
500 100
300 0
430 100
150 0
500 100
100 0
570 100
420 0
585 100
450 0
550 100
420 0
500 100
360 0
380 100
300 0
500 100
300 0
500 100
150 0
500 100
300 0
500 100
300 0
760 100
100 0
720 100
150 0
680 100
150 0
620 150
300 0
650 150
300 0
380 100
150 0
430 100
150 0
500 100
300 0
430 100
150 0
500 100
100 0
570 100
220 0
500 100
300 0
760 100
100 0
720 100
150 0
680 100
150 0
620 150
300 0
650 200
300 0
1020 80
300 0
1020 80
150 0
1020 80
300 0
380 100
300 0
500 100
300 0
760 100
100 0
720 100
150 0
680 100
150 0
620 150
300 0
650 150
300 0
380 100
150 0
430 100
150 0
500 100
300 0
430 100
150 0
500 100
100 0
570 100
420 0
585 100
450 0
550 100
420 0
500 100
360 0
380 100
300 0
500 100
300 0
500 100
150 0
500 100
300 0
500 60
150 0
500 80
300 0
500 60
350 0
500 80
150 0
580 80
350 0
660 80
150 0
500 80
300 0
430 80
150 0
380 80
600 0
500 60
150 0
500 80
300 0
500 60
350 0
500 80
150 0
580 80
150 0
660 80
550 0
870 80
325 0
760 80
600 0
500 60
150 0
500 80
300 0
500 60
350 0
500 80
150 0
580 80
350 0
660 80
150 0
500 80
300 0
430 80
150 0
380 80
600 0
660 100
150 0
660 100
300 0
660 100
300 0
510 100
100 0
660 100
300 0
770 100
550 0
380 100
575 0

@fulldecent fulldecent merged commit b4a1097 into fulldecent:master Nov 12, 2017
@fulldecent
Copy link
Copy Markdown
Owner

Sorry for the glacial pace here. And... it's merged! Thank you. Also updated to standardized tune format for #28.

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

Successfully merging this pull request may close these issues.

5 participants