Topic: Seeking free resources for use in simple open-source game

Hello folks,

First time poster, probably showing dreadful etiquette, but hoping someone will choose to help me anyway ;-)

I'm a programmer with no musical talent and currently working on a FREE and open-source simple little Tron light-cycle game for the PicoMite VGA and Colour Maximite 2.

It's nothing very special but it's keeping me out of trouble:

    https://youtu.be/Q9_FxvCC3v0

Its current music track is hopefully just temporary, it was composed for me by a friend over 20 years ago and I've already used it in something else, and in any case am hoping for something a little more thematic.

It's a simple 1-channel track played from MMBasic, the (incomplete) extract below will probably give some of you the idea

Dim MUSIC%(68)
Dim music_flag% = 1
Dim music_ptr% = Peek(VarAddr MUSIC%()) + 4

' Music and sound effects are played on SetTick interrupts.
SetTick 250, play_music, 1

' Run forever
Do : Loop

' Called from interrupt to play next note of music.
Sub play_music()
  If music_flag% Then
    Local note% = Peek(Byte music_ptr%)
    If note% = &hFF Then
      music_ptr% = Peek(VarAddr MUSIC%()) + 4
      note% = Peek(Byte music_ptr%)
    EndIf
    Play Sound 1, B, s, 440 * 2 ^ ((note% - 2) / 12.0), 15
    Inc music_ptr%
  Else
    Play Sound 1, B, O
  EndIf
End Sub

' Start a new sound effect.
Sub start_soundfx(ptr%, wait_%)
  If Not soundfx_flag% Then Exit Sub

  ' Wait for current sound effect to end.
  If wait_% Then Do While Peek(Byte soundfx_ptr%) <> &hFF : Loop

  soundfx_ptr% = ptr%

  ' Wait for first note of new sound effect to play.
  Do While soundfx_ptr% = ptr% : Loop
End Sub

' Called from interrupt to play next note of current sound effect.
Sub play_soundfx()
  If soundfx_flag% Then
    Local note% = Peek(Byte soundfx_ptr%)
    If note% < &hFF Then
      Play Sound 2, B, s, 440 * 2 ^ ((note% - 2) / 12.0)
      Inc soundfx_ptr%
    Else
      Play Sound 2, B, O
    EndIf
  Else
    Play Sound 2, B, O
  EndIf
End Sub

music_data:

Data &h0900090500000220, &h0900090509000905, &h0900090509000905, &h0900090509000905
Data &h1818181509000905, &h181818151818181A, &h151618161818181A, &h1516181613111516
Data &h1818181513111516, &h181818151518151A, &h151618131818181A, &h0C0E0C1315131516
Data &h181818150704000C, &h181818151818181A, &h151618161818181A, &h1516181613111516
Data &h1818181513111516, &h181818151518151A, &h151618131818181A, &h091D051115131516
Data &h1515150E0509051D, &h1515150E15151516, &h1013151315151516, &h1013151310131513
Data &h1515150E00040013, &h1515150E15151516, &h1311101315151516, &h1615131615131115
Data &h1818181500000C18, &h181818151818181A, &h151618161818181A, &h1516181613111516
Data &h1818181513111516, &h181818151518151A, &h151618131818181A, &h0C0E0C1315131516
Data &h181818150704000C, &h181818151818181A, &h151618161818181A, &h1516181613111516
Data &h1818181513111516, &h181818151518151A, &h151618131818181A, &h091D051115131516
Data &h1515150E0509051D, &h1515150E15151516, &h1013151315151516, &h1013151310131513
Data &h1515150E00040013, &h1515150E15151516, &h1311101315151516, &h1615131615131115
Data &h1818181500000C18, &h181818151818181A, &h151618161818181A, &h1516181613111516
Data &h1818181513111516, &h181818151518151A, &h151618131818181A, &h0C0E0C1315131516
Data &h181818150704000C, &h181818151818181A, &h151618161818181A, &h1516181613111516
Data &h1818181513111516, &h181818151518151A, &h151618131818181A, &h091D051115131516
Data &hFFFFFFFF0509051D

I don't suppose anyone can point me at a source of similar existing music tracks that aren't going to require too much work to convert and aren't going to require more than a name-check in the game's credits as "payment" ?

Best wishes,

Tom

Re: Seeking free resources for use in simple open-source game

Hi Tom,

Sorting you out with some existing music tracks that are free to use with attribution wouldn't be too difficult I guess. It's the "not too much work to convert" part that has me slightly worried.

Do you have any experience with Python or Rust? If so, you could build yourself an XM converter using either Shiru's Python-based xmlib or my slightly wonky Rust-based xmkit. Once you have that, you might even be able to convince someone on here to write some music for you.

The in-game music you have now doesn't sound like 1-bit music though? Note this forum is about 1-bit music, not 1-channel music. Though Shiru has some music that's both 1-bit and 1-channel - but that wouldn't necessary be that easy to convert.

3 (edited by thwill 2022-06-05 23:22:05)

Re: Seeking free resources for use in simple open-source game

Many thanks for the positive welcome @utz, and thanks for not just dismissing me as a freeloader, which of course in a manner of speaking I am ;-)

utz wrote:

It's the "not too much work to convert" part that has me slightly worried.

OK. The routine I posted:

  • only plays notes from the standard "western" music scale (which probably has a fancy name of which I am unaware) each encoded as a single byte.

  • plays all notes for the period between (software) interrupts, 0.25s, though because there is no pause between notes playing a single note for multiples of that length is possible.

  • plays all notes with the same volume.

  • doesn't explicitly have any concept of a "rest", though that would be easy enough to add

  • is simple enough to decode it doesn't consume much CPU time even when implemented in BASIC.

So in an ideal world I would find a music track simple enough to be adapted to those restrictions. However the world isn't necessarily ideal and I don't object to putting in some effort ;-)

utz wrote:

Do you have any experience with Python or Rust?

I'm mostly a Java and C/C++ programmer but I can get by in most other conventional programming languages if I've got an internet connection; Python shouldn't be a problem and I'm not (yet) scared of Rust.

utz wrote:

If so, you could build yourself an XM converter using either Shiru's Python-based xmlib or my slightly wonky Rust-based xmkit.

I obviously need to do some reading, and will try to do so before I post again. My initial thought is "Convert them into what ?", or is convert a euphamism for "play XM files" here ?

utz wrote:

... you might even be able to convince someone on here to write some music for you.

For my little game that does not seem like a worthwhile use of somebody's time and talent.

utz wrote:

The in-game music you have now doesn't sound like 1-bit music though? Note this forum is about 1-bit music, not 1-channel music. Though Shiru has some music that's both 1-bit and 1-channel - but that wouldn't necessary be that easy to convert.

I had a look at https://www.ludomusicology.org/2018/12/ … bit-music/ and since the PicoMite (specifically the Raspberry Pi Pico) has no DAC / specialised sound hardware then it might be considered 1-bit music(YMMV), I think it uses PWM to achieve audio. However I'm not working that close to the hardware so all this is hidden by the the MMBasic PLAY SOUND command which can output sine, square, triangle or rising sawtooth waves with 4 different waves on each of the left and right channels - the code I presented used a single sine wave going to both L&R channels. Note that the MMBasic firmware can actually play .WAV files (and on the Colour Maximite 2 only, .MOD files), but that rather feels like cheating.

I'm really just looking for something 80's videogame appropriate and at first blush this seemed like an approachable community who if they couldn't help me directly would be able to signpost the way.

Best wishes,

Tom

P.S.

I realised the code I posted was missing an important routine to populate the MUSIC%() array:

Sub read_music()
  Local i%
  Restore music_data
  For i% = 0 To Bound(MUSIC%(), 1)
    Read MUSIC%(i%)
  Next
End Sub

Re: Seeking free resources for use in simple open-source game

thwill wrote:

doesn't explicitly have any concept of a "rest", though that would be easy enough to add

Rest is an extremely useful feature, definitely worth adding.

thwill wrote:
utz wrote:

If so, you could build yourself an XM converter using either Shiru's Python-based xmlib or my slightly wonky Rust-based xmkit.

I obviously need to do some reading, and will try to do so before I post again. My initial thought is "Convert them into what ?", or is convert a euphamism for "play XM files" here ?

The converter should take an XM file as input and produce the required data statements for your music player. For 1-bit players, we usually use specially crafted XM templates that attempt to give a rough approximation of the final (converted) result, but in your case I think just some generic XM file with a single sine-wave instrument would be fine.

See this 1-bit engine package for an example of such a converter. Feel free to nick the xmkit library - it's pretty bad code, but it's C++.

thwill wrote:
utz wrote:

... you might even be able to convince someone on here to write some music for you.

For my little game that does not seem like a worthwhile use of somebody's time and talent.

The problem is that I'm not sure any of us have any ready made music laying around that fits the constraints of your player. You could, of course, grab some random XM file and convert that, but you'll find that more often than not musicians pack multiple elements of the music in the same channel, so taking a single channel and converting that to your player wouldn't make all that much sense.

A reasonably low-effort solution could be to find a MIDI of, say, the Tron movie theme, import it in an XM editor, edit it a bit to squeeze the main melody into one channel, and finally convert that to data statements for your player.

5 (edited by thwill 2022-06-06 13:54:44)

Re: Seeking free resources for use in simple open-source game

Hi @utz,

Thanks for taking the time to humour me. I'm going to go away and have a play but I have a suspicion that getting my head around this may require rather more time than I currently have available. For my immediate need I suspect I'll end up having to find a (very) simple copyright expired piano score to translate directly to my player - a piece of Ragtime perhaps big_smile big_smile big_smile.

Best wishes,

Tom

Re: Seeking free resources for use in simple open-source game

The whole thing about XM format is that it is just a convenient enough container that is easy to parse and convert into any custom format with strict channel management, and it allows to approximate the resulting sound while composing to some extent. So it is a easy way to set up a rudimentary but working tool chain to compose music for a custom sound system before taking a long mile of making custom trackers and stuff like that. Other than that, original purpose of the XM format is irrelevant here, i.e. it is not about playing actual XM files made to be played with regular XM players.

The same could be done with MIDI, but it is just way less convenient. The MIDI format is more difficult to parse, it does not feature a pattern format (which is the go to memory saving technique), the channel management is not strict, as each MIDI channel is polyphonic, and it takes more effort to make the composing tool to produce some sound that would be similar to the end result, to hear the approximation of the end result before finishing the song.

The sound approximation is important for chiptune musicians, as they rely on the tiniest details of their music arrangements to make it sound as impressive as possible within given limitations. Something as basic as a single channel rendition of Ragtime does not really need this.

You task in general looks much like something that creators of a simplistic Arduino sound routine would do - they're usually making a converter from a single voice MIDI into their custom sound format. So maybe google for articles on this, and you may find some converter code that would be relatively easy to adapt for your purpose.

website - 1bit music - other music - youtube - bandcamp - patreon - twitter (latest news there)