Giter Club home page Giter Club logo

hugedriver's Introduction

hUGEDriver

This is the repository for hUGEDriver, the music driver for the Game Boy which plays music created in hUGETracker.

If you want help using the tracker, driver, or just want to chat, join the hUGETracker Discord server!

Quick start (RGBDS)

  1. Export your song in "RGBDS .asm" format in hUGETracker.
  2. Choose a song descriptor name. This is what you will refer to the song as in your code. It must be a valid RGBDS symbol.
  3. Place the exported .asm file in your RGBDS project.
  4. Load hl with your song descriptor name, and call hUGE_init
  5. In your game's main loop or in a VBlank interrupt, call hUGE_dosound
  6. When assembling your game, be sure to specify your music file and hUGEDriver.asm in your call to rgbasm/rgblink!

Be sure to enable sound playback before you start!

ld a, $80
ld [rAUDENA], a
ld a, $FF
ld [rAUDTERM], a
ld a, $77
ld [rAUDVOL], a

See the rgbds_example directory for a working example!

Quick start (GBDK)

  1. Export your song in "GBDK .c" format in hUGETracker.
  2. Choose a song descriptor name. This is what you will refer to the song as in your code. It must be a valid C variable name.
  3. Place the exported .C file in your GBDK project.
  4. #include "hUGEDriver.h" in your game's main file
  5. Define extern const hUGESong_t your_song_descriptor_here in your game's main file
  6. Call hUGE_init(&your_song_descriptor_here) in your game's main file
  7. In your game's main loop or in a VBlank interrupt, call hUGE_dosound
  8. When compiling your game, be sure to specify your music file and hUGEDriver.o in your call to lcc!

Be sure to enable sound playback before you start!

NR52_REG = 0x80;
NR51_REG = 0xFF;
NR50_REG = 0x77;

See gbdk_example/src/gbdk_player_example.c for a working example!

Usage

This driver is suitable for use in homebrew games. hUGETracker exports data representing the various components of a song, as well as a song descriptor which is a small block of pointers that tell the driver how to initialize and play a song.

hUGETracker can export the data and song descriptor as a .asm or .c for use in RGBDS or GBDK based projects, respectively. Playing a song is as simple as calling hUGE_init with a pointer to your song descriptor, and then calling hUGE_dosound at a regular interval (usually on VBlank, the timer interrupt, or simply in your game's main loop)

In assembly:

ld hl, SONG_DESCRIPTOR
call hUGE_init

;; Repeatedly
call hUGE_dosound

In C:

extern const hUGESong_t song;

// In your initializtion code
__critical {
    hUGE_init(&song);
    add_VBL(hUGE_dosound);
}

Check out player.asm for a full fledged example of how to use the driver in an RGBDS project, and gbdk_example/gbdk_player_example.c for usage with GBDK C likewise.

hUGE_mute_channel

Caution: As an optimization, hUGEDriver avoids loading the same wave present in wave RAM; when "muting" CH3 and loading your own wave, make sure to set hUGE_current_wave to hUGE_NO_WAVE (a dummy value) to force a refresh.

License

hUGETracker and hUGEDriver are dedicated to the public domain.

hugedriver's People

Contributors

eievui5 avatar issotm avatar quinnyo avatar superdisk avatar untoxa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

hugedriver's Issues

Remove "generalized" stuff

Initially when designing this, I imagined that any given pattern could be played back by any type of channel (square/wave/noise). Since patterns mostly specify instrument numbers directly, and a given instrument can only be used by one type of channel, there are a few spots in the code that are essentially worthless, as the editor will know at compile-time exactly what pattern will be played by what channel and can specialize the effect command to be tailored to that channel immediately instead of during runtime which costs precious cycles.

_quantize_channel4_note and set_chn3_vol come to mind. However! if patterns contain only note values/effects and no specific instrument, they could be used by any channel and therefore this code would actually come in handy.

Honestly I think this is probably fine to leave in, but it's worth a think.

Support for RGB9, revision 7

rgb2sdas.exe reports:

ERROR: Unsupported object file version! This version of rgb2sdas supports RGB9, revision 6 files. The provided file is RGB9, revision 7.

Issue with Note Delay

Seems like hD has an issue with Note Delay (7xx) not working correctly.

Attached find an example which used Note Delay (701, 702, 703) at the end of the 1st order:
TR_Note-Delay-test-01.zip

Here is the result with a GBS using hD

test-hT.mp4

And here is a result with a GBS using fortISSimO (which renders the 7xx commands correctly imho):

test-fO.mp4

Videos where done with https://github.com/nununoisy/gb-presenter-rs which uses Sameboy for Audio rendering.

GBA support

Would it be too difficult to allow the Game Boy Advance to play hUGETracker music?

GBT Player already allows it, so it should be possible at least.

rgb2sdas Conflicting sdcc options

When build the GBDK 4.1.0 example program I got the following error:

#Build the rom!
../../gbdk/bin/lcc -I../include -o output.gb gbdk_player_example.c hUGEDriver.obj.o sample_song.c
gbdk_player_example.c:
sample_song.c:
?ASlink-Warning-Conflicting sdcc options:
   "-msm83" in module "gbdk_player_example" and
   "-mgbz80" in module "hUGEDriver_obj".
make: *** [Makefile:10 : all] Erreur 1

This can be fix by changing the lien 593 of rgb2sdas.pas from

Writeln(F, 'O -mgbz80'); to Writeln(F, 'O -msm83');

Error with add_VBL in gbdk_player_example.c

With GDBK 4.1.0 there is an error with add_VBL(hUGE_dosound);

gbdk_player_example.c:
gbdk_player_example.c:25: error 78: incompatible types
from type 'void function ( ) __sdcccall(0) fixed'
  to type 'void function ( ) code* fixed'

The example program builds and works when calling hUGE_dosound(); in loop, before wait_vbl_done();, although this is less cool

Set whether to loop; and get whether it's finished

Hi,

Thank you very much for making this great project! It's a really nice music driver for my favorite handheld console.

I wonder, is there any plan to support a loop flag to indicate whether to loop the sound, and is it possible to determine whether a sound is finished?

Thanks for your time!

Swing mode

You can implement a sort of swing rhythm in a song by using effect $Fxx and alternating between 2 tempos. We could probably build this in so it alternates between 2 (or even more) tick speeds automatically without hogging an effect channel doing it manually.

Adding waveform switching to channel 3

Right now, _AUD3WAVERAM is loaded with a constant value and isn't updated when the instrument changes.

We only want to write to wave ram when the instrument changes on tick zero, so this probably needs an extra variable to track the old waveform address (not instrument number, as instruments can have the same waveform!)

SGB Support?

Would it be too difficult to add in support for SGB-enhanced music like in Hercules and Animaniacs into HUGEDriver?

It's never been done before in homebrew, so maybe it is very difficult.

music credit

I used the sample_song.c found here without knowing the music name or the author so I couldn't give proper credits.

issue : give the name and author somewhere on this github.

Support a music bank

Carillon Player allows to run from a special bank with a fixed jump table that can be used to call it:

  • Player_Initialize at $4000
  • Player_MusicStart at $4003
  • Player_MusicStop at $4006
  • Player_SongSelect at $400c
  • Player_MusicUpdate at $4100

Being compatible with that would have two benefits:

  • Roms that use Carillon Player could easily switch to hUGEDriver
  • It could become an alternative solution for combining it with C functions without the need to translate the assembly

Starting a song in an arbitrary position.

In my game, I have one music for the stage and one for the pause menu.
I just reload the corresponding music on (un)pause.

I want to restart the stage music where it was on pause, but the current music position is lost when loading another song. So how can I do that?

Two things:

  1. I see there is no hUGE_Get_position or something similiar, but I suppose you can calculate that, but how?

also, is it possible to implement a hUGE_get_position()?

  1. I see there is a hUGE_set_position(unsigned char pattern); in the header, but how to use that? what pattern refers to?

Thanks!

Implement compression for patterns

As it stands, the contents of patterns can be fairly repetitive and not benefit from any sort of compression.

There are a couple solutions I've been thinking about:

  • Remove the restriction that patterns need to be 64 rows, and let patterns be any size, with some sort of terminator at the end to signify when it's over. This would allow musicians to write short phrases, and repeat them with only 2 bytes in the order table. Basslines and arps would benefit greatly from this sort of thing, and it's how AHX and Klystrack do it, I think. We could even just do pattern recognition/repetition logic in the tracker code itself so the user doesn't have to think about song size and can just focus on using it like a MOD tracker (4x64 patterns with lots of repetition)

  • Leave the 64 row restriction in place and simply do pattern repetition recognition in the tracker code, then implement "loop points," similar to ProTracker's E6x command. There's a lot of unused note constant values, since only 71 are used and there's a range up to 255.

I'm partial to the first option since I don't really like the idea of having 2 "methods" of breaking up music (patterns/loop areas), and the second option would require some more logic to handle looping in each channel, whereas the first option fits pretty nicely in with the current structure of the code.

To be honest, this can probably be put off until after the first release or whatever since what currently exists is (afaik) better size-wise than everything out there already.

Multiple feature requests

  • Add a way to stop playing and reset track pointer back to beginning
  • Add a way to pause music but continue on next time it's resumed
  • Add a way to resume paused music
  • Add a way to set whether the music loops
    If any of these are possible already, please let me know!

Support for RGB9, revision 8

ERROR: Unsupported object file version! This version of rgb2sdas supports RGB9, revision 6 & 7 files. The provided file is RGB9, revision 8.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.