gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS homebrew announcements > LIBXM7 - A C library to play XM modules on Nintendo DS...

#164543 - sverx - Thu Nov 06, 2008 5:08 pm

Hi!
finally, after many hours spent trying to write something that looks like an API documentation ;) I can release the long time ago promised XM replay library (see this topic...).

It works completely on ARM7, it has some effect column support, some volume column support, instruments with complete volume envelopes support, 8 & 16 bit samples with normal & ping-pong loop support...

Everything is explained with detail here

Feedback about the lib and the documentation is warmly welcome!

Thanks everybody that helped me to achieve this personal milestone... and I hope somebody will find my work worth a try :)

Claudio


Last edited by sverx on Fri Nov 07, 2008 3:49 pm; edited 1 time in total

#164548 - Legolas - Fri Nov 07, 2008 12:07 am

Nice! The demo is very interesting :)
However, IMHO you should release at least a small example with sources, something like setup/load/play/stop
_________________
My homepage!

#164568 - shaymanjw - Fri Nov 07, 2008 3:21 pm

I agree with Legolas. This looks really good, and I'd like to give it a try in my current project, but the instructions are quite vague on what needs to be done.
A small example project would be fab.

#164569 - sverx - Fri Nov 07, 2008 3:40 pm

shaymanjw wrote:
I agree with Legolas. This looks really good, and I'd like to give it a try in my current project, but the instructions are quite vague on what needs to be done.


Vague? :( So it's true I'm really bad in writing documentation :(
[ Gotta tell my boss :D ]

Anyway, what exactly isn't clear in the doc? I can try to explain better, even if it's hard for me... my english is really poor :|
[I had to ask my wife to correct the doc... we spent two hours 8| ... ]

shaymanjw wrote:
A small example project would be fab.


I'll promise to work on it. Even if it means I need to write the simpler interprocessor data exchange system I can imagine...

#164570 - shaymanjw - Fri Nov 07, 2008 4:34 pm

Don't worry, your English is great.

Basically my project is based on the combined ARM7/ARM9 template from the latest (released) LIBNDS. What would be really useful then is a small example based on this template, but that also uses your lib.

The stuff you mention (inter-processer data exchange) is where I am struggling...

One other question. Are we still able to use the LIBNDS 'playSound' command whilst using your lib?

#164571 - theli - Fri Nov 07, 2008 4:49 pm

well, counting there are only 3 functions available that's not really hard to put a simple example together:
http://theli.ho.ua/temp/lbxm7_demo.rar

this messy demo just plays bundled xm

#164572 - sverx - Fri Nov 07, 2008 5:08 pm

shaymanjw wrote:
Don't worry, your English is great.


Not as good as I want...

shaymanjw wrote:
Basically my project is based on the combined ARM7/ARM9 template from the latest (released) LIBNDS. What would be really useful then is a small example based on this template, but that also uses your lib.


I started writing it some minutes ago, then I read the message from theli :D

shaymanjw wrote:
The stuff you mention (inter-processer data exchange) is where I am struggling...


I know. It's the hardest part, IMHO. But depending on your needs could also be done in quite simple manners, for instance as theli did (I was going to write a similar example...)

shaymanjw wrote:
One other question. Are we still able to use the LIBNDS 'playSound' command whilst using your lib?


Yes, as long as you take care of not using the first N channels, the ones used by the XM module. For instance you could tweak the function that gives you the number of the 1st free channel so that it gives you the number starting from the 1st unused channel not including the ones used by the player. ...

Code:
s32 getFreeSoundChannel2 (int first) {
   int i;
   for (i=first; i<16; i++) {
      if ( (SCHANNEL_CR(i) & SCHANNEL_ENABLE) == 0 ) return i;
   }
   return -1;
}

calling it with
Code:
s32 res = getFreeSoundChannel2 (TheModule->NumberofChannels);

for example...

@theli: thanks :)

#164573 - Izhido - Fri Nov 07, 2008 6:52 pm

Nice work.

I, however, have a question. As of today (Nov. 07 2008), most of us are expecting a new dkA & libnds release with a revamped ARM7/9 communication process that should let us use WiFi & Sound with ARM9-only projects.

Will your library survive the new release? Or there are plans to modify it once the new release goes gold?

- Izhido

#164586 - shaymanjw - Sat Nov 08, 2008 6:43 pm

OK got this working nicely - thanks Theli for the example (and of course Sverx for the library).

There does seem to be a slight problem using playSound - it sounds like it's ignoring the sampleRate specified (as per the example, I commented out startSound in the ARM7 code - if I change the name to startSound2 for example, and then reference this in the VblankHandler code then the playSound stuff sounds fine).

The other option is that it's a bug in the original startSound routine.

Would appreciate your thoughts.

#164620 - sverx - Mon Nov 10, 2008 12:00 pm

Izhido wrote:
Nice work.

I, however, have a question. As of today (Nov. 07 2008), most of us are expecting a new dkA & libnds release with a revamped ARM7/9 communication process that should let us use WiFi & Sound with ARM9-only projects.

Will your library survive the new release? Or there are plans to modify it once the new release goes gold?


Thanks :)

I know that there are plans about that, but I do not know much more... I think that when the new libnds will arrive, I'll see how it'll be possibile to integrate my lib with that, so that you will be still able to use it even in ARM9-only projects. In the while I'll keep on working on the actual 'shape'...

shaymanjw wrote:
There does seem to be a slight problem using playSound - it sounds like it's ignoring the sampleRate specified (as per the example, I commented out startSound in the ARM7 code - if I change the name to startSound2 for example, and then reference this in the VblankHandler code then the playSound stuff sounds fine).

The other option is that it's a bug in the original startSound routine.


Don't know why it's ignoring the sample rate, but I think actually there's one small bug in the startSound()

the code I read in the combined template ARM7 is:
Code:
//---------------------------------------------------------------------------------
void startSound(int sampleRate, const void* data, u32 bytes, u8 channel, u8 vol,  u8 pan, u8 format) {
//---------------------------------------------------------------------------------
   SCHANNEL_TIMER(channel)  = SOUND_FREQ(sampleRate);
   SCHANNEL_SOURCE(channel) = (u32)data;
   SCHANNEL_LENGTH(channel) = bytes >> 2 ;
   SCHANNEL_CR(channel)     = SCHANNEL_ENABLE | SOUND_ONE_SHOT | SOUND_VOL(vol) | SOUND_PAN(pan) | (format==1?SOUND_8BIT:SOUND_16BIT);
}


and it's missing a
Code:
SCHANNEL_REPEAT_POINT(channel) = 0;

somewhere before the last instruction. Usually you wouldn't notice that, but if this channel has previously been used by a sample that had a loop, that value could be not 0 and affect the sample you want to play.

...but I guess that's not related the problem affecting you, anyway...

I hope it helps anyway :)

#164628 - AntonioND - Mon Nov 10, 2008 4:21 pm

sverx wrote:
and it's missing a
Code:
SCHANNEL_REPEAT_POINT(channel) = 0;

somewhere before the last instruction. Usually you wouldn't notice that, but if this channel has previously been used by a sample that had a loop, that value could be not 0 and affect the sample you want to play.

...but I guess that's not related the problem affecting you, anyway...

I hope it helps anyway :)

I didn't know that, thanks! It would have caused me some problems in the game I'm coding right now.

#164630 - sverx - Mon Nov 10, 2008 4:57 pm

AntonioND wrote:
I didn't know that, thanks! It would have caused me some problems in the game I'm coding right now.


Well, it could happen only if somewhere in your code you're using samples with loop that doesn't begin at the beginning of the sample (or if you're using libxm7 and you're re-using a channel where you've been playing another XM before and it had more channels than the one that you're currently playing...)

#164647 - hacker013 - Tue Nov 11, 2008 7:30 pm

this rocks, i go to use that in the new Xsystem Release
_________________
Website / Blog

Let the nds be with you.

#164659 - sverx - Wed Nov 12, 2008 5:07 pm

hacker013 wrote:
i go to use that in the new Xsystem Release


if you plan to write a routine to load XMs from a filesystem I can help you with that, if you need.

#164668 - hacker013 - Wed Nov 12, 2008 8:53 pm

That would be great, but i have first to make the pluginsystem to work.
_________________
Website / Blog

Let the nds be with you.

#164859 - sverx - Wed Nov 26, 2008 7:42 pm

Hi!
a short post to let you know I'm working hard these days on libxm7 to achieve soon the support of 80% of all the possible XM effects, of course the more common, first.
If somebody has some XMs to help me test effects... (I'm currectly testing effects 1xx, 2xx, 3xx, E1x, E2x, X1x, X2x and volume column effect Mx) please point them to me.
Thanks! :)

#164919 - sverx - Mon Dec 01, 2008 12:36 pm

shaymanjw wrote:
There does seem to be a slight problem using playSound - it sounds like it's ignoring the sampleRate specified (as per the example, I commented out startSound in the ARM7 code - if I change the name to startSound2 for example, and then reference this in the VblankHandler code then the playSound stuff sounds fine).

The other option is that it's a bug in the original startSound routine.

Would appreciate your thoughts.


Ow! Only now I realized it was my fault! It'll be corrected in the next version of the library, which I hope I'll release before the end of December... sorry :|

(yes, you have to rename startSound() to something else, if you need to use it, actually...)