chrismaltby / gb-studio

A quick and easy to use drag and drop retro game creator for your favourite handheld video game system
https://www.gbstudio.dev
MIT License
8.45k stars 468 forks source link

[Request] Support VGM and GBS Music Format #44

Closed clsource closed 5 years ago

clsource commented 5 years ago

Hello I think this project is awesome. Here are some ideas.

Mod file format support is great but there are some tools better suited for the job like deflemask http://deflemask.com/ that export gbs format.

https://mmitch.github.io/gbsplay/ http://www.angelfire.com/nc/ugetab/ http://web.archive.org/web/20171128170657/ftp://ftp.modland.com/pub/documents/format_documentation/Gameboy%20Sound%20System%20(.gbs).txt

GBS2GB117.zip

VGM is also a good choice https://en.wikipedia.org/wiki/VGM_(file_format)

Here is a player for the gameboy

http://jiggawatt.org/badc0de/dmvgm-4.zip

dmvgm-4.zip

Additional References

https://vgmrips.net/forum/viewtopic.php?f=3&t=107 https://github.com/Sanqui/gbvgm https://github.com/io7m/jvgm https://github.com/kuma4649/mml2vgm https://github.com/dzidzitop/vgmtag

Finally supporting midi files may be possible using

https://sourceforge.net/projects/midi2mod/ or mid2vgm https://vgmrips.net/forum/viewtopic.php?t=1929

Thanks đź‘Ť

chrismaltby commented 5 years ago

Thanks, lots of useful information there! Do you know what the CPU overhead is for this by any chance? According to the docs GBTPlayer seems to be around 7%.

If anyone would like to have a go at implementing, these two files are probably a good place to start https://github.com/chrismaltby/gb-studio/blob/master/appData/src/gb/src/MusicManager.c https://github.com/chrismaltby/gb-studio/blob/master/src/lib/compiler/compileMusic.js

clsource commented 5 years ago

Another way of doing this is creating a converter from vgm to gbt that should be easier to do i think.

Reference http://www.smspower.org/Music/VGMFileFormat?from=Development.VGMFormat

Some Libs

In Python https://github.com/jimbo1qaz/vgmviz https://github.com/cdodd/vgmparse

In JS https://github.com/apollolux/vgm-js https://github.com/wothke/vgmplay-0.40.6

In C https://github.com/vgmrips/vgmplay

Sample VGM FIle

Kirby's Dream Land - 02 - Green Greens.vgm.zip

Mod2GBT Code https://github.com/AntonioND/gbt-player/blob/master/mod2gbt/mod2gbt.c

đź’Ż

clsource commented 5 years ago

It seems that the gbtplayer author https://github.com/AntonioND/gbt-player/issues/3 does not support other file formats than mod.

This mean that the player assembler code must be changed in order to support gbs or vgm formats.

@chrismaltby I believe this would be 7% in CPU as well because it should be done in assembler too.

clsource commented 5 years ago

I found some additional drivers that could be useful

https://github.com/DevEd2/DevSound

More resources https://github.com/gbdev/awesome-gbdev https://github.com/junebug12851/GameboyBoilerplateProj

ISSOtm commented 5 years ago

It's not because a program is in ASM that it's fast. For example, DevSound linked above, usually takes a handful of scanlines to updates, but upwards of 20 when starting notes on CH3.

clsource commented 5 years ago

@ISSOtm seems fair enough. I currently lack the needed expertise to implement something like this. Hope someone with more knowledge can tackle implementing GBS support. That would be awesome đź‘Ť

ISSOtm commented 5 years ago

GBS support doesn't mean anything; GBS files are simply rips of literal sound code (as in, assembly) and data, and are simply ran cut cut-down emulators. GBS is not a sound format, if anything it's a container for different sound formats.

clsource commented 5 years ago

@ISSOtm so GBS can not be used in creating a GB ROM?. What is the recommended way to include music in a game?

clsource commented 5 years ago

By the way I'm not saying to drop support to gbt file format. I just want to use different tools like deflemask and littlesounddj to create game music. Mod files are cool.

AntonioND commented 5 years ago

As I've said in https://github.com/AntonioND/gbt-player/issues/3, it is not trivial to add support to other formats. GBS is a completely different approach to playing music than MOD. MOD is like a music sheet, GBS is like a series of instructions ("put your finger in key 5, press, wait for 5 seconds, release").

GBT took the approach of pre-converting MOD files so that it would be easier to parse them by GB software, but it is still pretty much a MOD player.

chrismaltby commented 5 years ago

Hi Antonio, thanks for inputting on this. I think I maybe just need to do some better documentation for the music support and get a few more sample files together, as you say it’s non trivial to support other formats.

Thanks for the great library by the way and sorry if you’re getting too many issues in at the moment, wasn’t expecting anywhere near this level of response on the project.

clsource commented 5 years ago

I´m closing this until a better approach is feasible. Mod files are cool enough for now and yes a better documentation or at least a video tutorial should do the trick for people new to game boy homebrew.

cyberic99 commented 5 years ago

as you say it’s non trivial to support other formats.

.gbs should be easy to support, I think.

You just have to load the gbs data, then call the play routine at each vblank

Some very useful code can be found here:

https://github.com/DevEd2/Deflemask2GB

AntonioND commented 5 years ago

@chrismaltby no worries! I'm glad that my library is useful, I didn't expect it to be so popular despite how simple it is.

clsource commented 5 years ago

I found this video that may be helpful

https://www.youtube.com/watch?v=psCxZr9iDck&list=PLeEj4c2zF7PaFv5MPYhNAkBGrkx4iPGJo&index=5

https://www.youtube.com/watch?v=TaqofsspB8Q&list=PLeEj4c2zF7PaFv5MPYhNAkBGrkx4iPGJo&index=7

https://github.com/gingemonster/GamingMonstersGameBoySampleCode/tree/master/06_sound

Pigu-A commented 5 years ago

I would be glad to help you porting DevSound to this program. The engine has demo/game mode option that disable lots of time consuming features but still leaves core ones intact which could bring raster time down to 16 scanlines (~10.4% CPU usage). The only problem though is that there's currently no music tools for generating the bytecodes for this engine (besides my partially working Deflemask .dmf converter). And I'm currently busy with final exam and my other projects so at least just take this into a consideration for now in case you wanted to write your own music editor in the app.

DevSound is way way more advanced than GBT. Just imagine what FamiTracker could do. In fact, I've been using this engine on all of my recent Gameboy music works.

cyberic99 commented 5 years ago

besides my partially working Deflemask .dmf converter

@Pigu-A is it available somewhere?

Pigu-A commented 5 years ago

Yeah. In fact, I just uploaded it for you. This is modified slightly from my actual one so it works with the main 2.4 branch.

cyberic99 commented 5 years ago

wow thanks @Pigu-A ! I need some time to try it, but that's cool!