Hello,
I am currently working on a library for Axe that will allow you to use music alongside your games. I call it Axe Clef, and it will come with a full fledged music editor to make it easier to make your music run inside your games. It should allow you to continue to have a game while the music is running, and will only work at 15MHz.
Discuss.
SirCmpwn wrote:
Hello,
I am currently working on a library for Axe that will allow you to use music alongside your games. I call it Axe Clef, and it will come with a full fledged music editor to make it easier to make your music run inside your games. It should allow you to continue to have a game while the music is running, and will only work at 15MHz.
Discuss.
This sounds like a pretty cool project. Needless to say, though, it's a big challenge, and maybe be bigger or smaller depending on how you decide to implement this. Are you thinking of doing something interrupt-based, or using a different method? If you're doing something interrupt-based, are you basing it off Calc84Maniac's work with his Project M? I look forward to more technical details.
Well, I was going to have the programs call an update method whenever it was convenient for them. It would play part of the music and return.
SirCmpwn wrote:
Well, I was going to have the programs call an update method whenever it was convenient for them. It would play part of the music and return.
Oh, so it's not really going to be simultaneous, then? Sad That's disappointing. That would mean that one can only move and update the screen while there is no music playing, correct? Although now that I think about it, this would still be useful for sound effects to punctuate the game; is that what you're thinking of?
I'm still hashing out the details, and I was thinking of perhaps having the user call it several times if need be, or perhaps forcing them into fast updates between music. It is intended for things like main menus and credits, with the occasional sound effects.
SirCmpwn wrote:
I'm still hashing out the details, and I was thinking of perhaps having the user call it several times if need be, or perhaps forcing them into fast updates between music. It is intended for things like main menus and credits, with the occasional sound effects.
That sounds excellent. Now, you're saying this is for use with Axe, so I can only assume that you're writing it in pure Assembly?
No, Axe includes the Freq( command to output sound.
SirCmpwn wrote:
No, Axe includes the Freq( command to output sound.
Oh, I didn't know that, that's pretty cool. I presume that allows you to specify a note and a duration? What if you want stereophonic or quadraphonic sound? What are you thinking of for the format, some setup that involves pre-defining a bunch of sounds, and then allowing something akin to PlaySound(1) or PlaySound(13), or have the program call something like PlaySound (A3@300ms, B3@200ms, C3@100ms)? (Of course, those are just to show the concepts that I'm thinking of)
Well, the Freq( command accepts sound in wavelength and length in microseconds. I was thinking of defining sound as hex, where the user could specify note length and value.
For chord type of sound, I have tried quickly switching between notes, which seems to work quite well. I will try this approach and see how it work out.
I'll probably be getting to adding interrupts soon, so you'll always have that as an option as well.

I don't know how chords actually work digitally. Would I be correct in saying that if you plotted the addition of the 2 or more waves that the "Zeros" of that function would be when the voltage in the port changes? That doesn't sound like it would capture enough the detail of the wave, but I'm not sure how else it could be converted to 2 bit sound...
quigibo wrote:
I'll probably be getting to adding interrupts soon, so you'll always have that as an option as well.

I don't know how chords actually work digitally. Would I be correct in saying that if you plotted the addition of the 2 or more waves that the "Zeros" of that function would be when the voltage in the port changes? That doesn't sound like it would capture enough the detail of the wave, but I'm not sure how else it could be converted to 2 bit sound...
Quig, in my experience two notes per channel, or 4 notes total, is about the most you can get without annoying distortion due to a lack of granularity. In an ideal world with fast processors, you could represent many more notes simultaneously, but we don't have the time resolution to change the port state fast enough for that.
After some study into the art of sound with Axe, I also have no idea how to implement this XD
I will not support multiple layers of sound (chords), but I can try to make one layer sound.
SirCmpwn wrote:
After some study into the art of sound with Axe, I also have no idea how to implement this XD
I will not support multiple layers of sound (chords), but I can try to make one layer sound.
Awww, sorry to hear it. You won't want to try implementing some inline ASM, you want to stick with Freq? I mean, you could alternate two Freq('s with very short periods in a tight loop, but there's no way the timing would work out, at least in thought-experiment terms. Smile
Alternating frequencies very fast just sounds like crap XD
If interrupts are implemented, then I can look into using calc84maniac's trick.
SirCmpwn wrote:
Alternating frequencies very fast just sounds like crap XD
If interrupts are implemented, then I can look into using calc84maniac's trick.
If you used some inline assembly, then it would work fine without an interrupt, but I presume you don't really have any interest in that?
I could use inline assembly, but I've never played with sound in assembly. Anyone have code that does that?
SirCmpwn wrote:
Alternating frequencies very fast just sounds like crap XD
If interrupts are implemented, then I can look into using calc84maniac's trick.
Yeah I experimented with this a while ago and I was disappointed by the result Sad. I hoped I could at least have some sort of NES style chords. You can have something like the Commodore 64, though.
SirCmpwn wrote:
I could use inline assembly, but I've never played with sound in assembly. Anyone have code that does that?
Absolutely! Do you want to take it from the MobileTunes 3 / QuadPlay source? This is a quadrophonic routine; if you'd prefer stereophonic, which would be easier and use half the space for sounds, we can design that too. Do you want that code?
Please please!
And well commented would be nice as well, so I can optimize it and possibly apply the solution in pure Axe.
SirCmpwn wrote:
Please please!
And well commented would be nice as well, so I can optimize it and possibly apply the solution in pure Axe.
Here it is; it's a fairly large chunk of code, so take a while to read it. This was originally written by Ben Ryves, with some minor modifications by me. The (bport) is of course the equate for the link port. I can provide you with the table of durations and frequencies for this as well, or you can just look at the mobileTunes readme. Smile


Code:
; Play the tone dur=bc, period = h,l,d,e (4 channel sound - h,l = left speaker, d,e = right speaker)
playTone:
   di
   xor a
   ld (toneMask1+1),a
   ld (toneMask2+1),a
   inc b
; INIT CHANNEL A

   ld a,h
   ld (toneAPitch+1),a
   or a
   jr z,isRestA
   ld a,1
   jr notRestA
isRestA:
   xor a
notRestA:
   ld (toneAChange+1),a

; INIT CHANNEL B

   ld a,l
   ld (toneBPitch+1),a
   or a
   jr z,isRestB
   ld a,1
   jr notRestB
isRestB:
   xor a
notRestB:
   ld (toneBChange+1),a


; INIT CHANNEL C

   ld a,d
   ld (toneCPitch+1),a
   or a
   jr z,isRestC
   ld a,2
   jr notRestC
isRestC:
   xor a
notRestC:
   ld (toneCChange+1),a

; INIT CHANNEL D

   ld a,e
   ld (toneDPitch+1),a
   or a
   jr z,isRestD
   ld a,2
   jr notRestD
isRestD:
   xor a
notRestD:
   ld (toneDChange+1),a

toneMaskPreserve:
   push bc
toneMask:
   and 1
   jr z,playPart2
   ld a,(toneMask1+1)
   jr playPart1
playPart2:
   ld a,(toneMask2+1)
playPart1:
   out (bPort),a
pitchLoop:


   dec h
   jr nz,noPitchA
toneMask1:
   ld a,0
toneAChange:
   xor 0
   ld (toneMask1+1),a
toneAPitch:
   ld h,0
noPitchA:


   dec l
   jr nz,noPitchB
toneMask2:
   ld a,0
toneBChange:
   xor 0
   ld (toneMask2+1),a
toneBPitch:
   ld l,0
noPitchB:



   dec d
   jr nz,noPitchC
   ld a,(toneMask1+1)
toneCChange:
   xor 0
   ld (toneMask1+1),a
toneCPitch:
   ld d,0
noPitchC:


   dec e
   jr nz,noPitchD
   ld a,(toneMask2+1)
toneDChange:
   xor 0
   ld (toneMask2+1),a
toneDPitch:
   ld e,0
noPitchD:



extendDuration:
   ld a,0
   dec a
   ld (extendDuration+1),a
   jr nz,toneMask

   ld a,KeyRow_Top
   pop bc
   out (1),a
   in a,(1)
   cp dkY
   jr nz,notTimeToQuit
   pop hl
   ret
notTimeToQuit:
   dec c
   jp nz,toneMaskPreserve
   dec b
   jp nz,toneMaskPreserve

   ret
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 2
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement