#1294 - joet - Thu Jan 16, 2003 2:19 pm
Hi - I've got to the point in a project where I want to add in some sound and music. It's a conversion of an old BBC game, so just for kicks I want to implement the music using simple playing of notes - ie. not a digital sample.
Now I know next to nothing about this kind of thing, beyond mucking about with BBC sound envelopes years ago.
In my naivity I figure that I can just store a simple sequence of notes and then play them back at the appropriate time - so my question is, would it be sufficient to tack on a bit of note playing stuff during my game tick function (ie. during vsync), or is it more sensible to handle this on a timer interrupt?
Also, how could I play some music which requires 2 simultaneous notes to be played (using different envelopes), plus some game sound.
#1297 - Splam - Thu Jan 16, 2003 3:14 pm
Just out of interest which beeb game is it? I started coding on the beeb maaaany years ago :)
As for playing sounds, if you only want beeb style sounds then you're probably best using the sound 1,2,3 and 4 hardware. These don't play samples but 2 have envelope funtionality on rectangular waveforms, one is a "noise channel" (like beeb had) and the last can play small (64 entry) samples (predefined waveforms really).
All pretty easy to use but obviously you need to write a "player" of some sort to feed the notes (frequencies) to the hardware. Lots faster than using Directsound anyway and therefore yeah, run it from vsync would be fine as unless you want to play hundreds of notes per second the 60hz refresh is plenty to have a simple tune and even create your own effects by altering the envelopes in realtime.
#1298 - joet - Thu Jan 16, 2003 3:26 pm
Cool - that's what I was hoping :)
I'm writing (again) a version of Repton 3 (+ all the levels from the subsequent releases).
It's pretty much all there now, just finishing it off - for some reason I never usually get to the point where I add sound in (I'm sure professionals audio programmers would seethe if they heard me refer to the sound bit as 'finishing off' :).
Unfortunately, due to the recent interest in Repton, owing to the Masubi deal and rumours of a soon-to-be-published GBA version, I'm not sure if I'll release it.
Might do with one level or something. It's a shame as it's pretty cool, if I do say so myself.
#1316 - tepples - Thu Jan 16, 2003 6:18 pm
joet wrote: |
Now I know next to nothing about this kind of thing, beyond mucking about with BBC sound envelopes years ago. |
The GB can't do amplitude envelopes. Unlike on the NES, writing to a GB tone generator's volume register while a note is playing doesn't change the volume of the playing note but rather sets the starting volume of the next note. Starting a new note just to change the volume will produce a click.
Quote: |
would it be sufficient to tack on a bit of note playing stuff during my game tick function (ie. during vsync) |
That's what most NES games do.
Quote: |
Also, how could I play some music which requires 2 simultaneous notes to be played (using different envelopes), plus some game sound. |
NES and GB games have a flag in RAM for each tone generator stating that it's in use by a sound effect and that the music code shouldn't write notes to it.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.